[gtksourceview/wip/gtk-buildable] view: implement GtkBuildable::get_internal_child() for "completion"
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/gtk-buildable] view: implement GtkBuildable::get_internal_child() for "completion"
- Date: Wed, 10 Sep 2014 21:08:33 +0000 (UTC)
commit 6939623de8af4ba0296388d215c51df4c7f72e58
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 | 48 +++++++++++++++++++++++++++++++++++++++-
tests/test-completion.ui | 6 +++++
2 files changed, 52 insertions(+), 2 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index ec5c340..b14df66 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -51,11 +51,29 @@
* SECTION:view
* @Short_description: The view object
* @Title: GtkSourceView
- * @See_also: #GtkTextView,#GtkSourceBuffer
+ * @See_also: #GtkTextView, #GtkSourceBuffer
*
* #GtkSourceView is the main object of the GtkSourceView library. It provides
* a text view with syntax highlighting, undo/redo and text marks. Use a
* #GtkSourceBuffer to display text with a #GtkSourceView.
+ *
+ * # GtkSourceView as GtkBuildable
+ *
+ * The GtkSourceView implementation of the #GtkBuildable interface exposes the
+ * #GtkSourceView:completion object with the internal-child "completion".
+ *
+ * An example of a UI definition fragment with GtkSourceView:
+ * |[
+ * <object class="GtkSourceView" id="source_view">
+ * <property name="tab_width">4</property>
+ * <property name="auto_indent">True</property>
+ * <child internal-child="completion">
+ * <object class="GtkSourceCompletion">
+ * <property name="select_on_show">False</property>
+ * </object>
+ * </child>
+ * </object>
+ * ]|
*/
/*
@@ -172,7 +190,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 +769,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]