Don't use container api on GtkListBox

This commit is contained in:
Matthias Clasen 2020-05-08 02:19:18 -04:00
parent ff91ce9eb4
commit 88141103cd
31 changed files with 211 additions and 229 deletions

View File

@ -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)

View File

@ -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),

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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;
GtkWidget *row;
rows = gtk_container_get_children (GTK_CONTAINER (sidebar->list_box));
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;
g_list_free (rows);
if (!GTK_IS_LIST_BOX_ROW (row))
continue;
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;
}

View File

@ -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 */

View File

@ -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);

View File

@ -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");
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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));

View File

@ -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);

View File

@ -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)

View File

@ -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 (child = gtk_widget_get_first_child (box);
child != NULL;
child = gtk_widget_get_next_sibling (child))
block_controller (G_OBJECT (child));
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), 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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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));
}

View File

@ -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);

View File

@ -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

View File

@ -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);
}
}

View File

@ -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

View File

@ -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

View File

@ -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;