[gnome-software/1381-category-page-loading-state-doesn-t-match-final-layout] gs-featured-carousel: Use empty content when no apps are set



commit 9706ea8f44612ac2c5d7521f60649f0049a09564
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jan 20 12:42:32 2022 +0100

    gs-featured-carousel: Use empty content when no apps are set
    
    This helps to show "being loaded" content in the carousel.

 src/gs-featured-carousel.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-featured-carousel.c b/src/gs-featured-carousel.c
index 50ceb2057..a75d11252 100644
--- a/src/gs-featured-carousel.c
+++ b/src/gs-featured-carousel.c
@@ -370,7 +370,9 @@ gs_featured_carousel_set_apps (GsFeaturedCarousel *self,
        g_return_if_fail (GS_IS_FEATURED_CAROUSEL (self));
        g_return_if_fail (apps == NULL || GS_IS_APP_LIST (apps));
 
-       if (apps == self->apps)
+       /* Need to cleanup the content also after the widget is created,
+        * thus always pass through for the NULL 'apps'. */
+       if (apps != NULL && apps == self->apps)
                return;
 
        stop_rotation_timer (self);
@@ -378,14 +380,22 @@ gs_featured_carousel_set_apps (GsFeaturedCarousel *self,
 
        g_set_object (&self->apps, apps);
 
-       for (guint i = 0; i < gs_app_list_length (apps); i++) {
-               GsApp *app = gs_app_list_index (apps, i);
-               GtkWidget *tile = gs_feature_tile_new (app);
+       if (apps != NULL) {
+               for (guint i = 0; i < gs_app_list_length (apps); i++) {
+                       GsApp *app = gs_app_list_index (apps, i);
+                       GtkWidget *tile = gs_feature_tile_new (app);
+                       gtk_widget_set_hexpand (tile, TRUE);
+                       gtk_widget_set_vexpand (tile, TRUE);
+                       gtk_widget_set_can_focus (tile, FALSE);
+                       g_signal_connect (tile, "clicked",
+                                         G_CALLBACK (app_tile_clicked_cb), self);
+                       adw_carousel_append (self->carousel, tile);
+               }
+       } else  {
+               GtkWidget *tile = gs_feature_tile_new (NULL);
                gtk_widget_set_hexpand (tile, TRUE);
                gtk_widget_set_vexpand (tile, TRUE);
                gtk_widget_set_can_focus (tile, FALSE);
-               g_signal_connect (tile, "clicked",
-                                 G_CALLBACK (app_tile_clicked_cb), self);
                adw_carousel_append (self->carousel, tile);
        }
 


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