[gtk+/wip/alexl/file-chooser-portal] portal filechooser: Send filters to the portal



commit c7c64f0718a3635fec8946dc9252cf82f254b69e
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 11 00:46:12 2016 -0400

    portal filechooser: Send filters to the portal

 gtk/gtkfilechoosernativeportal.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c
index 2454af1..13a5dbb 100644
--- a/gtk/gtkfilechoosernativeportal.c
+++ b/gtk/gtkfilechoosernativeportal.c
@@ -235,6 +235,24 @@ open_file_msg_cb (GObject *source_object,
     }
 }
 
+static GVariant *
+get_filters (GtkFileChooser *self)
+{
+  GSList *list, *l;
+  GVariantBuilder builder;
+
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(sa(us))"));
+  list = gtk_file_chooser_list_filters (self);
+  for (l = list; l; l = l->next)
+    {
+      GtkFileFilter *filter = l->data;
+      g_variant_builder_add (&builder, "@(sa(us))", gtk_file_filter_to_gvariant (filter));
+    }
+  g_slist_free (list);
+
+  return g_variant_builder_end (&builder);
+}
+
 gboolean
 gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
 {
@@ -327,6 +345,7 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
                            g_variant_new_string (self->cancel_label));
   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)));
 
   g_dbus_message_set_body (message,
                            g_variant_new ("(ss a{sv})",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]