mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
filechoosernativeportal: Allowing selecting folder(s)
Use the "directory" portal option when asked to select folders.
This commit is contained in:
parent
93ab478af1
commit
35fec1c6b2
@ -294,6 +294,7 @@ show_portal_file_chooser (GtkFileChooserNative *self,
|
||||
GDBusMessage *message;
|
||||
GVariantBuilder opt_builder;
|
||||
gboolean multiple;
|
||||
gboolean directory;
|
||||
const char *title;
|
||||
char *token;
|
||||
|
||||
@ -315,6 +316,7 @@ show_portal_file_chooser (GtkFileChooserNative *self,
|
||||
self, NULL);
|
||||
|
||||
multiple = gtk_file_chooser_get_select_multiple (GTK_FILE_CHOOSER (self));
|
||||
directory = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (self)) == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
|
||||
g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
|
||||
|
||||
g_variant_builder_add (&opt_builder, "{sv}", "handle_token",
|
||||
@ -323,6 +325,8 @@ show_portal_file_chooser (GtkFileChooserNative *self,
|
||||
|
||||
g_variant_builder_add (&opt_builder, "{sv}", "multiple",
|
||||
g_variant_new_boolean (multiple));
|
||||
g_variant_builder_add (&opt_builder, "{sv}", "directory",
|
||||
g_variant_new_boolean (directory));
|
||||
if (self->accept_label)
|
||||
g_variant_builder_add (&opt_builder, "{sv}", "accept_label",
|
||||
g_variant_new_string (self->accept_label));
|
||||
@ -422,9 +426,18 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
|
||||
method_name = "OpenFile";
|
||||
else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
||||
method_name = "SaveFile";
|
||||
else if (action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
{
|
||||
if (gtk_get_portal_interface_version (connection, "org.freedesktop.portal.FileChooser") < 3)
|
||||
{
|
||||
g_warning ("GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER is not supported by GtkFileChooserNativePortal because portal is too old");
|
||||
return FALSE;
|
||||
}
|
||||
method_name = "OpenFile";
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("GTK_FILE_CHOOSER_ACTION_%s is not supported by GtkFileChooserNativePortal", action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ? "SELECT_FOLDER" : "CREATE_FOLDER");
|
||||
g_warning ("GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER is not supported by GtkFileChooserNativePortal");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user