aboutsummaryrefslogtreecommitdiff
path: root/src/device-provider-upower.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2017-05-15 15:01:23 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-05-15 15:01:50 +0200
commitbd1a508aeb9e498dd782678da420d5baf639b4c0 (patch)
tree1b76d4f9435d12a34ab7241535bd673b082cc03f /src/device-provider-upower.c
parentdbfed3a9b70091667233b884d5a7fa3098f4d104 (diff)
downloadayatana-indicator-power-bd1a508aeb9e498dd782678da420d5baf639b4c0.tar.gz
ayatana-indicator-power-bd1a508aeb9e498dd782678da420d5baf639b4c0.tar.bz2
ayatana-indicator-power-bd1a508aeb9e498dd782678da420d5baf639b4c0.zip
Make device with power supply has higher sorting priority. (LP: #1100546)
Diffstat (limited to 'src/device-provider-upower.c')
-rw-r--r--src/device-provider-upower.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/device-provider-upower.c b/src/device-provider-upower.c
index 63f78ad..bfee80f 100644
--- a/src/device-provider-upower.c
+++ b/src/device-provider-upower.c
@@ -113,6 +113,7 @@ on_get_all_response (GObject * o, GAsyncResult * res, gpointer gdata)
gint64 time_to_empty = 0;
gint64 time_to_full = 0;
gint64 time;
+ gboolean power_supply = FALSE;
IndicatorPowerDevice * device;
priv_t * p = get_priv(data->self);
GVariant * dict = g_variant_get_child_value (response, 0);
@@ -122,6 +123,7 @@ on_get_all_response (GObject * o, GAsyncResult * res, gpointer gdata)
g_variant_lookup (dict, "Percentage", "d", &percentage);
g_variant_lookup (dict, "TimeToEmpty", "x", &time_to_empty);
g_variant_lookup (dict, "TimeToFull", "x", &time_to_full);
+ g_variant_lookup (dict, "PowerSupply", "b", &power_supply);
time = time_to_empty ? time_to_empty : time_to_full;
if ((device = g_hash_table_lookup (p->devices, data->path)))
@@ -131,6 +133,7 @@ on_get_all_response (GObject * o, GAsyncResult * res, gpointer gdata)
INDICATOR_POWER_DEVICE_OBJECT_PATH, data->path,
INDICATOR_POWER_DEVICE_PERCENTAGE, percentage,
INDICATOR_POWER_DEVICE_TIME, time,
+ INDICATOR_POWER_DEVICE_POWER_SUPPLY, power_supply,
NULL);
}
else
@@ -139,7 +142,8 @@ on_get_all_response (GObject * o, GAsyncResult * res, gpointer gdata)
kind,
percentage,
state,
- (time_t)time);
+ (time_t)time,
+ power_supply);
g_hash_table_insert (p->devices,
g_strdup (data->path),