[gnome-software] updates page: Show the available updates count on gnome-software startup



commit 75e685a8ba0902d2dc1437c48eb4758df14e6bbb
Author: Kalev Lember <klember redhat com>
Date:   Mon Mar 5 14:42:33 2018 +0100

    updates page: Show the available updates count on gnome-software startup
    
    This regressed in commit f9835d3b08df69ef19f2975f2b62c785aa8018b0.

 src/gs-updates-page.c | 54 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 21 deletions(-)
---
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index bb3f8726..fa77dbd9 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -347,14 +347,40 @@ gs_updates_page_get_state_string (GsPluginStatus status)
        return _("Looking for new updates…");
 }
 
+static void
+refresh_headerbar_updates_counter (GsUpdatesPage *self)
+{
+       GtkWidget *widget;
+       guint num_updates;
+
+       num_updates = _get_num_updates (self);
+
+       /* update the counter */
+       widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_updates_counter"));
+       if (num_updates > 0 &&
+           gs_plugin_loader_get_allow_updates (self->plugin_loader)) {
+               g_autofree gchar *text = NULL;
+               text = g_strdup_printf ("%u", num_updates);
+               gtk_label_set_label (GTK_LABEL (widget), text);
+               gtk_widget_show (widget);
+       } else {
+               gtk_widget_hide (widget);
+       }
+
+       /* update the tab style */
+       if (num_updates > 0 &&
+           gs_shell_get_mode (self->shell) != GS_SHELL_MODE_UPDATES)
+               gtk_style_context_add_class (gtk_widget_get_style_context (widget), "needs-attention");
+       else
+               gtk_style_context_remove_class (gtk_widget_get_style_context (widget), "needs-attention");
+}
+
 static void
 gs_updates_page_update_ui_state (GsUpdatesPage *self)
 {
-       GtkWidget *widget = NULL;
        gboolean allow_mobile_refresh = TRUE;
        g_autofree gchar *checked_str = NULL;
        g_autofree gchar *spinner_str = NULL;
-       guint num_updates = 0;
 
        if (gs_shell_get_mode (self->shell) != GS_SHELL_MODE_UPDATES)
                return;
@@ -505,25 +531,8 @@ gs_updates_page_update_ui_state (GsUpdatesPage *self)
                gtk_widget_set_visible (self->label_updates_last_checked, checked_str != NULL);
        }
 
-       /* set the right updates count */
-       num_updates = _get_num_updates (self);
-       widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_updates_counter"));
-       if (num_updates > 0 &&
-           gs_plugin_loader_get_allow_updates (self->plugin_loader)) {
-               g_autofree gchar *text = NULL;
-               text = g_strdup_printf ("%u", num_updates);
-               gtk_label_set_label (GTK_LABEL (widget), text);
-               gtk_widget_show (widget);
-       } else {
-               gtk_widget_hide (widget);
-       }
-
-       /* update the tab style */
-       if (num_updates > 0 &&
-           gs_shell_get_mode (self->shell) != GS_SHELL_MODE_UPDATES)
-               gtk_style_context_add_class (gtk_widget_get_style_context (widget), "needs-attention");
-       else
-               gtk_style_context_remove_class (gtk_widget_get_style_context (widget), "needs-attention");
+       /* update the counter in headerbar */
+       refresh_headerbar_updates_counter (self);
 }
 
 static void
@@ -1036,6 +1045,9 @@ gs_updates_page_get_updates_cb (GsPluginLoader *plugin_loader,
                                      _("U_pdate All"));
        }
 
+       /* update the counter in headerbar */
+       refresh_headerbar_updates_counter (self);
+
        /* no results */
        if (gs_app_list_length (list) == 0) {
                g_debug ("updates-shell: no updates to show");


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