[gnome-software/1381-category-page-loading-state-doesn-t-match-final-layout: 49/52] gs-featured-carousel: Use empty content when no apps are set
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1381-category-page-loading-state-doesn-t-match-final-layout: 49/52] gs-featured-carousel: Use empty content when no apps are set
- Date: Fri, 28 Jan 2022 09:56:43 +0000 (UTC)
commit 28ac1ebe59d4b14572fd67027a0303742af7e887
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 60b5d21d2..c0af48922 100644
--- a/src/gs-featured-carousel.c
+++ b/src/gs-featured-carousel.c
@@ -362,7 +362,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);
@@ -370,14 +372,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]