[gnome-software/gnome-3-26] overview page: Remove old recommended categories before adding new



commit 470bc278fa88ed9d6246bc0046b788ce8a9c2056
Author: Kalev Lember <klember redhat com>
Date:   Fri Jan 12 13:33:16 2018 +0100

    overview page: Remove old recommended categories before adding new
    
    This fixes a long standing bug where in some cases we'd load the
    overview page more than once, and each time add two more recommended
    categories.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784525

 src/gs-overview-page.c  |  9 +++++++--
 src/gs-overview-page.ui | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index b1bc95af..872f1cbf 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -58,6 +58,7 @@ typedef struct
        GtkWidget               *bin_featured;
        GtkWidget               *box_overview;
        GtkWidget               *box_popular;
+       GtkWidget               *box_popular_rotating;
        GtkWidget               *box_recent;
        GtkWidget               *featured_heading;
        GtkWidget               *category_heading;
@@ -326,14 +327,14 @@ gs_overview_page_get_category_apps_cb (GObject *source_object,
        g_signal_connect (button, "clicked",
                          G_CALLBACK (gs_overview_page_category_more_cb), self);
        gtk_container_add (GTK_CONTAINER (headerbox), button);
-       gtk_container_add (GTK_CONTAINER (priv->box_overview), headerbox);
+       gtk_container_add (GTK_CONTAINER (priv->box_popular_rotating), headerbox);
 
        /* add hiding box */
        box = gs_hiding_box_new ();
        gs_hiding_box_set_spacing (GS_HIDING_BOX (box), 14);
        gtk_widget_set_visible (box, TRUE);
        gtk_widget_set_valign (box, GTK_ALIGN_START);
-       gtk_container_add (GTK_CONTAINER (priv->box_overview), box);
+       gtk_container_add (GTK_CONTAINER (priv->box_popular_rotating), box);
 
        /* add all the apps */
        for (i = 0; i < gs_app_list_length (list) && i < N_TILES; i++) {
@@ -602,6 +603,9 @@ gs_overview_page_load (GsOverviewPage *self)
                g_autoptr(GPtrArray) cats_random = NULL;
                cats_random = gs_overview_page_get_random_categories ();
 
+               /* remove existing widgets, if any */
+               gs_container_remove_all (GTK_CONTAINER (priv->box_popular_rotating));
+
                /* load all the categories */
                for (i = 0; i < cats_random->len && i < MAX_CATS; i++) {
                        LoadData *load_data;
@@ -997,6 +1001,7 @@ gs_overview_page_class_init (GsOverviewPageClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, bin_featured);
        gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, box_overview);
        gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, box_popular);
+       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, box_popular_rotating);
        gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, box_recent);
        gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, category_heading);
        gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, featured_heading);
diff --git a/src/gs-overview-page.ui b/src/gs-overview-page.ui
index 799c44f0..14f77bba 100644
--- a/src/gs-overview-page.ui
+++ b/src/gs-overview-page.ui
@@ -378,6 +378,20 @@
                           </packing>
                         </child>
 
+                        <child>
+                          <object class="GtkBox" id="box_popular_rotating">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="valign">start</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">10</property>
+                          </packing>
+                        </child>
+
                       </object>
                     </child>
                   </object>


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