I am converting C++ applications from GTKMM 4.8 to 4.10 and disabling deprecated classes and functions. I used to use a Gtk::FileChooserDialog and am converting my applications to use the Gtk::FileDialog class instead. In the deprecated Gtk::FileChooser class there was a member function get_filter() which returned the currently selected filter. I used to use this in some of my applications to determine what format the user wishes to save the data in the application. I have looked for an equivalent in the Gtk::FileDialog class but cannot find one. Using the new class is there a way to determine what filter was selected ? I cannot guarantee that the user will append the correct extension to the filename entered and thus cannot use the filename as a means of determining filter selection. The get_default_filter() member only returns the default file filter set when the dialog was created and run. This is not what I want.
Further investigations
- Reviewed signals for a
Gio::ListStoreto determine if there was one that fired when an item was selected. The only one I could find wassignal_items_changed()which only fires when items are added or removed from the list store. - Reviewed signals for a
Gtk::FileFilterto determine if there was one that fired when an item was selected. The only one I could find wassignal_changedwhich only fires when the file filter's details are changed - not when it was selected.
Further investigation re single selection models
Created a Gtk::SingleSelection and then attached the list store that underlies the file filters to it. As long as I set an initial selection then I could fetch the selected item from the selection object and then use this item number to fetch the file filter. This is part way to a solution but how do I attach the selection model to the dialog or file filters so that when something changes I can obtain the file filter in question ?