[network-manager-applet] applet: add "Disable Notifications" option to right-click menu
- From: Dan Williams <dcbw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-applet] applet: add "Disable Notifications" option to right-click menu
- Date: Mon, 7 Dec 2009 21:36:55 +0000 (UTC)
commit dd2649d74f3e7781a6aa31cea9929dbd7453f8b5
Author: Alex Buell <alex buell munted org uk>
Date: Mon Dec 7 13:33:49 2009 -0800
applet: add "Disable Notifications" option to right-click menu
(with a few cleanups and fixes by dcbw to better match the how the
applet constructs the right-click menu)
src/applet-device-wifi.c | 6 +---
src/applet.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
src/applet.h | 11 +++++++--
3 files changed, 57 insertions(+), 7 deletions(-)
---
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 40c7804..4105652 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -47,8 +47,6 @@
#include "utils.h"
#include "wireless-dialog.h"
-#define PREF_SUPPRESS_WIRELESS_NEWORKS_AVAILABLE APPLET_PREFS_PATH "/suppress-wireless-networks-available"
-
#define ACTIVE_AP_TAG "active-ap"
static void wireless_dialog_response_cb (GtkDialog *dialog, gint response, gpointer user_data);
@@ -924,7 +922,7 @@ wifi_available_dont_show_cb (NotifyNotification *notify,
return;
gconf_client_set_bool (applet->gconf_client,
- PREF_SUPPRESS_WIRELESS_NEWORKS_AVAILABLE,
+ PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE,
TRUE,
NULL);
}
@@ -1027,7 +1025,7 @@ queue_avail_access_point_notification (NMDevice *device)
return;
if (gconf_client_get_bool (data->applet->gconf_client,
- PREF_SUPPRESS_WIRELESS_NEWORKS_AVAILABLE,
+ PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE,
NULL))
return;
diff --git a/src/applet.c b/src/applet.c
index 6ad6a8f..c401702 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -1628,6 +1628,30 @@ nma_set_networking_enabled_cb (GtkWidget *widget, NMApplet *applet)
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);
+ gconf_client_set_bool (applet->gconf_client,
+ PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE,
+ !state,
+ NULL);
+}
+
/*
* nma_menu_show_cb
*
@@ -1739,6 +1763,7 @@ nma_context_menu_update (NMApplet *applet)
NMState state;
gboolean have_wireless = FALSE;
gboolean wireless_hw_enabled;
+ gboolean notifications_enabled = TRUE;
state = nm_client_get_state (applet->nm_client);
@@ -1768,6 +1793,17 @@ nma_context_menu_update (NMApplet *applet)
gtk_widget_set_sensitive (GTK_WIDGET (applet->wifi_enabled_item),
wireless_hw_enabled);
+ /* Enabled notifications */
+ g_signal_handler_block (G_OBJECT (applet->notifications_enabled_item),
+ applet->notifications_enabled_toggled_id);
+ if ( gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_CONNECTED_NOTIFICATIONS, NULL)
+ && gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS, NULL)
+ && gconf_client_get_bool (applet->gconf_client, PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE, NULL))
+ notifications_enabled = FALSE;
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->notifications_enabled_item), notifications_enabled);
+ g_signal_handler_unblock (G_OBJECT (applet->notifications_enabled_item),
+ applet->notifications_enabled_toggled_id);
+
/* Don't show wifi-specific stuff if wireless is off */
if (state != NM_STATE_ASLEEP) {
const GPtrArray *devices;
@@ -1856,6 +1892,17 @@ static GtkWidget *nma_context_menu_create (NMApplet *applet)
nma_menu_add_separator_item (GTK_WIDGET (menu));
+ /* Toggle notifications item */
+ applet->notifications_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable N_otifications"));
+ id = g_signal_connect (applet->notifications_enabled_item,
+ "toggled",
+ G_CALLBACK (nma_set_notifications_enabled_cb),
+ applet);
+ applet->notifications_enabled_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 --git a/src/applet.h b/src/applet.h
index 208d68c..9930810 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -63,9 +63,10 @@ typedef struct
} NMAppletClass;
#define APPLET_PREFS_PATH "/apps/nm-applet"
-#define PREF_DISABLE_CONNECTED_NOTIFICATIONS APPLET_PREFS_PATH "/disable-connected-notifications"
-#define PREF_DISABLE_DISCONNECTED_NOTIFICATIONS APPLET_PREFS_PATH "/disable-disconnected-notifications"
-#define PREF_DISABLE_WIFI_CREATE APPLET_PREFS_PATH "/disable-wifi-create"
+#define PREF_DISABLE_CONNECTED_NOTIFICATIONS APPLET_PREFS_PATH "/disable-connected-notifications"
+#define PREF_DISABLE_DISCONNECTED_NOTIFICATIONS APPLET_PREFS_PATH "/disable-disconnected-notifications"
+#define PREF_DISABLE_WIFI_CREATE APPLET_PREFS_PATH "/disable-wifi-create"
+#define PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE APPLET_PREFS_PATH "/suppress-wireless-networks-available"
#define ICON_LAYER_LINK 0
#define ICON_LAYER_VPN 1
@@ -140,6 +141,10 @@ typedef struct
guint networking_enabled_toggled_id;
GtkWidget * wifi_enabled_item;
guint wifi_enabled_toggled_id;
+
+ GtkWidget * notifications_enabled_item;
+ guint notifications_enabled_toggled_id;
+
GtkWidget * info_menu_item;
GtkWidget * connections_menu_item;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]