[gtk+/portal: 6/18] portal: Send file filters to the portal



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

    portal: Send file 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 0df63c0..c2040ff 100644
--- a/gtk/gtkfilechoosernativeportal.c
+++ b/gtk/gtkfilechoosernativeportal.c
@@ -240,6 +240,24 @@ open_file_msg_cb (GObject *source_object,
   g_object_unref (reply);
 }
 
+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)
 {
@@ -335,6 +353,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]