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(-) 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