aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-11-06 13:59:36 -0600
committerCharles Kerr <charles.kerr@canonical.com>2012-11-06 13:59:36 -0600
commit75636fb425e2ea398f2883197bde70b96900cb6d (patch)
tree2c72115cd05db665a1034f8da11186a0db302b6d /src
parente555496b6486982a75429af159c6ecd556944ff6 (diff)
downloadayatana-indicator-power-75636fb425e2ea398f2883197bde70b96900cb6d.tar.gz
ayatana-indicator-power-75636fb425e2ea398f2883197bde70b96900cb6d.tar.bz2
ayatana-indicator-power-75636fb425e2ea398f2883197bde70b96900cb6d.zip
when choosing between two devices, always pick the one that's not a UP_DEVICE_KIND_LINE_POWER
Diffstat (limited to 'src')
-rw-r--r--src/indicator-power.c21
1 files changed, 20 insertions, 1 deletions
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;