[network-manager-applet] wimax: fix active connection menu item boldness



commit c1d73aced946f5ca791c402708c050be060e7160
Author: Dan Williams <dcbw redhat com>
Date:   Tue Mar 15 12:11:46 2011 -0500

    wimax: fix active connection menu item boldness
    
    The active WiMAX network provider name should be bold, but it
    wasn't.
    
    This was due to a limitation in the mobile broadband menu item,
    which only accounted for GSM/CDMA usage of the active item.  For
    GSM/CDMA, the "active item" (ie the item just underneath the
    device header) displays either the active connection, or if not
    connected, the registered network name and signal strength.  If
    not connected, the item insensitive because you need to pick a
    specific connection/APN to activate.
    
    With WiMAX, we can scan and get signal strength, so instead of
    showing connections in the menu, we show actual NSPs (ie, WiMAX
    Network Service Providers) determined from a scan.  We don't
    have any registration nonsense because the WiMAX device doesn't
    register with a network until it's told to do so, which happens
    when the user picks a network to connect to.  But due to the
    GSM/CDMA stuff above, the active item if connected wouldn't be
    bold.

 src/applet-device-cdma.c  |    5 ++++-
 src/applet-device-gsm.c   |    6 +++++-
 src/applet-device-wimax.c |    7 +++++--
 src/mb-menu-item.c        |   20 ++++++--------------
 src/mb-menu-item.h        |    1 +
 5 files changed, 21 insertions(+), 18 deletions(-)
---
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index 0e3f81c..7e7f033 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -301,11 +301,12 @@ cdma_add_menu_item (NMDevice *device,
 		item = nm_mb_menu_item_new (nm_setting_connection_get_id (s_con),
 		                            info->quality_valid ? info->quality : 0,
 		                            info->provider_name,
+		                            TRUE,
 		                            cdma_act_to_mb_act (info),
 		                            cdma_state_to_mb_state (info),
 		                            info->modem_enabled,
 		                            applet);
-
+		gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
 		add_connection_item (device, active, item, menu, applet);
 	}
 
