[gnome-packagekit] hide the update icon when all updates are blocked



commit 2a8633aa65ded4ad8d5865878a8824d1c5defade
Author: Jonathan Conder <j skurvy no-ip org>
Date:   Wed Mar 24 14:39:36 2010 +0000

    hide the update icon when all updates are blocked
    
    Basically, gpk-update-icon tells the user about available updates even when
    those updates are blocked. I investigated a bit and found that
    PK_INFO_ENUM_BLOCKED isn't recognised as a package info field for GetUpdates.
    
    I wrote a patch to resolve this, which works by setting PK_INFO_ENUM_BLOCKED to
    the lowest-priority info field, and hiding the icon when it is returned from
    pk_bitfield_contain_priority.
    
    I hope you agree that this is a good solution. However, for some backends it
    might be better to show a different icon rather than none at all, for example
    when an update is blocked due to an error. I think, though, that temporarily
    hiding an error (until a new update is found), is better than annoying a user
    who may have explicitly blocked updates for some package.
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 src/gpk-check-update.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 0257792..1c8f2c8 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -730,10 +730,14 @@ gpk_check_update_get_best_update_icon (GpkCheckUpdate *cupdate, GPtrArray *array
 					      PK_INFO_ENUM_BUGFIX,
 					      PK_INFO_ENUM_NORMAL,
 					      PK_INFO_ENUM_ENHANCEMENT,
-					      PK_INFO_ENUM_LOW, -1);
+					      PK_INFO_ENUM_LOW,
+					      PK_INFO_ENUM_BLOCKED, -1);
 	if (value == -1) {
 		egg_warning ("should not be possible!");
 		value = PK_INFO_ENUM_LOW;
+	} else if (value == PK_INFO_ENUM_BLOCKED) {
+		/* all updates are blocked */
+		return NULL;
 	}
 
 	/* get the icon */
@@ -915,8 +919,13 @@ gpk_check_update_get_updates_finished_cb (GObject *object, GAsyncResult *res, Gp
 		g_ptr_array_add (security_array, g_strdup (pk_package_get_id (item)));
 	}
 
-	/* work out icon (cannot be NULL) */
+	/* work out icon */
 	icon = gpk_check_update_get_best_update_icon (cupdate, array);
+	if (icon == NULL) {
+		egg_debug ("all updates blocked");
+		gpk_check_update_set_icon_name (cupdate, NULL);
+		goto out;
+	}
 	gpk_check_update_set_icon_name (cupdate, icon);
 
 	/* TRANSLATORS: tooltip: how many updates are waiting to be applied */



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