[glade] * plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c: Added support to GtkFileFilter for reading



commit 88e6033117142f4ce5fb9a3b8b0e7a077fd15b77
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Thu Jan 27 23:13:40 2011 +0900

    	* plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c: Added support to GtkFileFilter
    	  for reading and writing the new <mime-types> and <patterns> tags
    	  that are recently added to GtkFileFilter's GtkBuildable implementation.

 ChangeLog                |    4 ++
 plugins/gtk+/glade-gtk.c |  129 +++++++++++++++++++++++++++++++--------------
 plugins/gtk+/gtk+.xml.in |   27 +++++++++-
 3 files changed, 117 insertions(+), 43 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b51d687..c88029c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@
 	  as well as reading and writing the new <mime-types> <patterns> and <applications> tags
 	  that are recently added to GtkRecentFilter's GtkBuildable implementation.
 
+	* plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c: Added support to GtkFileFilter
+	  for reading and writing the new <mime-types> and <patterns> tags
+	  that are recently added to GtkFileFilter's GtkBuildable implementation.
+
 2011-01-26  Tristan Van Berkom <tristanvb openismus com>
 
 	* plugins/gtk+/Makefile.am, plugins/gtk+/glade-string-list.[ch]: Added Boxed type
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 3374b88..f39b981 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -11971,46 +11971,6 @@ typedef enum {
   FILTER_APPLICATION
 } FilterType;
 
-GladeEditorProperty *
-glade_gtk_recent_filter_create_eprop (GladeWidgetAdaptor * adaptor,
-				      GladePropertyClass * klass, 
-				      gboolean use_command)
-{
-  GladeEditorProperty *eprop;
-  GParamSpec          *pspec;
-
-  pspec = glade_property_class_get_pspec (klass);
-
-  if (pspec->value_type == GLADE_TYPE_STRING_LIST)
-    {
-      eprop = glade_eprop_string_list_new (klass, use_command, FALSE);
-    }
-  else
-    eprop = GWA_GET_CLASS
-        (G_TYPE_OBJECT)->create_eprop (adaptor, klass, use_command);
-
-  return eprop;
-}
-
-gchar *
-glade_gtk_recent_filter_string_from_value (GladeWidgetAdaptor * adaptor,
-					   GladePropertyClass * klass,
-					   const GValue * value)
-{
-  GParamSpec *pspec;
-
-  pspec = glade_property_class_get_pspec (klass);
-
-  if (pspec->value_type == GLADE_TYPE_STRING_LIST)
-    {
-      GList *list = g_value_get_boxed (value);
-
-      return glade_string_list_to_string (list);
-    }
-  else
-    return GWA_GET_CLASS
-        (G_TYPE_OBJECT)->string_from_value (adaptor, klass, value);
-}
 
 static void
 glade_gtk_filter_read_strings (GladeWidget  *widget,
@@ -12103,6 +12063,47 @@ glade_gtk_filter_write_strings (GladeWidget     *widget,
     }
 }
 
