FileChooser: Implement 'options' - 'choices'
This implements the 'options' - 'choices' parameter for the FileChooser portal which can be used to specify additional options to offer in the file dialog.
From the FileChooser spec:
choices a(ssa(ss)s) List of serialized combo boxes to add to the file chooser. For each element, the first string is an ID that will be returned with the response, te second string is a user-visible label. The a(ss) is the list of choices, each being a is an ID and a user-visible label. The final string is the initial selection, or "", to let the portal decide which choice will be initially selected. None of the strings, except for the initial selection, should be empty. As a special case, passing an empty array for the list of choices indicates a boolean choice that is typically displayed as a check button, using "true" and "false" as the choices. Example: [('encoding', 'Encoding', [('utf8', 'Unicode (UTF-8)'), ('latin15', 'Western')], 'latin15'), ('reencode', 'Reencode', , 'false')]
Attached is a gtk sample program that can be used to test the functionality (I have tested it on Debian testing with
libgtk-3-0:amd64 3.24.20-1 and
- Compile sample program:
gcc -o main_options main_options.cpp
- Run sample program using portal in a KDE Plasma session (so that Plasma-native file chooser is actually used):
- verify that the two options can be set in the file dialog:
- one checkbox for the option "Sample boolean choice" that is selected by default
- one combobox to choose one of the greek letters "Alpha", "Beta", "Gamma", with "Gamma" preselected
adapt selection for the two options as desired
select any file in the file system and press "OK"
verify that the program outputs the IDs of the choices that were made in step 4, e.g. the following (if checkbox was unselected and "Beta" was selected in the combobox):
selected booleanChoice: false selected letter: beta
NOTE: In order to avoid merge conflicts, this merge request also includes the commit from !2 (merged), since they touch the same code area. I'll be happy to drop that commit again from this merge request once !2 (merged) has been handled. (or let me know how to best handle this otherwise)