FileChooser: Return selected filter
This implements handling the current_filter
return
value which returns the filter that was selected in the
file chooser and was recently added to xdg-desktop-portal
and thus the FileChooser API in this commit.
A sample Gtk program to test the behaviour is attached: main_getfilter.cpp. (Alternatively, the one from https://gitlab.gnome.org/GNOME/gtk/-/issues/1820 can be used.)
This requires:
- a version of xdg-desktop-portal that includes the commit that added this to the spec and added the relevant implementation: https://github.com/flatpak/xdg-desktop-portal/commit/35fca7fae881bdaba1bebccf7775eba84407a488
- a Gtk version that includes the following two pending merge requests to make it work in a Gtk program like the sample program:
To test:
- Compile sample program:
gcc -g -O0 -o main_getfilter $(shell pkg-config --cflags gtk+-3.0) main_getfilter.cpp $(shell pkg-config --libs gtk+-3.0)
- Run sample program using portal in a KDE Plasma session (so that the Plasma-native file chooser is actually used):
GTK_USE_PORTAL=1 ./main_getfilter
-
Select any filter and press "Save"
-
Verify that the program output actually shows the name of the filter that was selected.
In combination with the xdg-desktop-portal commit and the pending Gtk MRs mentioned above, this makes the use case described in https://bugzilla.mozilla.org/show_bug.cgi?id=1517074 (and similar ones in Thunderbird) work when using the Plasma-native file chooser (GTK_USE_PORTAL=1
).