[gtk/kill-containers: 178/199] Don't use container api on GtkListBox
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/kill-containers: 178/199] Don't use container api on GtkListBox
- Date: Tue, 12 May 2020 00:38:51 +0000 (UTC)
commit 94f4e14f5862c02c05be2492c65f343375929b9d
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 8 02:19:18 2020 -0400
Don't use container api on GtkListBox
demos/gtk-demo/css_blendmodes.c | 7 ++-
demos/gtk-demo/css_multiplebgs.c | 6 +--
demos/gtk-demo/css_pixbufs.c | 6 +--
demos/gtk-demo/css_shadows.c | 6 +--
demos/gtk-demo/dnd.c | 4 +-
demos/gtk-demo/listbox.c | 2 +-
demos/gtk-demo/shortcut_triggers.c | 2 +-
docs/tools/widgets.c | 8 +--
gtk/gtklistbox.c | 2 +-
gtk/gtkplacessidebar.c | 104 ++++++++++++++++++-------------------
gtk/gtkplacesview.c | 41 +++++++--------
gtk/gtkshortcutswindow.c | 2 +-
gtk/gtksidebarrow.c | 5 +-
gtk/gtkstacksidebar.c | 4 +-
gtk/inspector/action-editor.c | 14 ++---
gtk/inspector/actions.c | 12 +++--
gtk/inspector/general.c | 18 ++++---
gtk/inspector/misc-info.c | 4 +-
gtk/inspector/prop-editor.c | 32 ++++++------
gtk/inspector/prop-list.c | 2 +-
gtk/inspector/size-groups.c | 12 ++---
gtk/inspector/strv-editor.c | 12 ++---
gtk/inspector/type-info.c | 27 ++++------
tests/testclipboard2.c | 4 +-
tests/testgtk.c | 2 +-
tests/testlist.c | 14 ++---
tests/testlist2.c | 2 +-
tests/testscrolledge.c | 10 ++--
tests/testscrolledwindow.c | 14 ++---
tests/testselectionmode.c | 23 ++++++--
testsuite/gtk/listbox.c | 41 ++++++---------
31 files changed, 212 insertions(+), 230 deletions(-)
---
diff --git a/demos/gtk-demo/css_blendmodes.c b/demos/gtk-demo/css_blendmodes.c
index 7031039225..3ddbbc0c37 100644
--- a/demos/gtk-demo/css_blendmodes.c
+++ b/demos/gtk-demo/css_blendmodes.c
@@ -79,7 +79,7 @@ setup_listbox (GtkBuilder *builder,
normal_row = NULL;
listbox = gtk_list_box_new ();
- gtk_container_add (GTK_CONTAINER (WID ("scrolledwindow")), listbox);
+ gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (WID ("scrolledwindow")), listbox);
g_signal_connect (listbox, "row-activated", G_CALLBACK (row_activated), provider);
@@ -95,9 +95,8 @@ setup_listbox (GtkBuilder *builder,
"xalign", 0.0,
NULL);
- gtk_container_add (GTK_CONTAINER (row), label);
-
- gtk_container_add (GTK_CONTAINER (listbox), row);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), label);
+ gtk_list_box_insert (GTK_LIST_BOX (listbox), row, -1);
/* The first selected row is "normal" */
if (g_strcmp0 (blend_modes[i].id, "normal") == 0)
diff --git a/demos/gtk-demo/css_multiplebgs.c b/demos/gtk-demo/css_multiplebgs.c
index 4a9dd81792..f9a66a5b35 100644
--- a/demos/gtk-demo/css_multiplebgs.c
+++ b/demos/gtk-demo/css_multiplebgs.c
@@ -114,7 +114,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
/* Need a filler so we get a handle */
child = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (paned), child);
+ gtk_paned_set_start_child (GTK_PANED (paned), child);
text = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (text,
@@ -129,9 +129,9 @@ do_css_multiplebgs (GtkWidget *do_widget)
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
container = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (paned), container);
+ gtk_paned_set_end_child (GTK_PANED (paned), container);
child = gtk_text_view_new_with_buffer (text);
- gtk_container_add (GTK_CONTAINER (container), child);
+ gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
g_signal_connect (text,
"changed",
G_CALLBACK (css_text_changed),
diff --git a/demos/gtk-demo/css_pixbufs.c b/demos/gtk-demo/css_pixbufs.c
index 2617c76280..b05e208edc 100644
--- a/demos/gtk-demo/css_pixbufs.c
+++ b/demos/gtk-demo/css_pixbufs.c
@@ -83,7 +83,7 @@ do_css_pixbufs (GtkWidget *do_widget)
/* Need a filler so we get a handle */
child = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (paned), child);
+ gtk_paned_set_start_child (GTK_PANED (paned), child);
text = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (text,
@@ -98,9 +98,9 @@ do_css_pixbufs (GtkWidget *do_widget)
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
container = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (paned), container);
+ gtk_paned_set_end_child (GTK_PANED (paned), container);
child = gtk_text_view_new_with_buffer (text);
- gtk_container_add (GTK_CONTAINER (container), child);
+ gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
g_signal_connect (text, "changed",
G_CALLBACK (css_text_changed), provider);
diff --git a/demos/gtk-demo/css_shadows.c b/demos/gtk-demo/css_shadows.c
index b41e7eb16f..ba94b888f2 100644
--- a/demos/gtk-demo/css_shadows.c
+++ b/demos/gtk-demo/css_shadows.c
@@ -101,7 +101,7 @@ do_css_shadows (GtkWidget *do_widget)
gtk_window_set_child (GTK_WINDOW (window), paned);
child = create_toolbar ();
- gtk_container_add (GTK_CONTAINER (paned), child);
+ gtk_paned_set_start_child (GTK_PANED (paned), child);
text = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (text,
@@ -116,9 +116,9 @@ do_css_shadows (GtkWidget *do_widget)
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
container = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (paned), container);
+ gtk_paned_set_end_child (GTK_PANED (paned), container);
child = gtk_text_view_new_with_buffer (text);
- gtk_container_add (GTK_CONTAINER (container), child);
+ gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
g_signal_connect (text, "changed",
G_CALLBACK (css_text_changed), provider);
diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c
index 98faf8a9f9..ac9a8ab9f1 100644
--- a/demos/gtk-demo/dnd.c
+++ b/demos/gtk-demo/dnd.c
@@ -119,7 +119,7 @@ new_item_cb (GtkWidget *button, gpointer data)
GtkWidget *item;
item = canvas_item_new (pos_x, pos_y);
- gtk_container_add (GTK_CONTAINER (canvas), item);
+ gtk_fixed_put (GTK_FIXED (canvas), item, 0, 0);
apply_transform (item);
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
@@ -457,7 +457,7 @@ do_dnd (GtkWidget *do_widget)
GtkWidget *item;
item = canvas_item_new (x, y);
- gtk_container_add (GTK_CONTAINER (canvas), item);
+ gtk_fixed_put (GTK_FIXED (canvas), item, 0, 0);
apply_transform (item);
x += 150;
diff --git a/demos/gtk-demo/listbox.c b/demos/gtk-demo/listbox.c
index 9221cab837..ae67cf91df 100644
--- a/demos/gtk-demo/listbox.c
+++ b/demos/gtk-demo/listbox.c
@@ -377,7 +377,7 @@ do_listbox (GtkWidget *do_widget)
message = gtk_message_new (lines[i]);
row = gtk_message_row_new (message);
gtk_widget_show (GTK_WIDGET (row));
- gtk_container_add (GTK_CONTAINER (listbox), GTK_WIDGET (row));
+ gtk_list_box_insert (GTK_LIST_BOX (listbox), GTK_WIDGET (row), -1);
}
g_strfreev (lines);
diff --git a/demos/gtk-demo/shortcut_triggers.c b/demos/gtk-demo/shortcut_triggers.c
index 126b9f051d..b84cb0354c 100644
--- a/demos/gtk-demo/shortcut_triggers.c
+++ b/demos/gtk-demo/shortcut_triggers.c
@@ -71,7 +71,7 @@ do_shortcut_triggers (GtkWidget *do_widget)
GtkWidget *row;
row = gtk_label_new (shortcuts[i].description);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
controller = gtk_shortcut_controller_new ();
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (controller),
GTK_SHORTCUT_SCOPE_GLOBAL);
diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
index 3415b2b730..2a1858e978 100644
--- a/docs/tools/widgets.c
+++ b/docs/tools/widgets.c
@@ -1265,7 +1265,7 @@ create_list_box (void)
gtk_widget_set_hexpand (button, TRUE);
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (row), button);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_container_add (GTK_CONTAINER (row), gtk_label_new ("Line One"));
button = gtk_check_button_new ();
@@ -1273,7 +1273,7 @@ create_list_box (void)
gtk_widget_set_hexpand (button, TRUE);
gtk_widget_set_halign (button, GTK_ALIGN_END);
gtk_container_add (GTK_CONTAINER (row), button);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
gtk_list_box_select_row (GTK_LIST_BOX (list), GTK_LIST_BOX_ROW (gtk_widget_get_parent (row)));
row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_container_add (GTK_CONTAINER (row), gtk_label_new ("Line Two"));
@@ -1281,14 +1281,14 @@ create_list_box (void)
gtk_widget_set_hexpand (button, TRUE);
gtk_widget_set_halign (button, GTK_ALIGN_END);
gtk_container_add (GTK_CONTAINER (row), button);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_container_add (GTK_CONTAINER (row), gtk_label_new ("Line Three"));
button = gtk_entry_new ();
gtk_widget_set_hexpand (button, TRUE);
gtk_widget_set_halign (button, GTK_ALIGN_END);
gtk_container_add (GTK_CONTAINER (row), button);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
gtk_container_add (GTK_CONTAINER (widget), list);
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 74a413ffb1..0a3fad9d20 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -3617,7 +3617,7 @@ gtk_list_box_bind_model (GtkListBox *box,
{
GtkWidget *row = g_sequence_get (iter);
iter = g_sequence_iter_next (iter);
- gtk_list_box_remove (GTK_CONTAINER (box), row);
+ gtk_list_box_remove (GTK_LIST_BOX (box), row);
}
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 06712a79e2..0b43e070f3 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -479,7 +479,7 @@ add_place (GtkPlacesSidebar *sidebar,
G_CALLBACK (on_row_dragged), row);
gtk_widget_add_controller (row, GTK_EVENT_CONTROLLER (gesture));
- gtk_container_add (GTK_CONTAINER (sidebar->list_box), GTK_WIDGET (row));
+ gtk_list_box_insert (GTK_LIST_BOX (sidebar->list_box), GTK_WIDGET (row), -1);
return row;
}
@@ -687,15 +687,17 @@ file_is_shown (GtkPlacesSidebar *sidebar,
GFile *file)
{
gchar *uri;
- GList *rows;
- GList *l;
+ GtkWidget *row;
gboolean found = FALSE;
- rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box));
- l = rows;
- while (l != NULL && !found)
+ for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box));
+ row != NULL && !found;
+ row = gtk_widget_get_next_sibling (row))
{
- g_object_get (l->data, "uri", &uri, NULL);
+ if (!GTK_IS_LIST_BOX_ROW (row))
+ continue;
+
+ g_object_get (row, "uri", &uri, NULL);
if (uri)
{
GFile *other;
@@ -704,11 +706,8 @@ file_is_shown (GtkPlacesSidebar *sidebar,
g_object_unref (other);
g_free (uri);
}
- l = l->next;
}
- g_list_free (rows);
-
return found;
}
@@ -979,7 +978,7 @@ update_places (GtkPlacesSidebar *sidebar)
gchar *tooltip;
GList *network_mounts, *network_volumes;
GIcon *new_bookmark_icon;
- GList *children;
+ GtkWidget *child;
#ifdef HAVE_CLOUDPROVIDERS
GList *cloud_providers;
GList *cloud_providers_accounts;
@@ -1002,10 +1001,8 @@ update_places (GtkPlacesSidebar *sidebar)
/* Reset drag state, just in case we update the places while dragging or
* ending a drag */
stop_drop_feedback (sidebar);
- children = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box));
- for (l = children; l; l = l->next)
- gtk_container_remove (GTK_CONTAINER (sidebar->list_box), l->data);
- g_list_free (children);
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box))))
+ gtk_list_box_remove (GTK_LIST_BOX (sidebar->list_box), child);
network_mounts = network_volumes = NULL;
@@ -1575,19 +1572,21 @@ static void
update_possible_drop_targets (GtkPlacesSidebar *sidebar,
const GValue *value)
{
- GList *rows;
- GList *l;
- gboolean sensitive;
-
- rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box));
+ GtkWidget *row;
- for (l = rows; l != NULL; l = l->next)
+ for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box));
+ row != NULL;
+ row = gtk_widget_get_next_sibling (row))
{
- sensitive = value == NULL || check_valid_drop_target (sidebar, GTK_SIDEBAR_ROW (l->data), value);
- gtk_widget_set_sensitive (GTK_WIDGET (l->data), sensitive);
- }
+ gboolean sensitive;
+
+ if (!GTK_IS_LIST_BOX_ROW (row))
+ continue;
- g_list_free (rows);
+ sensitive = value == NULL ||
+ check_valid_drop_target (sidebar, GTK_SIDEBAR_ROW (row), value);
+ gtk_widget_set_sensitive (row, sensitive);
+ }
}
static void
@@ -1626,7 +1625,7 @@ stop_drop_feedback (GtkPlacesSidebar *sidebar)
if (sidebar->row_placeholder != NULL)
{
if (gtk_widget_get_parent (sidebar->row_placeholder) != NULL)
- gtk_container_remove (GTK_CONTAINER (sidebar), sidebar->row_placeholder);
+ gtk_list_box_remove (GTK_LIST_BOX (sidebar), sidebar->row_placeholder);
sidebar->row_placeholder = NULL;
}
@@ -1683,10 +1682,7 @@ drag_motion_callback (GtkDropTarget *target,
}
if (gtk_widget_get_parent (sidebar->row_placeholder) != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (sidebar->list_box),
- sidebar->row_placeholder);
- }
+ gtk_list_box_remove (GTK_LIST_BOX (sidebar->list_box), sidebar->row_placeholder);
if (row != NULL)
{
@@ -2201,8 +2197,7 @@ rename_entry_changed (GtkEntry *entry,
gchar *uri;
const gchar *new_name;
gboolean found = FALSE;
- GList *rows;
- GList *l;
+ GtkWidget *row;
new_name = gtk_editable_get_text (GTK_EDITABLE (sidebar->rename_entry));
@@ -2213,10 +2208,14 @@ rename_entry_changed (GtkEntry *entry,
return;
}
- rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box));
- for (l = rows; l && !found; l = l->next)
+ for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box));
+ row != NULL && !found;
+ row = gtk_widget_get_next_sibling (row))
{
- g_object_get (l->data,
+ if (!GTK_IS_LIST_BOX_ROW (row))
+ continue;
+
+ g_object_get (row,
"place-type", &type,
"uri", &uri,
"label", &name,
@@ -2230,7 +2229,6 @@ rename_entry_changed (GtkEntry *entry,
g_free (uri);
g_free (name);
}
- g_list_free (rows);
gtk_widget_set_sensitive (sidebar->rename_button, !found);
gtk_label_set_label (GTK_LABEL (sidebar->rename_error),
@@ -4470,8 +4468,7 @@ void
gtk_places_sidebar_set_location (GtkPlacesSidebar *sidebar,
GFile *location)
{
- GList *children;
- GList *child;
+ GtkWidget *row;
gchar *row_uri;
gchar *uri;
gboolean found = FALSE;
@@ -4491,14 +4488,18 @@ gtk_places_sidebar_set_location (GtkPlacesSidebar *sidebar,
uri = g_file_get_uri (location);
- children = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box));
- for (child = children; child != NULL && !found; child = child->next)
+ for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box));
+ row != NULL && !found;
+ row = gtk_widget_get_next_sibling (row))
{
- g_object_get (child->data, "uri", &row_uri, NULL);
+ if (!GTK_IS_LIST_BOX_ROW (row))
+ continue;
+
+ g_object_get (row, "uri", &row_uri, NULL);
if (row_uri != NULL && g_strcmp0 (row_uri, uri) == 0)
{
gtk_list_box_select_row (GTK_LIST_BOX (sidebar->list_box),
- GTK_LIST_BOX_ROW (child->data));
+ GTK_LIST_BOX_ROW (row));
found = TRUE;
}
@@ -4506,7 +4507,6 @@ gtk_places_sidebar_set_location (GtkPlacesSidebar *sidebar,
}
g_free (uri);
- g_list_free (children);
out:
g_object_notify_by_pspec (G_OBJECT (sidebar), properties[PROP_LOCATION]);
@@ -4898,24 +4898,25 @@ GFile *
gtk_places_sidebar_get_nth_bookmark (GtkPlacesSidebar *sidebar,
gint n)
{
- GList *rows;
- GList *l;
+ GtkWidget *row;
int k;
GFile *file;
g_return_val_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar), NULL);
file = NULL;
- rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box));
- l = rows;
-
k = 0;
- while (l != NULL)
+ for (row = gtk_widget_get_first_child (GTK_WIDGET (sidebar->list_box));
+ row != NULL;
+ row = gtk_widget_get_next_sibling (row))
{
GtkPlacesSidebarPlaceType place_type;
gchar *uri;
- g_object_get (l->data,
+ if (!GTK_IS_LIST_BOX_ROW (row))
+ continue;
+
+ g_object_get (row,
"place-type", &place_type,
"uri", &uri,
NULL);
@@ -4930,11 +4931,8 @@ gtk_places_sidebar_get_nth_bookmark (GtkPlacesSidebar *sidebar,
k++;
}
g_free (uri);
- l = l->next;
}
- g_list_free (rows);
-
return file;
}
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index fa4ac5201a..94ca0d09e7 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -548,8 +548,8 @@ populate_servers (GtkPlacesView *view)
}
/* clear previous items */
- while ((child = gtk_widget_get_first_child (view->recent_servers_listbox)))
- gtk_container_remove (GTK_CONTAINER (view->recent_servers_listbox), child);
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (view->recent_servers_listbox))))
+ gtk_list_box_remove (GTK_LIST_BOX (view->listbox), child);
gtk_list_store_clear (view->completion_store);
@@ -606,7 +606,7 @@ populate_servers (GtkPlacesView *view)
gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 2);
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), grid);
- gtk_container_add (GTK_CONTAINER (view->recent_servers_listbox), row);
+ gtk_list_box_insert (GTK_LIST_BOX (view->recent_servers_listbox), row, -1);
/* custom data */
data = g_new0 (RemoveServerData, 1);
@@ -631,27 +631,24 @@ populate_servers (GtkPlacesView *view)
static void
update_view_mode (GtkPlacesView *view)
{
- GList *children;
- GList *l;
+ GtkWidget *child;
gboolean show_listbox;
show_listbox = FALSE;
/* drives */
- children = gtk_container_get_children (GTK_CONTAINER (view->listbox));
-
- for (l = children; l; l = l->next)
+ for (child = gtk_widget_get_first_child (GTK_WIDGET (view->listbox));
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
{
/* GtkListBox filter rows by changing their GtkWidget::child-visible property */
- if (gtk_widget_get_child_visible (l->data))
+ if (gtk_widget_get_child_visible (child))
{
show_listbox = TRUE;
break;
}
}
- g_list_free (children);
-
if (!show_listbox &&
view->search_query &&
view->search_query[0] != '\0')
@@ -698,7 +695,7 @@ insert_row (GtkPlacesView *view,
gtk_places_view_row_set_path_size_group (GTK_PLACES_VIEW_ROW (row), view->path_size_group);
gtk_places_view_row_set_space_size_group (GTK_PLACES_VIEW_ROW (row), view->space_size_group);
- gtk_container_add (GTK_CONTAINER (view->listbox), row);
+ gtk_list_box_insert (GTK_LIST_BOX (view->listbox), row, -1);
}
static void
@@ -838,23 +835,21 @@ add_file (GtkPlacesView *view,
static gboolean
has_networks (GtkPlacesView *view)
{
- GList *l;
- GList *children;
+ GtkWidget *child;
gboolean has_network = FALSE;
- children = gtk_container_get_children (GTK_CONTAINER (view->listbox));
- for (l = children; l != NULL; l = l->next)
+ for (child = gtk_widget_get_first_child (GTK_WIDGET (view->listbox));
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
{
- if (GPOINTER_TO_INT (g_object_get_data (l->data, "is-network")) == TRUE &&
- g_object_get_data (l->data, "is-placeholder") == NULL)
+ if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (child), "is-network")) &&
+ g_object_get_data (G_OBJECT (child), "is-placeholder") == NULL)
{
has_network = TRUE;
break;
}
}
- g_list_free (children);
-
return has_network;
}
@@ -879,7 +874,7 @@ update_network_state (GtkPlacesView *view)
/* mark the row as placeholder, so it always goes first */
g_object_set_data (G_OBJECT (view->network_placeholder),
"is-placeholder", GINT_TO_POINTER (TRUE));
- gtk_container_add (GTK_CONTAINER (view->listbox), view->network_placeholder);
+ gtk_list_box_insert (GTK_LIST_BOX (view->listbox), view->network_placeholder, -1);
}
if (gtk_places_view_get_fetching_networks (view))
@@ -1093,8 +1088,8 @@ update_places (GtkPlacesView *view)
GtkWidget *child;
/* Clear all previously added items */
- while ((child = gtk_widget_get_first_child (view->listbox)))
- gtk_container_remove (GTK_CONTAINER (view->listbox), child);
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (view->listbox))))
+ gtk_list_box_remove (GTK_LIST_BOX (view->listbox), child);
view->network_placeholder = NULL;
/* Inform clients that we started loading */
diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c
index 68ce8b8c70..1e87a8a732 100644
--- a/gtk/gtkshortcutswindow.c
+++ b/gtk/gtkshortcutswindow.c
@@ -370,7 +370,7 @@ gtk_shortcuts_window_add_section (GtkShortcutsWindow *self,
NULL);
g_object_set_data (G_OBJECT (section), "gtk-shortcuts-title", 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));
+ gtk_list_box_insert (GTK_LIST_BOX (priv->list_box), GTK_WIDGET (row), -1);
update_title_stack (self);
diff --git a/gtk/gtksidebarrow.c b/gtk/gtksidebarrow.c
index 9b7c19d86a..0a2749a122 100644
--- a/gtk/gtksidebarrow.c
+++ b/gtk/gtksidebarrow.c
@@ -330,8 +330,6 @@ gtk_sidebar_row_set_property (GObject *object,
self->placeholder = g_value_get_boolean (value);
if (self->placeholder)
{
- GtkWidget *child;
-
g_clear_object (&self->start_icon);
g_clear_object (&self->end_icon);
g_free (self->label);
@@ -349,8 +347,7 @@ gtk_sidebar_row_set_property (GObject *object,
g_clear_object (&self->mount);
g_clear_object (&self->cloud_provider_account);
- while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
- gtk_container_remove (GTK_CONTAINER (self), child);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (self), NULL);
gtk_widget_add_css_class (GTK_WIDGET (self), "sidebar-placeholder-row");
}
diff --git a/gtk/gtkstacksidebar.c b/gtk/gtkstacksidebar.c
index 37eccfb7c3..f72000ab3b 100644
--- a/gtk/gtkstacksidebar.c
+++ b/gtk/gtkstacksidebar.c
@@ -236,7 +236,7 @@ add_child (guint position,
page = g_list_model_get_item (G_LIST_MODEL (self->pages), position);
update_row (self, page, row);
- gtk_container_add (GTK_CONTAINER (self->list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (self->list), row, -1);
g_object_set_data (G_OBJECT (row), "child-index", GUINT_TO_POINTER (position));
if (gtk_selection_model_is_selected (self->pages, position))
@@ -270,7 +270,7 @@ clear_sidebar (GtkStackSidebar *self)
g_hash_table_iter_init (&iter, self->rows);
while (g_hash_table_iter_next (&iter, (gpointer *)&page, (gpointer *)&row))
{
- gtk_container_remove (GTK_CONTAINER (self->list), row);
+ gtk_list_box_remove (GTK_LIST_BOX (self->list), row);
g_hash_table_iter_remove (&iter);
g_signal_handlers_disconnect_by_func (page, on_page_updated, self);
}
diff --git a/gtk/inspector/action-editor.c b/gtk/inspector/action-editor.c
index ba8f227c92..fa74f2cfee 100644
--- a/gtk/inspector/action-editor.c
+++ b/gtk/inspector/action-editor.c
@@ -143,13 +143,10 @@ variant_editor_set_value (GtkWidget *editor,
}
else
{
- GList *children;
- GtkEntry *entry;
+ GtkWidget *entry;
gchar *text;
- children = gtk_container_get_children (GTK_CONTAINER (editor));
- entry = children->data;
- g_list_free (children);
+ entry = gtk_widget_get_first_child (editor);
text = g_variant_print (value, FALSE);
gtk_editable_set_text (GTK_EDITABLE (entry), text);
@@ -178,14 +175,11 @@ variant_editor_get_value (GtkWidget *editor)
}
else
{
- GList *children;
- GtkEntry *entry;
+ GtkWidget *entry;
const gchar *text;
- children = gtk_container_get_children (GTK_CONTAINER (editor));
- entry = children->data;
+ entry = gtk_widget_get_first_child (editor);
text = gtk_editable_get_text (GTK_EDITABLE (entry));
- g_list_free (children);
value = g_variant_parse (type, text, NULL, NULL, NULL);
}
diff --git a/gtk/inspector/actions.c b/gtk/inspector/actions.c
index d7018078ba..78133cb456 100644
--- a/gtk/inspector/actions.c
+++ b/gtk/inspector/actions.c
@@ -123,7 +123,7 @@ add_action (GtkInspectorActions *sl,
gtk_container_add (GTK_CONTAINER (box), editor);
g_object_set_data (G_OBJECT (row), "editor", editor);
- gtk_container_add (GTK_CONTAINER (sl->priv->list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (sl->priv->list), row, -1);
g_free (state_string);
}
@@ -134,12 +134,16 @@ find_row (GtkInspectorActions *sl,
{
GtkWidget *row = NULL;
GtkWidget *widget;
+ const char *key;
for (widget = gtk_widget_get_first_child (sl->priv->list);
widget;
widget = gtk_widget_get_next_sibling (widget))
{
- const char *key = g_object_get_data (G_OBJECT (widget), "key");
+ if (!GTK_IS_LIST_BOX_ROW (widget))
+ continue;
+
+ key = g_object_get_data (G_OBJECT (widget), "key");
if (g_str_equal (key, action_name))
{
row = widget;
@@ -167,7 +171,7 @@ action_removed_cb (GActionGroup *group,
row = find_row (sl, action_name);
if (row)
- gtk_container_remove (GTK_CONTAINER (sl->priv->list), row);
+ gtk_list_box_remove (GTK_LIST_BOX (sl->priv->list), row);
}
static void
@@ -312,7 +316,7 @@ gtk_inspector_actions_set_object (GtkInspectorActions *sl,
remove_group (sl, page, sl->priv->group);
while ((child = gtk_widget_get_first_child (sl->priv->list)))
- gtk_container_remove (GTK_CONTAINER (sl->priv->list), child);
+ gtk_list_box_remove (GTK_LIST_BOX (sl->priv->list), child);
if (GTK_IS_APPLICATION (object))
add_group (sl, page, G_ACTION_GROUP (object));
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index 5e52fcd63a..36b6ad0b9a 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -523,7 +523,14 @@ populate_display (GdkDisplay *display, GtkInspectorGeneral *gen)
gtk_widget_show (gen->priv->display_composited);
list = GTK_LIST_BOX (gen->priv->display_box);
- children = gtk_container_get_children (GTK_CONTAINER (list));
+ children = NULL;
+ for (child = gtk_widget_get_first_child (GTK_WIDGET (list));
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ {
+ if (GTK_IS_LIST_BOX_ROW (child))
+ children = g_list_prepend (children, child);
+ }
for (l = children; l; l = l->next)
{
child = l->data;
@@ -532,7 +539,7 @@ populate_display (GdkDisplay *display, GtkInspectorGeneral *gen)
gtk_widget_is_ancestor (gen->priv->display_composited, child))
continue;
- gtk_container_remove (GTK_CONTAINER (list), child);
+ gtk_list_box_remove (list, child);
}
g_list_free (children);
@@ -792,13 +799,12 @@ add_seat (GtkInspectorGeneral *gen,
static void
populate_seats (GtkInspectorGeneral *gen)
{
+ GtkWidget *child;
GList *list, *l;
int i;
- list = gtk_container_get_children (GTK_CONTAINER (gen->priv->device_box));
- for (l = list; l; l = l->next)
- gtk_container_remove (GTK_CONTAINER (gen->priv->device_box), GTK_WIDGET (l->data));
- g_list_free (list);
+ while ((child = gtk_widget_get_first_child (gen->priv->device_box)))
+ gtk_list_box_remove (GTK_LIST_BOX (gen->priv->device_box), child);
list = gdk_display_list_seats (gen->priv->display);
diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c
index e7dd6df908..54d7e993bb 100644
--- a/gtk/inspector/misc-info.c
+++ b/gtk/inspector/misc-info.c
@@ -331,8 +331,8 @@ update_info (gpointer data)
AtkRole role;
GList *list, *l;
- while ((child = gtk_widget_get_first_child (sl->priv->mnemonic_label)))
- gtk_container_remove (GTK_CONTAINER (sl->priv->mnemonic_label), child);
+ while ((child = gtk_widget_get_first_child (sl->priv->mnemonic_label)))
+ gtk_widget_unparent (child);
list = gtk_widget_list_mnemonic_labels (GTK_WIDGET (sl->priv->object));
for (l = list; l; l = l->next)
diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c
index 94d4577c6d..ff8f18cc81 100644
--- a/gtk/inspector/prop-editor.c
+++ b/gtk/inspector/prop-editor.c
@@ -551,7 +551,6 @@ flags_to_string (GFlagsClass *flags_class,
static void
flags_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
- GList *children, *c;
GValue val = G_VALUE_INIT;
GFlagsClass *fclass;
guint flags;
@@ -561,6 +560,7 @@ flags_changed (GObject *object, GParamSpec *pspec, gpointer data)
GtkWidget *viewport;
GtkWidget *box;
char *str;
+ GtkWidget *child;
fclass = G_FLAGS_CLASS (g_type_class_peek (pspec->value_type));
@@ -577,19 +577,21 @@ flags_changed (GObject *object, GParamSpec *pspec, gpointer data)
sw = gtk_popover_get_child (GTK_POPOVER (popover));
viewport = gtk_scrolled_window_get_child (GTK_SCROLLED_WINDOW (sw));
box = gtk_viewport_get_child (GTK_VIEWPORT (viewport));
- children = gtk_container_get_children (GTK_CONTAINER (box));
-
- for (c = children; c; c = c->next)
- block_controller (G_OBJECT (c->data));
-
- for (c = children, i = 0; c; c = c->next, i++)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (c->data),
+ for (child = gtk_widget_get_first_child (box);
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ block_controller (G_OBJECT (child));
+
+ for (child = gtk_widget_get_first_child (box), i = 0;
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child), i++)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (child),
(fclass->values[i].value & flags) != 0);
- for (c = children; c; c = c->next)
- unblock_controller (G_OBJECT (c->data));
-
- g_list_free (children);
+ for (child = gtk_widget_get_first_child (box);
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ unblock_controller (G_OBJECT (child));
}
static gunichar
@@ -671,11 +673,9 @@ object_changed (GObject *object, GParamSpec *pspec, gpointer data)
gchar *str;
GObject *obj;
- GList *children = gtk_container_get_children (GTK_CONTAINER (data));
- label = GTK_WIDGET (children->data);
- button = GTK_WIDGET (children->next->data);
+ label = gtk_widget_get_first_child (GTK_WIDGET (data));
+ button = gtk_widget_get_next_sibling (label);
g_object_get (object, pspec->name, &obj, NULL);
- g_list_free (children);
str = object_label (obj, pspec);
diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c
index b26c0fc70e..a0d1d76435 100644
--- a/gtk/inspector/prop-list.c
+++ b/gtk/inspector/prop-list.c
@@ -612,7 +612,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
continue;
row = gtk_inspector_prop_list_create_row (pl, prop);
- gtk_container_add (GTK_CONTAINER (pl->priv->list2), row);
+ gtk_list_box_insert (GTK_LIST_BOX (pl->priv->list2), row, -1);
}
g_free (props);
diff --git a/gtk/inspector/size-groups.c b/gtk/inspector/size-groups.c
index dd39b8293b..19946541ca 100644
--- a/gtk/inspector/size-groups.c
+++ b/gtk/inspector/size-groups.c
@@ -183,16 +183,10 @@ G_DEFINE_TYPE (GtkInspectorSizeGroups, gtk_inspector_size_groups, GTK_TYPE_BOX)
static void
clear_view (GtkInspectorSizeGroups *sl)
{
- GList *children, *l;
GtkWidget *child;
- children = gtk_container_get_children (GTK_CONTAINER (sl));
- for (l = children; l; l = l->next)
- {
- child = l->data;
- gtk_container_remove (GTK_CONTAINER (sl), child);
- }
- g_list_free (children);
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (sl))))
+ gtk_container_remove (GTK_CONTAINER (sl), child);
}
static void
@@ -215,7 +209,7 @@ add_widget (GtkInspectorSizeGroups *sl,
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), label);
- gtk_container_add (GTK_CONTAINER (listbox), row);
+ gtk_list_box_insert (listbox, row, -1);
}
static void
diff --git a/gtk/inspector/strv-editor.c b/gtk/inspector/strv-editor.c
index 2471251fd8..77cb5551e8 100644
--- a/gtk/inspector/strv-editor.c
+++ b/gtk/inspector/strv-editor.c
@@ -136,7 +136,7 @@ gtk_inspector_strv_editor_set_strv (GtkInspectorStrvEditor *editor,
editor->blocked = TRUE;
- while ((child = gtk_widget_get_first_child (editor->box)))
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (editor->box))))
gtk_container_remove (GTK_CONTAINER (editor->box), child);
if (strv)
@@ -153,20 +153,20 @@ gtk_inspector_strv_editor_set_strv (GtkInspectorStrvEditor *editor,
gchar **
gtk_inspector_strv_editor_get_strv (GtkInspectorStrvEditor *editor)
{
- GList *children, *l;
+ GtkWidget *child;
GPtrArray *p;
p = g_ptr_array_new ();
- children = gtk_container_get_children (GTK_CONTAINER (editor->box));
- for (l = children; l; l = l->next)
+ for (child = gtk_widget_get_first_child (editor->box);
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
{
GtkEntry *entry;
- entry = GTK_ENTRY (g_object_get_data (G_OBJECT (l->data), "entry"));
+ entry = GTK_ENTRY (g_object_get_data (G_OBJECT (child), "entry"));
g_ptr_array_add (p, g_strdup (gtk_editable_get_text (GTK_EDITABLE (entry))));
}
- g_list_free (children);
g_ptr_array_add (p, NULL);
diff --git a/gtk/inspector/type-info.c b/gtk/inspector/type-info.c
index 9f793d9b05..f14d32cb61 100644
--- a/gtk/inspector/type-info.c
+++ b/gtk/inspector/type-info.c
@@ -47,8 +47,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorTypePopover, gtk_inspector_type_popover,
GTK_TYPE_POPOVER)
static void
-add_row (GtkContainer *box,
- const gchar *name)
+add_row (GtkWidget *box,
+ const char *name)
{
GtkWidget *row;
GtkWidget *label;
@@ -69,15 +69,7 @@ add_row (GtkContainer *box,
NULL);
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), label);
- gtk_container_add (box, row);
-}
-
-static void
-remove_row (GtkWidget *item,
- gpointer data)
-{
- if (GTK_IS_LIST_BOX_ROW (item))
- gtk_container_remove (GTK_CONTAINER (data), item);
+ gtk_list_box_insert (GTK_LIST_BOX (box), row, -1);
}
void
@@ -91,6 +83,7 @@ gtk_inspector_type_popover_set_gtype (GtkInspectorTypePopover *self,
GType *interfaces;
GType tmp;
gint i;
+ GtkWidget *child;
g_return_if_fail (GTK_IS_INSPECTOR_TYPE_POPOVER (self));
@@ -101,10 +94,10 @@ gtk_inspector_type_popover_set_gtype (GtkInspectorTypePopover *self,
priv->type = gtype;
- gtk_container_foreach (GTK_CONTAINER (priv->parents),
- remove_row, priv->parents);
- gtk_container_foreach (GTK_CONTAINER (priv->interfaces),
- remove_row, priv->interfaces);
+ while ((child = gtk_widget_get_first_child (priv->parents)))
+ gtk_list_box_remove (GTK_LIST_BOX (priv->parents), child);
+ while ((child = gtk_widget_get_first_child (priv->interfaces)))
+ gtk_list_box_remove (GTK_LIST_BOX (priv->interfaces), child);
implements = g_hash_table_new (g_str_hash, g_str_equal);
@@ -112,7 +105,7 @@ gtk_inspector_type_popover_set_gtype (GtkInspectorTypePopover *self,
do
{
- add_row (GTK_CONTAINER (priv->parents), g_type_name (tmp));
+ add_row (priv->parents, g_type_name (tmp));
interfaces = g_type_interfaces (tmp, NULL);
@@ -126,7 +119,7 @@ gtk_inspector_type_popover_set_gtype (GtkInspectorTypePopover *self,
g_hash_table_iter_init (&iter, implements);
while (g_hash_table_iter_next (&iter, (gpointer *) &name, NULL))
- add_row (GTK_CONTAINER (priv->interfaces), name);
+ add_row (priv->interfaces, name);
g_hash_table_unref (implements);
}
diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c
index 7c93c302df..a7d61be95b 100644
--- a/tests/testclipboard2.c
+++ b/tests/testclipboard2.c
@@ -207,7 +207,7 @@ format_list_add_row (GtkWidget *list,
gtk_container_add (GTK_CONTAINER (box), gtk_label_new (format_name));
gdk_content_formats_unref (formats);
- gtk_container_add (GTK_CONTAINER (list), box);
+ gtk_list_box_insert (GTK_LIST_BOX (list), box, -1);
}
static void
@@ -222,7 +222,7 @@ clipboard_formats_change_cb (GdkClipboard *clipboard,
gsize i, n;
while ((row = GTK_WIDGET (gtk_list_box_get_row_at_index (GTK_LIST_BOX (list), 0))))
- gtk_container_remove (GTK_CONTAINER (list), row);
+ gtk_list_box_remove (GTK_LIST_BOX (list), row);
formats = gdk_clipboard_get_formats (clipboard);
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 0e4c6e0171..244cfe08bc 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -1547,7 +1547,7 @@ create_listbox (GtkWidget *widget)
{
gint value = g_random_int_range (0, 10000);
label = gtk_label_new (g_strdup_printf ("Value %u", value));
- gtk_container_add (GTK_CONTAINER (list), label);
+ gtk_list_box_insert (GTK_LIST_BOX (list), label, -1);
g_object_set_data (G_OBJECT (gtk_widget_get_parent (label)), "value", GINT_TO_POINTER (value));
}
diff --git a/tests/testlist.c b/tests/testlist.c
index 497122844f..c001651a4d 100644
--- a/tests/testlist.c
+++ b/tests/testlist.c
@@ -197,7 +197,7 @@ add_clicked_cb (GtkButton *button,
static int new_button_nr = 1;
new_row = row_new( g_strdup_printf ("blah2 new %d", new_button_nr), new_button_nr);
- gtk_container_add (GTK_CONTAINER (list), new_row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), new_row, -1);
new_button_nr++;
}
@@ -294,13 +294,13 @@ main (int argc, char *argv[])
g_signal_connect (list, "row-selected", G_CALLBACK (row_selected_cb), NULL);
row = row_new ("blah4", 4);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
row3 = row = row_new ("blah3", 3);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
row = row_new ("blah1", 1);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
row = row_new ("blah2", 2);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
row = row_new (NULL, 0);
row_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
@@ -315,14 +315,14 @@ main (int argc, char *argv[])
check = gtk_check_button_new ();
gtk_container_add (GTK_CONTAINER (row_vbox), check);
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), row_vbox);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
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_list_box_row_set_child (GTK_LIST_BOX_ROW (row), button);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (hbox), vbox);
diff --git a/tests/testlist2.c b/tests/testlist2.c
index 90a6fe1539..bfb009be5b 100644
--- a/tests/testlist2.c
+++ b/tests/testlist2.c
@@ -8,7 +8,7 @@ row_unrevealed (GObject *revealer, GParamSpec *pspec, gpointer data)
row = gtk_widget_get_parent (GTK_WIDGET (revealer));
list = gtk_widget_get_parent (row);
- gtk_container_remove (GTK_CONTAINER (list), row);
+ gtk_list_box_remove (GTK_LIST_BOX (list), row);
}
static void
diff --git a/tests/testscrolledge.c b/tests/testscrolledge.c
index 16d8ac7664..150d6fa936 100644
--- a/tests/testscrolledge.c
+++ b/tests/testscrolledge.c
@@ -27,11 +27,11 @@ populate_list (GtkListBox *list)
gchar *text;
GtkWidget *row, *label;
gint n;
- GList *l;
+ GtkWidget *child;
- l = gtk_container_get_children (GTK_CONTAINER (list));
- n = g_list_length (l);
- g_list_free (l);
+ for (child = gtk_widget_get_first_child (GTK_WIDGET (list)), n = 0;
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child), n++) ;
for (i = 1; i <= 50; i++)
{
@@ -46,7 +46,7 @@ populate_list (GtkListBox *list)
gtk_widget_set_margin_bottom (label, 10);
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), label);
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
}
}
diff --git a/tests/testscrolledwindow.c b/tests/testscrolledwindow.c
index ffbd26bae5..c6b6ebf12b 100644
--- a/tests/testscrolledwindow.c
+++ b/tests/testscrolledwindow.c
@@ -58,23 +58,19 @@ add_row (GtkButton *button,
GtkWidget *row;
row = g_object_new (GTK_TYPE_LIST_BOX_ROW, NULL);
- gtk_container_add (GTK_CONTAINER (row), gtk_label_new ("test"));
- gtk_container_add (GTK_CONTAINER (listbox), row);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), gtk_label_new ("test"));
+ gtk_list_box_insert (GTK_LIST_BOX (listbox), row, -1);
}
static void
remove_row (GtkButton *button,
GtkListBox *listbox)
{
- GList *children, *last;
-
- children = gtk_container_get_children (GTK_CONTAINER (listbox));
- last = g_list_last (children);
+ GtkWidget *last;
+ last = gtk_widget_get_last_child (GTK_WIDGET (listbox));
if (last)
- gtk_container_remove (GTK_CONTAINER (listbox), last->data);
-
- g_list_free (children);
+ gtk_list_box_remove (GTK_LIST_BOX (listbox), last);
}
static void
diff --git a/tests/testselectionmode.c b/tests/testselectionmode.c
index 7e912c9ae3..65747dbfe8 100644
--- a/tests/testselectionmode.c
+++ b/tests/testselectionmode.c
@@ -39,7 +39,7 @@ selectable_row_add (SelectableRow *row, GtkWidget *child)
}
static void
-update_selectable (GtkWidget *widget, gpointer data)
+update_selectable (GtkWidget *widget)
{
SelectableRow *row = (SelectableRow *)widget;
GtkListBox *list;
@@ -53,7 +53,7 @@ update_selectable (GtkWidget *widget, gpointer data)
}
static void
-update_selected (GtkWidget *widget, gpointer data)
+update_selected (GtkWidget *widget)
{
SelectableRow *row = (SelectableRow *)widget;
@@ -103,6 +103,7 @@ selection_mode_enter (GtkButton *button, GtkBuilder *builder)
GtkWidget *cancelbutton;
GtkWidget *selectbutton;
GtkWidget *titlestack;
+ GtkWidget *child;
header = GTK_WIDGET (gtk_builder_get_object (builder, "header"));
list = GTK_WIDGET (gtk_builder_get_object (builder, "list"));
@@ -120,7 +121,10 @@ selection_mode_enter (GtkButton *button, GtkBuilder *builder)
gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (list), FALSE);
gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_MULTIPLE);
- gtk_container_forall (GTK_CONTAINER (list), update_selectable, NULL);
+ for (child = gtk_widget_get_first_child (list);
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ update_selectable (child);
}
static void
@@ -132,6 +136,7 @@ selection_mode_leave (GtkButton *button, GtkBuilder *builder)
GtkWidget *cancelbutton;
GtkWidget *selectbutton;
GtkWidget *titlestack;
+ GtkWidget *child;
header = GTK_WIDGET (gtk_builder_get_object (builder, "header"));
list = GTK_WIDGET (gtk_builder_get_object (builder, "list"));
@@ -149,7 +154,10 @@ selection_mode_leave (GtkButton *button, GtkBuilder *builder)
gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (list), TRUE);
gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);
- gtk_container_forall (GTK_CONTAINER (list), update_selectable, NULL);
+ for (child = gtk_widget_get_first_child (list);
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ update_selectable (child);
}
static void
@@ -167,7 +175,12 @@ select_none (GAction *action, GVariant *param, GtkWidget *list)
static void
selected_rows_changed (GtkListBox *list)
{
- gtk_container_forall (GTK_CONTAINER (list), update_selected, NULL);
+ GtkWidget *child;
+
+ for (child = gtk_widget_get_first_child (GTK_WIDGET (list));
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ update_selected (child);
}
int
diff --git a/testsuite/gtk/listbox.c b/testsuite/gtk/listbox.c
index 49e3e996bf..c36c855faa 100644
--- a/testsuite/gtk/listbox.c
+++ b/testsuite/gtk/listbox.c
@@ -23,22 +23,19 @@ sort_list (GtkListBoxRow *row1,
static void
check_sorted (GtkListBox *list)
{
- GList *children;
GtkWidget *row, *label;
gint n1, n2;
- GList *l;
n2 = n1 = 0;
- children = gtk_container_get_children (GTK_CONTAINER (list));
- for (l = children; l; l = l->next)
+ for (row = gtk_widget_get_first_child (GTK_WIDGET (list));
+ row != NULL;
+ row = gtk_widget_get_next_sibling (row))
{
- row = l->data;
n1 = n2;
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);
}
- g_list_free (children);
}
static void
@@ -62,7 +59,7 @@ test_sort (void)
label = gtk_label_new (s);
g_object_set_data (G_OBJECT (label), "data", GINT_TO_POINTER (r));
g_free (s);
- gtk_container_add (GTK_CONTAINER (list), label);
+ gtk_list_box_insert (GTK_LIST_BOX (list), label, -1);
}
count = 0;
@@ -121,7 +118,7 @@ test_selection (void)
label = gtk_label_new (s);
g_object_set_data (G_OBJECT (label), "data", GINT_TO_POINTER (i));
g_free (s);
- gtk_container_add (GTK_CONTAINER (list), label);
+ gtk_list_box_insert (GTK_LIST_BOX (list), label, -1);
}
count = 0;
@@ -145,7 +142,7 @@ test_selection (void)
g_assert (row2 == row);
gtk_list_box_set_selection_mode (list, GTK_SELECTION_BROWSE);
- gtk_container_remove (GTK_CONTAINER (list), GTK_WIDGET (row));
+ gtk_list_box_remove (GTK_LIST_BOX (list), GTK_WIDGET (row));
g_assert (callback_row == NULL);
g_assert_cmpint (count, ==, 4);
row2 = gtk_list_box_get_selected_row (list);
@@ -211,7 +208,7 @@ test_multi_selection (void)
label = gtk_label_new (s);
g_object_set_data (G_OBJECT (label), "data", GINT_TO_POINTER (i));
g_free (s);
- gtk_container_add (GTK_CONTAINER (list), label);
+ gtk_list_box_insert (GTK_LIST_BOX (list), label, -1);
}
count = 0;
@@ -283,19 +280,17 @@ filter_func (GtkListBoxRow *row,
static void
check_filtered (GtkListBox *list)
{
- GList *children, *l;
gint count;
GtkWidget *row;
count = 0;
- children = gtk_container_get_children (GTK_CONTAINER (list));
- for (l = children; l; l = l->next)
+ for (row = gtk_widget_get_first_child (GTK_WIDGET (list));
+ row != NULL;
+ row = gtk_widget_get_next_sibling (row))
{
- row = l->data;
if (gtk_widget_get_child_visible (row))
count++;
}
- g_list_free (children);
g_assert_cmpint (count, ==, 50);
}
@@ -322,7 +317,7 @@ test_filter (void)
label = gtk_label_new (s);
g_object_set_data (G_OBJECT (label), "data", GINT_TO_POINTER (i));
g_free (s);
- gtk_container_add (GTK_CONTAINER (list), label);
+ gtk_list_box_insert (GTK_LIST_BOX (list), label, -1);
}
count = 0;
@@ -374,19 +369,17 @@ header_func (GtkListBoxRow *row,
static void
check_headers (GtkListBox *list)
{
- GList *children, *l;
gint count;
- GtkListBoxRow *row;
+ GtkWidget *row;
count = 0;
- children = gtk_container_get_children (GTK_CONTAINER (list));
- for (l = children; l; l = l->next)
+ for (row = gtk_widget_get_first_child (GTK_WIDGET (list));
+ row != NULL;
+ row = gtk_widget_get_next_sibling (row))
{
- row = l->data;
- if (gtk_list_box_row_get_header (row) != NULL)
+ if (gtk_list_box_row_get_header (GTK_LIST_BOX_ROW (row)) != NULL)
count++;
}
- g_list_free (children);
g_assert_cmpint (count, ==, 50);
}
@@ -413,7 +406,7 @@ test_header (void)
label = gtk_label_new (s);
g_object_set_data (G_OBJECT (label), "data", GINT_TO_POINTER (i));
g_free (s);
- gtk_container_add (GTK_CONTAINER (list), label);
+ gtk_list_box_insert (GTK_LIST_BOX (list), label, -1);
}
count = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]