[PATCH] properly honor "actions" capability as announced by running notification daemon



patch against 0.7.1 rc3

=== modified file 'src/applet.c'
--- a/src/applet.c	2009-02-18 16:48:04 +0000
+++ b/src/applet.c	2009-03-10 13:36:00 +0000
@@ -65,16 +65,17 @@
 #include "applet-device-gsm.h"
 #include "applet-device-cdma.h"
 #include "applet-dialogs.h"
 #include "vpn-password-dialog.h"
 #include "applet-dbus-manager.h"
 #include "utils.h"
 #include "gconf-helpers.h"
 
+#define NOTIFY_CAPS_ACTIONS_KEY "actions"
 
 G_DEFINE_TYPE(NMApplet, nma, G_TYPE_OBJECT)
 
 static NMActiveConnection *
 applet_get_best_activating_connection (NMApplet *applet, NMDevice **device)
 {
 	NMActiveConnection *best = NULL;
 	NMDevice *best_dev = NULL;
@@ -391,17 +392,17 @@ applet_do_notify (NMApplet *applet,
 	notify = notify_notification_new (summary, message,
 	                                  icon ? icon : GTK_STOCK_NETWORK, NULL);
 	applet->notification = notify;
 
 	notify_notification_attach_to_status_icon (notify, applet->status_icon);
 	notify_notification_set_urgency (notify, urgency);
 	notify_notification_set_timeout (notify, NOTIFY_EXPIRES_DEFAULT);
 
-	if (action1) {
+	if (applet->notify_with_actions && action1) {
 		notify_notification_add_action (notify, action1, action1_label,
 		                                action1_cb, action1_user_data, NULL);
 	}
 
 	if (!notify_notification_show (notify, &error)) {
 		g_warning ("Failed to show notification: %s", error->message);
 		g_error_free (error);
 	}
@@ -2472,16 +2473,17 @@ applet_pre_keyring_callback (gpointer us
 
 static GObject *
 constructor (GType type,
              guint n_props,
              GObjectConstructParam *construct_props)
 {
 	NMApplet *applet;
 	AppletDBusManager *dbus_mgr;
+	GList *server_caps;
 
 	applet = NM_APPLET (G_OBJECT_CLASS (nma_parent_class)->constructor (type, n_props, construct_props));
 
 	g_set_application_name (_("NetworkManager Applet"));
 	gtk_window_set_default_icon_name (GTK_STOCK_NETWORK);
 
 	applet->glade_file = g_build_filename (GLADEDIR, "applet.glade", NULL);
 	if (!applet->glade_file || !g_file_test (applet->glade_file, G_FILE_TEST_IS_REGULAR)) {
@@ -2502,16 +2504,25 @@ constructor (GType type,
 	/* Load pixmaps and create applet widgets */
 	if (!setup_widgets (applet))
 		goto error;
 	nma_icons_init (applet);
 
 	if (!notify_is_initted ())
 		notify_init ("NetworkManager");
 
+	server_caps = notify_get_server_caps();
+	if (g_list_find (server_caps, NOTIFY_CAPS_ACTIONS_KEY))
+		applet->notify_with_actions = TRUE;
+	else
+		applet->notify_with_actions = FALSE;
+
+	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.");
 		g_object_unref (applet);
 		return NULL;
 	}
 
 	applet->dbus_settings = (NMDBusSettings *) nm_dbus_settings_system_new (applet_dbus_manager_get_connection (dbus_mgr));

=== modified file 'src/applet.h'
--- a/src/applet.h	2009-02-18 16:29:49 +0000
+++ b/src/applet.h	2009-03-10 13:36:13 +0000
@@ -138,16 +138,17 @@ typedef struct
 	guint           networking_enabled_toggled_id;
 	GtkWidget *		wifi_enabled_item;
 	guint           wifi_enabled_toggled_id;
 	GtkWidget *		info_menu_item;
 	GtkWidget *		connections_menu_item;
 
 	GladeXML *		info_dialog_xml;
 	NotifyNotification*	notification;
+	gboolean		notify_with_actions;
 } NMApplet;
 
 
 struct NMADeviceClass {
 	NMConnection * (*new_auto_connection)  (NMDevice *device,
 	                                        NMApplet *applet,
 	                                        gpointer user_data);
 



 - Alexander



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]