[gtk+] GtkListBox: Support placeholders in ui files



commit 291e4e107d7a1d5bc7b846ecae7284121b067a64
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 12 18:54:44 2014 -0400

    GtkListBox: Support placeholders in ui files
    
    This makes the gtk_list_box_set_placeholder functionality
    available from GtkBuilder
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738111

 gtk/gtklistbox.c |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 83aea78..5b04223 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -147,7 +147,12 @@ enum {
 #define BOX_PRIV(box) ((GtkListBoxPrivate*)gtk_list_box_get_instance_private ((GtkListBox*)(box)))
 #define ROW_PRIV(row) ((GtkListBoxRowPrivate*)gtk_list_box_row_get_instance_private ((GtkListBoxRow*)(row)))
 
-G_DEFINE_TYPE_WITH_PRIVATE (GtkListBox, gtk_list_box, GTK_TYPE_CONTAINER)
+static void     gtk_list_box_buildable_interface_init     (GtkBuildableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkListBox, gtk_list_box, GTK_TYPE_CONTAINER,
+                         G_ADD_PRIVATE (GtkListBox)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+                                                gtk_list_box_buildable_interface_init))
 G_DEFINE_TYPE_WITH_PRIVATE (GtkListBoxRow, gtk_list_box_row, GTK_TYPE_BIN)
 
 static void                 gtk_list_box_apply_filter_all             (GtkListBox          *box);
@@ -3517,3 +3522,23 @@ gtk_list_box_row_class_init (GtkListBoxRowClass *klass)
   g_object_class_install_properties (object_class, LAST_ROW_PROPERTY, row_properties);
 
 }
+
+static void
+gtk_list_box_buildable_add_child (GtkBuildable *buildable,
+                                  GtkBuilder   *builder,
+                                  GObject      *child,
+                                  const gchar  *type)
+{
+  if (type && strcmp (type, "placeholder") == 0)
+    gtk_list_box_set_placeholder (GTK_LIST_BOX (buildable), GTK_WIDGET (child));
+  else if (!type)
+    gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
+  else
+    GTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type);
+}
+
+static void
+gtk_list_box_buildable_interface_init (GtkBuildableIface *iface)
+{
+  iface->add_child = gtk_list_box_buildable_add_child;
+}


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