GTKMM 4.10 - Obtain file filter selected in Gtk::FileDialog when presenting save() dialog to user

72 Views Asked by At

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

  1. Reviewed signals for a Gio::ListStore to determine if there was one that fired when an item was selected. The only one I could find was signal_items_changed() which only fires when items are added or removed from the list store.
  2. Reviewed signals for a Gtk::FileFilter to determine if there was one that fired when an item was selected. The only one I could find was signal_changed which 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 ?

0

There are 0 best solutions below