Merge lp:~charlesk/indicator-power/lp-1388235-use-new-battery-icons-rtm-14.09 into lp:indicator-power/rtm-14.09
- lp-1388235-use-new-battery-icons-rtm-14.09
- Merge into trunk.rtm-14.09
Proposed by
Charles Kerr
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Charles Kerr | ||||
Approved revision: | 274 | ||||
Merged at revision: | 274 | ||||
Proposed branch: | lp:~charlesk/indicator-power/lp-1388235-use-new-battery-icons-rtm-14.09 | ||||
Merge into: | lp:indicator-power/rtm-14.09 | ||||
Diff against target: |
207 lines (+60/-6) 3 files modified
src/device.c (+32/-3) tests/manual (+8/-1) tests/test-device.cc (+20/-2) |
||||
To merge this branch: | bzr merge lp:~charlesk/indicator-power/lp-1388235-use-new-battery-icons-rtm-14.09 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
dobey (community) | Approve | ||
Review via email: mp+249684@code.launchpad.net |
Commit message
Use the new power level icons for a more accurate display of the battery level.
Description of the change
rtm-14.09 backport of <https:/
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/device.c' | |||
2 | --- src/device.c 2014-07-29 14:49:19 +0000 | |||
3 | +++ src/device.c 2015-02-13 16:46:19 +0000 | |||
4 | @@ -319,7 +319,23 @@ | |||
5 | 319 | } | 319 | } |
6 | 320 | 320 | ||
7 | 321 | static const gchar * | 321 | static const gchar * |
9 | 322 | get_device_icon_index (gdouble percentage) | 322 | get_closest_10_percent_percentage (gdouble percentage) |
10 | 323 | { | ||
11 | 324 | if (percentage >= 95) return "100"; | ||
12 | 325 | if (percentage >= 85) return "090"; | ||
13 | 326 | if (percentage >= 75) return "080"; | ||
14 | 327 | if (percentage >= 65) return "070"; | ||
15 | 328 | if (percentage >= 55) return "060"; | ||
16 | 329 | if (percentage >= 45) return "050"; | ||
17 | 330 | if (percentage >= 35) return "040"; | ||
18 | 331 | if (percentage >= 21) return "030"; /* don't round down to 20: see bug #1388235 */ | ||
19 | 332 | if (percentage >= 15) return "020"; | ||
20 | 333 | if (percentage >= 5) return "010"; | ||
21 | 334 | return "000"; | ||
22 | 335 | } | ||
23 | 336 | |||
24 | 337 | static const gchar * | ||
25 | 338 | get_fallback_device_icon_index (gdouble percentage) | ||
26 | 323 | { | 339 | { |
27 | 324 | if (percentage >= 90) return "100"; | 340 | if (percentage >= 90) return "100"; |
28 | 325 | if (percentage >= 70) return "080"; | 341 | if (percentage >= 70) return "080"; |
29 | @@ -364,6 +380,7 @@ | |||
30 | 364 | { | 380 | { |
31 | 365 | const gchar *suffix_str; | 381 | const gchar *suffix_str; |
32 | 366 | const gchar *index_str; | 382 | const gchar *index_str; |
33 | 383 | const gchar *index_str_2; | ||
34 | 367 | 384 | ||
35 | 368 | /* LCOV_EXCL_START */ | 385 | /* LCOV_EXCL_START */ |
36 | 369 | g_return_val_if_fail (INDICATOR_IS_POWER_DEVICE(device), NULL); | 386 | g_return_val_if_fail (INDICATOR_IS_POWER_DEVICE(device), NULL); |
37 | @@ -406,9 +423,15 @@ | |||
38 | 406 | 423 | ||
39 | 407 | case UP_DEVICE_STATE_CHARGING: | 424 | case UP_DEVICE_STATE_CHARGING: |
40 | 408 | suffix_str = get_device_icon_suffix (percentage); | 425 | suffix_str = get_device_icon_suffix (percentage); |
42 | 409 | index_str = get_device_icon_index (percentage); | 426 | index_str = get_closest_10_percent_percentage (percentage); |
43 | 410 | g_ptr_array_add (names, g_strdup_printf ("%s-%s-charging", kind_str, index_str)); | 427 | g_ptr_array_add (names, g_strdup_printf ("%s-%s-charging", kind_str, index_str)); |
44 | 411 | g_ptr_array_add (names, g_strdup_printf ("gpm-%s-%s-charging", kind_str, index_str)); | 428 | g_ptr_array_add (names, g_strdup_printf ("gpm-%s-%s-charging", kind_str, index_str)); |
45 | 429 | index_str_2 = get_fallback_device_icon_index (percentage); | ||
46 | 430 | if (g_strcmp0 (index_str, index_str_2)) | ||
47 | 431 | { | ||
48 | 432 | g_ptr_array_add (names, g_strdup_printf ("%s-%s-charging", kind_str, index_str_2)); | ||
49 | 433 | g_ptr_array_add (names, g_strdup_printf ("gpm-%s-%s-charging", kind_str, index_str_2)); | ||
50 | 434 | } | ||
51 | 412 | g_ptr_array_add (names, g_strdup_printf ("%s-%s-charging-symbolic", kind_str, suffix_str)); | 435 | g_ptr_array_add (names, g_strdup_printf ("%s-%s-charging-symbolic", kind_str, suffix_str)); |
52 | 413 | g_ptr_array_add (names, g_strdup_printf ("%s-%s-charging", kind_str, suffix_str)); | 436 | g_ptr_array_add (names, g_strdup_printf ("%s-%s-charging", kind_str, suffix_str)); |
53 | 414 | break; | 437 | break; |
54 | @@ -417,9 +440,15 @@ | |||
55 | 417 | case UP_DEVICE_STATE_DISCHARGING: | 440 | case UP_DEVICE_STATE_DISCHARGING: |
56 | 418 | case UP_DEVICE_STATE_PENDING_DISCHARGE: | 441 | case UP_DEVICE_STATE_PENDING_DISCHARGE: |
57 | 419 | suffix_str = get_device_icon_suffix (percentage); | 442 | suffix_str = get_device_icon_suffix (percentage); |
59 | 420 | index_str = get_device_icon_index (percentage); | 443 | index_str = get_closest_10_percent_percentage (percentage); |
60 | 421 | g_ptr_array_add (names, g_strdup_printf ("%s-%s", kind_str, index_str)); | 444 | g_ptr_array_add (names, g_strdup_printf ("%s-%s", kind_str, index_str)); |
61 | 422 | g_ptr_array_add (names, g_strdup_printf ("gpm-%s-%s", kind_str, index_str)); | 445 | g_ptr_array_add (names, g_strdup_printf ("gpm-%s-%s", kind_str, index_str)); |
62 | 446 | index_str_2 = get_fallback_device_icon_index (percentage); | ||
63 | 447 | if (g_strcmp0 (index_str, index_str_2)) | ||
64 | 448 | { | ||
65 | 449 | g_ptr_array_add (names, g_strdup_printf ("%s-%s", kind_str, index_str_2)); | ||
66 | 450 | g_ptr_array_add (names, g_strdup_printf ("gpm-%s-%s", kind_str, index_str_2)); | ||
67 | 451 | } | ||
68 | 423 | g_ptr_array_add (names, g_strdup_printf ("%s-%s-symbolic", kind_str, suffix_str)); | 452 | g_ptr_array_add (names, g_strdup_printf ("%s-%s-symbolic", kind_str, suffix_str)); |
69 | 424 | g_ptr_array_add (names, g_strdup_printf ("%s-%s", kind_str, suffix_str)); | 453 | g_ptr_array_add (names, g_strdup_printf ("%s-%s", kind_str, suffix_str)); |
70 | 425 | break; | 454 | break; |
71 | 426 | 455 | ||
72 | === modified file 'tests/manual' | |||
73 | --- tests/manual 2014-10-14 19:09:32 +0000 | |||
74 | +++ tests/manual 2015-02-13 16:46:19 +0000 | |||
75 | @@ -13,7 +13,6 @@ | |||
76 | 13 | --object-path /com/canonical/indicator/power/Testing \ | 13 | --object-path /com/canonical/indicator/power/Testing \ |
77 | 14 | --method org.freedesktop.DBus.Properties.GetAll \ | 14 | --method org.freedesktop.DBus.Properties.GetAll \ |
78 | 15 | com.canonical.indicator.power.Testing | 15 | com.canonical.indicator.power.Testing |
79 | 16 | ({'MockBatteryEnabled': <false>, 'MockBatteryLevel': <uint32 50>, 'MockBatteryState': <'discharging'>, 'MockBatteryMinutesLeft': <uint32 30>},) | ||
80 | 17 | 16 | ||
81 | 18 | Enable the mock battery: | 17 | Enable the mock battery: |
82 | 19 | 18 | ||
83 | @@ -88,6 +87,14 @@ | |||
84 | 88 | <dd>ubuntu-system-settings should be launched to the Battery page </dd> | 87 | <dd>ubuntu-system-settings should be launched to the Battery page </dd> |
85 | 89 | </dl> | 88 | </dl> |
86 | 90 | 89 | ||
87 | 90 | Test-case indicator-power/low-power-icon | ||
88 | 91 | <dl> | ||
89 | 92 | <dt>Wait for the system's battery level to drop to 21% (or fake it, see 'Notes on Battery Testing' above)</dt> | ||
90 | 93 | <dd>The indicator's icon should use the non-critical coloring (eg, grey)</dd> | ||
91 | 94 | <dt>Wait for the system's battery level to drop to 20% (or fake it, see 'Notes on Battery Testing' above)</dt> | ||
92 | 95 | <dd>The indicator's icon should use the critical coloring (eg, red)</dd> | ||
93 | 96 | </dl> | ||
94 | 97 | |||
95 | 91 | Test-case indicator-power/device-brightness-slider | 98 | Test-case indicator-power/device-brightness-slider |
96 | 92 | <dl> | 99 | <dl> |
97 | 93 | <dt>On a device, pull down the power indicator's menu</dt> | 100 | <dt>On a device, pull down the power indicator's menu</dt> |
98 | 94 | 101 | ||
99 | === modified file 'tests/test-device.cc' | |||
100 | --- tests/test-device.cc 2014-09-08 16:16:29 +0000 | |||
101 | +++ tests/test-device.cc 2015-02-13 16:46:19 +0000 | |||
102 | @@ -297,7 +297,6 @@ | |||
103 | 297 | g_object_set (o, INDICATOR_POWER_DEVICE_KIND, kind, | 297 | g_object_set (o, INDICATOR_POWER_DEVICE_KIND, kind, |
104 | 298 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_EMPTY, | 298 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_EMPTY, |
105 | 299 | NULL); | 299 | NULL); |
106 | 300 | |||
107 | 301 | g_string_append_printf (expected, "%s-empty-symbolic;", kind_str); | 300 | g_string_append_printf (expected, "%s-empty-symbolic;", kind_str); |
108 | 302 | g_string_append_printf (expected, "gpm-%s-empty;", kind_str); | 301 | g_string_append_printf (expected, "gpm-%s-empty;", kind_str); |
109 | 303 | g_string_append_printf (expected, "gpm-%s-000;", kind_str); | 302 | g_string_append_printf (expected, "gpm-%s-000;", kind_str); |
110 | @@ -323,7 +322,6 @@ | |||
111 | 323 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, | 322 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, |
112 | 324 | INDICATOR_POWER_DEVICE_PERCENTAGE, 95.0, | 323 | INDICATOR_POWER_DEVICE_PERCENTAGE, 95.0, |
113 | 325 | NULL); | 324 | NULL); |
114 | 326 | |||
115 | 327 | g_string_append_printf (expected, "%s-100-charging;", kind_str); | 325 | g_string_append_printf (expected, "%s-100-charging;", kind_str); |
116 | 328 | g_string_append_printf (expected, "gpm-%s-100-charging;", kind_str); | 326 | g_string_append_printf (expected, "gpm-%s-100-charging;", kind_str); |
117 | 329 | g_string_append_printf (expected, "%s-full-charging-symbolic;", kind_str); | 327 | g_string_append_printf (expected, "%s-full-charging-symbolic;", kind_str); |
118 | @@ -336,6 +334,8 @@ | |||
119 | 336 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, | 334 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, |
120 | 337 | INDICATOR_POWER_DEVICE_PERCENTAGE, 85.0, | 335 | INDICATOR_POWER_DEVICE_PERCENTAGE, 85.0, |
121 | 338 | NULL); | 336 | NULL); |
122 | 337 | g_string_append_printf (expected, "%s-090-charging;", kind_str); | ||
123 | 338 | g_string_append_printf (expected, "gpm-%s-090-charging;", kind_str); | ||
124 | 339 | g_string_append_printf (expected, "%s-080-charging;", kind_str); | 339 | g_string_append_printf (expected, "%s-080-charging;", kind_str); |
125 | 340 | g_string_append_printf (expected, "gpm-%s-080-charging;", kind_str); | 340 | g_string_append_printf (expected, "gpm-%s-080-charging;", kind_str); |
126 | 341 | g_string_append_printf (expected, "%s-full-charging-symbolic;", kind_str); | 341 | g_string_append_printf (expected, "%s-full-charging-symbolic;", kind_str); |
127 | @@ -348,6 +348,8 @@ | |||
128 | 348 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, | 348 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, |
129 | 349 | INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0, | 349 | INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0, |
130 | 350 | NULL); | 350 | NULL); |
131 | 351 | g_string_append_printf (expected, "%s-050-charging;", kind_str); | ||
132 | 352 | g_string_append_printf (expected, "gpm-%s-050-charging;", kind_str); | ||
133 | 351 | g_string_append_printf (expected, "%s-060-charging;", kind_str); | 353 | g_string_append_printf (expected, "%s-060-charging;", kind_str); |
134 | 352 | g_string_append_printf (expected, "gpm-%s-060-charging;", kind_str); | 354 | g_string_append_printf (expected, "gpm-%s-060-charging;", kind_str); |
135 | 353 | g_string_append_printf (expected, "%s-good-charging-symbolic;", kind_str); | 355 | g_string_append_printf (expected, "%s-good-charging-symbolic;", kind_str); |
136 | @@ -360,6 +362,8 @@ | |||
137 | 360 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, | 362 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, |
138 | 361 | INDICATOR_POWER_DEVICE_PERCENTAGE, 25.0, | 363 | INDICATOR_POWER_DEVICE_PERCENTAGE, 25.0, |
139 | 362 | NULL); | 364 | NULL); |
140 | 365 | g_string_append_printf (expected, "%s-030-charging;", kind_str); | ||
141 | 366 | g_string_append_printf (expected, "gpm-%s-030-charging;", kind_str); | ||
142 | 363 | g_string_append_printf (expected, "%s-020-charging;", kind_str); | 367 | g_string_append_printf (expected, "%s-020-charging;", kind_str); |
143 | 364 | g_string_append_printf (expected, "gpm-%s-020-charging;", kind_str); | 368 | g_string_append_printf (expected, "gpm-%s-020-charging;", kind_str); |
144 | 365 | g_string_append_printf (expected, "%s-low-charging-symbolic;", kind_str); | 369 | g_string_append_printf (expected, "%s-low-charging-symbolic;", kind_str); |
145 | @@ -372,6 +376,8 @@ | |||
146 | 372 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, | 376 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_CHARGING, |
147 | 373 | INDICATOR_POWER_DEVICE_PERCENTAGE, 5.0, | 377 | INDICATOR_POWER_DEVICE_PERCENTAGE, 5.0, |
148 | 374 | NULL); | 378 | NULL); |
149 | 379 | g_string_append_printf (expected, "%s-010-charging;", kind_str); | ||
150 | 380 | g_string_append_printf (expected, "gpm-%s-010-charging;", kind_str); | ||
151 | 375 | g_string_append_printf (expected, "%s-000-charging;", kind_str); | 381 | g_string_append_printf (expected, "%s-000-charging;", kind_str); |
152 | 376 | g_string_append_printf (expected, "gpm-%s-000-charging;", kind_str); | 382 | g_string_append_printf (expected, "gpm-%s-000-charging;", kind_str); |
153 | 377 | g_string_append_printf (expected, "%s-caution-charging-symbolic;", kind_str); | 383 | g_string_append_printf (expected, "%s-caution-charging-symbolic;", kind_str); |
154 | @@ -396,6 +402,8 @@ | |||
155 | 396 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_DISCHARGING, | 402 | INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_DISCHARGING, |
156 | 397 | INDICATOR_POWER_DEVICE_PERCENTAGE, 85.0, | 403 | INDICATOR_POWER_DEVICE_PERCENTAGE, 85.0, |
157 | 398 | NULL); | 404 | NULL); |
158 | 405 | g_string_append_printf (expected, "%s-090;", kind_str); | ||
159 | 406 | g_string_append_printf (expected, "gpm-%s-090;", kind_str); | ||
160 | 399 | g_string_append_printf (expected, "%s-080;", kind_str); | 407 | g_string_append_printf (expected, "%s-080;", kind_str); |
161 | 400 | g_string_append_printf (expected, "gpm-%s-080;", kind_str); | 408 | g_string_append_printf (expected, "gpm-%s-080;", kind_str); |
162 | 401 | g_string_append_printf (expected, "%s-full-symbolic;", kind_str); | 409 | g_string_append_printf (expected, "%s-full-symbolic;", kind_str); |
163 | @@ -409,6 +417,8 @@ | |||
164 | 409 | INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0, | 417 | INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0, |
165 | 410 | INDICATOR_POWER_DEVICE_TIME, guint64(60*60), | 418 | INDICATOR_POWER_DEVICE_TIME, guint64(60*60), |
166 | 411 | NULL); | 419 | NULL); |
167 | 420 | g_string_append_printf (expected, "%s-050;", kind_str); | ||
168 | 421 | g_string_append_printf (expected, "gpm-%s-050;", kind_str); | ||
169 | 412 | g_string_append_printf (expected, "%s-060;", kind_str); | 422 | g_string_append_printf (expected, "%s-060;", kind_str); |
170 | 413 | g_string_append_printf (expected, "gpm-%s-060;", kind_str); | 423 | g_string_append_printf (expected, "gpm-%s-060;", kind_str); |
171 | 414 | g_string_append_printf (expected, "%s-good-symbolic;", kind_str); | 424 | g_string_append_printf (expected, "%s-good-symbolic;", kind_str); |
172 | @@ -422,6 +432,8 @@ | |||
173 | 422 | INDICATOR_POWER_DEVICE_PERCENTAGE, 25.0, | 432 | INDICATOR_POWER_DEVICE_PERCENTAGE, 25.0, |
174 | 423 | INDICATOR_POWER_DEVICE_TIME, guint64(60*60), | 433 | INDICATOR_POWER_DEVICE_TIME, guint64(60*60), |
175 | 424 | NULL); | 434 | NULL); |
176 | 435 | g_string_append_printf (expected, "%s-030;", kind_str); | ||
177 | 436 | g_string_append_printf (expected, "gpm-%s-030;", kind_str); | ||
178 | 425 | g_string_append_printf (expected, "%s-020;", kind_str); | 437 | g_string_append_printf (expected, "%s-020;", kind_str); |
179 | 426 | g_string_append_printf (expected, "gpm-%s-020;", kind_str); | 438 | g_string_append_printf (expected, "gpm-%s-020;", kind_str); |
180 | 427 | g_string_append_printf (expected, "%s-low-symbolic;", kind_str); | 439 | g_string_append_printf (expected, "%s-low-symbolic;", kind_str); |
181 | @@ -435,6 +447,8 @@ | |||
182 | 435 | INDICATOR_POWER_DEVICE_PERCENTAGE, 25.0, | 447 | INDICATOR_POWER_DEVICE_PERCENTAGE, 25.0, |
183 | 436 | INDICATOR_POWER_DEVICE_TIME, guint64(60*15), | 448 | INDICATOR_POWER_DEVICE_TIME, guint64(60*15), |
184 | 437 | NULL); | 449 | NULL); |
185 | 450 | g_string_append_printf (expected, "%s-030;", kind_str); | ||
186 | 451 | g_string_append_printf (expected, "gpm-%s-030;", kind_str); | ||
187 | 438 | g_string_append_printf (expected, "%s-020;", kind_str); | 452 | g_string_append_printf (expected, "%s-020;", kind_str); |
188 | 439 | g_string_append_printf (expected, "gpm-%s-020;", kind_str); | 453 | g_string_append_printf (expected, "gpm-%s-020;", kind_str); |
189 | 440 | g_string_append_printf (expected, "%s-low-symbolic;", kind_str); | 454 | g_string_append_printf (expected, "%s-low-symbolic;", kind_str); |
190 | @@ -448,6 +462,8 @@ | |||
191 | 448 | INDICATOR_POWER_DEVICE_PERCENTAGE, 5.0, | 462 | INDICATOR_POWER_DEVICE_PERCENTAGE, 5.0, |
192 | 449 | INDICATOR_POWER_DEVICE_TIME, guint64(60*60), | 463 | INDICATOR_POWER_DEVICE_TIME, guint64(60*60), |
193 | 450 | NULL); | 464 | NULL); |
194 | 465 | g_string_append_printf (expected, "%s-010;", kind_str); | ||
195 | 466 | g_string_append_printf (expected, "gpm-%s-010;", kind_str); | ||
196 | 451 | g_string_append_printf (expected, "%s-000;", kind_str); | 467 | g_string_append_printf (expected, "%s-000;", kind_str); |
197 | 452 | g_string_append_printf (expected, "gpm-%s-000;", kind_str); | 468 | g_string_append_printf (expected, "gpm-%s-000;", kind_str); |
198 | 453 | g_string_append_printf (expected, "%s-caution-symbolic;", kind_str); | 469 | g_string_append_printf (expected, "%s-caution-symbolic;", kind_str); |
199 | @@ -461,6 +477,8 @@ | |||
200 | 461 | INDICATOR_POWER_DEVICE_PERCENTAGE, 5.0, | 477 | INDICATOR_POWER_DEVICE_PERCENTAGE, 5.0, |
201 | 462 | INDICATOR_POWER_DEVICE_TIME, guint64(60*15), | 478 | INDICATOR_POWER_DEVICE_TIME, guint64(60*15), |
202 | 463 | NULL); | 479 | NULL); |
203 | 480 | g_string_append_printf (expected, "%s-010;", kind_str); | ||
204 | 481 | g_string_append_printf (expected, "gpm-%s-010;", kind_str); | ||
205 | 464 | g_string_append_printf (expected, "%s-000;", kind_str); | 482 | g_string_append_printf (expected, "%s-000;", kind_str); |
206 | 465 | g_string_append_printf (expected, "gpm-%s-000;", kind_str); | 483 | g_string_append_printf (expected, "gpm-%s-000;", kind_str); |
207 | 466 | g_string_append_printf (expected, "%s-caution-symbolic;", kind_str); | 484 | g_string_append_printf (expected, "%s-caution-symbolic;", kind_str); |
Looks ok to me.