[PATCH] v3 Disabling/enabling notifications in NM 0.7.2



> Sure, I can roll v3 of my patch with these new changes, I'll have it
> sorted over the weekend. 

OK, here's v3 of my patch for the notifications, it's been cut down
considerably. Thanks, it works quite nicely!

Regards,
Alex
-- 
http://www.munted.org.uk

One very high maintenance cat living here.
diff -uNr network-manager-applet-0.7.2.orig/src/applet.c network-manager-applet-0.7.2/src/applet.c
--- network-manager-applet-0.7.2.orig/src/applet.c	2009-11-23 19:27:58.000000000 +0000
+++ network-manager-applet-0.7.2/src/applet.c	2009-12-05 13:23:02.941969584 +0000
@@ -479,6 +479,12 @@
 	    && strcmp (id, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS))
 		return;
 
+	if ((strcmp (id, PREF_DISABLE_CONNECTED_NOTIFICATIONS) == 0)
+	    || (strcmp (id, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS) == 0))
+		gtk_check_menu_item_set_active( 
+			GTK_CHECK_MENU_ITEM(
+				applet->notifications_enabled_item), FALSE);
+
 	gconf_client_set_bool (applet->gconf_client, id, TRUE, NULL);
 }
 
@@ -1352,6 +1358,22 @@
 	nm_client_sleep (applet->nm_client, !state);
 }
 
+
+static void 
+nma_set_notifications_enabled_cb (GtkWidget *widget, NMApplet *applet)
+{
+	gboolean state;
+
+	g_return_if_fail (applet != NULL);
+
+	state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
+
+	gconf_client_set_bool(applet->gconf_client, 
+		PREF_DISABLE_CONNECTED_NOTIFICATIONS, !state, NULL);
+	gconf_client_set_bool(applet->gconf_client,
+		PREF_DISABLE_DISCONNECTED_NOTIFICATIONS, !state, NULL);
+}
+
 /*
  * nma_menu_show_cb
  *
@@ -1580,6 +1602,20 @@
 
 	nma_menu_add_separator_item (GTK_WIDGET (menu));
 
+	/* Toggle connection notifications item */
+	applet->notifications_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable connection notifications"));
+	if (!gconf_client_get_bool(applet->gconf_client, PREF_DISABLE_CONNECTED_NOTIFICATIONS, NULL))
+		gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM (applet->notifications_enabled_item), TRUE);
+
+	id = g_signal_connect (applet->notifications_enabled_item,
+		"toggled",
+		G_CALLBACK (nma_set_notifications_enabled_cb),
+		applet);
+	applet->notifications_toggled_id = id;
+	gtk_menu_shell_append (menu, applet->notifications_enabled_item);
+
+	nma_menu_add_separator_item (GTK_WIDGET (menu));
+
 	/* 'Connection Information' item */
 	applet->info_menu_item = gtk_image_menu_item_new_with_mnemonic (_("Connection _Information"));
 	g_signal_connect_swapped (applet->info_menu_item,
diff -uNr network-manager-applet-0.7.2.orig/src/applet.h network-manager-applet-0.7.2/src/applet.h
--- network-manager-applet-0.7.2.orig/src/applet.h	2009-11-23 19:27:58.000000000 +0000
+++ network-manager-applet-0.7.2/src/applet.h	2009-12-05 13:18:23.912011524 +0000
@@ -139,6 +139,10 @@
 	guint           networking_enabled_toggled_id;
 	GtkWidget *		wifi_enabled_item;
 	guint           wifi_enabled_toggled_id;
+
+	GtkWidget	*notifications_enabled_item;
+	guint		notifications_toggled_id;
+
 	GtkWidget *		info_menu_item;
 	GtkWidget *		connections_menu_item;
 


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