[gtksourceview/wip/gtk-buildable] completion: implement GtkBuildable::get_internal_child()



commit aff726eb19ccddd1a9bb8848ef0cc7d5110a5b23
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Sep 10 23:16:37 2014 +0200

    completion: implement GtkBuildable::get_internal_child()
    
    For the info_window.

 gtksourceview/gtksourcecompletion.c |   47 ++++++++++++++++++++++++++++++++++-
 tests/test-completion.ui            |    6 ++++
 2 files changed, 52 insertions(+), 1 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 5c45ba5..861e8eb 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -72,6 +72,25 @@
  *
  * A same #GtkSourceCompletionProvider object can be used for several
  * #GtkSourceCompletion.
+ *
+ * # GtkSourceCompletion as GtkBuildable
+ *
+ * The GtkSourceCompletion implementation of the #GtkBuildable interface exposes
+ * the info window object (see gtk_source_completion_get_info_window()) with the
+ * internal-child "info_window".
+ *
+ * An example of a UI definition fragment with GtkSourceCompletion:
+ * |[
+ * <object class="GtkSourceCompletion">
+ *   <property name="select_on_show">False</property>
+ *   <child internal-child="info_window">
+ *     <object class="GtkSourceCompletionInfo">
+ *       <property name="border_width">1</property>
+ *       <property name="margin">6</property>
+ *     </object>
+ *   </child>
+ * </object>
+ * ]|
  */
 
 /* Idea to improve the code: use a composite widget template. This class is not
@@ -184,7 +203,12 @@ struct _GtkSourceCompletionPrivate
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceCompletion, gtk_source_completion, G_TYPE_OBJECT)
+static void    gtk_source_completion_buildable_interface_init (GtkBuildableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkSourceCompletion, gtk_source_completion, G_TYPE_OBJECT,
+                        G_ADD_PRIVATE (GtkSourceCompletion)
+                        G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+                                               gtk_source_completion_buildable_interface_init))
 
 static void
 scroll_to_iter (GtkSourceCompletion *completion,
@@ -2541,6 +2565,27 @@ gtk_source_completion_init (GtkSourceCompletion *completion)
        completion->priv = gtk_source_completion_get_instance_private (completion);
 }
 
+static GObject *
+gtk_source_completion_buildable_get_internal_child (GtkBuildable *buildable,
+                                                   GtkBuilder   *builder,
+                                                   const gchar  *childname)
+{
+       GtkSourceCompletion *completion = GTK_SOURCE_COMPLETION (buildable);
+
+       if (g_strcmp0 (childname, "info_window") == 0)
+       {
+               return G_OBJECT (gtk_source_completion_get_info_window (completion));
+       }
+
+       return NULL;
+}
+
+static void
+gtk_source_completion_buildable_interface_init (GtkBuildableIface *iface)
+{
+       iface->get_internal_child = gtk_source_completion_buildable_get_internal_child;
+}
+
 void
 _gtk_source_completion_add_proposals (GtkSourceCompletion         *completion,
                                       GtkSourceCompletionContext  *context,
diff --git a/tests/test-completion.ui b/tests/test-completion.ui
index f6f653e..0924f55 100644
--- a/tests/test-completion.ui
+++ b/tests/test-completion.ui
@@ -354,6 +354,12 @@
                   <object class="GtkSourceCompletion">
                     <property name="select_on_show">False</property>
                     <property name="remember_info_visibility">True</property>
+                    <child internal-child="info_window">
+                      <object class="GtkSourceCompletionInfo">
+                        <property name="border_width">1</property>
+                        <property name="margin">6</property>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>


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