Skip to content

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:

To test:

  1. 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)

  1. 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

  1. Select any filter and press "Save"

  2. 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).

Merge request reports