aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/indicator-power.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/indicator-power.c b/src/indicator-power.c
index 52843d3..2179c3f 100644
--- a/src/indicator-power.c
+++ b/src/indicator-power.c
@@ -315,7 +315,7 @@ build_device_time_details (const gchar *device_name,
*accesible_name = g_strdup (*details);
*short_details = g_strdup (_("(charged)"));
}
- else
+ else if (percentage > 0)
{
/* TRANSLATORS: %2 is a percentage value. Note: this string is only
* used when we don't have a time value */
@@ -325,6 +325,12 @@ build_device_time_details (const gchar *device_name,
*short_details = g_strdup_printf (_("(%.0lf%%)"),
percentage);
}
+ else
+ {
+ *details = g_strdup_printf (_("%s (not present)"), device_name);
+ *accesible_name = g_strdup (*details);
+ *short_details = g_strdup (_("(not present)"));
+ }
}
}
@@ -394,6 +400,9 @@ menu_add_device (GtkMenu *menu,
g_signal_connect (G_OBJECT (item), "activate",
G_CALLBACK (show_info_cb), NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ g_free (device_icon);
+ g_free (object_path);
}
static gsize
@@ -509,6 +518,10 @@ get_primary_device (GVariant *devices)
g_debug ("%s: got data from object %s", G_STRFUNC, object_path);
+ /* not battery */
+ if (kind != UP_DEVICE_KIND_BATTERY)
+ continue;
+
if (state == UP_DEVICE_STATE_DISCHARGING)
{
discharging = TRUE;
@@ -533,6 +546,9 @@ get_primary_device (GVariant *devices)
}
}
+ g_free (device_icon);
+ g_free (object_path);
+
if (discharging)
{
primary_device = primary_device_discharging;