diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-02-01 18:58:48 -0600 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-02-01 18:58:48 -0600 |
commit | 7c8371d127b16cd2fe2893605b6cdf61a94b2451 (patch) | |
tree | f03647568ac21eba23ac14b0b842d47c3e8becb6 /src/indicator-power.c | |
parent | 85a04b44e3e4f77db07c52ab8667195c6c98cedf (diff) | |
download | ayatana-indicator-power-7c8371d127b16cd2fe2893605b6cdf61a94b2451.tar.gz ayatana-indicator-power-7c8371d127b16cd2fe2893605b6cdf61a94b2451.tar.bz2 ayatana-indicator-power-7c8371d127b16cd2fe2893605b6cdf61a94b2451.zip |
group the indicator_power lifecycle funcs together
Diffstat (limited to 'src/indicator-power.c')
-rw-r--r-- | src/indicator-power.c | 120 |
1 files changed, 61 insertions, 59 deletions
diff --git a/src/indicator-power.c b/src/indicator-power.c index 4eebf3a..27202cb 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -100,11 +100,10 @@ static GtkMenu* get_menu (IndicatorObject * io); static const gchar* get_accessible_desc (IndicatorObject * io); static const gchar* get_name_hint (IndicatorObject * io); +static void gsd_appeared_callback (GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data); G_DEFINE_TYPE (IndicatorPower, indicator_power, INDICATOR_OBJECT_TYPE); - - static void indicator_power_class_init (IndicatorPowerClass *klass) { @@ -124,6 +123,66 @@ indicator_power_class_init (IndicatorPowerClass *klass) } static void +indicator_power_init (IndicatorPower *self) +{ + IndicatorPowerPrivate *priv; + + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + INDICATOR_POWER_TYPE, + IndicatorPowerPrivate); + priv = self->priv; + + /* Init variables */ + priv->menu = NULL; + priv->accessible_desc = NULL; + + + priv->watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION, + DBUS_SERVICE, + G_BUS_NAME_WATCHER_FLAGS_NONE, + gsd_appeared_callback, + NULL, + self, + NULL); + + priv->settings = g_settings_new ("com.canonical.indicator.power"); +} + +static void +indicator_power_dispose (GObject *object) +{ + IndicatorPowerPrivate *priv = INDICATOR_POWER(object)->priv; + + if (priv->devices != NULL) { + g_variant_unref (priv->devices); + priv->devices = NULL; + } + + if (priv->device != NULL) { + g_variant_unref (priv->device); + priv->device = NULL; + } + + g_clear_object (&priv->settings); + + G_OBJECT_CLASS (indicator_power_parent_class)->dispose (object); +} + +static void +indicator_power_finalize (GObject *object) +{ + IndicatorPowerPrivate *priv = INDICATOR_POWER(object)->priv; + + g_free (priv->accessible_desc); + + G_OBJECT_CLASS (indicator_power_parent_class)->finalize (object); +} + +/*** +**** +***/ + +static void show_info_cb (GtkMenuItem *item, gpointer data) { @@ -868,63 +927,6 @@ gsd_appeared_callback (GDBusConnection *connection, self); } -static void -indicator_power_init (IndicatorPower *self) -{ - IndicatorPowerPrivate *priv; - - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - INDICATOR_POWER_TYPE, - IndicatorPowerPrivate); - priv = self->priv; - - /* Init variables */ - priv->menu = NULL; - priv->accessible_desc = NULL; - - - priv->watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION, - DBUS_SERVICE, - G_BUS_NAME_WATCHER_FLAGS_NONE, - gsd_appeared_callback, - NULL, - self, - NULL); - - /* GSettings */ - priv->settings = g_settings_new ("com.canonical.indicator.power"); -} - -static void -indicator_power_dispose (GObject *object) -{ - IndicatorPowerPrivate *priv = INDICATOR_POWER(object)->priv; - - if (priv->devices != NULL) { - g_variant_unref (priv->devices); - priv->devices = NULL; - } - - if (priv->device != NULL) { - g_variant_unref (priv->device); - priv->device = NULL; - } - - g_clear_object (&priv->settings); - - G_OBJECT_CLASS (indicator_power_parent_class)->dispose (object); -} - -static void -indicator_power_finalize (GObject *object) -{ - IndicatorPowerPrivate *priv = INDICATOR_POWER(object)->priv; - - g_free (priv->accessible_desc); - - G_OBJECT_CLASS (indicator_power_parent_class)->finalize (object); -} - |