+GladeEditorProperty *
+glade_gtk_recent_file_filter_create_eprop (GladeWidgetAdaptor * adaptor,
+					   GladePropertyClass * klass, 
+					   gboolean use_command)
+{
+  GladeEditorProperty *eprop;
+  GParamSpec          *pspec;
+
+  pspec = glade_property_class_get_pspec (klass);
+
+  if (pspec->value_type == GLADE_TYPE_STRING_LIST)
+    {
+      eprop = glade_eprop_string_list_new (klass, use_command, FALSE);
+    }
+  else
+    eprop = GWA_GET_CLASS
+        (G_TYPE_OBJECT)->create_eprop (adaptor, klass, use_command);
+
+  return eprop;
+}
+
+gchar *
+glade_gtk_recent_file_filter_string_from_value (GladeWidgetAdaptor * adaptor,
+						GladePropertyClass * klass,
+						const GValue * value)
+{
+  GParamSpec *pspec;
+
+  pspec = glade_property_class_get_pspec (klass);
+
+  if (pspec->value_type == GLADE_TYPE_STRING_LIST)
+    {
+      GList *list = g_value_get_boxed (value);
+
+      return glade_string_list_to_string (list);
+    }
+  else
+    return GWA_GET_CLASS
+        (G_TYPE_OBJECT)->string_from_value (adaptor, klass, value);
+}
+
 void
 glade_gtk_recent_filter_read_widget (GladeWidgetAdaptor *adaptor,
 				     GladeWidget        *widget, 
@@ -12159,3 +12160,51 @@ glade_gtk_recent_filter_write_widget (GladeWidgetAdaptor *adaptor,
   else
     glade_xml_node_append_child (node, strings_node);
 }
+
+/*--------------------------- GtkFileFilter ---------------------------------*/
+void
+glade_gtk_file_filter_read_widget (GladeWidgetAdaptor *adaptor,
+				   GladeWidget        *widget, 
+				   GladeXmlNode       *node)
+{
+  if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+    return;
+
+  /* First chain up and read in all the normal properties.. */
+  GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
+
+  glade_gtk_filter_read_strings (widget, node, FILTER_MIME, "glade-mime-types");
+  glade_gtk_filter_read_strings (widget, node, FILTER_PATTERN, "glade-patterns");
+}
+
+void
+glade_gtk_file_filter_write_widget (GladeWidgetAdaptor *adaptor,
+				    GladeWidget        *widget,
+				    GladeXmlContext    *context, 
+				    GladeXmlNode       *node)
+{
+  GladeXmlNode *strings_node;
+
+  if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+    return;
+
+  /* First chain up and read in all the normal properties.. */
+  GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
+
+  strings_node = glade_xml_node_new (context, GLADE_TAG_MIME_TYPES);
+  glade_gtk_filter_write_strings (widget, context, strings_node, FILTER_MIME, "glade-mime-types");
+
+  if (!glade_xml_node_get_children (strings_node))
+    glade_xml_node_delete (strings_node);
+  else
+    glade_xml_node_append_child (node, strings_node);
+
+
+  strings_node = glade_xml_node_new (context, GLADE_TAG_PATTERNS);
+  glade_gtk_filter_write_strings (widget, context, strings_node, FILTER_PATTERN, "glade-patterns");
+
+  if (!glade_xml_node_get_children (strings_node))
+    glade_xml_node_delete (strings_node);
+  else
+    glade_xml_node_append_child (node, strings_node);
+}
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 67cdf85..3bcf7f2 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -3367,12 +3367,33 @@ embedded in another object</_tooltip>
     </glade-widget-class>
 
     <glade-widget-class name="GtkFileFilter" generic-name="filefilter" _title="File Filter" 
-			toplevel="True"/>
+			toplevel="True">
+      <create-editor-property-function>glade_gtk_recent_file_filter_create_eprop</create-editor-property-function>
+      <string-from-value-function>glade_gtk_recent_file_filter_string_from_value</string-from-value-function>
+      <read-widget-function>glade_gtk_recent_filter_read_widget</read-widget-function>
+      <write-widget-function>glade_gtk_recent_filter_write_widget</write-widget-function>
+      <properties>
+	<property id="glade-mime-types" _name="Mime Types" save="False" ignore="True" since="3.0">
+	  <parameter-spec>
+	    <type>GParamBoxed</type>
+	    <value-type>GladeStringList</value-type>
+	  </parameter-spec>
+	  <_tooltip>The list of mime types to add to the filter</_tooltip>
+	</property>
+	<property id="glade-patterns" _name="Patterns" save="False" ignore="True" since="3.0">
+	  <parameter-spec>
+	    <type>GParamBoxed</type>
+	    <value-type>GladeStringList</value-type>
+	  </parameter-spec>
+	  <_tooltip>The list of file name patterns to add to the filter</_tooltip>
+	</property>
+      </properties>
+    </glade-widget-class>
 
     <glade-widget-class name="GtkRecentFilter" generic-name="recentfilter" _title="Recent Filter" 
 			toplevel="True">
-      <create-editor-property-function>glade_gtk_recent_filter_create_eprop</create-editor-property-function>
-      <string-from-value-function>glade_gtk_recent_filter_string_from_value</string-from-value-function>
+      <create-editor-property-function>glade_gtk_recent_file_filter_create_eprop</create-editor-property-function>
+      <string-from-value-function>glade_gtk_recent_file_filter_string_from_value</string-from-value-function>
       <read-widget-function>glade_gtk_recent_filter_read_widget</read-widget-function>
       <write-widget-function>glade_gtk_recent_filter_write_widget</write-widget-function>
       <properties>



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