[gtk/bin-removal: 19/40] listboxrow: Derive from GtkWidget
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/bin-removal: 19/40] listboxrow: Derive from GtkWidget
- Date: Tue, 5 May 2020 02:55:29 +0000 (UTC)
commit 12ecbd15080f1dc3b301ee3df10d50d4899ae007
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 3 00:09:18 2020 -0400
listboxrow: Derive from GtkWidget
We want to remove GtkBin and GtkContainer as they don't
provide much useful functionality anymore.
See #2681
demos/icon-browser/iconbrowserwin.c | 2 +-
gtk/a11y/gtklistboxrowaccessible.c | 4 +-
gtk/gtklistbox.c | 91 ++++++++++++++++++++++++++++++++++---
gtk/gtklistbox.h | 13 ++++--
gtk/gtkshortcutswindow.c | 2 +-
gtk/gtkstacksidebar.c | 4 +-
gtk/inspector/actions.c | 2 +-
gtk/inspector/controllers.c | 2 +-
gtk/inspector/general.c | 4 +-
gtk/inspector/object-tree.c | 2 +-
gtk/inspector/prop-list.c | 2 +-
gtk/inspector/recorder.c | 2 +-
gtk/inspector/size-groups.c | 2 +-
gtk/inspector/type-info.c | 2 +-
gtk/ui/gtkplacesviewrow.ui | 4 +-
gtk/ui/gtksidebarrow.ui | 4 +-
tests/testlist.c | 6 +--
tests/testlist3.c | 4 +-
tests/testscrolledge.c | 2 +-
testsuite/gtk/listbox.c | 10 ++--
20 files changed, 124 insertions(+), 40 deletions(-)
---
diff --git a/demos/icon-browser/iconbrowserwin.c b/demos/icon-browser/iconbrowserwin.c
index 858e246c5e..b525034362 100644
--- a/demos/icon-browser/iconbrowserwin.c
+++ b/demos/icon-browser/iconbrowserwin.c
@@ -228,7 +228,7 @@ selected_context_changed (GtkListBox *list, IconBrowserWindow *win)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (win->search), FALSE);
- label = gtk_bin_get_child (GTK_BIN (row));
+ label = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (row));
win->current_context = g_object_get_data (G_OBJECT (label), "context");
gtk_tree_model_filter_refilter (win->filter_model);
}
diff --git a/gtk/a11y/gtklistboxrowaccessible.c b/gtk/a11y/gtklistboxrowaccessible.c
index 27f962347e..6a37efb1a5 100644
--- a/gtk/a11y/gtklistboxrowaccessible.c
+++ b/gtk/a11y/gtklistboxrowaccessible.c
@@ -22,7 +22,7 @@
#include "gtk/gtklistbox.h"
-G_DEFINE_TYPE (GtkListBoxRowAccessible, gtk_list_box_row_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE)
+G_DEFINE_TYPE (GtkListBoxRowAccessible, gtk_list_box_row_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
static void
gtk_list_box_row_accessible_init (GtkListBoxRowAccessible *accessible)
@@ -50,7 +50,7 @@ gtk_list_box_row_accessible_ref_state_set (AtkObject *obj)
if (widget != NULL)
{
parent = gtk_widget_get_parent (widget);
- if (parent != NULL &&
+ if (parent != NULL &&
GTK_IS_LIST_BOX (parent) &&
gtk_list_box_get_selection_mode (GTK_LIST_BOX (parent)) != GTK_SELECTION_NONE)
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 28f7299023..fd9376ae35 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -21,6 +21,7 @@
#include "gtkactionhelperprivate.h"
#include "gtkadjustmentprivate.h"
+#include "gtkbinlayout.h"
#include "gtkbuildable.h"
#include "gtkcssnodeprivate.h"
#include "gtkgestureclick.h"
@@ -156,6 +157,7 @@ struct _GtkListBoxClass
typedef struct
{
+ GtkWidget *child;
GSequenceIter *iter;
GtkWidget *header;
GtkActionHelper *action_helper;
@@ -197,6 +199,7 @@ enum {
ROW_PROP_0,
ROW_PROP_ACTIVATABLE,
ROW_PROP_SELECTABLE,
+ ROW_PROP_CHILD,
/* actionable properties */
ROW_PROP_ACTION_NAME,
@@ -211,13 +214,16 @@ static GtkBuildableIface *parent_buildable_iface;
static void gtk_list_box_buildable_interface_init (GtkBuildableIface *iface);
+static void gtk_list_box_row_buildable_iface_init (GtkBuildableIface *iface);
static void gtk_list_box_row_actionable_iface_init (GtkActionableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkListBox, gtk_list_box, GTK_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_list_box_buildable_interface_init))
-G_DEFINE_TYPE_WITH_CODE (GtkListBoxRow, gtk_list_box_row, GTK_TYPE_BIN,
+G_DEFINE_TYPE_WITH_CODE (GtkListBoxRow, gtk_list_box_row, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (GtkListBoxRow)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+ gtk_list_box_row_buildable_iface_init )
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIONABLE, gtk_list_box_row_actionable_iface_init))
static void gtk_list_box_apply_filter_all (GtkListBox *box);
@@ -328,6 +334,29 @@ static guint signals[LAST_SIGNAL] = { 0 };
static GParamSpec *row_properties[LAST_ROW_PROPERTY] = { NULL, };
static guint row_signals[ROW__LAST_SIGNAL] = { 0 };
+
+static GtkBuildableIface *parent_row_buildable_iface;
+
+static void
+gtk_list_box_row_buildable_add_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *type)
+{
+ if (GTK_IS_WIDGET (child))
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (buildable), GTK_WIDGET (child));
+ else
+ parent_row_buildable_iface->add_child (buildable, builder, child, type);
+}
+
+static void
+gtk_list_box_row_buildable_iface_init (GtkBuildableIface *iface)
+{
+ parent_row_buildable_iface = g_type_interface_peek_parent (iface);
+
+ iface->add_child = gtk_list_box_row_buildable_add_child;
+}
+
/**
* gtk_list_box_new:
*
@@ -2605,7 +2634,7 @@ gtk_list_box_insert (GtkListBox *box,
else
{
row = GTK_LIST_BOX_ROW (gtk_list_box_row_new ());
- gtk_container_add (GTK_CONTAINER (row), child);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), child);
}
if (box->sort_func != NULL)
@@ -2851,6 +2880,42 @@ gtk_list_box_row_new (void)
return g_object_new (GTK_TYPE_LIST_BOX_ROW, NULL);
}
+/**
+ * gtk_list_box_row_set_child:
+ * @row: a #GtkListBoxRow
+ * @child: (allow-none): the child widget
+ *
+ * Sets the child widget of @self.
+ */
+void
+gtk_list_box_row_set_child (GtkListBoxRow *row,
+ GtkWidget *child)
+{
+ GtkListBoxRowPrivate *priv = ROW_PRIV (row);
+
+ g_clear_pointer (&priv->child, gtk_widget_unparent);
+
+ priv->child = child;
+ if (child)
+ gtk_widget_set_parent (child, GTK_WIDGET (row));
+
+ g_object_notify_by_pspec (G_OBJECT (row), row_properties[ROW_PROP_CHILD]);
+}
+
+/**
+ * gtk_list_box_row_get_child:
+ * @row: a #GtkListBoxRow
+ *
+ * Gets the child widget of @row.
+ *
+ * Returns: (nullable) (transfer none): the child widget of @row
+ */
+GtkWidget *
+gtk_list_box_row_get_child (GtkListBoxRow *row)
+{
+ return ROW_PRIV (row)->child;
+}
+
static void
gtk_list_box_row_set_focus (GtkListBoxRow *row)
{
@@ -2868,9 +2933,7 @@ gtk_list_box_row_focus (GtkWidget *widget,
{
GtkListBoxRow *row = GTK_LIST_BOX_ROW (widget);
gboolean had_focus = FALSE;
- GtkWidget *child;
-
- child = gtk_bin_get_child (GTK_BIN (widget));
+ GtkWidget *child = ROW_PRIV (row)->child;
g_object_get (widget, "has-focus", &had_focus, NULL);
if (had_focus)
@@ -3233,6 +3296,9 @@ gtk_list_box_row_get_property (GObject *obj,
case ROW_PROP_ACTION_TARGET:
g_value_set_variant (value, gtk_action_helper_get_action_target_value (ROW_PRIV (row)->action_helper));
break;
+ case ROW_PROP_CHILD:
+ g_value_set_object (value, gtk_list_box_row_get_child (row));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
break;
@@ -3261,6 +3327,9 @@ gtk_list_box_row_set_property (GObject *obj,
case ROW_PROP_ACTION_TARGET:
gtk_list_box_row_set_action_target_value (GTK_ACTIONABLE (row), g_value_get_variant (value));
break;
+ case ROW_PROP_CHILD:
+ gtk_list_box_row_set_child (row, g_value_get_object (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
break;
@@ -3307,6 +3376,7 @@ gtk_list_box_row_dispose (GObject *object)
GtkListBoxRowPrivate *priv = ROW_PRIV (row);
g_clear_object (&priv->action_helper);
+ g_clear_pointer (&priv->child, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_list_box_row_parent_class)->dispose (object);
}
@@ -3333,8 +3403,6 @@ gtk_list_box_row_class_init (GtkListBoxRowClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LIST_BOX_ROW_ACCESSIBLE);
-
object_class->get_property = gtk_list_box_row_get_property;
object_class->set_property = gtk_list_box_row_set_property;
object_class->finalize = gtk_list_box_row_finalize;
@@ -3391,11 +3459,20 @@ gtk_list_box_row_class_init (GtkListBoxRowClass *klass)
TRUE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+ row_properties[ROW_PROP_CHILD] =
+ g_param_spec_object ("child",
+ P_("Child"),
+ P_("The child widget"),
+ GTK_TYPE_WIDGET,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (object_class, LAST_ROW_PROPERTY, row_properties);
g_object_class_override_property (object_class, ROW_PROP_ACTION_NAME, "action-name");
g_object_class_override_property (object_class, ROW_PROP_ACTION_TARGET, "action-target");
+ gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LIST_BOX_ROW_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("row"));
}
diff --git a/gtk/gtklistbox.h b/gtk/gtklistbox.h
index bcd1d1da96..57f26f8c3b 100644
--- a/gtk/gtklistbox.h
+++ b/gtk/gtklistbox.h
@@ -26,7 +26,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
-#include <gtk/gtkbin.h>
+#include <gtk/gtkcontainer.h>
G_BEGIN_DECLS
@@ -48,7 +48,7 @@ typedef struct _GtkListBoxRowClass GtkListBoxRowClass;
struct _GtkListBoxRow
{
- GtkBin parent_instance;
+ GtkWidget parent_instance;
};
/**
@@ -58,7 +58,7 @@ struct _GtkListBoxRow
*/
struct _GtkListBoxRowClass
{
- GtkBinClass parent_class;
+ GtkWidgetClass parent_class;
/*< public >*/
@@ -129,6 +129,13 @@ GDK_AVAILABLE_IN_ALL
GType gtk_list_box_row_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_list_box_row_new (void);
+
+GDK_AVAILABLE_IN_ALL
+void gtk_list_box_row_set_child (GtkListBoxRow *row,
+ GtkWidget *child);
+GDK_AVAILABLE_IN_ALL
+GtkWidget *gtk_list_box_row_get_child (GtkListBoxRow *row);
+
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_list_box_row_get_header (GtkListBoxRow *row);
GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c
index e98644fb09..60ed0cca53 100644
--- a/gtk/gtkshortcutswindow.c
+++ b/gtk/gtkshortcutswindow.c
@@ -365,7 +365,7 @@ gtk_shortcuts_window_add_section (GtkShortcutsWindow *self,
"xalign", 0.5f,
NULL);
g_object_set_data (G_OBJECT (section), "gtk-shortcuts-title", label);
- gtk_container_add (GTK_CONTAINER (row), GTK_WIDGET (label));
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), GTK_WIDGET (label));
gtk_container_add (GTK_CONTAINER (priv->list_box), GTK_WIDGET (row));
update_title_stack (self);
diff --git a/gtk/gtkstacksidebar.c b/gtk/gtkstacksidebar.c
index 8dfed9c749..b28ad7c17a 100644
--- a/gtk/gtkstacksidebar.c
+++ b/gtk/gtkstacksidebar.c
@@ -194,7 +194,7 @@ update_row (GtkStackSidebar *self,
"visible", &visible,
NULL);
- item = gtk_bin_get_child (GTK_BIN (row));
+ item = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (row));
gtk_label_set_text (GTK_LABEL (item), title);
gtk_widget_set_visible (row, visible && title != NULL);
@@ -231,7 +231,7 @@ add_child (guint position,
gtk_widget_set_halign (item, GTK_ALIGN_START);
gtk_widget_set_valign (item, GTK_ALIGN_CENTER);
row = gtk_list_box_row_new ();
- gtk_container_add (GTK_CONTAINER (row), item);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), item);
page = g_list_model_get_item (G_LIST_MODEL (self->pages), position);
update_row (self, page, row);
diff --git a/gtk/inspector/actions.c b/gtk/inspector/actions.c
index 4d2daf0b0c..c50b71cd46 100644
--- a/gtk/inspector/actions.c
+++ b/gtk/inspector/actions.c
@@ -88,7 +88,7 @@ add_action (GtkInspectorActions *sl,
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
label = gtk_label_new (name);
gtk_widget_add_css_class (label, "cell");
diff --git a/gtk/inspector/controllers.c b/gtk/inspector/controllers.c
index 95b9ff3efa..a36e1ee304 100644
--- a/gtk/inspector/controllers.c
+++ b/gtk/inspector/controllers.c
@@ -122,7 +122,7 @@ create_controller_widget (gpointer item,
row = gtk_list_box_row_new ();
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 40);
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
gtk_widget_set_margin_start (box, 10);
gtk_widget_set_margin_end (box, 10);
gtk_widget_set_margin_top (box, 10);
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index 3cb2a3f6f2..5bffd5b1b7 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -184,7 +184,7 @@ add_check_row (GtkInspectorGeneral *gen,
gtk_container_add (GTK_CONTAINER (box), check);
row = gtk_list_box_row_new ();
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
gtk_widget_set_hexpand (box, FALSE);
@@ -227,7 +227,7 @@ add_label_row (GtkInspectorGeneral *gen,
gtk_container_add (GTK_CONTAINER (box), label);
row = gtk_list_box_row_new ();
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
gtk_widget_set_hexpand (box, FALSE);
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c
index 5676b3586e..239f70358a 100644
--- a/gtk/inspector/object-tree.c
+++ b/gtk/inspector/object-tree.c
@@ -999,7 +999,7 @@ gtk_inspector_object_tree_create_list_widget (gpointer row_item,
}
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
column = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_size_group_add_widget (wt->priv->type_size_group, column);
diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c
index 380b3511e7..53600015a5 100644
--- a/gtk/inspector/prop-list.c
+++ b/gtk/inspector/prop-list.c
@@ -529,7 +529,7 @@ gtk_inspector_prop_list_create_row (GtkInspectorPropList *pl,
g_object_set_data (G_OBJECT (row), "pspec", prop);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
label = gtk_label_new (prop->name);
gtk_widget_add_css_class (label, "cell");
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index d59d7ca8a6..af212bed91 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -307,7 +307,7 @@ create_widget_for_render_node (gpointer row_item,
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
row = gtk_list_box_row_new ();
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
/* expander */
depth = gtk_tree_list_row_get_depth (row_item);
diff --git a/gtk/inspector/size-groups.c b/gtk/inspector/size-groups.c
index 10d3d24286..dd39b8293b 100644
--- a/gtk/inspector/size-groups.c
+++ b/gtk/inspector/size-groups.c
@@ -214,7 +214,7 @@ add_widget (GtkInspectorSizeGroups *sl,
gtk_widget_set_margin_bottom (label, 10);
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
- gtk_container_add (GTK_CONTAINER (row), label);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), label);
gtk_container_add (GTK_CONTAINER (listbox), row);
}
diff --git a/gtk/inspector/type-info.c b/gtk/inspector/type-info.c
index d4990f1de4..9f793d9b05 100644
--- a/gtk/inspector/type-info.c
+++ b/gtk/inspector/type-info.c
@@ -68,7 +68,7 @@ add_row (GtkContainer *box,
"xalign", 0.0,
NULL);
- gtk_container_add (GTK_CONTAINER (row), label);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), label);
gtk_container_add (box, row);
}
diff --git a/gtk/ui/gtkplacesviewrow.ui b/gtk/ui/gtkplacesviewrow.ui
index bd4ec79d89..915d20a189 100644
--- a/gtk/ui/gtkplacesviewrow.ui
+++ b/gtk/ui/gtkplacesviewrow.ui
@@ -3,7 +3,7 @@
<requires lib="gtk+" version="3.16"/>
<template class="GtkPlacesViewRow" parent="GtkListBoxRow">
<property name="width-request">100</property>
- <child>
+ <property name="child">
<object class="GtkBox" id="box">
<property name="margin-start">12</property>
<property name="margin-end">12</property>
@@ -79,6 +79,6 @@
</object>
</child>
</object>
- </child>
+ </property>
</template>
</interface>
diff --git a/gtk/ui/gtksidebarrow.ui b/gtk/ui/gtksidebarrow.ui
index e2dc479476..38ecbf3be8 100644
--- a/gtk/ui/gtksidebarrow.ui
+++ b/gtk/ui/gtksidebarrow.ui
@@ -7,7 +7,7 @@
<style>
<class name="sidebar-row"/>
</style>
- <child>
+ <property name="child">
<object class="GtkRevealer" id="revealer">
<property name="reveal-child">1</property>
<signal name="notify::child-revealed" handler="on_child_revealed"/>
@@ -67,6 +67,6 @@
</object>
</child>
</object>
- </child>
+ </property>
</template>
</interface>
diff --git a/tests/testlist.c b/tests/testlist.c
index d0ff42a902..c382097a11 100644
--- a/tests/testlist.c
+++ b/tests/testlist.c
@@ -51,7 +51,7 @@ row_new (const gchar* text, gint sort_id) {
if (text != NULL)
{
row->label = gtk_label_new (text);
- gtk_container_add (GTK_CONTAINER (row), row->label);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), row->label);
gtk_widget_show (row->label);
}
row->sort_id = sort_id;
@@ -317,14 +317,14 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (row_vbox), row_hbox);
check = gtk_check_button_new ();
gtk_container_add (GTK_CONTAINER (row_vbox), check);
- gtk_container_add (GTK_CONTAINER (row), row_vbox);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), row_vbox);
gtk_container_add (GTK_CONTAINER (list), row);
row = row_new (NULL, 0);
button = gtk_button_new_with_label ("focusable row");
gtk_widget_set_hexpand (button, FALSE);
gtk_widget_set_halign (button, GTK_ALIGN_START);
- gtk_container_add (GTK_CONTAINER (row), button);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), button);
gtk_container_add (GTK_CONTAINER (list), row);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
diff --git a/tests/testlist3.c b/tests/testlist3.c
index bc2f61e83f..b067a5b42c 100644
--- a/tests/testlist3.c
+++ b/tests/testlist3.c
@@ -68,7 +68,7 @@ create_row (const gchar *text)
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
g_object_set (box, "margin-start", 10, "margin-end", 10, NULL);
label = gtk_label_new (text);
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
gtk_widget_set_hexpand (label, TRUE);
gtk_container_add (GTK_CONTAINER (box), label);
gtk_container_add (GTK_CONTAINER (box), image);
@@ -91,7 +91,7 @@ on_row_activated (GtkListBox *self,
GtkWidget *child)
{
const char *id;
- id = g_object_get_data (G_OBJECT (gtk_bin_get_child (GTK_BIN (child))), "id");
+ id = g_object_get_data (G_OBJECT (gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (child))), "id");
g_message ("Row activated %p: %s", child, id);
}
diff --git a/tests/testscrolledge.c b/tests/testscrolledge.c
index b6b393167f..97d50ded68 100644
--- a/tests/testscrolledge.c
+++ b/tests/testscrolledge.c
@@ -45,7 +45,7 @@ populate_list (GtkListBox *list)
gtk_widget_set_margin_top (label, 10);
gtk_widget_set_margin_bottom (label, 10);
gtk_widget_set_halign (label, GTK_ALIGN_START);
- gtk_container_add (GTK_CONTAINER (row), label);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), label);
gtk_container_add (GTK_CONTAINER (list), row);
}
}
diff --git a/testsuite/gtk/listbox.c b/testsuite/gtk/listbox.c
index e868f9ae9e..49e3e996bf 100644
--- a/testsuite/gtk/listbox.c
+++ b/testsuite/gtk/listbox.c
@@ -11,10 +11,10 @@ sort_list (GtkListBoxRow *row1,
(*count)++;
- label1 = gtk_bin_get_child (GTK_BIN (row1));
+ label1 = gtk_list_box_row_get_child (row1);
n1 = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label1), "data"));
- label2 = gtk_bin_get_child (GTK_BIN (row2));
+ label2 = gtk_list_box_row_get_child (row2);
n2 = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label2), "data"));
return (n1 - n2);
@@ -34,7 +34,7 @@ check_sorted (GtkListBox *list)
{
row = l->data;
n1 = n2;
- label = gtk_bin_get_child (GTK_BIN (row));
+ label = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (row));
n2 = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), "data"));
g_assert_cmpint (n1, <=, n2);
}
@@ -274,7 +274,7 @@ filter_func (GtkListBoxRow *row,
(*count)++;
- child = gtk_bin_get_child (GTK_BIN (row));
+ child = gtk_list_box_row_get_child (row);
i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (child), "data"));
return (i % 2) == 0;
@@ -356,7 +356,7 @@ header_func (GtkListBoxRow *row,
(*count)++;
- child = gtk_bin_get_child (GTK_BIN (row));
+ child = gtk_list_box_row_get_child (row);
i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (child), "data"));
if (i % 2 == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]