network-manager-applet r655 - in trunk: . src



Author: dcbw
Date: Tue Apr  8 16:02:29 2008
New Revision: 655
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=655&view=rev

Log:
2008-04-08  Dan Williams  <dcbw redhat com>

	* src/applet-device-gsm.c
	  src/applet-device-wireless.c
	  src/applet-device-cdma.c
	  src/applet-device-wired.c
		- Handle unmanaged devices and wireless-disabled better



Modified:
   trunk/ChangeLog
   trunk/src/applet-device-cdma.c
   trunk/src/applet-device-gsm.c
   trunk/src/applet-device-wired.c
   trunk/src/applet-device-wireless.c

Modified: trunk/src/applet-device-cdma.c
==============================================================================
--- trunk/src/applet-device-cdma.c	(original)
+++ trunk/src/applet-device-cdma.c	Tue Apr  8 16:02:29 2008
@@ -186,11 +186,11 @@
 	CdmaMenuItemInfo *info;
 
 	state = nm_device_get_state (device);
-	if (!(state == NM_DEVICE_STATE_ACTIVATED || /* activated */
-	      state == NM_DEVICE_STATE_PREPARE ||   /* or activating */
-	      state == NM_DEVICE_STATE_CONFIG ||
-	      state == NM_DEVICE_STATE_NEED_AUTH ||
-	      state == NM_DEVICE_STATE_IP_CONFIG))
+	if (   state == NM_DEVICE_STATE_UNKNOWN
+	    || state == NM_DEVICE_STATE_UNMANAGED
+	    || state == NM_DEVICE_STATE_UNAVAILABLE
+	    || state == NM_DEVICE_STATE_DISCONNECTED
+	    || state == NM_DEVICE_STATE_FAILED)
 		return;
 
 	item = gtk_menu_item_new_with_label (_("Disconnect..."));
@@ -246,8 +246,6 @@
 	item = gtk_menu_item_new_with_label (text);
 	g_free (text);
 
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
 	label = gtk_bin_get_child (GTK_BIN (item));
 	bold_text = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
 	                                     gtk_label_get_text (GTK_LABEL (label)));
@@ -255,6 +253,17 @@
 	g_free (bold_text);
 
 	gtk_widget_set_sensitive (item, FALSE);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+	gtk_widget_show (item);
+
+	/* Notify user of unmanaged device */
+	if (!nm_device_get_managed (device)) {
+		item = gtk_menu_item_new_with_label (_("device is unmanaged"));
+		gtk_widget_set_sensitive (item, FALSE);
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+		gtk_widget_show (item);
+		goto out;
+	}
 
 	if (g_slist_length (connections))
 		add_connection_items (device, connections, active, menu, applet);
@@ -262,7 +271,7 @@
 		add_default_connection_item (device, menu, applet);
 	add_disconnect_item (device, menu, applet);
 
-	gtk_widget_show (item);
+out:
 	g_slist_free (connections);
 }
 

Modified: trunk/src/applet-device-gsm.c
==============================================================================
--- trunk/src/applet-device-gsm.c	(original)
+++ trunk/src/applet-device-gsm.c	Tue Apr  8 16:02:29 2008
@@ -187,11 +187,11 @@
 	GSMMenuItemInfo *info;
 
 	state = nm_device_get_state (device);
-	if (!(state == NM_DEVICE_STATE_ACTIVATED || /* activated */
-	      state == NM_DEVICE_STATE_PREPARE ||   /* or activating */
-	      state == NM_DEVICE_STATE_CONFIG ||
-	      state == NM_DEVICE_STATE_NEED_AUTH ||
-	      state == NM_DEVICE_STATE_IP_CONFIG))
+	if (   state == NM_DEVICE_STATE_UNKNOWN
+	    || state == NM_DEVICE_STATE_UNMANAGED
+	    || state == NM_DEVICE_STATE_UNAVAILABLE
+	    || state == NM_DEVICE_STATE_DISCONNECTED
+	    || state == NM_DEVICE_STATE_FAILED)
 		return;
 
 	item = gtk_menu_item_new_with_label (_("Disconnect..."));
@@ -247,8 +247,6 @@
 	item = gtk_menu_item_new_with_label (text);
 	g_free (text);
 
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
 	label = gtk_bin_get_child (GTK_BIN (item));
 	bold_text = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
 	                                     gtk_label_get_text (GTK_LABEL (label)));
@@ -256,6 +254,17 @@
 	g_free (bold_text);
 
 	gtk_widget_set_sensitive (item, FALSE);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+	gtk_widget_show (item);
+
+	/* Notify user of unmanaged device */
+	if (!nm_device_get_managed (device)) {
+		item = gtk_menu_item_new_with_label (_("device is unmanaged"));
+		gtk_widget_set_sensitive (item, FALSE);
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+		gtk_widget_show (item);
+		goto out;
+	}
 
 	if (g_slist_length (connections))
 		add_connection_items (device, connections, active, menu, applet);
@@ -263,7 +272,7 @@
 		add_default_connection_item (device, menu, applet);
 	add_disconnect_item (device, menu, applet);
 
-	gtk_widget_show (item);
+out:
 	g_slist_free (connections);
 }
 

Modified: trunk/src/applet-device-wired.c
==============================================================================
--- trunk/src/applet-device-wired.c	(original)
+++ trunk/src/applet-device-wired.c	Tue Apr  8 16:02:29 2008
@@ -201,8 +201,6 @@
 	item = gtk_menu_item_new_with_label (text);
 	g_free (text);
 
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
 	/* Only dim the item if the device supports carrier detection AND
 	 * we know it doesn't have a link.
 	 */
@@ -215,13 +213,25 @@
 	gtk_label_set_markup (GTK_LABEL (label), bold_text);
 	g_free (bold_text);
 
+	gtk_widget_set_sensitive (item, FALSE);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+	gtk_widget_show (item);
+
+	/* Notify user of unmanaged device */
+	if (!nm_device_get_managed (device)) {
+		item = gtk_menu_item_new_with_label (_("device is unmanaged"));
+		gtk_widget_set_sensitive (item, FALSE);
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+		gtk_widget_show (item);
+		goto out;
+	}
+
 	if (g_slist_length (connections))
 		add_connection_items (device, connections, carrier, active, menu, applet);
 	else
 		add_default_connection_item (device, carrier, menu, applet);
 
-	gtk_widget_set_sensitive (item, FALSE);
-	gtk_widget_show (item);
+out:
 	g_slist_free (connections);
 }
 

Modified: trunk/src/applet-device-wireless.c
==============================================================================
--- trunk/src/applet-device-wireless.c	(original)
+++ trunk/src/applet-device-wireless.c	Tue Apr  8 16:02:29 2008
@@ -678,8 +678,22 @@
 	gtk_widget_show (item);
 
 	/* Don't display APs when wireless is disabled */
-	if (!nm_client_wireless_get_enabled (applet->nm_client))
+	if (!nm_client_wireless_get_enabled (applet->nm_client)) {
+		item = gtk_menu_item_new_with_label (_("wireless is disabled"));
+		gtk_widget_set_sensitive (item, FALSE);
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+		gtk_widget_show (item);
 		goto out;
+	}
+
+	/* Notify user of unmanaged device */
+	if (!nm_device_get_managed (device)) {
+		item = gtk_menu_item_new_with_label (_("device is unmanaged"));
+		gtk_widget_set_sensitive (item, FALSE);
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+		gtk_widget_show (item);
+		goto out;
+	}
 
 	active_ap = nm_device_802_11_wireless_get_active_access_point (wdev);
 



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