Dear all,
is it possible to retrieve the active filter of a GtkFileDialog and how ?
I have some issue with the OSX build of my program, the depreciated gtk_file_chooser_get_filter function seems to be broken for MacOS (it works fine on Linux), and I figured that I need to update my code to use the GtkFileDialog widget instead of the GtkFileChooserDialog widget.
But when checking the GtkFileDialog page I cannot find any method to retrieve the active filter for the widget … any idea how to do this ?
The other option would be to store the information when changing the filter, is this possible ?
No. The completion callback gives you control after the file has been selected, so there’s nothing you can do about it.
Additionally, GtkFileDialog calls the platform’s native file selection dialog which gives no guarantee about filters or anything else post-construction.
Again, no: the operation is stateless. There’s no “dialog”, only an operation started asynchronously and then your code getting notified of the choice made. For instance, on Linux, the whole operation happens out of process through the xdg-desktop-portal implementation, which means you can’t have custom code running.
@ebassi thank you for your answer,
well I used a dialog to select files (atomic coordinates for that matter) that can be of many different formats, the user select the appropriate file filter, then the file, press ok (or whatever), then I used to retrieve the active file filter using gtk_file_chooser_get_filter () … and hence the file format and what to do to open this file because all formats are different.
You can check my code here:
I need to know which format, or file filter, was selected by the user to know how to open the file.
The solution for that workflow is to split the file selection from the format selection; you should have a separate dialog that lets you select the format and then the file. Once you put the file selection inside its independent step, it’s easier to add more steps at a later date, instead of shoving them all into the file selection process.
For inspiration, you can look at the export process in applications such as GIMP or Inkscape.