diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-05-08 02:19:18 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-11 22:21:39 -0400 |
commit | 88141103cdf5fd294b19d4473245f42201aa6b93 (patch) | |
tree | 362ab942aad3cb7da2158ca34e865e00a14489c5 /gtk | |
parent | ff91ce9eb45f0aac43b218b05cbf8e5b89ed8e32 (diff) | |
download | gtk+-88141103cdf5fd294b19d4473245f42201aa6b93.tar.gz |
Don't use container api on GtkListBox
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtklistbox.c | 2 | ||||
-rw-r--r-- | gtk/gtkplacessidebar.c | 104 | ||||
-rw-r--r-- | gtk/gtkplacesview.c | 41 | ||||
-rw-r--r-- | gtk/gtkshortcutswindow.c | 2 | ||||
-rw-r--r-- | gtk/gtksidebarrow.c | 5 | ||||
-rw-r--r-- | gtk/gtkstacksidebar.c | 4 | ||||
-rw-r--r-- | gtk/inspector/action-editor.c | 14 | ||||
-rw-r--r-- | gtk/inspector/actions.c | 12 | ||||
-rw-r--r-- | gtk/inspector/general.c | 18 | ||||
-rw-r--r-- | gtk/inspector/misc-info.c | 4 | ||||
-rw-r--r-- | gtk/inspector/prop-editor.c | 32 | ||||
-rw-r--r-- | gtk/inspector/prop-list.c | 2 | ||||
-rw-r--r-- | gtk/inspector/size-groups.c | 12 | ||||
-rw-r--r-- | gtk/inspector/strv-editor.c | 12 | ||||
-rw-r--r-- | gtk/inspector/type-info.c | 27 |
15 files changed, 136 insertions, 155 deletions
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); } |