[PATCH] Disabling/enabling notifications in NM 0.7.2] (resend)



-------- Forwarded Message --------
> From: Alex Buell <alex buell munted org uk>
> Reply-to: alex buell munted org uk
> To: Dan Williams <dcbw redhat com>
> Cc: networkmanager-list gnome org
> Subject: [PATCH] Disabling/enabling notifications in NM 0.7.2
> Date: Thu, 26 Nov 2009 18:49:01 +0000
> 
> Here is version 2 of the patch, changes include moving from the old
> preferences dialog to the right click menu, which I agree is a far
> better option. It's all complete now, thanks for your kind attention. 
> 
> I enjoyed myself hacking upon NetworkManager 0.7.2, hopefully I may do
> some more hacking in the future!
> 
> Patch is attached.
> 
> Regards,
> Alex
> _______________________________________________
> NetworkManager-list mailing list
> NetworkManager-list gnome org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list
-- 
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-11-26 18:40:24.058464897 +0000
@@ -479,6 +479,16 @@
 	    && strcmp (id, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS))
 		return;
 
+	if (strcmp (id, PREF_DISABLE_CONNECTED_NOTIFICATIONS) == 0)
+		gtk_check_menu_item_set_active( 
+			GTK_CHECK_MENU_ITEM(
+				applet->connected_notification_enabled_item), FALSE);
+
+	if (strcmp (id, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS) == 0)
+		gtk_check_menu_item_set_active( 
+			GTK_CHECK_MENU_ITEM(
+				applet->disconnected_notification_enabled_item), FALSE);
+
 	gconf_client_set_bool (applet->gconf_client, id, TRUE, NULL);
 }
 
@@ -1352,6 +1362,32 @@
 	nm_client_sleep (applet->nm_client, !state);
 }
 
+
+static void 
+nma_set_connected_notification_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);
+}
+
+static void 
+nma_set_disconnected_notification_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_DISCONNECTED_NOTIFICATIONS, !state, NULL);
+}
+
+
 /*
  * nma_menu_show_cb
  *
@@ -1580,6 +1616,32 @@
 
 	nma_menu_add_separator_item (GTK_WIDGET (menu));
 
+	/* Toggle connection notifications item */
+	applet->connected_notification_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->connected_notification_enabled_item), TRUE);
+
+	id = g_signal_connect (applet->connected_notification_enabled_item,
+		"toggled",
+		G_CALLBACK (nma_set_connected_notification_enabled_cb),
+		applet);
+	applet->connected_notification_toggled_id = id;
+	gtk_menu_shell_append (menu, applet->connected_notification_enabled_item);
+
+	/* Toggle disconnection notifications item */
+	applet->disconnected_notification_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable disconnection notifications"));
+	if (!gconf_client_get_bool(applet->gconf_client, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS, NULL))
+		gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM (applet->disconnected_notification_enabled_item), TRUE);
+
+	id = g_signal_connect (applet->disconnected_notification_enabled_item,
+			"toggled",
+			G_CALLBACK (nma_set_disconnected_notification_enabled_cb),
+			applet);
+	applet->disconnected_notification_toggled_id = id;
+	gtk_menu_shell_append (menu, applet->disconnected_notification_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-11-26 17:41:22.596092541 +0000
@@ -139,6 +139,13 @@
 	guint           networking_enabled_toggled_id;
 	GtkWidget *		wifi_enabled_item;
 	guint           wifi_enabled_toggled_id;
+
+	GtkWidget	*connected_notification_enabled_item;
+	guint		connected_notification_toggled_id;
+
+	GtkWidget	*disconnected_notification_enabled_item;
+	guint		disconnected_notification_toggled_id;
+
 	GtkWidget *		info_menu_item;
 	GtkWidget *		connections_menu_item;
 


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