diff options
author | Bastien Nocera <hadess@hadess.net> | 2020-03-13 17:50:41 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-03-21 15:46:05 -0400 |
commit | e99d1605dc829e6ae56c0a1aaedf86bdd7d36210 (patch) | |
tree | c69c151dd28434cf1cfead26851f5a3199c59c77 /gtk/gtkfilechoosernativeportal.c | |
parent | bf988f8d07d9ec0b8fb20cb2ead67fb91cecde85 (diff) | |
download | gtk+-e99d1605dc829e6ae56c0a1aaedf86bdd7d36210.tar.gz |
filechoosernativeportal: Allowing selecting folder(s)
Use the "directory" portal option when asked to select folders.
Diffstat (limited to 'gtk/gtkfilechoosernativeportal.c')
-rw-r--r-- | gtk/gtkfilechoosernativeportal.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c index 6ee6f276b6..2e3c49a887 100644 --- a/gtk/gtkfilechoosernativeportal.c +++ b/gtk/gtkfilechoosernativeportal.c @@ -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; } |