From 75636fb425e2ea398f2883197bde70b96900cb6d Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 6 Nov 2012 13:59:36 -0600 Subject: when choosing between two devices, always pick the one that's not a UP_DEVICE_KIND_LINE_POWER --- src/indicator-power.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-power.c b/src/indicator-power.c index 4118dcc..888e186 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -357,7 +357,8 @@ build_menu (IndicatorPower *self) 2. discharging items with an unknown time remaining 3. charging items from most time left to charge to least time left to charge 4. charging items with an unknown time remaining - 5. everything else */ + 5. everything except line-power, because it's not interesting + 6. line-power */ static gint device_compare_func (gconstpointer ga, gconstpointer gb) { @@ -418,6 +419,24 @@ device_compare_func (gconstpointer ga, gconstpointer gb) } } + if (!ret) /* make UP_DEVICE_KIND_LINE_POWER go last because it's not interesting */ + { + const UpDeviceKind a_kind = indicator_power_device_get_kind (a); + const UpDeviceKind b_kind = indicator_power_device_get_kind (b); + + if ((a_kind == UP_DEVICE_KIND_LINE_POWER) || (b_kind == UP_DEVICE_KIND_LINE_POWER)) + { + if (a_kind != UP_DEVICE_KIND_LINE_POWER) /* b is a line-power */ + { + ret = -1; + } + else if (b_kind != UP_DEVICE_KIND_LINE_POWER) /* a is a line-power */ + { + ret = 1; + } + } + } + if (!ret) ret = a_state - b_state; -- cgit v1.2.3 From a2e4245288d1b1d55ed3deab8e76ec3cd2fbb3e5 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 6 Nov 2012 14:56:52 -0600 Subject: when choosing a primary device from devices that are neither charging nor discharging, prefer batteries, then everything except line-power, then line power --- src/indicator-power.c | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/indicator-power.c b/src/indicator-power.c index 888e186..06f1c2e 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -352,13 +352,38 @@ build_menu (IndicatorPower *self) gtk_widget_show_all (GTK_WIDGET (priv->menu)); } +/* the higher the weight, the more interesting the device */ +static int +get_device_kind_weight (const IndicatorPowerDevice * device) +{ + UpDeviceKind kind; + static gboolean initialized = FALSE; + static int weights[UP_DEVICE_KIND_LAST]; + + kind = indicator_power_device_get_kind (device); + g_return_val_if_fail (0<=kind && kind weight_b) { - if (a_kind != UP_DEVICE_KIND_LINE_POWER) /* b is a line-power */ - { - ret = -1; - } - else if (b_kind != UP_DEVICE_KIND_LINE_POWER) /* a is a line-power */ - { - ret = 1; - } + ret = -1; + } + else if (weight_a < weight_b) + { + ret = 1; } } -- cgit v1.2.3 From f446e2fbf12b6210faf76fb78d8020647834fbff Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 7 Nov 2012 11:29:51 -0600 Subject: change indicator_power_device_get_time_details() s.t. the 'short details' for an AC Adapter is an empty string. --- src/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/device.c b/src/device.c index 490ff1a..d028ab7 100644 --- a/src/device.c +++ b/src/device.c @@ -612,7 +612,7 @@ indicator_power_device_get_time_details (const IndicatorPowerDevice * device, { *details = g_strdup (device_name); *accessible_name = g_strdup (device_name); - *short_details = g_strdup (device_name); + *short_details = g_strdup (""); } else { -- cgit v1.2.3