Merge branch 'portal-dir-chooser' into 'master'

filechoosernativeportal: Allowing selecting folder(s)

See merge request GNOME/gtk!1552
This commit is contained in:
Matthias Clasen 2020-03-21 20:29:11 +00:00
commit 84e58aa393

View File

@ -296,6 +296,7 @@ show_portal_file_chooser (GtkFileChooserNative *self,
GDBusMessage *message;
GVariantBuilder opt_builder;
gboolean multiple;
gboolean directory;
const char *title;
char *token;
@ -317,6 +318,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",
@ -325,6 +327,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));
@ -419,13 +423,14 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self,
action = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (self));
if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
if (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
method_name = "OpenFile";
else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
method_name = "SaveFile";
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;
}