[gnome-software: 21/110] Replace gtk_container_destroy with alternative ways




commit fd00ce2f5792d09abe2223918d1fc4de6c0e21ce
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Aug 21 19:52:49 2021 -0300

    Replace gtk_container_destroy with alternative ways
    
    This covers the second case mentioned in the previous commit.
    
    Note: Once again, there's no AdwDeck. This API is fruit of my
    imagination. It'll be directly ported to AdwLeaflet soon.

 src/gs-repo-row.c        | 5 ++++-
 src/gs-update-dialog.c   | 2 +-
 src/gs-updates-page.c    | 2 +-
 src/gs-updates-section.c | 7 ++-----
 4 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/gs-repo-row.c b/src/gs-repo-row.c
index 7df24e0e3..eced34ffd 100644
--- a/src/gs-repo-row.c
+++ b/src/gs-repo-row.c
@@ -44,6 +44,7 @@ static void
 refresh_ui (GsRepoRow *row)
 {
        GsRepoRowPrivate *priv = gs_repo_row_get_instance_private (row);
+       GtkListBox *listbox;
        gboolean active = FALSE;
        gboolean state_sensitive = FALSE;
        gboolean busy = priv->busy_counter> 0;
@@ -77,7 +78,9 @@ refresh_ui (GsRepoRow *row)
                break;
        case GS_APP_STATE_UNAVAILABLE:
                g_signal_handler_unblock (priv->disable_switch, priv->switch_handler_id);
-               gtk_widget_destroy (GTK_WIDGET (row));
+               listbox = GTK_LIST_BOX (gtk_widget_get_parent (GTK_WIDGET (row)));
+               g_assert (listbox != NULL);
+               gtk_list_box_remove (listbox, GTK_WIDGET (row));
                return;
        default:
                state_sensitive = TRUE;
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 4f2a3a2ac..67b6cf3ee 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -52,7 +52,7 @@ deck_child_transition_cb (AdwDeck *deck, GParamSpec *pspec, GsUpdateDialog *dial
                return;
 
        while ((child = adw_deck_get_adjacent_child (deck, ADW_NAVIGATION_DIRECTION_FORWARD)))
-               gtk_widget_destroy (child);
+               adw_deck_remove (deck, child);
 }
 
 static void
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index 1eab2c13d..f07cb100a 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -1402,7 +1402,7 @@ gs_updates_page_dispose (GObject *object)
 
        for (guint i = 0; i < GS_UPDATES_SECTION_KIND_LAST; i++) {
                if (self->sections[i] != NULL) {
-                       gtk_widget_destroy (GTK_WIDGET (self->sections[i]));
+                       gtk_widget_unparent (GTK_WIDGET (self->sections[i]));
                        self->sections[i] = NULL;
                }
        }
diff --git a/src/gs-updates-section.c b/src/gs-updates-section.c
index e76654c20..f09a33e8f 100644
--- a/src/gs-updates-section.c
+++ b/src/gs-updates-section.c
@@ -108,7 +108,7 @@ _row_unrevealed_cb (GObject *row, GParamSpec *pspec, gpointer data)
 
        gs_app_list_remove (self->list, gs_app_row_get_app (GS_APP_ROW (row)));
 
-       gtk_widget_destroy (GTK_WIDGET (row));
+       gtk_list_box_remove (GTK_LIST_BOX (self->listbox), GTK_WIDGET (row));
 
        if (!gs_app_list_length (self->list))
                gtk_widget_hide (widget);
@@ -167,10 +167,7 @@ gs_updates_section_remove_all (GsUpdatesSection *self)
        children = gtk_container_get_children (GTK_CONTAINER (self));
        for (GList *l = children; l != NULL; l = l->next) {
                GtkWidget *w = GTK_WIDGET (l->data);
-               /* Destroying, rather than just removing, prevents the ::unrevealed
-                * signal from being emitted, which would cause unfortunate reentrancy.
-                */
-               gtk_widget_destroy (w);
+               gtk_list_box_remove (GTK_LIST_BOX (self->listbox), GTK_WIDGET (w));
        }
        gs_app_list_remove_all (self->list);
        gtk_widget_hide (GTK_WIDGET (self));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]