[GTK4] FileChooser "selection-changed" signal alternative

In GTK3, FileChooser emitted the “selection-changed” and “file-activated” signals, however in GTK4 they were removed. What signals do I connect to instead to listen to the user selecting a different file?

File chooser Gtk 4 image preview - #2 by ebassi said:

they can listen to the selection changes on the file chooser widget to update the preview

How do I listen to selection changes in GTK4?

Bumping, I have not yet found a workaround. It seems to me that the selection-changed signal was removed without replacement unless I’m missing something obvious

I probably forgot that we had to remove the selection-changed signal because it exposed internal details of the file chooser that could not possibly work across native widgets.

So it turns out I was wrong: you cannot implement a preview widget with the file chooser in GTK4. Luckily, GtkFileChooser has been deprecated entirely, and for GTK 4.10 we are planning to provide an icon grid with larger thumbnails that will make the preview unnecessary to begin with.

1 Like

Thank you for the response

I ended up implementing the preview by adding atick_callback to the widget and just checking every frame if the selection changed and then emitting my own signal. Obviously this is terrible style and goes against the signal architecture but it will have to do for now, as I needed the custom preview to display information about a custom file-type that’s specific to my application.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.