[PATCH] Disabling/enabling notifications in NM 0.7.2 - still W-I-P



The patch attached below is a patch I've been working on for the last
couple of hours. It's still work in progress though. I should finish
this by this time tomorrow but I'd like some feedback...

This patch allows the user to disable or enable the connected /
disconnected notification dialogs when required. 

Cheers,
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-11-25 22:03:27.766816057 +0000
@@ -1538,6 +1538,12 @@
 }
 
 static void
+nma_preferences_cb (NMApplet *applet)
+{
+	applet_preferences_dialog_show (applet);
+}
+
+static void
 applet_connection_info_cb (NMApplet *applet)
 {
 	applet_info_dialog_show (applet);
@@ -1600,6 +1606,16 @@
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (applet->connections_menu_item), image);
 	gtk_menu_shell_append (menu, applet->connections_menu_item);
 
+	/* Preferences */
+	applet->preferences_menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
+	g_signal_connect(applet->preferences_menu_item, 
+				"activate", 
+				G_CALLBACK (nma_preferences_cb), 
+				applet);
+	image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (applet->preferences_menu_item), image);
+	gtk_menu_shell_append (menu, applet->preferences_menu_item);
+
 	/* Separator */
 	nma_menu_add_separator_item (GTK_WIDGET (menu));
 
diff -uNr network-manager-applet-0.7.2.orig/src/applet-dialogs.c network-manager-applet-0.7.2/src/applet-dialogs.c
--- network-manager-applet-0.7.2.orig/src/applet-dialogs.c	2009-11-23 19:27:58.000000000 +0000
+++ network-manager-applet-0.7.2/src/applet-dialogs.c	2009-11-25 23:24:17.703875264 +0000
@@ -563,6 +563,52 @@
 }
 
 void
+applet_preferences_dialog_show (NMApplet *applet)
+{
+	GtkWidget *dialog;
+	GtkWidget *prefs_enable_connection, *prefs_disable_connection;
+	GtkWidget *close_button;
+
+	gboolean enable_connection, disable_connection;
+
+	const int num_buttons = 3;
+	gchar *button_types[] = { GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_CANCEL };
+	GtkWidget *button_table, *button_box, *buttons[num_buttons];
+	int i;
+
+	enable_connection = gconf_client_get_bool(applet->gconf_client, PREF_DISABLE_CONNECTED_NOTIFICATIONS, NULL);
+	disable_connection = gconf_client_get_bool(applet->gconf_client, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS, NULL);
+
+	dialog = gtk_dialog_new();
+
+	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
+	gtk_window_set_title(GTK_WINDOW(dialog), _("Preferences"));
+
+	prefs_enable_connection = gtk_check_button_new_with_label("Display Connection Dialogs");
+	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), prefs_enable_connection, TRUE, TRUE, 5);
+
+	prefs_disable_connection = gtk_check_button_new_with_label("Display Disconnection Dialogs");
+	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), prefs_disable_connection, TRUE, TRUE, 5);
+
+	button_table = gtk_table_new(1, num_buttons, TRUE);
+	button_box = gtk_hbox_new(FALSE, 1);
+	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), button_box, TRUE, TRUE, 0);
+	gtk_container_add(GTK_CONTAINER(button_box), button_table);
+
+	for (i = 0; i < num_buttons; i++)
+	{
+		buttons[i] = gtk_button_new_from_stock(button_types[i]);
+		g_signal_connect_swapped(G_OBJECT(buttons[i]), "clicked", G_CALLBACK(gtk_widget_destroy), G_OBJECT(dialog));
+		gtk_table_attach_defaults(GTK_TABLE(button_table), buttons[i], i, i + 1, 0, 1);
+	}
+
+	gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
+	gtk_widget_show(dialog);
+	
+	g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
+}
+
+void
 applet_about_dialog_show (NMApplet *applet)
 {
 	static const gchar *authors[] = {
diff -uNr network-manager-applet-0.7.2.orig/src/applet-dialogs.h network-manager-applet-0.7.2/src/applet-dialogs.h
--- network-manager-applet-0.7.2.orig/src/applet-dialogs.h	2009-10-22 00:22:24.000000000 +0100
+++ network-manager-applet-0.7.2/src/applet-dialogs.h	2009-11-25 21:19:52.529492781 +0000
@@ -29,6 +29,8 @@
 
 void applet_info_dialog_show (NMApplet *applet);
 
+void applet_preferences_dialog_show (NMApplet *applet);
+
 void applet_about_dialog_show (NMApplet *applet);
 
 GtkWidget *applet_warning_dialog_show (const char *message);
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-25 21:56:29.911929321 +0000
@@ -141,6 +141,7 @@
 	guint           wifi_enabled_toggled_id;
 	GtkWidget *		info_menu_item;
 	GtkWidget *		connections_menu_item;
+	GtkWidget *	preferences_menu_item;
 
 	GladeXML *		info_dialog_xml;
 	NotifyNotification*	notification;


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