From a136cbae8f8848d49976512f7f0ec73137428ea0 Mon Sep 17 00:00:00 2001 From: Michael Catanzaro Date: Thu, 29 Nov 2018 15:34:17 -0600 Subject: [PATCH 1/3] filechoosernative: forward current_filter to delegate dialog gtk_file_chooser_set_filter() doesn't work for GtkFileChooserNative. The code forwards added and removed filters to the delegate dialog, but doesn't do anything to set the selected one, so the wrong one gets chosen. So fix that. This only fixes the fallback dialog. The portal will be fixed in a subsequent commit. Partial fix for #1492 --- gtk/gtkfilechoosernative.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtkfilechoosernative.c b/gtk/gtkfilechoosernative.c index cfa274f4f1..cf1d97b31d 100644 --- a/gtk/gtkfilechoosernative.c +++ b/gtk/gtkfilechoosernative.c @@ -466,6 +466,7 @@ gtk_file_chooser_native_set_property (GObject *object, case GTK_FILE_CHOOSER_PROP_FILTER: self->current_filter = g_value_get_object (value); + gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (self->dialog), self->current_filter); g_object_notify (G_OBJECT (self), "filter"); break; From 330794474636eef4cc0b990452c4f4e62a918050 Mon Sep 17 00:00:00 2001 From: Michael Catanzaro Date: Mon, 14 Jan 2019 20:53:19 -0600 Subject: [PATCH 2/3] filechoosernativeportal: remove redundant casts We are casting from GtkFileChooserNative to... GtkFileChooserNative. Boo. --- gtk/gtkfilechoosernativeportal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c index f22d734f5a..3a372e7058 100644 --- a/gtk/gtkfilechoosernativeportal.c +++ b/gtk/gtkfilechoosernativeportal.c @@ -332,10 +332,10 @@ show_portal_file_chooser (GtkFileChooserNative *self, g_variant_builder_add (&opt_builder, "{sv}", "modal", g_variant_new_boolean (data->modal)); g_variant_builder_add (&opt_builder, "{sv}", "filters", get_filters (GTK_FILE_CHOOSER (self))); - if (GTK_FILE_CHOOSER_NATIVE (self)->current_name) + if (self->current_name) g_variant_builder_add (&opt_builder, "{sv}", "current_name", g_variant_new_string (GTK_FILE_CHOOSER_NATIVE (self)->current_name)); - if (GTK_FILE_CHOOSER_NATIVE (self)->current_folder) + if (self->current_folder) { gchar *path; @@ -344,7 +344,7 @@ show_portal_file_chooser (GtkFileChooserNative *self, g_variant_new_bytestring (path)); g_free (path); } - if (GTK_FILE_CHOOSER_NATIVE (self)->current_file) + if (self->current_file) { gchar *path; @@ -354,7 +354,7 @@ show_portal_file_chooser (GtkFileChooserNative *self, g_free (path); } - if (GTK_FILE_CHOOSER_NATIVE (self)->choices) + if (self->choices) g_variant_builder_add (&opt_builder, "{sv}", "choices", serialize_choices (GTK_FILE_CHOOSER_NATIVE (self))); From c0a0bfd38841f8937a32e2ea8abbc2960db772cf Mon Sep 17 00:00:00 2001 From: Michael Catanzaro Date: Tue, 15 Jan 2019 19:51:00 -0600 Subject: [PATCH 3/3] filechoosernativeportal: stuff the current filter into options We need to tell the portal what filter is supposed to be selected by default, or it will just pick the first one, which could be wrong and annoying. This will require updated xdg-desktop-portal and xdg-desktop-portal-gtk to work properly. Fixes #1492 --- gtk/gtkfilechoosernativeportal.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c index 3a372e7058..07cbb5b4bc 100644 --- a/gtk/gtkfilechoosernativeportal.c +++ b/gtk/gtkfilechoosernativeportal.c @@ -332,6 +332,9 @@ show_portal_file_chooser (GtkFileChooserNative *self, g_variant_builder_add (&opt_builder, "{sv}", "modal", g_variant_new_boolean (data->modal)); g_variant_builder_add (&opt_builder, "{sv}", "filters", get_filters (GTK_FILE_CHOOSER (self))); + if (self->current_filter) + g_variant_builder_add (&opt_builder, "{sv}", "current_filter", + gtk_file_filter_to_gvariant (self->current_filter)); if (self->current_name) g_variant_builder_add (&opt_builder, "{sv}", "current_name", g_variant_new_string (GTK_FILE_CHOOSER_NATIVE (self)->current_name));