[gnome-software/1587-updates-glitchy-empty-list: 5/11] gs-app-row: Unmapped row does not hide




commit a52597928b5811a1d640cca38ef2751553158427
Author: Milan Crha <mcrha redhat com>
Date:   Wed Aug 24 05:56:19 2022 +0200

    gs-app-row: Unmapped row does not hide
    
    The GtkRevealer does not animate when the widget is not mapped, thus
    just emit the "unrevealed" signal on an idle callback in such case.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1587

 src/gs-app-row.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 952dadbef..4b0c421f7 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -49,6 +49,7 @@ typedef struct
        gboolean         show_installed_size;
        gboolean         show_installed;
        guint            pending_refresh_id;
+       guint            unreveal_in_idle_id;
        gboolean         is_narrow;
 } GsAppRowPrivate;
 
@@ -553,6 +554,19 @@ child_unrevealed (GObject *revealer, GParamSpec *pspec, gpointer user_data)
        g_signal_emit (app_row, signals[SIGNAL_UNREVEALED], 0);
 }
 
+static gboolean
+child_unrevealed_unmapped_cb (gpointer user_data)
+{
+       GsAppRow *app_row = user_data;
+       GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
+
+       priv->unreveal_in_idle_id = 0;
+
+       g_signal_emit (app_row, signals[SIGNAL_UNREVEALED], 0);
+
+       return G_SOURCE_REMOVE;
+}
+
 void
 gs_app_row_unreveal (GsAppRow *app_row)
 {
@@ -564,6 +578,14 @@ gs_app_row_unreveal (GsAppRow *app_row)
        child = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (app_row));
        gtk_widget_set_sensitive (child, FALSE);
 
+       /* Revealer does not animate when the widget is not mapped */
+       if (!gtk_widget_get_mapped (GTK_WIDGET (app_row))) {
+               GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
+               if (priv->unreveal_in_idle_id == 0)
+                       priv->unreveal_in_idle_id = g_idle_add_full (G_PRIORITY_HIGH, 
child_unrevealed_unmapped_cb, app_row, NULL);
+               return;
+       }
+
        revealer = gtk_revealer_new ();
        gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
        gtk_widget_show (revealer);
@@ -734,10 +756,8 @@ gs_app_row_dispose (GObject *object)
                g_signal_handlers_disconnect_by_func (priv->app, gs_app_row_notify_props_changed_cb, app_row);
 
        g_clear_object (&priv->app);
-       if (priv->pending_refresh_id != 0) {
-               g_source_remove (priv->pending_refresh_id);
-               priv->pending_refresh_id = 0;
-       }
+       g_clear_handle_id (&priv->pending_refresh_id, g_source_remove);
+       g_clear_handle_id (&priv->unreveal_in_idle_id, g_source_remove);
 
        G_OBJECT_CLASS (gs_app_row_parent_class)->dispose (object);
 }


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