[gnome-control-center] power: Describe batteries properly when not called BAT0
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] power: Describe batteries properly when not called BAT0
- Date: Thu, 4 Jun 2015 16:32:15 +0000 (UTC)
commit f31c3b16c7aa3a95bbe4db2286378c8a755540e8
Author: Bastien Nocera <hadess hadess net>
Date: Thu May 7 12:26:12 2015 +0200
power: Describe batteries properly when not called BAT0
When the main battery isn't called BAT0, as happens on a dual-battery,
convertible Toshiba laptop, we would tag both batteries as "Extra". Mark
the first one as being the main battery.
In the longer-term, we'll have UPower exporting the exact information
about which is in the "dock" and which is in the same package as the
processing unit, when the kernel exports it.
See https://bugzilla.kernel.org/show_bug.cgi?id=97841
https://bugzilla.gnome.org/show_bug.cgi?id=748592
panels/power/cc-power-panel.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 35f9ab8..f30b90e 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -397,7 +397,6 @@ add_battery (CcPowerPanel *panel, UpDevice *device)
GtkWidget *levelbar;
GtkWidget *widget;
gchar *s;
- gchar *native_path;
gchar *icon_name;
const gchar *name;
@@ -405,11 +404,10 @@ add_battery (CcPowerPanel *panel, UpDevice *device)
"kind", &kind,
"state", &state,
"percentage", &percentage,
- "native-path", &native_path,
"icon-name", &icon_name,
NULL);
- if (native_path && strstr (native_path, "BAT0"))
+ if (g_object_get_data (G_OBJECT (device), "is-main-battery") != NULL)
name = C_("Battery name", "Main");
else
name = C_("Battery name", "Extra");
@@ -471,7 +469,6 @@ add_battery (CcPowerPanel *panel, UpDevice *device)
gtk_size_group_add_widget (priv->row_sizegroup, row);
gtk_widget_show_all (row);
- g_free (native_path);
g_free (icon_name);
gtk_widget_set_visible (priv->battery_section, TRUE);
@@ -726,13 +723,22 @@ up_client_changed (UpClient *client,
}
else
{
+ gboolean is_extra_battery = FALSE;
+
/* Count the batteries */
for (i = 0; priv->devices != NULL && i < priv->devices->len; i++)
{
UpDevice *device = (UpDevice*) g_ptr_array_index (priv->devices, i);
g_object_get (device, "kind", &kind, NULL);
if (kind == UP_DEVICE_KIND_BATTERY)
- n_batteries++;
+ {
+ n_batteries++;
+ if (is_extra_battery == FALSE)
+ {
+ is_extra_battery = TRUE;
+ g_object_set_data (G_OBJECT (device), "is-main-battery", GINT_TO_POINTER(TRUE));
+ }
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]