Exposed GtkTreeView's internal GtkTreeSelection for builder files

This commit is contained in:
Tristan Van Berkom 2010-06-25 12:14:28 -04:00
parent d986066cb5
commit 17516dc83c
2 changed files with 38 additions and 13 deletions

View File

@ -46,7 +46,8 @@ former you can use gtk_tree_view_convert_widget_to_bin_window_coords()
<title>GtkTreeView as GtkBuildable</title>
<para>
The GtkTreeView implementation of the GtkBuildable interface accepts
GtkTreeViewColumn objects as &lt;child&gt; elements in UI definitions.
GtkTreeViewColumn objects as &lt;child&gt; elements and exposes the
internal GtkTreeSelection in UI definitions.
</para>
<example>
<title>A UI definition fragment with GtkTreeView</title>
@ -64,6 +65,11 @@ GtkTreeViewColumn objects as &lt;child&gt; elements in UI definitions.
</child>
</object>
</child>
<child internal-child="selection">
<object class="GtkTreeSelection" id="selection">
<signal name="changed" handler="on_treeview_selection_changed"/>
</object>
</child>
</object>
]]></programlisting>
</example>

View File

@ -466,11 +466,14 @@ static GtkTreeViewColumn *gtk_tree_view_get_drop_column (GtkTreeView *tree
gint drop_position);
/* GtkBuildable */
static void gtk_tree_view_buildable_add_child (GtkBuildable *tree_view,
GtkBuilder *builder,
GObject *child,
const gchar *type);
static void gtk_tree_view_buildable_init (GtkBuildableIface *iface);
static void gtk_tree_view_buildable_add_child (GtkBuildable *tree_view,
GtkBuilder *builder,
GObject *child,
const gchar *type);
static GObject *gtk_tree_view_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder,
const gchar *childname);
static void gtk_tree_view_buildable_init (GtkBuildableIface *iface);
static gboolean scroll_row_timeout (gpointer data);
@ -1317,12 +1320,6 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
g_type_class_add_private (o_class, sizeof (GtkTreeViewPrivate));
}
static void
gtk_tree_view_buildable_init (GtkBuildableIface *iface)
{
iface->add_child = gtk_tree_view_buildable_add_child;
}
static void
gtk_tree_view_init (GtkTreeView *tree_view)
{
@ -1545,7 +1542,16 @@ gtk_tree_view_finalize (GObject *object)
G_OBJECT_CLASS (gtk_tree_view_parent_class)->finalize (object);
}
static GtkBuildableIface *parent_buildable_iface;
static void
gtk_tree_view_buildable_init (GtkBuildableIface *iface)
{
parent_buildable_iface = g_type_interface_peek_parent (iface);
iface->add_child = gtk_tree_view_buildable_add_child;
iface->get_internal_child = gtk_tree_view_buildable_get_internal_child;
}
static void
gtk_tree_view_buildable_add_child (GtkBuildable *tree_view,
@ -1556,6 +1562,19 @@ gtk_tree_view_buildable_add_child (GtkBuildable *tree_view,
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), GTK_TREE_VIEW_COLUMN (child));
}
static GObject *
gtk_tree_view_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder,
const gchar *childname)
{
if (strcmp (childname, "selection") == 0)
return G_OBJECT (GTK_TREE_VIEW (buildable)->priv->selection);
return parent_buildable_iface->get_internal_child (buildable,
builder,
childname);
}
/* GtkObject Methods
*/