[gtksourceview/wip/gtk-buildable: 1/2] completion: implement GtkBuildable::get_internal_child()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/gtk-buildable: 1/2] completion: implement GtkBuildable::get_internal_child()
- Date: Fri, 12 Sep 2014 17:32:06 +0000 (UTC)
commit ac1f6517996d77e11a67cb9d6aa0bfbe0887a984
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 | 46 ++++++++++++++++++++++++++++++++++-
tests/test-completion.ui | 5 ++++
2 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 5c45ba5..9b64da5 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -72,6 +72,24 @@
*
* 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">6</property>
+ * </object>
+ * </child>
+ * </object>
+ * ]|
*/
/* Idea to improve the code: use a composite widget template. This class is not
@@ -184,7 +202,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 +2564,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 077ff5d..5158af0 100644
--- a/tests/test-completion.ui
+++ b/tests/test-completion.ui
@@ -353,6 +353,11 @@
<child internal-child="completion">
<object class="GtkSourceCompletion">
<property name="remember_info_visibility">True</property>
+ <child internal-child="info_window">
+ <object class="GtkSourceCompletionInfo">
+ <property name="border_width">3</property>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]