[gtk+/builder-details] Added GtkBuildable support to add "tag" children to GtkTextTagTable.



commit 75841f767431f5e258de08998da63257bb954104
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Jan 9 14:06:19 2011 +0900

    Added GtkBuildable support to add "tag" children to GtkTextTagTable.

 gtk/gtktexttagtable.c |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 45 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktexttagtable.c b/gtk/gtktexttagtable.c
index b1a99ff..ea68ad9 100644
--- a/gtk/gtktexttagtable.c
+++ b/gtk/gtktexttagtable.c
@@ -28,6 +28,7 @@
 
 #include "gtktexttagtable.h"
 
+#include "gtkbuildable.h"
 #include "gtktexttagprivate.h"
 #include "gtkmarshalers.h"
 #include "gtktextbuffer.h" /* just for the lame notify_will_remove_tag hack */
@@ -44,9 +45,26 @@
  * You may wish to begin by reading the <link linkend="TextWidget">text widget
  * conceptual overview</link> which gives an overview of all the objects and data
  * types related to the text widget and how they work together.
+ *
+ * <refsect2 id="GtkTextTagTable-BUILDER-UI">
+ * <title>GtkTextTagTables as GtkBuildable</title>
+ * <para>
+ * The GtkTextTagTable implementation of the GtkBuildable interface
+ * supports adding tags by specifying "tag" as the "type" 
+ * attribute of a &lt;child&gt; element.
+ *
+ * <example>
+ * <title>A UI definition fragment specifying tags</title>
+ * <programlisting><![CDATA[
+ * <object class="GtkTextTagTable">
+ *  <child type="tag">
+ *    <object class="GtkTextTag"/>
+ *  </child>
+ * </object>
+ * ]]></programlisting>
+ * </example>
  */
 
-
 struct _GtkTextTagTablePrivate
 {
   GHashTable *hash;
@@ -78,9 +96,17 @@ static void gtk_text_tag_table_get_property (GObject              *object,
                                              GValue               *value,
                                              GParamSpec           *pspec);
 
+static void gtk_text_tag_table_buildable_interface_init (GtkBuildableIface   *iface);
+static void gtk_text_tag_table_buildable_add_child      (GtkBuildable        *buildable,
+							 GtkBuilder          *builder,
+							 GObject             *child,
+							 const gchar         *type);
+
 static guint signals[LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE (GtkTextTagTable, gtk_text_tag_table, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_CODE (GtkTextTagTable, gtk_text_tag_table, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+                                                gtk_text_tag_table_buildable_interface_init))
 
 static void
 gtk_text_tag_table_class_init (GtkTextTagTableClass *klass)
@@ -246,6 +272,23 @@ gtk_text_tag_table_get_property (GObject      *object,
     }
 }
 
+static void
+gtk_text_tag_table_buildable_interface_init (GtkBuildableIface   *iface)
+{
+  iface->add_child = gtk_text_tag_table_buildable_add_child;
+}
+
+static void
+gtk_text_tag_table_buildable_add_child (GtkBuildable        *buildable,
+					GtkBuilder          *builder,
+					GObject             *child,
+					const gchar         *type)
+{
+  if (type && strcmp (type, "tag") == 0)
+    gtk_text_tag_table_add (GTK_TEXT_TAG_TABLE (buildable),
+			    GTK_TEXT_TAG (child));
+}
+
 /**
  * gtk_text_tag_table_add:
  * @table: a #GtkTextTagTable



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