[gnome-software] trivial: Do not show the [0] counter when there are no updates
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Do not show the [0] counter when there are no updates
- Date: Thu, 2 Jun 2016 20:02:38 +0000 (UTC)
commit 20ed47cd7d4a091df8d3ee044e6bee2ef3572ff3
Author: Richard Hughes <richard hughsie com>
Date: Thu Jun 2 21:02:02 2016 +0100
trivial: Do not show the [0] counter when there are no updates
src/gs-shell-updates.c | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 62fa26a..0f5f15e 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -482,6 +482,21 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
/* get the results */
list = gs_plugin_loader_get_updates_finish (plugin_loader, res, &error);
+ if (list == NULL) {
+ gs_shell_updates_clear_flag (self, GS_SHELL_UPDATES_FLAG_HAS_UPDATES);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("updates-shell: failed to get updates: %s", error->message);
+ gtk_label_set_label (GTK_LABEL (self->label_updates_failed),
+ error->message);
+ gs_shell_updates_set_state (self,
+ GS_SHELL_UPDATES_STATE_FAILED);
+ widget = GTK_WIDGET (gtk_builder_get_object (self->builder,
+ "button_updates_counter"));
+ gtk_widget_hide (widget);
+ return;
+ }
+
+ /* add the results */
self->all_updates_are_live = TRUE;
self->any_require_reboot = FALSE;
for (i = 0; list != NULL && i < gs_app_list_length (list); i++) {
@@ -505,8 +520,10 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
_("Restart & _Install"));
}
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_updates_counter"));
- if (list != NULL && !gs_update_monitor_is_managed ()) {
+ /* update the counter */
+ widget = GTK_WIDGET (gtk_builder_get_object (self->builder,
+ "button_updates_counter"));
+ if (gs_app_list_length (list) > 0 && !gs_update_monitor_is_managed ()) {
g_autofree gchar *text = NULL;
text = g_strdup_printf ("%d", gs_app_list_length (list));
gtk_label_set_label (GTK_LABEL (widget), text);
@@ -515,22 +532,13 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
gtk_widget_hide (widget);
}
- if (list != NULL &&
+ /* update the tab style */
+ if (gs_app_list_length (list) > 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");
- if (list == NULL) {
- gs_shell_updates_clear_flag (self, GS_SHELL_UPDATES_FLAG_HAS_UPDATES);
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("updates-shell: failed to get updates: %s", error->message);
- gtk_label_set_label (GTK_LABEL (self->label_updates_failed),
- error->message);
- gs_shell_updates_set_state (self,
- GS_SHELL_UPDATES_STATE_FAILED);
- }
-
/* 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]