From 681e4e979ea8964279b99550f080b5df1c4eccf0 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 26 Oct 2012 15:20:16 +0200 Subject: 12.10.3 --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ff89f0e..294276f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +12.10.3 + - Show the proper icon for mice and ups devices. (LP: #1066208) + - Follow the spec when choosing the primary device (LP: #1071645) + - Fix minor memory leaks + 12.10.2 - Show a more accurate view of discharging batteries (LP: #1054146) - Fix a GIcon memory leak diff --git a/configure.ac b/configure.ac index 5fbf2e5..d21fa91 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([indicator-power], - [12.10.2], + [12.10.3], [http://bugs.launchpad.net/indicator-power], [indicator-power], [http://launchpad.net/indicator-power]) -- cgit v1.2.3 From 014fbc261c19e75f24d46f3f06d3abf63840529e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 4 Nov 2012 11:48:11 -0600 Subject: 12.10.4 --- NEWS | 3 +++ configure.ac | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 294276f..e068a49 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +12.10.4 + - Fix primary device selection bug introduced in 12.10.3 (LP: #1071757) + 12.10.3 - Show the proper icon for mice and ups devices. (LP: #1066208) - Follow the spec when choosing the primary device (LP: #1071645) diff --git a/configure.ac b/configure.ac index d21fa91..9a0e06c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([indicator-power], - [12.10.3], + [12.10.4], [http://bugs.launchpad.net/indicator-power], [indicator-power], [http://launchpad.net/indicator-power]) -- cgit v1.2.3 From e555496b6486982a75429af159c6ecd556944ff6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 6 Nov 2012 13:42:53 -0600 Subject: add unit test (currently failing) to test for the bug reported in LP bug #1075192 --- tests/test-device.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/test-device.cc b/tests/test-device.cc index 18bdc08..16194c9 100644 --- a/tests/test-device.cc +++ b/tests/test-device.cc @@ -587,19 +587,21 @@ TEST_F(DeviceTest, ChoosePrimary) sorted in order of preference wrt the spec's criteria. So tests[i] should be picked over any test with an index greater than i */ struct { + int kind; int state; guint64 time; double percentage; } tests[] = { - { UP_DEVICE_STATE_DISCHARGING, 49, 50.0 }, - { UP_DEVICE_STATE_DISCHARGING, 50, 50.0 }, - { UP_DEVICE_STATE_DISCHARGING, 50, 100.0 }, - { UP_DEVICE_STATE_DISCHARGING, 51, 50.0 }, - { UP_DEVICE_STATE_CHARGING, 50, 50.0 }, - { UP_DEVICE_STATE_CHARGING, 49, 50.0 }, - { UP_DEVICE_STATE_CHARGING, 49, 100.0 }, - { UP_DEVICE_STATE_CHARGING, 48, 50.0 }, - { UP_DEVICE_STATE_FULLY_CHARGED, 0, 50.0 } + { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 49, 50.0 }, + { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 50, 50.0 }, + { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 50, 100.0 }, + { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 51, 50.0 }, + { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 50, 50.0 }, + { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 49, 50.0 }, + { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 49, 100.0 }, + { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 48, 50.0 }, + { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_FULLY_CHARGED, 0, 50.0 }, + { UP_DEVICE_KIND_LINE_POWER, UP_DEVICE_STATE_UNKNOWN, 0, 0.0 } }; device_list = NULL; @@ -610,11 +612,13 @@ TEST_F(DeviceTest, ChoosePrimary) { for (int j=i+1; j 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(-) 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 7b37016d3e8114cbb19c25121185e799a5fb342f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 6 Nov 2012 14:54:57 -0600 Subject: in TestDevice.ChoosePrimary, add another test (currently failing) to confirm that when indicator-datetime is choosing from devices that are neither charging nor discharging, batteries are more interesting than other devices, and other devices are more interesting than UP_DEVICE_KIND_LINE_POWER --- tests/test-device.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-device.cc b/tests/test-device.cc index 16194c9..27cbf35 100644 --- a/tests/test-device.cc +++ b/tests/test-device.cc @@ -601,6 +601,7 @@ TEST_F(DeviceTest, ChoosePrimary) { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 49, 100.0 }, { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 48, 50.0 }, { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_FULLY_CHARGED, 0, 50.0 }, + { UP_DEVICE_KIND_KEYBOARD, UP_DEVICE_STATE_FULLY_CHARGED, 0, 50.0 }, { UP_DEVICE_KIND_LINE_POWER, UP_DEVICE_STATE_UNKNOWN, 0, 0.0 } }; -- 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(-) 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 a499914c45cf4bf2208c857f54783cfcd48c1427 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 7 Nov 2012 11:25:41 -0600 Subject: modify DeviceTest.Labels s.t. it fails (currently failing) if the 'short' string for an AC Adapter is nonempty. --- tests/test-device.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-device.cc b/tests/test-device.cc index 27cbf35..021404f 100644 --- a/tests/test-device.cc +++ b/tests/test-device.cc @@ -555,7 +555,7 @@ TEST_F(DeviceTest, Labels) INDICATOR_POWER_DEVICE_PERCENTAGE, 0.0, INDICATOR_POWER_DEVICE_TIME, guint64(0), NULL); - check_strings (device, "AC Adapter", "AC Adapter", "AC Adapter"); + check_strings (device, "", "AC Adapter", "AC Adapter"); // cleanup g_object_unref(o); -- 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(-) 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 From 727b8cab56a9ecd920c5656d09de0c5e6470017b Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 8 Nov 2012 11:35:21 -0600 Subject: add 'check-news' to AM_INIT_AUTOMAKE --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5fbf2e5..384e007 100644 --- a/configure.ac +++ b/configure.ac @@ -7,11 +7,11 @@ AC_INIT([indicator-power], AC_PREREQ([2.64]) AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_SRCDIR([configure.ac]) +AC_CONFIG_SRCDIR([src/device.c]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([1.11 -Wall foreign dist-xz]) +AM_INIT_AUTOMAKE([1.11 -Wall foreign dist-xz check-news]) AM_MAINTAINER_MODE([enable]) AM_SILENT_RULES([yes]) -- cgit v1.2.3 From 7c335dd41dc68368c5fb52951acd1a145a572484 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 13 Nov 2012 14:44:16 -0600 Subject: 12.10.5 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9a0e06c..476a4f2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([indicator-power], - [12.10.4], + [12.10.5], [http://bugs.launchpad.net/indicator-power], [indicator-power], [http://launchpad.net/indicator-power]) -- cgit v1.2.3 From 17629a4f743c1bbae6f170eeb613bd4e9c4e7978 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 13 Nov 2012 14:50:29 -0600 Subject: bump NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index e068a49..255db6f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +12.10.5 + - Fix a device display bug introduced in 12.10.3 (LP: #1075192) + 12.10.4 - Fix primary device selection bug introduced in 12.10.3 (LP: #1071757) -- cgit v1.2.3