Merge lp:~charlesk/indicator-power/lp-811777 into lp:indicator-power/13.10

Proposed by Charles Kerr
Status: Merged
Approved by: Charles Kerr
Approved revision: 193
Merged at revision: 188
Proposed branch: lp:~charlesk/indicator-power/lp-811777
Merge into: lp:indicator-power/13.10
Diff against target: 959 lines (+322/-214)
8 files modified
data/com.canonical.indicator.power.gschema.xml.in (+5/-0)
src/device-provider.c (+1/-1)
src/device.c (+120/-56)
src/device.h (+16/-15)
src/service.c (+76/-84)
tests/test-dbus-listener.cc (+11/-11)
tests/test-device.cc (+90/-44)
tests/test-service.cc (+3/-3)
To merge this branch: bzr merge lp:~charlesk/indicator-power/lp-811777
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+181707@code.launchpad.net

Description of the change

Updates the power indicator to match the spec changes at <https://wiki.ubuntu.com/Power?action=diff&rev2=37&rev1=36>.

This patch is based from hloeung's nice patch, fixes a few edge cases, adds unit tests for labels, headers, & accessible text for all combinations of show time & show percentage, and cleans up the bindings between GSettings and the checkbox actions.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
192. By Charles Kerr

copyediting: more descriptive comments when building label/header/a11y text

193. By Charles Kerr

copyediting: some newly-dead code should have been removed instead of just commented out

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Only comment is that this should probably be deleted. Otherwise, cool!

610 + //g_signal_connect (p->settings, "changed::" SETTINGS_SHOW_TIME_S,
611 + // G_CALLBACK(on_show_time_setting_changed), self);

Top approve when that gets dropped.

review: Approve
Revision history for this message
Charles Kerr (charlesk) wrote :

heh, looks like we both saw that at the same time :)

> 193. By Charles Kerr 29 minutes ago
> copyediting: some newly-dead code should have been removed instead of just commented out

