[network-manager-applet/NETWORKMANAGER_APPLET_0_7] applet: add GConf key to allow disabling "Create new wireless network..."



commit b77c7cf79470af123c5039c4864b34da814bd956
Author: Dan Williams <dcbw redhat com>
Date:   Fri Nov 6 17:02:38 2009 -0800

    applet: add GConf key to allow disabling "Create new wireless network..."
    
    Sysadmins can now set a GConf mandatory key with value of "FALSE" to
    disable the "Create new wireless network" menu item.

 nm-applet.schemas.in     |   13 +++++++++++++
 src/applet-device-wifi.c |   10 ++++++++++
 src/applet.h             |    5 +++--
 3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/nm-applet.schemas.in b/nm-applet.schemas.in
index 75930e1..844ed29 100644
--- a/nm-applet.schemas.in
+++ b/nm-applet.schemas.in
@@ -57,6 +57,19 @@
         </long>
       </locale>
     </schema>
+    <schema>
+      <key>/schemas/apps/nm-applet/disable-wifi-create</key>
+      <applyto>/apps/nm-applet/disable-wifi-create</applyto>
+      <owner>nm-applet</owner>
+      <type>bool</type>
+      <default>FALSE</default>
+      <locale name="C">
+        <short>Disable WiFi Create</short>
+        <long>
+          Set to TRUE to disable creation of adhoc networks when using the applet.
+        </long>
+      </locale>
+    </schema>
 
   </schemalist>
 </gconfschemafile>
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index fb62f61..141b524 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -117,6 +117,8 @@ nma_menu_add_create_network_item (GtkWidget *menu, NMApplet *applet)
 {
 	GtkWidget *menu_item;
 	GtkWidget *label;
+	GError *error = NULL;
+	gboolean disabled;
 
 	menu_item = gtk_menu_item_new ();
 	label = gtk_label_new_with_mnemonic (_("Create _New Wireless Network..."));
@@ -125,6 +127,14 @@ nma_menu_add_create_network_item (GtkWidget *menu, NMApplet *applet)
 	gtk_widget_show_all (menu_item);
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
 	g_signal_connect (menu_item, "activate", G_CALLBACK (new_network_activate_cb), applet);
+
+	/* FIXME: should really use PolicyKit and NM permissions here instead
+	 * using using GConf mandatory settings.  But this works for now.
+	 */
+	disabled = gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_WIFI_CREATE, &error);
+	if (error || disabled)
+		gtk_widget_set_sensitive (GTK_WIDGET (menu_item), FALSE);
+	g_clear_error (&error);
 }
 
 
diff --git a/src/applet.h b/src/applet.h
index acacc2e..a0f9bc9 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -63,8 +63,9 @@ 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_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 ICON_LAYER_LINK 0
 #define ICON_LAYER_VPN 1



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