@@ -321,10 +322,12 @@ cdma_add_menu_item (NMDevice *device,
 		item = nm_mb_menu_item_new (NULL,
 		                            info->quality_valid ? info->quality : 0,
 		                            info->provider_name,
+		                            FALSE,
 		                            cdma_act_to_mb_act (info),
 		                            cdma_state_to_mb_state (info),
 		                            info->modem_enabled,
 		                            applet);
+		gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 60aca0b..94ceb1c 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -345,11 +345,12 @@ gsm_add_menu_item (NMDevice *device,
 		item = nm_mb_menu_item_new (nm_setting_connection_get_id (s_con),
 		                            info->quality_valid ? info->quality : 0,
 		                            info->op_name,
+		                            TRUE,
 		                            gsm_act_to_mb_act (info),
 		                            gsm_state_to_mb_state (info),
 		                            info->modem_enabled,
 		                            applet);
-
+		gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
 		add_connection_item (device, active, item, menu, applet);
 	}
 
@@ -361,13 +362,16 @@ gsm_add_menu_item (NMDevice *device,
 			gtk_widget_show (item);
 		}
 	} else {
+		/* Otherwise show idle registration state or disabled */
 		item = nm_mb_menu_item_new (NULL,
 		                            info->quality_valid ? info->quality : 0,
 		                            info->op_name,
+		                            FALSE,
 		                            gsm_act_to_mb_act (info),
 		                            gsm_state_to_mb_state (info),
 		                            info->modem_enabled,
 		                            applet);
+		gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 
diff --git a/src/applet-device-wimax.c b/src/applet-device-wimax.c
index f10d1ec..5a4a6c2 100644
--- a/src/applet-device-wimax.c
+++ b/src/applet-device-wimax.c
@@ -135,6 +135,7 @@ nsp_type_to_mb_state (NMWimaxNspNetworkType nsp_type)
 static GtkWidget *
 new_nsp_menu_item (NMDeviceWimax *device,
                    NMConnection *connection,
+                   gboolean active,
                    NMWimaxNsp *nsp,
                    NMApplet *applet)
 {
@@ -146,10 +147,12 @@ new_nsp_menu_item (NMDeviceWimax *device,
 	item = nm_mb_menu_item_new (nm_wimax_nsp_get_name (nsp),
 		                        nm_wimax_nsp_get_signal_quality (nsp),
 		                        NULL,
+		                        active,
 		                        MB_TECH_WIMAX,
 		                        nsp_type_to_mb_state (nm_wimax_nsp_get_network_type (nsp)),
 		                        TRUE,
 		                        applet);
+	gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
 
 	info = g_slice_new0 (WimaxMenuItemInfo);
 	info->applet = applet;
@@ -240,7 +243,7 @@ wimax_add_menu_item (NMDevice *device,
 	if (!nma_menu_device_check_unusable (device)) {
 		active_nsp = nm_device_wimax_get_active_nsp (wimax);
 		if (active_nsp) {
-			item = new_nsp_menu_item (wimax, active, active_nsp, applet);
+			item = new_nsp_menu_item (wimax, active, TRUE, active_nsp, applet);
 			if (item) {
 				gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 				gtk_widget_show (item);
@@ -285,7 +288,7 @@ wimax_add_menu_item (NMDevice *device,
 			NMConnection *connection = NULL;
 
 			connection = get_connection_for_nsp (connections, nsp);
-			item = new_nsp_menu_item (wimax, connection, nsp, applet);
+			item = new_nsp_menu_item (wimax, connection, FALSE, nsp, applet);
 			if (item) {
 				gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 				gtk_widget_show (item);
diff --git a/src/mb-menu-item.c b/src/mb-menu-item.c
index a470d2b..eaf2e40 100644
--- a/src/mb-menu-item.c
+++ b/src/mb-menu-item.c
@@ -81,6 +81,7 @@ GtkWidget *
 nm_mb_menu_item_new (const char *connection_name,
                      guint32 strength,
                      const char *provider,
+                     gboolean active,
                      guint32 technology,
                      guint32 state,
                      gboolean enabled,
@@ -166,26 +167,17 @@ nm_mb_menu_item_new (const char *connection_name,
 		break;
 	}
 
-	/* Assume a connection name means the label should be active */
-	if (enabled && connection_name) {
+	if (enabled && connection_name && active) {
 		char *markup;
 
-		if (technology == MB_TECH_WIMAX) {
-			/* WiMAX NSPs aren't shown in bold */
-			gtk_label_set_use_markup (GTK_LABEL (priv->desc), FALSE);
-			gtk_label_set_text (GTK_LABEL (priv->desc), priv->desc_string);
-		} else {
-			gtk_label_set_use_markup (GTK_LABEL (priv->desc), TRUE);
-			markup = g_markup_printf_escaped ("<b>%s</b>", priv->desc_string);
-			gtk_label_set_markup (GTK_LABEL (priv->desc), markup);
-			g_free (markup);
-		}
-		gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
+		gtk_label_set_use_markup (GTK_LABEL (priv->desc), TRUE);
+		markup = g_markup_printf_escaped ("<b>%s</b>", priv->desc_string);
+		gtk_label_set_markup (GTK_LABEL (priv->desc), markup);
+		g_free (markup);
 	} else {
 		/* Disconnected and disabled states */
 		gtk_label_set_use_markup (GTK_LABEL (priv->desc), FALSE);
 		gtk_label_set_text (GTK_LABEL (priv->desc), priv->desc_string);
-		gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
 	}
 
 	/* And the strength icon, if we have strength information at all */
diff --git a/src/mb-menu-item.h b/src/mb-menu-item.h
index cba8df4..e38ed9f 100644
--- a/src/mb-menu-item.h
+++ b/src/mb-menu-item.h
@@ -49,6 +49,7 @@ GType	   nm_mb_menu_item_get_type (void) G_GNUC_CONST;
 GtkWidget *nm_mb_menu_item_new (const char *connection_name,
                                 guint32 strength,
                                 const char *provider,
+                                gboolean active,
                                 guint32 technology,
                                 guint32 state,
                                 gboolean enabled,



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