> Ted Gould (ted) wrote 13 minutes ago:
> Only comment is that this should probably be deleted. Otherwise, cool!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/com.canonical.indicator.power.gschema.xml.in'
--- data/com.canonical.indicator.power.gschema.xml.in 2012-02-02 05:00:03 +0000
+++ data/com.canonical.indicator.power.gschema.xml.in 2013-08-23 14:01:50 +0000
@@ -10,6 +10,11 @@
10 <_summary>Show time in Menu Bar</_summary>10 <_summary>Show time in Menu Bar</_summary>
11 <_description>Whether or not to show the time in the menu bar.</_description>11 <_description>Whether or not to show the time in the menu bar.</_description>
12 </key>12 </key>
13 <key name="show-percentage" type="b">
14 <default>false</default>
15 <_summary>Show percentage in Menu Bar</_summary>
16 <_description>Whether or not to show the percentage in the menu bar.</_description>
17 </key>
13 <key enum="icon-policy-enum" name="icon-policy">18 <key enum="icon-policy-enum" name="icon-policy">
14 <default>"present"</default>19 <default>"present"</default>
15 <_summary>When to show the battery status in the menu bar.</_summary>20 <_summary>When to show the battery status in the menu bar.</_summary>
1621
=== modified file 'src/device-provider.c'
--- src/device-provider.c 2013-06-19 15:01:19 +0000
+++ src/device-provider.c 2013-08-23 14:01:50 +0000
@@ -54,7 +54,7 @@
54 * An easy way to free the list properly in one step is as follows:54 * An easy way to free the list properly in one step is as follows:
55 *55 *
56 * g_slist_free_full (list, (GDestroyNotify)g_object_unref);56 * g_slist_free_full (list, (GDestroyNotify)g_object_unref);
57 * 57 *
58 * Return value: (element-type IndicatorPowerDevice)58 * Return value: (element-type IndicatorPowerDevice)
59 * (transfer full):59 * (transfer full):
60 * list of devices60 * list of devices
6161
=== modified file 'src/device.c'
--- src/device.c 2013-06-17 04:16:19 +0000
+++ src/device.c 2013-08-23 14:01:50 +0000
@@ -449,10 +449,11 @@
449****449****
450***/450***/
451451
452/* Format time remaining for reading ("H:MM") and speech ("H hours, MM minutes") */
452static void453static void
453get_timestring (guint64 time_secs,454get_timestring (guint64 time_secs,
454 gchar **short_timestring,455 gchar **readable_timestring,
455 gchar **detailed_timestring)456 gchar **accessible_timestring)
456{457{
457 gint hours;458 gint hours;
458 gint minutes;459 gint minutes;
@@ -462,16 +463,16 @@
462463
463 if (minutes == 0)464 if (minutes == 0)
464 {465 {
465 *short_timestring = g_strdup (_("Unknown time"));466 *readable_timestring = g_strdup (_("Unknown time"));
466 *detailed_timestring = g_strdup (_("Unknown time"));467 *accessible_timestring = g_strdup (_("Unknown time"));
467468
468 return;469 return;
469 }470 }
470471
471 if (minutes < 60)472 if (minutes < 60)
472 {473 {
473 *short_timestring = g_strdup_printf ("0:%.2i", minutes);474 *readable_timestring = g_strdup_printf ("0:%.2i", minutes);
474 *detailed_timestring = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "%i minute",475 *accessible_timestring = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "%i minute",
475 "%i minutes",476 "%i minutes",
476 minutes), minutes);477 minutes), minutes);
477 return;478 return;
@@ -480,11 +481,11 @@
480 hours = minutes / 60;481 hours = minutes / 60;
481 minutes = minutes % 60;482 minutes = minutes % 60;
482483
483 *short_timestring = g_strdup_printf ("%i:%.2i", hours, minutes);484 *readable_timestring = g_strdup_printf ("%i:%.2i", hours, minutes);
484485
485 if (minutes == 0)486 if (minutes == 0)
486 {487 {
487 *detailed_timestring = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, 488 *accessible_timestring = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
488 "%i hour",489 "%i hour",
489 "%i hours",490 "%i hours",
490 hours), hours);491 hours), hours);
@@ -493,7 +494,7 @@
493 {494 {
494 /* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes"495 /* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes"
495 * Swap order with "%2$s %2$i %1$s %1$i if needed */496 * Swap order with "%2$s %2$i %1$s %1$i if needed */
496 *detailed_timestring = g_strdup_printf (_("%i %s %i %s"),497 *accessible_timestring = g_strdup_printf (_("%i %s %i %s"),
497 hours, g_dngettext (GETTEXT_PACKAGE, "hour", "hours", hours),498 hours, g_dngettext (GETTEXT_PACKAGE, "hour", "hours", hours),
498 minutes, g_dngettext (GETTEXT_PACKAGE, "minute", "minutes", minutes));499 minutes, g_dngettext (GETTEXT_PACKAGE, "minute", "minutes", minutes));
499 }500 }
@@ -561,86 +562,149 @@
561 return text;562 return text;
562}563}
563564
564void565static char *
565indicator_power_device_get_time_details (const IndicatorPowerDevice * device,566join_strings (const char * name, const char * time, const char * percent)
566 gchar ** short_details,567{
567 gchar ** details,568 char * str;
568 gchar ** accessible_name)569 const gboolean have_name = name && *name;
570 const gboolean have_time = time && *time;
571 const gboolean have_percent = percent && *percent;
572
573 if (have_name && have_time && have_percent)
574 str = g_strdup_printf (_("%s (%s, %s)"), name, time, percent);
575 else if (have_name && have_time)
576 str = g_strdup_printf (_("%s (%s)"), name, time);
577 else if (have_name && have_percent)
578 str = g_strdup_printf (_("%s (%s)"), name, percent);
579 else if (have_name)
580 str = g_strdup (name);
581 else if (have_time && have_percent)
582 str = g_strdup_printf (_("(%s, %s)"), time, percent);
583 else if (have_time)
584 str = g_strdup_printf (_("(%s)"), time);
585 else if (have_percent)
586 str = g_strdup_printf (_("(%s)"), percent);
587 else
588 str = g_strdup ("");
589
590 return str;
591}
592
593static void
594indicator_power_device_get_text (const IndicatorPowerDevice * device,
595 gboolean show_time_in_header,
596 gboolean show_percentage_in_header,
597 gchar ** header,
598 gchar ** label,
599 gchar ** a11y)
569{600{
570 if (!INDICATOR_IS_POWER_DEVICE(device))601 if (!INDICATOR_IS_POWER_DEVICE(device))
571 {602 {
572 *short_details = NULL;603 if (a11y != NULL) *a11y = NULL;
573 *details = NULL;604 if (label != NULL) *label = NULL;
574 *accessible_name = NULL;605 if (header != NULL) *header = NULL;
575 g_warning ("%s: %p is not an IndicatorPowerDevice", G_STRFUNC, device);606 g_warning ("%s: %p is not an IndicatorPowerDevice", G_STRFUNC, device);
576 return;607 return;
577 }608 }
578609
579 const time_t time = indicator_power_device_get_time (device);610 const time_t time = indicator_power_device_get_time (device);
580 const UpDeviceState state = indicator_power_device_get_state (device);611 const UpDeviceState state = indicator_power_device_get_state (device);
612 const UpDeviceKind kind = indicator_power_device_get_kind (device);
613 const gchar * device_name = device_kind_to_localised_string (kind);
581 const gdouble percentage = indicator_power_device_get_percentage (device);614 const gdouble percentage = indicator_power_device_get_percentage (device);
582 const UpDeviceKind kind = indicator_power_device_get_kind (device);615 char pctstr[32] = { '\0' };
583 const gchar * device_name = device_kind_to_localised_string (kind);616 g_snprintf (pctstr, sizeof(pctstr), "%.0lf%%", percentage);
617
618 GString * terse_time = g_string_new (NULL);
619 GString * verbose_time = g_string_new (NULL);
620 GString * accessible_time = g_string_new (NULL);
584621
585 if (time > 0)622 if (time > 0)
586 {623 {
587 gchar *short_timestring = NULL;624 char * readable_timestr = NULL;
588 gchar *detailed_timestring = NULL;625 char * accessible_timestr = NULL;
589626 get_timestring (time, &readable_timestr, &accessible_timestr);
590 get_timestring (time,
591 &short_timestring,
592 &detailed_timestring);
593627
594 if (state == UP_DEVICE_STATE_CHARGING)628 if (state == UP_DEVICE_STATE_CHARGING)
595 {629 {
596 /* TRANSLATORS: %2 is a time string, e.g. "1 hour 5 minutes" */630 g_string_assign (terse_time, readable_timestr);
597 *accessible_name = g_strdup_printf (_("%s (%s to charge (%.0lf%%))"), device_name, detailed_timestring, percentage);631 g_string_printf (verbose_time, _("%s to charge"), readable_timestr);
598 *details = g_strdup_printf (_("%s (%s to charge)"), device_name, short_timestring);632 g_string_printf (accessible_time, _("%s to charge"), accessible_timestr);
599 *short_details = g_strdup_printf ("(%s)", short_timestring);
600 }633 }
601 else if ((state == UP_DEVICE_STATE_DISCHARGING) && (time > (60*60*12)))634 else if ((state == UP_DEVICE_STATE_DISCHARGING) && (time <= (60*60*12)))
602 {635 {
603 *accessible_name = g_strdup_printf (_("%s"), device_name);636 g_string_assign (terse_time, readable_timestr);
604 *details = g_strdup_printf (_("%s"), device_name);637 g_string_printf (verbose_time, _("%s left"), readable_timestr);
605 *short_details = g_strdup (short_timestring);638 g_string_printf (accessible_time, _("%s left"), accessible_timestr);
606 }639 }
607 else640 else
608 {641 {
609 /* TRANSLATORS: %2 is a time string, e.g. "1 hour 5 minutes" */642 /* if there's more than 12 hours remaining, we don't show it */
610 *accessible_name = g_strdup_printf (_("%s (%s left (%.0lf%%))"), device_name, detailed_timestring, percentage);
611 *details = g_strdup_printf (_("%s (%s left)"), device_name, short_timestring);
612 *short_details = g_strdup (short_timestring);
613 }643 }
614644
615 g_free (short_timestring);645 g_free (readable_timestr);
616 g_free (detailed_timestring);646 g_free (accessible_timestr);
617 }647 }
618 else if (state == UP_DEVICE_STATE_FULLY_CHARGED)648 else if (state == UP_DEVICE_STATE_FULLY_CHARGED)
619 {649 {
620 *details = g_strdup_printf (_("%s (charged)"), device_name);650 g_string_assign (verbose_time, _("charged"));
621 *accessible_name = g_strdup (*details);651 g_string_assign (accessible_time, _("charged"));
622 *short_details = g_strdup ("");
623 }652 }
624 else if (percentage > 0)653 else if (percentage > 0)
625 {654 {
626 /* TRANSLATORS: %2 is a percentage value. Note: this string is only655 g_string_assign (terse_time, _("estimating…"));
627 * used when we don't have a time value */656 g_string_assign (verbose_time, _("estimating…"));
628 *details = g_strdup_printf (_("%s (%.0lf%%)"), device_name, percentage);657 g_string_assign (accessible_time, _("estimating…"));
629 *accessible_name = g_strdup (*details);
630 *short_details = g_strdup_printf (_("(%.0lf%%)"), percentage);
631 }
632 else if (kind == UP_DEVICE_KIND_LINE_POWER)
633 {
634 *details = g_strdup (device_name);
635 *accessible_name = g_strdup (device_name);
636 *short_details = g_strdup ("");
637 }658 }
638 else659 else
639 {660 {
640 *details = g_strdup_printf (_("%s (not present)"), device_name);661 *pctstr = '\0';
641 *accessible_name = g_strdup (*details);662
642 *short_details = g_strdup (_("(not present)"));663 if (kind != UP_DEVICE_KIND_LINE_POWER)
664 {
665 g_string_assign (verbose_time, _("not present"));
666 g_string_assign (accessible_time, _("not present"));
667 }
643 }668 }
669
670 if (header != NULL)
671 *header = join_strings (NULL,
672 show_time_in_header ? terse_time->str : "",
673 show_percentage_in_header ? pctstr : "");
674
675 if (label != NULL)
676 *label = join_strings (device_name,
677 verbose_time->str,
678 NULL);
679
680 if (a11y != NULL)
681 *a11y = join_strings (device_name,
682 accessible_time->str,
683 pctstr);
684
685 g_string_free (terse_time, TRUE);
686 g_string_free (verbose_time, TRUE);
687 g_string_free (accessible_time, TRUE);
688}
689
690gchar *
691indicator_power_device_get_label (const IndicatorPowerDevice * device)
692{
693 gchar * label = NULL;
694 indicator_power_device_get_text (device, FALSE, FALSE,
695 NULL, &label, NULL);
696 return label;
697}
698
699void
700indicator_power_device_get_header (const IndicatorPowerDevice * device,
701 gboolean show_time,
702 gboolean show_percentage,
703 gchar ** header,
704 gchar ** a11y)
705{
706 indicator_power_device_get_text (device, show_time, show_percentage,
707 header, NULL, a11y);
644}708}
645709
646/***710/***
647711
=== modified file 'src/device.h'
--- src/device.h 2013-06-17 04:16:19 +0000
+++ src/device.h 2013-08-23 14:01:50 +0000
@@ -116,21 +116,22 @@
116IndicatorPowerDevice* indicator_power_device_new_from_variant (GVariant * variant);116IndicatorPowerDevice* indicator_power_device_new_from_variant (GVariant * variant);
117117
118118
119UpDeviceKind indicator_power_device_get_kind (const IndicatorPowerDevice * device);119UpDeviceKind indicator_power_device_get_kind (const IndicatorPowerDevice * device);
120UpDeviceState indicator_power_device_get_state (const IndicatorPowerDevice * device);120UpDeviceState indicator_power_device_get_state (const IndicatorPowerDevice * device);
121const gchar * indicator_power_device_get_object_path (const IndicatorPowerDevice * device);121const gchar * indicator_power_device_get_object_path (const IndicatorPowerDevice * device);
122gdouble indicator_power_device_get_percentage (const IndicatorPowerDevice * device);122gdouble indicator_power_device_get_percentage (const IndicatorPowerDevice * device);
123time_t indicator_power_device_get_time (const IndicatorPowerDevice * device);123time_t indicator_power_device_get_time (const IndicatorPowerDevice * device);
124124
125GStrv indicator_power_device_get_icon_names (const IndicatorPowerDevice * device);125GStrv indicator_power_device_get_icon_names (const IndicatorPowerDevice * device);
126GIcon * indicator_power_device_get_gicon (const IndicatorPowerDevice * device);126GIcon * indicator_power_device_get_gicon (const IndicatorPowerDevice * device);
127127
128void indicator_power_device_get_time_details (const IndicatorPowerDevice * device,128gchar * indicator_power_device_get_label (const IndicatorPowerDevice * device);
129 gchar ** short_details,129
130 gchar ** details,130void indicator_power_device_get_header (const IndicatorPowerDevice * device,
131 gchar ** accessible_name);131 gboolean show_time,
132132 gboolean show_percentage,
133133 gchar ** header,
134 gchar ** a11y);
134135
135136
136G_END_DECLS137G_END_DECLS
137138
=== modified file 'src/service.c'
--- src/service.c 2013-08-20 03:47:23 +0000
+++ src/service.c 2013-08-23 14:01:50 +0000
@@ -33,6 +33,7 @@
3333
34#define SETTINGS_SHOW_TIME_S "show-time"34#define SETTINGS_SHOW_TIME_S "show-time"
35#define SETTINGS_ICON_POLICY_S "icon-policy"35#define SETTINGS_ICON_POLICY_S "icon-policy"
36#define SETTINGS_SHOW_PERCENTAGE_S "show-percentage"
3637
37G_DEFINE_TYPE (IndicatorPowerService,38G_DEFINE_TYPE (IndicatorPowerService,
38 indicator_power_service,39 indicator_power_service,
@@ -112,6 +113,7 @@
112 GSimpleActionGroup * actions;113 GSimpleActionGroup * actions;
113 GSimpleAction * header_action;114 GSimpleAction * header_action;
114 GSimpleAction * show_time_action;115 GSimpleAction * show_time_action;
116 GSimpleAction * show_percentage_action;
115 GSimpleAction * battery_level_action;117 GSimpleAction * battery_level_action;
116 GSimpleAction * brightness_action;118 GSimpleAction * brightness_action;
117119
@@ -318,16 +320,13 @@
318320
319 if (p->primary_device != NULL)321 if (p->primary_device != NULL)
320 {322 {
321 gchar * details;323 indicator_power_device_get_header (p->primary_device,
322324 g_settings_get_boolean (p->settings, SETTINGS_SHOW_TIME_S),
323 indicator_power_device_get_time_details (p->primary_device,325 g_settings_get_boolean (p->settings, SETTINGS_SHOW_PERCENTAGE_S),
324 &label,326 &label,
325 &details,327 &a11y);
326 &a11y);
327328
328 icon = indicator_power_device_get_gicon (p->primary_device);329 icon = indicator_power_device_get_gicon (p->primary_device);
329
330 g_free (details);
331 }330 }
332331
333 g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));332 g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));
@@ -337,9 +336,7 @@
337336
338 if (label != NULL)337 if (label != NULL)
339 {338 {
340 if (g_settings_get_boolean (p->settings, SETTINGS_SHOW_TIME_S))339 g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label));
341 g_variant_builder_add (&b, "{sv}", "label",
342 g_variant_new_string (label));
343340
344 g_free (label);341 g_free (label);
345 }342 }
@@ -376,33 +373,24 @@
376373
377 if (kind != UP_DEVICE_KIND_LINE_POWER)374 if (kind != UP_DEVICE_KIND_LINE_POWER)
378 {375 {
379 char * brief;376 GIcon * icon;
380 char * label;377 char * label;
381 char * a11y;
382 GMenuItem * menu_item;378 GMenuItem * menu_item;
383 GIcon * icon = indicator_power_device_get_gicon (device);379
384380 icon = indicator_power_device_get_gicon (device);
385 indicator_power_device_get_time_details (device,381 label = indicator_power_device_get_label (device);
386 &brief,
387 &label,
388 &a11y);
389
390 menu_item = g_menu_item_new (label, "indicator.activate-statistics");382 menu_item = g_menu_item_new (label, "indicator.activate-statistics");
391383
392 if (icon != NULL)384 if (icon != NULL)
393 {385 g_menu_item_set_attribute_value (menu_item,
394 g_menu_item_set_attribute_value (menu_item,386 G_MENU_ATTRIBUTE_ICON,
395 G_MENU_ATTRIBUTE_ICON,387 g_icon_serialize (icon));
396 g_icon_serialize (icon));
397 }
398388
399 g_menu_append_item (menu, menu_item);389 g_menu_append_item (menu, menu_item);
400 g_object_unref (menu_item);390 g_object_unref (menu_item);
401391
402 g_clear_object (&icon);392 g_clear_object (&icon);
403 g_free (brief);
404 g_free (label);393 g_free (label);
405 g_free (a11y);
406 }394 }
407}395}
408396
@@ -521,6 +509,10 @@
521 "indicator.show-time");509 "indicator.show-time");
522510
523 g_menu_append (menu,511 g_menu_append (menu,
512 _("Show Percentage in Menu Bar"),
513 "indicator.show-percentage");
514
515 g_menu_append (menu,
524 _("Power Settings…"),516 _("Power Settings…"),
525 "indicator.activate-settings");517 "indicator.activate-settings");
526518
@@ -706,49 +698,15 @@
706 execute_command ("gnome-power-statistics");698 execute_command ("gnome-power-statistics");
707}699}
708700
709/* FIXME: use a GBinding to tie the gaction's state and the GSetting together? */701/***
710702****
711static void703***/
712set_show_time_flag (IndicatorPowerService * self, gboolean b)
713{
714 GVariant * v;
715 priv_t * p = self->priv;
716
717 /* update the settings */
718 if (b != g_settings_get_boolean (p->settings, SETTINGS_SHOW_TIME_S))
719 g_settings_set_boolean (p->settings, SETTINGS_SHOW_TIME_S, b);
720
721 /* update the action state */
722 v = g_action_get_state (G_ACTION(p->show_time_action));
723 if (b != g_variant_get_boolean (v))
724 g_simple_action_set_state (p->show_time_action, g_variant_new_boolean (b));
725 g_variant_unref (v);
726
727 rebuild_header_now (self);
728}
729static void
730on_show_time_setting_changed (GSettings * settings, gchar * key, gpointer gself)
731{
732 set_show_time_flag (INDICATOR_POWER_SERVICE(gself),
733 g_settings_get_boolean (settings, key));
734}
735
736static void
737on_show_time_action_state_changed (GAction * action,
738 GParamSpec * pspec G_GNUC_UNUSED,
739 gpointer gself)
740{
741 GVariant * v = g_action_get_state (action);
742 set_show_time_flag (INDICATOR_POWER_SERVICE(gself),
743 g_variant_get_boolean (v));
744 g_variant_unref (v);
745}
746704
747/* toggles the state */705/* toggles the state */
748static void706static void
749on_show_time_action_activated (GSimpleAction * simple,707on_toggle_action_activated (GSimpleAction * simple,
750 GVariant * parameter G_GNUC_UNUSED,708 GVariant * parameter G_GNUC_UNUSED,
751 gpointer unused G_GNUC_UNUSED)709 gpointer unused G_GNUC_UNUSED)
752{710{
753 GVariant * v = g_action_get_state (G_ACTION (simple));711 GVariant * v = g_action_get_state (G_ACTION (simple));
754 gboolean flag = g_variant_get_boolean (v);712 gboolean flag = g_variant_get_boolean (v);
@@ -756,11 +714,27 @@
756 g_variant_unref (v);714 g_variant_unref (v);
757}715}
758716
717static gboolean
718settings_to_action_state (GValue * value,
719 GVariant * variant,
720 gpointer user_data G_GNUC_UNUSED)
721{
722 g_value_set_variant (value, variant);
723 return TRUE;
724}
725
726static GVariant *
727action_state_to_settings (const GValue * value,
728 const GVariantType * expected_type G_GNUC_UNUSED,
729 gpointer user_data G_GNUC_UNUSED)
730{
731 return g_value_dup_variant (value);
732}
733
759static void734static void
760init_gactions (IndicatorPowerService * self)735init_gactions (IndicatorPowerService * self)
761{736{
762 GSimpleAction * a;737 GSimpleAction * a;
763 gboolean show_time;
764 priv_t * p = self->priv;738 priv_t * p = self->priv;
765739
766 GActionEntry entries[] = {740 GActionEntry entries[] = {
@@ -777,33 +751,47 @@
777751
778 /* add the header action */752 /* add the header action */
779 a = g_simple_action_new_stateful ("_header", NULL, create_header_state (self));753 a = g_simple_action_new_stateful ("_header", NULL, create_header_state (self));
780 g_simple_action_group_insert (p->actions, G_ACTION(a));754 g_action_map_add_action (G_ACTION_MAP(p->actions), G_ACTION(a));
781 p->header_action = a;755 p->header_action = a;
782756
783 /* add the power-level action */757 /* add the power-level action */
784 a = g_simple_action_new_stateful ("battery-level", NULL, g_variant_new_uint32(0));758 a = g_simple_action_new_stateful ("battery-level", NULL, g_variant_new_uint32(0));
785 g_simple_action_set_enabled (a, FALSE);759 g_simple_action_set_enabled (a, FALSE);
786 g_simple_action_group_insert (p->actions, G_ACTION(a));760 g_action_map_add_action (G_ACTION_MAP(p->actions), G_ACTION(a));
787 p->battery_level_action = a;761 p->battery_level_action = a;
788762
789 /* add the brightness action */763 /* add the brightness action */
790 a = g_simple_action_new_stateful ("brightness", NULL, action_state_for_brightness (self));764 a = g_simple_action_new_stateful ("brightness", NULL, action_state_for_brightness (self));
791 g_simple_action_group_insert (p->actions, G_ACTION(a));765 g_action_map_add_action (G_ACTION_MAP(p->actions), G_ACTION(a));
792 g_signal_connect (a, "change-state", G_CALLBACK(on_brightness_change_requested), self);766 g_signal_connect (a, "change-state", G_CALLBACK(on_brightness_change_requested), self);
793 p->brightness_action = a;767 p->brightness_action = a;
794768
795 /* add the show-time action */769 /* add the show-time action */
796 show_time = g_settings_get_boolean (p->settings, SETTINGS_SHOW_TIME_S);770 a = g_simple_action_new ("show-time", NULL);
797 a = g_simple_action_new_stateful ("show-time",771 g_settings_bind_with_mapping (p->settings, SETTINGS_SHOW_TIME_S,
798 NULL,772 a, "state",
799 g_variant_new_boolean(show_time));773 G_SETTINGS_BIND_DEFAULT,
800 g_signal_connect (a, "activate",774 settings_to_action_state,
801 G_CALLBACK(on_show_time_action_activated), self);775 action_state_to_settings,
802 g_signal_connect (a, "notify",776 NULL, NULL);
803 G_CALLBACK(on_show_time_action_state_changed), self);777 g_signal_connect (a, "activate", G_CALLBACK(on_toggle_action_activated), self);
804 g_simple_action_group_insert (p->actions, G_ACTION(a));778 g_signal_connect_swapped (a, "notify", G_CALLBACK(rebuild_header_now), self);
779 g_action_map_add_action (G_ACTION_MAP(p->actions), G_ACTION(a));
805 p->show_time_action = a;780 p->show_time_action = a;
806781
782 /* add the show-percentage action */
783 a = g_simple_action_new ("show-percentage", NULL);
784 g_settings_bind_with_mapping (p->settings, SETTINGS_SHOW_PERCENTAGE_S,
785 a, "state",
786 G_SETTINGS_BIND_DEFAULT,
787 settings_to_action_state,
788 action_state_to_settings,
789 NULL, NULL);
790 g_signal_connect (a, "activate", G_CALLBACK(on_toggle_action_activated), self);
791 g_signal_connect_swapped (a, "notify", G_CALLBACK(rebuild_header_now), self);
792 g_action_map_add_action (G_ACTION_MAP(p->actions), G_ACTION(a));
793 p->show_percentage_action = a;
794
807 rebuild_header_now (self);795 rebuild_header_now (self);
808}796}
809797
@@ -949,7 +937,7 @@
949{937{
950 IndicatorPowerService * self = INDICATOR_POWER_SERVICE (o);938 IndicatorPowerService * self = INDICATOR_POWER_SERVICE (o);
951 priv_t * p = self->priv;939 priv_t * p = self->priv;
952 940
953 switch (property_id)941 switch (property_id)
954 {942 {
955 case PROP_DEVICE_PROVIDER:943 case PROP_DEVICE_PROVIDER:
@@ -1014,10 +1002,16 @@
1014 g_clear_object (&p->show_time_action);1002 g_clear_object (&p->show_time_action);
1015 }1003 }
10161004
1005 if (p->show_percentage_action != NULL)
1006 {
1007 g_signal_handlers_disconnect_by_data (p->show_percentage_action, self);
1008
1009 g_clear_object (&p->show_percentage_action);
1010 }
1011
1017 g_clear_object (&p->brightness_action);1012 g_clear_object (&p->brightness_action);
1018 g_clear_object (&p->battery_level_action);1013 g_clear_object (&p->battery_level_action);
1019 g_clear_object (&p->header_action);1014 g_clear_object (&p->header_action);
1020 g_clear_object (&p->show_time_action);
1021 g_clear_object (&p->actions);1015 g_clear_object (&p->actions);
10221016
1023 g_clear_object (&p->conn);1017 g_clear_object (&p->conn);
@@ -1051,8 +1045,6 @@
10511045
1052 g_signal_connect_swapped (p->settings, "changed::" SETTINGS_ICON_POLICY_S,1046 g_signal_connect_swapped (p->settings, "changed::" SETTINGS_ICON_POLICY_S,
1053 G_CALLBACK(rebuild_header_now), self);1047 G_CALLBACK(rebuild_header_now), self);
1054 g_signal_connect (p->settings, "changed::" SETTINGS_SHOW_TIME_S,
1055 G_CALLBACK(on_show_time_setting_changed), self);
10561048
1057 p->own_id = g_bus_own_name (G_BUS_TYPE_SESSION,1049 p->own_id = g_bus_own_name (G_BUS_TYPE_SESSION,
1058 BUS_NAME,1050 BUS_NAME,
10591051
=== modified file 'tests/test-dbus-listener.cc'
--- tests/test-dbus-listener.cc 2013-01-17 21:07:08 +0000
+++ tests/test-dbus-listener.cc 2013-08-23 14:01:50 +0000
@@ -4,16 +4,16 @@
4Authors:4Authors:
5 Charles Kerr <charles.kerr@canonical.com>5 Charles Kerr <charles.kerr@canonical.com>
66
7This program is free software: you can redistribute it and/or modify it 7This program is free software: you can redistribute it and/or modify it
8under the terms of the GNU General Public License version 3, as published 8under the terms of the GNU General Public License version 3, as published
9by the Free Software Foundation.9by the Free Software Foundation.
1010
11This program is distributed in the hope that it will be useful, but 11This program is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranties of 12WITHOUT ANY WARRANTY; without even the implied warranties of
13MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 13MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14PURPOSE. See the GNU General Public License for more details.14PURPOSE. See the GNU General Public License for more details.
1515
16You should have received a copy of the GNU General Public License along 16You should have received a copy of the GNU General Public License along
17with this program. If not, see <http://www.gnu.org/licenses/>.17with this program. If not, see <http://www.gnu.org/licenses/>.
18*/18*/
1919
@@ -40,7 +40,7 @@
40 int gsd_name_ownership_id;40 int gsd_name_ownership_id;
41 int gsd_power_registration_id;41 int gsd_power_registration_id;
42 char * gsd_power_error_string;42 char * gsd_power_error_string;
43 43
44 protected:44 protected:
4545
46 static void46 static void
@@ -234,7 +234,7 @@
234234
235 // cleanup235 // cleanup
236 g_object_run_dispose (o); // used to get coverage of both branches in the object's dispose func's g_clear_*() calls236 g_object_run_dispose (o); // used to get coverage of both branches in the object's dispose func's g_clear_*() calls
237 g_object_unref (o); 237 g_object_unref (o);
238}238}
239239
240TEST_F(DbusListenerTest, GSDHasNoDevices)240TEST_F(DbusListenerTest, GSDHasNoDevices)
@@ -261,7 +261,7 @@
261261
262 // cleanup262 // cleanup
263 g_object_run_dispose (o); // used to get coverage of both branches in the object's dispose func's g_clear_*() calls263 g_object_run_dispose (o); // used to get coverage of both branches in the object's dispose func's g_clear_*() calls
264 g_object_unref (o); 264 g_object_unref (o);
265}265}
266266
267TEST_F(DbusListenerTest, GSDReturnsError)267TEST_F(DbusListenerTest, GSDReturnsError)
@@ -285,7 +285,7 @@
285285
286 // cleanup286 // cleanup
287 g_object_run_dispose (o); // used to get coverage of both branches in the object's dispose func's g_clear_*() calls287 g_object_run_dispose (o); // used to get coverage of both branches in the object's dispose func's g_clear_*() calls
288 g_object_unref (o); 288 g_object_unref (o);
289}289}
290290
291/* This test emits a PropertiesChanged signal and confirms that291/* This test emits a PropertiesChanged signal and confirms that
@@ -347,5 +347,5 @@
347 ASSERT_EQ (g_slist_length(devices), 2);347 ASSERT_EQ (g_slist_length(devices), 2);
348348
349 // cleanup349 // cleanup
350 g_object_unref (o); 350 g_object_unref (o);
351}351}
352352
=== modified file 'tests/test-device.cc'
--- tests/test-device.cc 2013-06-17 23:01:51 +0000
+++ tests/test-device.cc 2013-08-23 14:01:50 +0000
@@ -4,16 +4,16 @@
4Authors:4Authors:
5 Charles Kerr <charles.kerr@canonical.com>5 Charles Kerr <charles.kerr@canonical.com>
66
7This program is free software: you can redistribute it and/or modify it 7This program is free software: you can redistribute it and/or modify it
8under the terms of the GNU General Public License version 3, as published 8under the terms of the GNU General Public License version 3, as published
9by the Free Software Foundation.9by the Free Software Foundation.
1010
11This program is distributed in the hope that it will be useful, but 11This program is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranties of 12WITHOUT ANY WARRANTY; without even the implied warranties of
13MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 13MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14PURPOSE. See the GNU General Public License for more details.14PURPOSE. See the GNU General Public License for more details.
1515
16You should have received a copy of the GNU General Public License along 16You should have received a copy of the GNU General Public License along
17with this program. If not, see <http://www.gnu.org/licenses/>.17with this program. If not, see <http://www.gnu.org/licenses/>.
18*/18*/
1919
@@ -69,27 +69,52 @@
69 g_strfreev (names);69 g_strfreev (names);
70 }70 }
7171
72 void check_strings (const IndicatorPowerDevice * device,72 void check_label (const IndicatorPowerDevice * device,
73 const char * expected_timestring,73 const char * expected_label)
74 const char * expected_details,74 {
75 const char * expected_accessible)75 char * label;
76 {76
77 char * timestring = NULL;77 label = indicator_power_device_get_label (device);
78 char * details = NULL;78 EXPECT_STREQ (expected_label, label);
79 char * accessible = NULL;79
8080 g_free (label);
81 indicator_power_device_get_time_details (device, &timestring, &details, &accessible);81 }
82 EXPECT_STREQ (expected_timestring, timestring);82
83 EXPECT_STREQ (expected_details, details);83 void check_header (const IndicatorPowerDevice * device,
84 EXPECT_STREQ (expected_accessible, accessible);84 const char * expected_time_and_percent,
8585 const char * expected_time,
86 g_free (accessible);86 const char * expected_percent,
87 g_free (details);87 const char * expected_a11y)
88 g_free (timestring);88 {
89 char * label;
90 char * a11y;
91
92 indicator_power_device_get_header (device, true, true, &label, &a11y);
93 EXPECT_STREQ (expected_time_and_percent, label);
94 EXPECT_STREQ (expected_a11y, a11y);
95 g_free (label);
96 g_free (a11y);
97
98 indicator_power_device_get_header (device, true, false, &label, &a11y);
99 EXPECT_STREQ (expected_time, label);
100 EXPECT_STREQ (expected_a11y, a11y);
101 g_free (label);
102 g_free (a11y);
103
104 indicator_power_device_get_header (device, false, true, &label, &a11y);
105 EXPECT_STREQ (expected_percent, label);
106 EXPECT_STREQ (expected_a11y, a11y);
107 g_free (label);
108 g_free (a11y);
109
110 indicator_power_device_get_header (device, false, false, &label, &a11y);
111 ASSERT_TRUE (!label || !*label);
112 EXPECT_STREQ (expected_a11y, a11y);
113 g_free (label);
114 g_free (a11y);
89 }115 }
90};116};
91117
92
93/***118/***
94****119****
95***/120***/
@@ -266,7 +291,7 @@
266 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, kind,291 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, kind,
267 INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_EMPTY,292 INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_EMPTY,
268 NULL);293 NULL);
269 294
270 g_string_append_printf (expected, "%s-empty-symbolic;", kind_str);295 g_string_append_printf (expected, "%s-empty-symbolic;", kind_str);
271 g_string_append_printf (expected, "gpm-%s-empty;", kind_str);296 g_string_append_printf (expected, "gpm-%s-empty;", kind_str);
272 g_string_append_printf (expected, "gpm-%s-000;", kind_str);297 g_string_append_printf (expected, "gpm-%s-000;", kind_str);
@@ -434,7 +459,7 @@
434459
435 // state unknown460 // state unknown
436 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, kind,461 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, kind,
437 INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_UNKNOWN, 462 INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_UNKNOWN,
438 NULL);463 NULL);
439 g_string_append_printf (expected, "%s-missing-symbolic;", kind_str);464 g_string_append_printf (expected, "%s-missing-symbolic;", kind_str);
440 g_string_append_printf (expected, "gpm-%s-missing;", kind_str);465 g_string_append_printf (expected, "gpm-%s-missing;", kind_str);
@@ -456,19 +481,21 @@
456 g_setenv ("LANG", "en_US.UTF-8", TRUE);481 g_setenv ("LANG", "en_US.UTF-8", TRUE);
457482
458 // bad args: NULL device483 // bad args: NULL device
459 log_count_ipower_expected++;484 log_count_ipower_expected += 5;
460 check_strings (NULL, NULL, NULL, NULL);485 check_label (NULL, NULL);
486 check_header (NULL, NULL, NULL, NULL, NULL);
461487
462 // bad args: a GObject that isn't a device488 // bad args: a GObject that isn't a device
463 log_count_ipower_expected++;489 log_count_ipower_expected += 5;
464 GObject * o = G_OBJECT(g_cancellable_new());490 GObject * o = G_OBJECT(g_cancellable_new());
465 check_strings ((IndicatorPowerDevice*)o, NULL, NULL, NULL);491 check_label ((IndicatorPowerDevice*)o, NULL);
492 check_header (NULL, NULL, NULL, NULL, NULL);
466 g_object_unref (o);493 g_object_unref (o);
467494
468 /**495 /**
469 ***496 ***
470 **/497 **/
471 498
472 IndicatorPowerDevice * device = INDICATOR_POWER_DEVICE (g_object_new (INDICATOR_POWER_DEVICE_TYPE, NULL));499 IndicatorPowerDevice * device = INDICATOR_POWER_DEVICE (g_object_new (INDICATOR_POWER_DEVICE_TYPE, NULL));
473 o = G_OBJECT(device);500 o = G_OBJECT(device);
474501
@@ -478,9 +505,11 @@
478 INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0,505 INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0,
479 INDICATOR_POWER_DEVICE_TIME, guint64(60*61),506 INDICATOR_POWER_DEVICE_TIME, guint64(60*61),
480 NULL);507 NULL);
481 check_strings (device, "(1:01)",508 check_label (device, "Battery (1:01 to charge)");
482 "Battery (1:01 to charge)",509 check_header (device, "(1:01, 50%)",
483 "Battery (1 hour 1 minute to charge (50%))");510 "(1:01)",
511 "(50%)",
512 "Battery (1 hour 1 minute to charge, 50%)");
484513
485 // discharging, < 12 hours left514 // discharging, < 12 hours left
486 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,515 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,
@@ -488,25 +517,36 @@
488 INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0,517 INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0,
489 INDICATOR_POWER_DEVICE_TIME, guint64(60*61),518 INDICATOR_POWER_DEVICE_TIME, guint64(60*61),
490 NULL);519 NULL);
491 check_strings (device, "1:01",520 check_label (device, "Battery (1:01 left)");
492 "Battery (1:01 left)",521 check_header (device, "(1:01, 50%)",
493 "Battery (1 hour 1 minute left (50%))");522 "(1:01)",
523 "(50%)",
524 "Battery (1 hour 1 minute left, 50%)");
494525
495 // discharging, > 12 hours left526 // discharging, > 12 hours left
527 // we don't show the clock time when > 12 hours dischargin
496 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,528 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,
497 INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_DISCHARGING,529 INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_DISCHARGING,
498 INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0,530 INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0,
499 INDICATOR_POWER_DEVICE_TIME, guint64(60*60*13),531 INDICATOR_POWER_DEVICE_TIME, guint64(60*60*13),
500 NULL);532 NULL);
501 check_strings (device, "13:00", "Battery", "Battery");533 check_label (device, "Battery");
534 check_header (device, "(50%)",
535 "",
536 "(50%)",
537 "Battery (50%)");
502538
503 // fully charged539// fully charged
504 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,540 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,
505 INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_FULLY_CHARGED,541 INDICATOR_POWER_DEVICE_STATE, UP_DEVICE_STATE_FULLY_CHARGED,
506 INDICATOR_POWER_DEVICE_PERCENTAGE, 100.0,542 INDICATOR_POWER_DEVICE_PERCENTAGE, 100.0,
507 INDICATOR_POWER_DEVICE_TIME, guint64(0),543 INDICATOR_POWER_DEVICE_TIME, guint64(0),
508 NULL);544 NULL);
509 check_strings (device, "", "Battery (charged)", "Battery (charged)");545 check_label (device, "Battery (charged)");
546 check_header (device, "(100%)",
547 "",
548 "(100%)",
549 "Battery (charged, 100%)");
510550
511 // percentage but no time estimate551 // percentage but no time estimate
512 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,552 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,
@@ -514,7 +554,11 @@
514 INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0,554 INDICATOR_POWER_DEVICE_PERCENTAGE, 50.0,
515 INDICATOR_POWER_DEVICE_TIME, guint64(0),555 INDICATOR_POWER_DEVICE_TIME, guint64(0),
516 NULL);556 NULL);
517 check_strings (device, "(50%)", "Battery (50%)", "Battery (50%)");557 check_label (device, "Battery (estimating…)");
558 check_header (device, "(estimating…, 50%)",
559 "(estimating…)",
560 "(50%)",
561 "Battery (estimating…, 50%)");
518562
519 // no percentage, no time estimate563 // no percentage, no time estimate
520 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,564 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_BATTERY,
@@ -522,7 +566,8 @@
522 INDICATOR_POWER_DEVICE_PERCENTAGE, 0.0,566 INDICATOR_POWER_DEVICE_PERCENTAGE, 0.0,
523 INDICATOR_POWER_DEVICE_TIME, guint64(0),567 INDICATOR_POWER_DEVICE_TIME, guint64(0),
524 NULL);568 NULL);
525 check_strings (device, "(not present)", "Battery (not present)", "Battery (not present)");569 check_label (device, "Battery (not present)");
570 check_header (device, "", "", "", "Battery (not present)");
526571
527 // power line572 // power line
528 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_LINE_POWER,573 g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_LINE_POWER,
@@ -530,7 +575,8 @@
530 INDICATOR_POWER_DEVICE_PERCENTAGE, 0.0,575 INDICATOR_POWER_DEVICE_PERCENTAGE, 0.0,
531 INDICATOR_POWER_DEVICE_TIME, guint64(0),576 INDICATOR_POWER_DEVICE_TIME, guint64(0),
532 NULL);577 NULL);
533 check_strings (device, "", "AC Adapter", "AC Adapter");578 check_label (device, "AC Adapter");
579 check_header (device, "", "", "", "AC Adapter");
534580
535 // cleanup581 // cleanup
536 g_object_unref(o);582 g_object_unref(o);
@@ -605,7 +651,7 @@
605 ASSERT_EQ (a, indicator_power_service_choose_primary_device(device_list));651 ASSERT_EQ (a, indicator_power_service_choose_primary_device(device_list));
606 }652 }
607 }653 }
608 654
609 // cleanup655 // cleanup
610 g_list_free_full (device_list, g_object_unref);656 g_list_free_full (device_list, g_object_unref);
611}657}
612658
=== modified file 'tests/test-service.cc'
--- tests/test-service.cc 2013-06-17 23:01:51 +0000
+++ tests/test-service.cc 2013-08-23 14:01:50 +0000
@@ -65,7 +65,7 @@
65 virtual void SetUp()65 virtual void SetUp()
66 {66 {
67 ensure_glib_initialized ();67 ensure_glib_initialized ();
68 68
69 g_setenv( "GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE);69 g_setenv( "GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE);
7070
71 ac_device = indicator_power_device_new (71 ac_device = indicator_power_device_new (
@@ -90,7 +90,7 @@
90 const char* GetAccessibleDesc (IndicatorPower * power) const90 const char* GetAccessibleDesc (IndicatorPower * power) const
91 {91 {
92 GList * entries = indicator_object_get_entries (INDICATOR_OBJECT(power));92 GList * entries = indicator_object_get_entries (INDICATOR_OBJECT(power));
93 g_assert (g_list_length(entries) == 1); 93 g_assert (g_list_length(entries) == 1);
94 IndicatorObjectEntry * entry = static_cast<IndicatorObjectEntry*>(entries->data);94 IndicatorObjectEntry * entry = static_cast<IndicatorObjectEntry*>(entries->data);
95 const char * ret = entry->accessible_desc;95 const char * ret = entry->accessible_desc;
96 g_list_free (entries);96 g_list_free (entries);
@@ -120,7 +120,7 @@
120 devices = g_slist_append (devices, ac_device);120 devices = g_slist_append (devices, ac_device);
121 devices = g_slist_append (devices, battery_device);121 devices = g_slist_append (devices, battery_device);
122 indicator_power_set_devices (power, devices);122 indicator_power_set_devices (power, devices);
123 g_slist_free (devices); 123 g_slist_free (devices);
124124
125 g_object_unref (power);125 g_object_unref (power);
126}126}

Subscribers

People subscribed via source and target branches