[network-manager-applet] applet: delay notification capabilities checking until needed (bgo #610881)
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] applet: delay notification capabilities checking until needed (bgo #610881)
- Date: Wed, 24 Feb 2010 00:03:51 +0000 (UTC)
commit 3bd98a574204ec33510969abc00cf5f904823761
Author: Martin Pitt <martin pitt ubuntu com>
Date: Tue Feb 23 16:03:05 2010 -0800
applet: delay notification capabilities checking until needed (bgo #610881)
src/applet.c | 38 ++++++++++++++++++++++++++------------
src/applet.h | 1 -
2 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/src/applet.c b/src/applet.c
index 1c9efae..820faaa 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -612,6 +612,31 @@ applet_clear_notify (NMApplet *applet)
applet->notification = NULL;
}
+static gboolean
+applet_notify_server_has_actions ()
+{
+ static gboolean queried = FALSE;
+ static gboolean has_actions = FALSE;
+ GList *server_caps, *iter;
+
+ if (queried)
+ return has_actions;
+
+ server_caps = notify_get_server_caps();
+ for (iter = server_caps; iter; iter = g_list_next (iter)) {
+ if (!strcmp ((const char *) iter->data, NOTIFY_CAPS_ACTIONS_KEY)) {
+ has_actions = TRUE;
+ break;
+ }
+ }
+
+ g_list_foreach (server_caps, (GFunc) g_free, NULL);
+ g_list_free (server_caps);
+ queried = TRUE;
+
+ return has_actions;
+}
+
void
applet_do_notify (NMApplet *applet,
NotifyUrgency urgency,
@@ -648,7 +673,7 @@ applet_do_notify (NMApplet *applet,
notify_notification_set_urgency (notify, urgency);
notify_notification_set_timeout (notify, NOTIFY_EXPIRES_DEFAULT);
- if (applet->notify_with_actions && action1) {
+ if (applet_notify_server_has_actions () && action1) {
notify_notification_add_action (notify, action1, action1_label,
action1_cb, action1_user_data, NULL);
}
@@ -2925,7 +2950,6 @@ constructor (GType type,
{
NMApplet *applet;
AppletDBusManager *dbus_mgr;
- GList *server_caps, *iter;
applet = NM_APPLET (G_OBJECT_CLASS (nma_parent_class)->constructor (type, n_props, construct_props));
@@ -2956,16 +2980,6 @@ constructor (GType type,
if (!notify_is_initted ())
notify_init ("NetworkManager");
- server_caps = notify_get_server_caps();
- applet->notify_with_actions = FALSE;
- for (iter = server_caps; iter; iter = g_list_next (iter)) {
- if (!strcmp ((const char *) iter->data, NOTIFY_CAPS_ACTIONS_KEY))
- applet->notify_with_actions = TRUE;
- }
-
- g_list_foreach (server_caps, (GFunc) g_free, NULL);
- g_list_free (server_caps);
-
dbus_mgr = applet_dbus_manager_get ();
if (dbus_mgr == NULL) {
nm_warning ("Couldn't initialize the D-Bus manager.");
diff --git a/src/applet.h b/src/applet.h
index 10377cb..f24250e 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -152,7 +152,6 @@ typedef struct
GladeXML * info_dialog_xml;
NotifyNotification* notification;
- gboolean notify_with_actions;
} NMApplet;
typedef void (*AppletNewAutoConnectionCallback) (NMConnection *connection,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]