diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2014-10-14 14:09:00 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2014-10-14 14:09:00 -0500 |
commit | 407c63c08ab7c08085230712cf0d1020f01f1cc3 (patch) | |
tree | 3d96598112bf60eba85dc7d46dd05cb2427b0da4 /src/notifier.c | |
parent | 1e530c28e3b72cdb130594a8c46c6db462f49af4 (diff) | |
download | ayatana-indicator-power-407c63c08ab7c08085230712cf0d1020f01f1cc3.tar.gz ayatana-indicator-power-407c63c08ab7c08085230712cf0d1020f01f1cc3.tar.bz2 ayatana-indicator-power-407c63c08ab7c08085230712cf0d1020f01f1cc3.zip |
fix notify get-capabilities startup blocking bug found in testing
Diffstat (limited to 'src/notifier.c')
-rw-r--r-- | src/notifier.c | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/src/notifier.c b/src/notifier.c index 993e332..b0fce15 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -76,6 +76,8 @@ typedef struct GDBusConnection * bus; DbusBattery * dbus_battery; /* com.canonical.indicator.power.Battery skeleton */ + + guint notify_init_tag; } IndicatorPowerNotifierPrivate; @@ -332,6 +334,12 @@ my_dispose (GObject * o) IndicatorPowerNotifier * const self = INDICATOR_POWER_NOTIFIER(o); priv_t * const p = get_priv (self); + if (p->notify_init_tag) + { + g_source_remove(p->notify_init_tag); + p->notify_init_tag = 0; + } + indicator_power_notifier_set_bus (self, NULL); notification_clear (self); indicator_power_notifier_set_battery (self, NULL); @@ -354,6 +362,35 @@ my_finalize (GObject * o G_GNUC_UNUSED) **** Instantiation ***/ +static gboolean +notify_init_idle (gpointer gself) +{ + IndicatorPowerNotifier * self = INDICATOR_POWER_NOTIFIER(gself); + + actions_supported = FALSE; + + if (!notify_init("indicator-power-service")) + { + g_critical("Unable to initialize libnotify! Notifications might not be shown."); + } + else + { + GList * caps; + GList * l; + + /* see if actions are supported */ + caps = notify_get_server_caps(); + for (l=caps; l!=NULL && !actions_supported; l=l->next) + if (!g_strcmp0(l->data, "actions")) + actions_supported = TRUE; + + g_list_free_full(caps, g_free); + } + + get_priv(self)->notify_init_tag = 0; + return G_SOURCE_REMOVE; +} + static void indicator_power_notifier_init (IndicatorPowerNotifier * self) { @@ -367,24 +404,7 @@ indicator_power_notifier_init (IndicatorPowerNotifier * self) if (!instance_count++) { - actions_supported = FALSE; - - if (!notify_init("indicator-power-service")) - { - g_critical("Unable to initialize libnotify! Notifications might not be shown."); - } - else - { - GList * caps; - GList * l; - - /* see if actions are supported */ - caps = notify_get_server_caps(); - for (l=caps; l!=NULL && !actions_supported; l=l->next) - if (!g_strcmp0(l->data, "actions")) - actions_supported = TRUE; - g_list_free_full(caps, g_free); - } + p->notify_init_tag = g_idle_add (notify_init_idle, self); } } |