[libdazzle] suggestions: add buildable support



commit 1c5175d50ae4d53c8d11ecd4a29aecc9e5060ce8
Author: Christian Hergert <chergert redhat com>
Date:   Mon Apr 22 14:22:32 2019 -0700

    suggestions: add buildable support

 src/suggestions/dzl-suggestion-button.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/src/suggestions/dzl-suggestion-button.c b/src/suggestions/dzl-suggestion-button.c
index 45b5ba5..64a4e13 100644
--- a/src/suggestions/dzl-suggestion-button.c
+++ b/src/suggestions/dzl-suggestion-button.c
@@ -39,7 +39,11 @@ enum {
   N_PROPS
 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (DzlSuggestionButton, dzl_suggestion_button, GTK_TYPE_STACK)
+static void buildable_iface_init (GtkBuildableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (DzlSuggestionButton, dzl_suggestion_button, GTK_TYPE_STACK,
+                         G_ADD_PRIVATE (DzlSuggestionButton)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, buildable_iface_init))
 
 static GParamSpec *properties [N_PROPS];
 
@@ -297,3 +301,27 @@ dzl_suggestion_button_get_button (DzlSuggestionButton *self)
 
   return priv->button;
 }
+
+static GObject *
+get_internal_child (GtkBuildable *buildable,
+                    GtkBuilder   *builder,
+                    const gchar  *childname)
+{
+  DzlSuggestionButton *self = (DzlSuggestionButton *)buildable;
+  DzlSuggestionButtonPrivate *priv = dzl_suggestion_button_get_instance_private (self);
+
+  g_assert (DZL_IS_SUGGESTION_BUTTON (self));
+
+  if (g_strcmp0 (childname, "entry") == 0)
+    return G_OBJECT (priv->entry);
+  else if (g_strcmp0 (childname, "button") == 0)
+    return G_OBJECT (priv->button);
+  else
+    return NULL;
+}
+
+static void
+buildable_iface_init (GtkBuildableIface *iface)
+{
+  iface->get_internal_child = get_internal_child;
+}


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