diff options
author | Alexander Mikhaylenko <alexm@gnome.org> | 2022-02-16 13:45:21 +0500 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2022-02-18 15:47:03 +0000 |
commit | 9464fe084317f8648261b081bd2b494636422ec2 (patch) | |
tree | 161a6e2f772bbd9ab4a50d5186d812ff2614fa82 /src/ephy-encoding-dialog.c | |
parent | 646544c089ed88e579e47bb34f977f95a3336d41 (diff) | |
download | epiphany-9464fe084317f8648261b081bd2b494636422ec2.tar.gz |
Stop using gtk_container_get_children() for GtkListBox and GtkFlowBox
Leave one instance in EphyHistoryDialog that gets the last child of the
listbox - that would be painful to do with gtk_list_box_get_row_at_index()
and in GTK4 we'll just use gtk_widget_get_last_child() instead.
Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1072>
Diffstat (limited to 'src/ephy-encoding-dialog.c')
-rw-r--r-- | src/ephy-encoding-dialog.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c index 862d13aed..e305bb14e 100644 --- a/src/ephy-encoding-dialog.c +++ b/src/ephy-encoding-dialog.c @@ -77,30 +77,29 @@ select_encoding_row (GtkListBox *list_box, EphyEncoding *encoding) { const char *target_encoding; - GList *rows, *r; + GtkListBoxRow *row; + int i = 0; target_encoding = ephy_encoding_get_encoding (encoding); - rows = gtk_container_get_children (GTK_CONTAINER (list_box)); - for (r = rows; r != NULL; r = r->next) { + while ((row = gtk_list_box_get_row_at_index (list_box, i++))) { EphyEncodingRow *ephy_encoding_row; EphyEncoding *ephy_encoding; const char *encoding_string = NULL; - ephy_encoding_row = EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (r->data))); + ephy_encoding_row = EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (row))); ephy_encoding = ephy_encoding_row_get_encoding (ephy_encoding_row); encoding_string = ephy_encoding_get_encoding (ephy_encoding); if (g_strcmp0 (encoding_string, target_encoding) == 0) { ephy_encoding_row_set_selected (ephy_encoding_row, TRUE); - gtk_list_box_select_row (list_box, GTK_LIST_BOX_ROW (r->data)); + gtk_list_box_select_row (list_box, row); /* TODO scroll to row */ break; } } - g_list_free (rows); } static void @@ -221,21 +220,16 @@ ephy_encoding_dialog_response_cb (GtkWidget *widget, } static void -clean_selected_row (gpointer row, - gpointer null_pointer) -{ - EphyEncodingRow *ephy_encoding_row; - ephy_encoding_row = EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (row))); - ephy_encoding_row_set_selected (ephy_encoding_row, FALSE); -} - -static void clean_selected_list_box (GtkListBox *list_box) { - GList *rows; - rows = gtk_container_get_children (GTK_CONTAINER (list_box)); - g_list_foreach (rows, (GFunc)clean_selected_row, NULL); - g_list_free (rows); + GtkListBoxRow *row; + int i = 0; + + while ((row = gtk_list_box_get_row_at_index (list_box, i++))) { + EphyEncodingRow *ephy_encoding_row = + EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (row))); + ephy_encoding_row_set_selected (ephy_encoding_row, FALSE); + } } static void |