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



commit 4adbf2b32952538320d17f186c109a03210b6025
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Sep 10 21:15:30 2014 +0200

    view: implement GtkBuildable::get_internal_child() for "completion"
    
    To be able to configure the completion directly in the .ui file, like it
    is done in test-completion.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=736367

 gtksourceview/gtksourceview.c |   28 +++++++++++++++++++++++++++-
 tests/test-completion.ui      |    6 ++++++
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index ec5c340..dd83de6 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -172,7 +172,12 @@ struct _MarkCategory
        gint                     priority;
 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceView, gtk_source_view, GTK_TYPE_TEXT_VIEW)
+static void    gtk_source_view_buildable_interface_init (GtkBuildableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkSourceView, gtk_source_view, GTK_TYPE_TEXT_VIEW,
+                        G_ADD_PRIVATE (GtkSourceView)
+                        G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+                                               gtk_source_view_buildable_interface_init))
 
 /* Implement DnD for application/x-color drops */
 typedef enum {
@@ -746,6 +751,27 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
                                      G_TYPE_INT, 1);
 }
 
+static GObject *
+gtk_source_view_buildable_get_internal_child (GtkBuildable *buildable,
+                                             GtkBuilder   *builder,
+                                             const gchar  *childname)
+{
+       GtkSourceView *view = GTK_SOURCE_VIEW (buildable);
+
+       if (g_strcmp0 (childname, "completion") == 0)
+       {
+               return G_OBJECT (gtk_source_view_get_completion (view));
+       }
+
+       return NULL;
+}
+
+static void
+gtk_source_view_buildable_interface_init (GtkBuildableIface *iface)
+{
+       iface->get_internal_child = gtk_source_view_buildable_get_internal_child;
+}
+
 static void
 gtk_source_view_set_property (GObject      *object,
                              guint         prop_id,
diff --git a/tests/test-completion.ui b/tests/test-completion.ui
index 245041f..f6f653e 100644
--- a/tests/test-completion.ui
+++ b/tests/test-completion.ui
@@ -350,6 +350,12 @@
                 <property name="tab_width">4</property>
                 <property name="auto_indent">True</property>
                 <property name="indent_on_tab">False</property>
+                <child internal-child="completion">
+                  <object class="GtkSourceCompletion">
+                    <property name="select_on_show">False</property>
+                    <property name="remember_info_visibility">True</property>
+                  </object>
+                </child>
               </object>
             </child>
           </object>


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