diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2014-10-14 20:58:28 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2014-10-14 20:58:28 -0500 |
commit | ee53f5d18009dba3cf69ddb2e2135ae2197c43b2 (patch) | |
tree | 30fae10e06f643d665a9ff88e9f47f3da63faf45 /src | |
parent | 5f316dca4eab9f3b3048af82c680087949dc7d1f (diff) | |
download | ayatana-indicator-power-ee53f5d18009dba3cf69ddb2e2135ae2197c43b2.tar.gz ayatana-indicator-power-ee53f5d18009dba3cf69ddb2e2135ae2197c43b2.tar.bz2 ayatana-indicator-power-ee53f5d18009dba3cf69ddb2e2135ae2197c43b2.zip |
r273 tried to fix the blocking bug listed at http://paste.ubuntu.com/8562226/, but in the process introduced a new bug that manifested in RTM. This removes r273 and uses a different fix.
Diffstat (limited to 'src')
-rw-r--r-- | src/notifier.c | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/src/notifier.c b/src/notifier.c index b0fce15..4888610 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -55,8 +55,6 @@ static GParamSpec * properties[LAST_PROP]; static int instance_count = 0; -static gboolean actions_supported = FALSE; - /** *** **/ @@ -77,7 +75,8 @@ typedef struct GDBusConnection * bus; DbusBattery * dbus_battery; /* com.canonical.indicator.power.Battery skeleton */ - guint notify_init_tag; + gboolean caps_queried; + gboolean actions_supported; } IndicatorPowerNotifierPrivate; @@ -184,6 +183,33 @@ on_dismiss_clicked(NotifyNotification * nn G_GNUC_UNUSED, /* no-op; libnotify warns if we have a NULL action callback */ } +static gboolean +are_actions_supported(IndicatorPowerNotifier * self) +{ + priv_t * const p = get_priv(self); + + if (!p->caps_queried) + { + gboolean actions_supported; + GList * caps; + GList * l; + + /* see if actions are supported */ + actions_supported = FALSE; + caps = notify_get_server_caps(); + for (l=caps; l!=NULL && !actions_supported; l=l->next) + if (!g_strcmp0(l->data, "actions")) + actions_supported = TRUE; + + p->actions_supported = actions_supported; + p->caps_queried = TRUE; + + g_list_free_full(caps, g_free); + } + + return p->actions_supported; +} + static void notification_show(IndicatorPowerNotifier * self) { @@ -216,7 +242,7 @@ notification_show(IndicatorPowerNotifier * self) g_strfreev (icon_names); g_free (body); - if (actions_supported) + if (are_actions_supported(self)) { notify_notification_set_hint(nn, "x-canonical-snap-decisions", g_variant_new_string("true")); notify_notification_set_hint(nn, "x-canonical-non-shaped-icon", g_variant_new_string("true")); @@ -334,12 +360,6 @@ 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); @@ -362,34 +382,6 @@ 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) @@ -402,10 +394,8 @@ indicator_power_notifier_init (IndicatorPowerNotifier * self) p->power_level = POWER_LEVEL_OK; - if (!instance_count++) - { - p->notify_init_tag = g_idle_add (notify_init_idle, self); - } + if (!instance_count++ && !notify_init("indicator-power-service")) + g_critical("Unable to initialize libnotify! Notifications might not be shown."); } static void |