[gnome-color-manager] trivial: Do not show a age for profiles that do not have a created value



commit 57e1aa176166c81be902939eab9f233be51e4acf
Author: Richard Hughes <richard hughsie com>
Date:   Wed May 18 14:06:11 2011 +0100

    trivial: Do not show a age for profiles that do not have a created value
    
    This happens for the default CUPS meta-profiles.

 src/gcm-cell-renderer-profile-date.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/gcm-cell-renderer-profile-date.c b/src/gcm-cell-renderer-profile-date.c
index 4f8dcc9..b7e4322 100644
--- a/src/gcm-cell-renderer-profile-date.c
+++ b/src/gcm-cell-renderer-profile-date.c
@@ -60,6 +60,7 @@ gcm_cell_renderer_get_profile_date (CdProfile *profile)
 {
 	gint now;
 	gint64 age;
+	gint64 created;
 	GString *string;
 
 	if (profile == NULL) {
@@ -70,7 +71,12 @@ gcm_cell_renderer_get_profile_date (CdProfile *profile)
 
 	/* get profile age */
 	now = g_get_real_time () / G_USEC_PER_SEC;
-	age = now - cd_profile_get_created (profile);
+	created = cd_profile_get_created (profile);
+	if (created == 0) {
+		string = g_string_new ("");
+		goto out;
+	}
+	age = now - created;
 
 	/* days */
 	string = g_string_new ("");
@@ -109,8 +115,10 @@ gcm_cell_renderer_get_profile_date (CdProfile *profile)
 	/* fallback */
 	g_string_append_printf (string, _("Less than 1 week"));
 out:
-	g_string_prepend (string, "<span foreground='gray'>");
-	g_string_append (string, "</span>");
+	if (string->len > 0) {
+		g_string_prepend (string, "<span foreground='gray'>");
+		g_string_append (string, "</span>");
+	}
 	return string;
 }
 



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