aboutsummaryrefslogtreecommitdiff
path: root/src/service.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-08-22 09:55:30 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-08-22 09:55:30 -0500
commit3d4c3f2d2f0ebf2b39738531bd8b708d53d2206f (patch)
treeb43fcc6a9bbde59a321fc2dc43fd4b9fe716fb3b /src/service.c
parenta402b61b0acc81a808f9cb353e0df81bb9b14de0 (diff)
parentc7e1740203b41bb9cb12da0ea97477363224e3ee (diff)
downloadayatana-indicator-power-3d4c3f2d2f0ebf2b39738531bd8b708d53d2206f.tar.gz
ayatana-indicator-power-3d4c3f2d2f0ebf2b39738531bd8b708d53d2206f.tar.bz2
ayatana-indicator-power-3d4c3f2d2f0ebf2b39738531bd8b708d53d2206f.zip
sync with trunk.
Diffstat (limited to 'src/service.c')
-rw-r--r--src/service.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/service.c b/src/service.c
index 7478d0f..0cd448b 100644
--- a/src/service.c
+++ b/src/service.c
@@ -22,8 +22,10 @@
#include <gio/gio.h>
#include <url-dispatcher.h>
+#include "dbus-shared.h"
#include "device.h"
#include "device-provider.h"
+#include "notifier.h"
#include "ib-brightness-control.h"
#include "ib-brightness-uscreen-control.h"
#include "service.h"
@@ -120,6 +122,7 @@ struct _IndicatorPowerServicePrivate
GList * devices; /* IndicatorPowerDevice */
IndicatorPowerDeviceProvider * device_provider;
+ IndicatorPowerNotifier * notifier;
};
typedef IndicatorPowerServicePrivate priv_t;
@@ -592,14 +595,14 @@ rebuild_now (IndicatorPowerService * self, guint sections)
struct ProfileMenuInfo * desktop = &p->menus[PROFILE_DESKTOP];
struct ProfileMenuInfo * greeter = &p->menus[PROFILE_DESKTOP_GREETER];
- if (p->conn == NULL) /* we haven't built the menus yet */
- return;
-
if (sections & SECTION_HEADER)
{
g_simple_action_set_state (p->header_action, create_header_state (self));
}
+ if (p->conn == NULL) /* we haven't built the menus yet */
+ return;
+
if (sections & SECTION_DEVICES)
{
rebuild_section (desktop->submenu, 0, create_desktop_devices_section (self, PROFILE_DESKTOP));
@@ -821,6 +824,9 @@ on_bus_acquired (GDBusConnection * connection,
p->conn = g_object_ref (G_OBJECT (connection));
+ /* export the battery properties */
+ indicator_power_notifier_set_bus (p->notifier, connection);
+
/* export the actions */
if ((id = g_dbus_connection_export_action_group (connection,
BUS_PATH,
@@ -920,6 +926,12 @@ on_devices_changed (IndicatorPowerService * self)
g_clear_object (&p->primary_device);
p->primary_device = indicator_power_service_choose_primary_device (p->devices);
+ /* update the notifier's battery */
+ if ((p->primary_device != NULL) && (indicator_power_device_get_kind(p->primary_device) == UP_DEVICE_KIND_BATTERY))
+ indicator_power_notifier_set_battery (p->notifier, p->primary_device);
+ else
+ indicator_power_notifier_set_battery (p->notifier, NULL);
+
/* update the battery-level action's state */
if (p->primary_device == NULL)
battery_level = 0;
@@ -1001,6 +1013,7 @@ my_dispose (GObject * o)
g_clear_object (&p->settings);
}
+ g_clear_object (&p->notifier);
g_clear_object (&p->brightness_action);
g_clear_object (&p->battery_level_action);
g_clear_object (&p->header_action);
@@ -1035,6 +1048,8 @@ indicator_power_service_init (IndicatorPowerService * self)
p->settings = g_settings_new ("com.canonical.indicator.power");
+ p->notifier = indicator_power_notifier_new ();
+
uscreen_proxy = uscreen_get_proxy(&brightness_params);
if (uscreen_proxy != NULL)
{