[gnome-power-manager] trivial: provide some text for devices that are not present in gpm_upower_get_device_summary()



commit 215f6839390026369edb574afc14000b8af786bc
Author: Richard Hughes <richard hughsie com>
Date:   Wed Mar 31 15:23:11 2010 +0100

    trivial: provide some text for devices that are not present in gpm_upower_get_device_summary()

 src/gpm-engine.c |    4 ++++
 src/gpm-upower.c |    9 ++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/gpm-engine.c b/src/gpm-engine.c
index 59d65db..d292f89 100644
--- a/src/gpm-engine.c
+++ b/src/gpm-engine.c
@@ -237,6 +237,7 @@ gpm_engine_get_summary (GpmEngine *engine)
 	UpDevice *device;
 	GString *tooltip = NULL;
 	gchar *part;
+	gboolean is_present;
 
 	g_return_val_if_fail (GPM_IS_ENGINE (engine), NULL);
 
@@ -247,6 +248,9 @@ gpm_engine_get_summary (GpmEngine *engine)
 	array = engine->priv->array;
 	for (i=0;i<array->len;i++) {
 		device = g_ptr_array_index (engine->priv->array, i);
+		g_object_get (device, "is-present", &is_present, NULL);
+		if (!is_present)
+			continue;
 		part = gpm_upower_get_device_summary (device);
 		if (part != NULL)
 			g_string_append_printf (tooltip, "%s\n", part);
diff --git a/src/gpm-upower.c b/src/gpm-upower.c
index 5a7007f..3a866e7 100644
--- a/src/gpm-upower.c
+++ b/src/gpm-upower.c
@@ -203,11 +203,14 @@ gpm_upower_get_device_summary (UpDevice *device)
 		      "time-to-empty", &time_to_empty,
 		      NULL);
 
-	if (!is_present)
-		return NULL;
-
 	kind_desc = gpm_device_kind_to_localised_string (kind, 1);
 
+	/* not installed */
+	if (!is_present) {
+		/* TRANSLATORS: device not present */
+		return g_strdup_printf (_("%s not present"), kind_desc);
+	}
+
 	/* don't display all the extra stuff for keyboards and mice */
 	if (kind == UP_DEVICE_KIND_MOUSE ||
 	    kind == UP_DEVICE_KIND_KEYBOARD ||



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