[gnome-software/mwleeds/hardcoded-pwa-list: 13/14] gs-category-page: Put web apps in a separate section




commit da2e070308568a0fe9933aa2e1488ae8a4785b72
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Thu Mar 24 14:19:52 2022 -0700

    gs-category-page: Put web apps in a separate section

 src/gs-category-page.c  | 10 +++++++++-
 src/gs-category-page.ui | 28 ++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-category-page.c b/src/gs-category-page.c
index 93a45486d..be690e270 100644
--- a/src/gs-category-page.c
+++ b/src/gs-category-page.c
@@ -34,6 +34,7 @@ struct _GsCategoryPage
        GtkWidget       *scrolledwindow_category;
        GtkWidget       *featured_flow_box;
        GtkWidget       *recently_updated_flow_box;
+       GtkWidget       *web_apps_flow_box;
 };
 
 G_DEFINE_TYPE (GsCategoryPage, gs_category_page, GS_TYPE_PAGE)
@@ -289,6 +290,7 @@ load_category_finish (LoadCategoryData *data)
        /* Remove the loading tiles. */
        gs_widget_remove_all (self->featured_flow_box, (GsRemoveFunc) gtk_flow_box_remove);
        gs_widget_remove_all (self->recently_updated_flow_box, (GsRemoveFunc) gtk_flow_box_remove);
+       gs_widget_remove_all (self->web_apps_flow_box, (GsRemoveFunc) gtk_flow_box_remove);
        gs_widget_remove_all (self->category_detail_box, (GsRemoveFunc) gtk_flow_box_remove);
 
        /* Last 30 days */
@@ -332,6 +334,8 @@ load_category_finish (LoadCategoryData *data)
                                recently_updated = g_slist_remove (recently_updated, tile);
                                min_release_date = gs_app_get_release_date (gs_app_tile_get_app (GS_APP_TILE 
(recently_updated->data)));
                        }
+               } else if (gs_app_get_kind (app) == AS_COMPONENT_KIND_WEB_APP) {
+                       flow_box = self->web_apps_flow_box;
                }
 
                if (flow_box != NULL) {
@@ -354,6 +358,7 @@ load_category_finish (LoadCategoryData *data)
        /* Show each of the flow boxes if they have any children. */
        gtk_widget_set_visible (self->featured_flow_box, gtk_flow_box_get_child_at_index (GTK_FLOW_BOX 
(self->featured_flow_box), 0) != NULL);
        gtk_widget_set_visible (self->recently_updated_flow_box, gtk_flow_box_get_child_at_index 
(GTK_FLOW_BOX (self->recently_updated_flow_box), 0) != NULL);
+       gtk_widget_set_visible (self->web_apps_flow_box, gtk_flow_box_get_child_at_index (GTK_FLOW_BOX 
(self->web_apps_flow_box), 0) != NULL);
        gtk_widget_set_visible (self->category_detail_box, gtk_flow_box_get_child_at_index (GTK_FLOW_BOX 
(self->category_detail_box), 0) != NULL);
 
        load_category_data_free (data);
@@ -385,6 +390,7 @@ gs_category_page_load_category (GsCategoryPage *self)
        gs_category_page_add_placeholders (self, GTK_FLOW_BOX (self->category_detail_box),
                                           MIN (30, gs_category_get_size (self->subcategory)));
        gs_category_page_add_placeholders (self, GTK_FLOW_BOX (self->recently_updated_flow_box), 
MAX_RECENTLY_UPDATED_APPS);
+       gs_category_page_add_placeholders (self, GTK_FLOW_BOX (self->web_apps_flow_box), 30);
 
        if (featured_subcat != NULL) {
                /* set up the placeholders as having the featured category is a good
@@ -408,9 +414,10 @@ gs_category_page_load_category (GsCategoryPage *self)
         * query.
         *
         * Once both queries have returned, turn the list of featured apps into
-        * a filter, and split the main list in three:
+        * a filter, and split the main list in four:
         *  - Featured apps
         *  - Recently updated apps
+        *  - Web apps
         *  - Everything else
         * Then populate the UI.
         *
@@ -670,6 +677,7 @@ gs_category_page_class_init (GsCategoryPageClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, scrolledwindow_category);
        gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, featured_flow_box);
        gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, recently_updated_flow_box);
+       gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, web_apps_flow_box);
 
        gtk_widget_class_bind_template_callback (widget_class, top_carousel_app_clicked_cb);
 }
diff --git a/src/gs-category-page.ui b/src/gs-category-page.ui
index 5ab50b4da..4fd72a32c 100644
--- a/src/gs-category-page.ui
+++ b/src/gs-category-page.ui
@@ -89,6 +89,34 @@
                       </object>
                     </child>
 
+                    <child>
+                      <object class="GtkLabel" id="web_apps_heading">
+                        <property name="visible" bind-source="web_apps_flow_box" bind-property="visible" 
bind-flags="sync-create|bidirectional" />
+                        <property name="xalign">0</property>
+                        <property name="margin_top">24</property>
+                        <property name="label" translatable="yes" comments="Heading for web apps on a 
category page">Picks from the Web</property>
+                        <style>
+                          <class name="heading"/>
+                        </style>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkFlowBox" id="web_apps_flow_box">
+                        <property name="visible">False</property>
+                        <property name="column_spacing">14</property>
+                        <property name="halign">fill</property>
+                        <property name="row_spacing">14</property>
+                        <property name="homogeneous">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="valign">start</property>
+                        <property name="selection-mode">none</property>
+                        <accessibility>
+                          <relation name="labelled-by">web_apps_heading</relation>
+                        </accessibility>
+                      </object>
+                    </child>
+
                     <child>
                       <object class="GtkLabel" id="other_heading">
                         <property name="visible" bind-source="category_detail_box" bind-property="visible" 
bind-flags="sync-create|bidirectional" />


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