Re: Ubuntu's network-manager-applet indicator patch



On Sat, Mar 5, 2011 at 11:40 AM, Dan Williams <dcbw redhat com> wrote:
[...]
> We make all the device-class icon functions (like bt_get_icon or
> cdma_get_icon etc) return gboolean, but we add GdkPixbuf **out_pixbuf
> and const char **out_icon_name arguments to them.  That way we can use
> the same function no matter whether it's an indicator or normal
> GtkStatusIcon.  The functions will return TRUE if they have a specific
> icon to use, and will place that icon in the out_pixbuf (if using
> GtkStatusIcon) or out_icon_name (if using appindicator).  Something more
> like the attached patch (not compile tested)?

Your patch worked with only minor changes. I ended up using
foo_set_icon to have one single place to set the icon. I've attached a
new revision of my patch.

>
> Also, are the 3G signal icons *really* called "gsm-3g-xx"?  Clearly
> there is more 3G than just GSM...  Nor is GSM 3G :)

Yeah, that's because 3G icons are all the same, and omit the actual
technology symbol. I agree that the name isn't great though.

I guess it's somewhat similar for the other icons: I created extra
icons for the "-secure" names since it's not possible to generate
icons on the fly by compositing pixbufs. They are the same icons with
the padlock pre-composited.

Mathieu Trudel-Lapierre <mathieu tl gmail com>
Freenode: cyphermox, Jabber: mathieu tl gmail com
4096R/EE018C93 1967 8F7D 03A1 8F38 732E  FF82 C126 33E1 EE01 8C93
From: Mathieu Trudel-Lapierre <mathieu trudel-lapierre canonical com>
Subject: Implement conditional support for libappindicator

To get better integration with Unity (and actually have nm-applet show up at
all with Unity / compiz), implement drawing the applet using libappindicator.

To play well with others, this patch actually implements libappindicator
conditionally to running configure with --enable-indicator.

=== modified file 'configure.ac'
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/configure.ac
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/configure.ac	2011-03-04 11:01:16.000000000 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/configure.ac	2011-03-11 16:03:26.326652171 -0500
@@ -114,6 +114,14 @@
 		;;
 esac
 
+AC_ARG_ENABLE([indicator],
+[  --enable-appindicator  Enables using libappindicator to draw the applet
+                          on the screen, instead of the standard status icons.],
+[
+	PKG_CHECK_MODULES(APPINDICATOR, appindicator-0.1)
+	AC_DEFINE([ENABLE_INDICATOR], 1, [Enable using libappindicator])
+])
+
 AM_CONDITIONAL(HAVE_GBT, test x"$have_gbt" = "xyes")
 
 # Check for libnotify >= 0.7
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/Makefile.am
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/Makefile.am	2011-03-04 11:01:16.000000000 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/Makefile.am	2011-03-11 16:03:26.326652171 -0500
@@ -5,6 +5,7 @@
 nm_applet_CPPFLAGS = \
 	$(NMA_CFLAGS) \
 	$(NOTIFY_CFLAGS) \
+	$(APPINDICATOR_CFLAGS) \
 	-DICONDIR=\""$(datadir)/icons"\"						\
 	-DUIDIR=\""$(uidir)"\"							\
 	-DBINDIR=\""$(bindir)"\"								\
@@ -56,6 +57,7 @@
 	-lm \
 	$(NMA_LIBS) \
 	$(NOTIFY_LIBS) \
+	$(APPINDICATOR_LIBS) \
 	${top_builddir}/src/marshallers/libmarshallers.la \
 	${top_builddir}/src/utils/libutils.la \
 	${top_builddir}/src/gconf-helpers/libgconf-helpers.la \
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-bt.c
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/applet-device-bt.c	2011-03-04 11:01:16.000000000 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-bt.c	2011-03-11 16:03:26.326652171 -0500
@@ -154,7 +154,9 @@
 
 	item = applet_menu_item_create_device_item_helper (device, applet, text);
 
+#ifndef ENABLE_INDICATOR
 	gtk_widget_set_sensitive (item, FALSE);
+#endif
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	gtk_widget_show (item);
 
@@ -209,15 +211,16 @@
 	}
 }
 
-static GdkPixbuf *
+static void
 bt_get_icon (NMDevice *device,
              NMDeviceState state,
              NMConnection *connection,
+             GdkPixbuf **out_pixbuf,
+             char **out_indicator_icon,
              char **tip,
              NMApplet *applet)
 {
 	NMSettingConnection *s_con;
-	GdkPixbuf *pixbuf = NULL;
 	const char *id;
 
 	id = nm_device_get_iface (NM_DEVICE (device));
@@ -240,14 +243,13 @@
 		*tip = g_strdup_printf (_("Requesting a network address for '%s'..."), id);
 		break;
 	case NM_DEVICE_STATE_ACTIVATED:
-		pixbuf = nma_icon_check_and_load ("nm-device-wwan", &applet->wwan_icon, applet);
+		*out_indicator_icon = g_strdup_printf ("nm-device-wwan");
+		*out_pixbuf = nma_icon_check_and_load ("nm-device-wwan", &applet->wwan_icon, applet);
 		*tip = g_strdup_printf (_("Mobile broadband connection '%s' active"), id);
 		break;
 	default:
 		break;
 	}
-
-	return pixbuf;
 }
 
 typedef struct {
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-cdma.c
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/applet-device-cdma.c	2011-03-04 11:01:16.000000000 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-cdma.c	2011-03-11 16:03:26.326652171 -0500
@@ -263,6 +263,9 @@
 	char *text;
 	GtkWidget *item;
 	GSList *connections, *all, *iter;
+#ifdef ENABLE_INDICATOR
+	GtkWidget *signal_icon;
+#endif
 
 	info = g_object_get_data (G_OBJECT (device), "devinfo");
 
@@ -284,7 +287,9 @@
 	}
 
 	item = applet_menu_item_create_device_item_helper (device, applet, text);
+#ifndef ENABLE_INDICATOR
 	gtk_widget_set_sensitive (item, FALSE);
+#endif
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	gtk_widget_show (item);
 	g_free (text);
@@ -296,6 +301,7 @@
 		s_con = (NMSettingConnection *) nm_connection_get_setting (active, NM_TYPE_SETTING_CONNECTION);
 		g_assert (s_con);
 
+#ifndef ENABLE_INDICATOR
 		item = nm_mb_menu_item_new (nm_setting_connection_get_id (s_con),
 		                            info->quality_valid ? info->quality : 0,
 		                            info->provider_name,
@@ -303,6 +309,21 @@
 		                            cdma_state_to_mb_state (info),
 		                            info->modem_enabled,
 		                            applet);
+#else
+                text = mobile_helper_get_connection_label (nm_setting_connection_get_id (s_con),
+                                                            info->provider_name,
+                                                            cdma_act_to_mb_act (info),
+                                                            cdma_state_to_mb_state (info));
+                item = gtk_image_menu_item_new_with_label (text);
+                g_free (text);
+                text = mobile_helper_get_quality_icon (info->quality_valid ?
+							info->quality : 0,
+							applet);
+                signal_icon = gtk_image_new_from_icon_name (text, GTK_ICON_SIZE_LARGE_TOOLBAR);
+                g_free (text);
+                gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), signal_icon);
+                gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+#endif
 
 		add_connection_item (device, active, item, menu, applet);
 	}
@@ -316,6 +337,7 @@
 		}
 	} else {
 		/* Otherwise show idle registration state or disabled */
+#ifndef ENABLE_INDICATOR
 		item = nm_mb_menu_item_new (NULL,
 		                            info->quality_valid ? info->quality : 0,
 		                            info->provider_name,
@@ -323,6 +345,22 @@
 		                            cdma_state_to_mb_state (info),
 		                            info->modem_enabled,
 		                            applet);
+#else
+                text = mobile_helper_get_connection_label (NULL,
+                                                            info->provider_name,
+                                                            cdma_act_to_mb_act (info),
+                                                            cdma_state_to_mb_state (info));
+                item = gtk_image_menu_item_new_with_label (text);
+                g_free (text);
+                text = mobile_helper_get_quality_icon (info->quality_valid ?
+							info->quality : 0,
+							applet);
+                signal_icon = gtk_image_new_from_icon_name (text, GTK_ICON_SIZE_LARGE_TOOLBAR);
+                g_free (text);
+                gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), signal_icon);
+                gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+                gtk_widget_set_sensitive (item, FALSE);
+#endif
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 
@@ -387,15 +425,16 @@
 	check_start_polling (info);
 }
 
-static GdkPixbuf *
+static void
 cdma_get_icon (NMDevice *device,
                NMDeviceState state,
                NMConnection *connection,
+               GdkPixbuf **out_pixbuf,
+               char **out_indicator_icon,
                char **tip,
                NMApplet *applet)
 {
 	NMSettingConnection *s_con;
-	GdkPixbuf *pixbuf = NULL;
 	const char *id;
 	CdmaDeviceInfo *info;
 	gboolean mb_state;
@@ -424,11 +463,14 @@
 		break;
 	case NM_DEVICE_STATE_ACTIVATED:
 		mb_state = cdma_state_to_mb_state (info);
-		pixbuf = mobile_helper_get_status_pixbuf (info->quality,
+		*out_pixbuf = mobile_helper_get_status_pixbuf (info->quality,
 		                                          info->quality_valid,
 		                                          mb_state,
 		                                          cdma_act_to_mb_act (info),
 		                                          applet);
+		*out_indicator_icon = mobile_helper_get_quality_icon (info->quality_valid ?
+									info->quality : 0,
+									applet);
 
 		if ((mb_state != MB_STATE_UNKNOWN) && info->quality_valid) {
 			gboolean roaming = (mb_state == MB_STATE_ROAMING);
@@ -443,8 +485,6 @@
 	default:
 		break;
 	}
-
-	return pixbuf;
 }
 
 typedef struct {
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-gsm.c
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/applet-device-gsm.c	2011-03-11 16:03:26.186652171 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-gsm.c	2011-03-11 16:03:26.336652171 -0500
@@ -41,6 +41,7 @@
 #include "applet-device-gsm.h"
 #include "utils.h"
 #include "mobile-wizard.h"
+#include "mobile-helpers.h"
 #include "applet-dialogs.h"
 #include "mb-menu-item.h"
 #include "nma-marshal.h"
@@ -307,6 +308,9 @@
 	char *text;
 	GtkWidget *item;
 	GSList *connections, *all, *iter;
+#ifdef ENABLE_INDICATOR
+	GtkWidget *signal_icon;
+#endif
 
 	info = g_object_get_data (G_OBJECT (device), "devinfo");
 
@@ -328,7 +332,9 @@
 	}
 
 	item = applet_menu_item_create_device_item_helper (device, applet, text);
+#ifndef ENABLE_INDICATOR
 	gtk_widget_set_sensitive (item, FALSE);
+#endif
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	gtk_widget_show (item);
 	g_free (text);
@@ -340,6 +346,7 @@
 		s_con = (NMSettingConnection *) nm_connection_get_setting (active, NM_TYPE_SETTING_CONNECTION);
 		g_assert (s_con);
 
+#ifndef ENABLE_INDICATOR
 		item = nm_mb_menu_item_new (nm_setting_connection_get_id (s_con),
 		                            info->quality_valid ? info->quality : 0,
 		                            info->op_name,
@@ -347,6 +354,21 @@
 		                            gsm_state_to_mb_state (info),
 		                            info->modem_enabled,
 		                            applet);
+#else
+		text = mobile_helper_get_connection_label (nm_setting_connection_get_id (s_con),
+							    info->op_name,
+							    gsm_act_to_mb_act (info),
+							    gsm_state_to_mb_state (info));
+		item = gtk_image_menu_item_new_with_label (text);
+		g_free (text);
+		text = mobile_helper_get_quality_icon (info->quality_valid ?
+							info->quality : 0,
+							applet);
+		signal_icon = gtk_image_new_from_icon_name (text, GTK_ICON_SIZE_LARGE_TOOLBAR);
+		g_free (text);
+		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), signal_icon);
+		gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+#endif
 
 		add_connection_item (device, active, item, menu, applet);
 	}
@@ -359,6 +381,7 @@
 			gtk_widget_show (item);
 		}
 	} else {
+#ifndef ENABLE_INDICATOR
 		item = nm_mb_menu_item_new (NULL,
 		                            info->quality_valid ? info->quality : 0,
 		                            info->op_name,
@@ -366,6 +389,23 @@
 		                            gsm_state_to_mb_state (info),
 		                            info->modem_enabled,
 		                            applet);
+#else
+		text = mobile_helper_get_connection_label (NULL,
+							    info->op_name,
+							    gsm_act_to_mb_act (info),
+							    gsm_state_to_mb_state (info));
+		item = gtk_image_menu_item_new_with_label (text);
+		g_free (text);
+		text = mobile_helper_get_quality_icon (info->quality_valid ?
+							info->quality : 0,
+							applet);
+		signal_icon = gtk_image_new_from_icon_name (text, GTK_ICON_SIZE_LARGE_TOOLBAR);
+		g_free (text);
+		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), signal_icon);
+		gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+		gtk_widget_set_sensitive (item, FALSE);
+#endif
+
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 
@@ -425,15 +465,16 @@
 	check_start_polling (info);
 }
 
-static GdkPixbuf *
+static void
 gsm_get_icon (NMDevice *device,
               NMDeviceState state,
               NMConnection *connection,
+              GdkPixbuf **out_pixbuf,
+              char **out_indicator_icon,
               char **tip,
               NMApplet *applet)
 {
 	NMSettingConnection *s_con;
-	GdkPixbuf *pixbuf = NULL;
 	const char *id;
 	GsmDeviceInfo *info;
 	guint32 mb_state;
@@ -462,11 +503,14 @@
 		break;
 	case NM_DEVICE_STATE_ACTIVATED:
 		mb_state = gsm_state_to_mb_state (info);
-		pixbuf = mobile_helper_get_status_pixbuf (info->quality,
+		*out_pixbuf = mobile_helper_get_status_pixbuf (info->quality,
 		                                          info->quality_valid,
 		                                          mb_state,
 		                                          gsm_act_to_mb_act (info),
 		                                          applet);
+		*out_indicator_icon = mobile_helper_get_quality_icon (info->quality_valid ?
+								info->quality : 0,
+								applet);
 
 		if ((mb_state != MB_STATE_UNKNOWN) && info->quality_valid) {
 			gboolean roaming = (mb_state == MB_STATE_ROAMING);
@@ -481,8 +525,6 @@
 	default:
 		break;
 	}
-
-	return pixbuf;
 }
 
 typedef struct {
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-wifi.c
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/applet-device-wifi.c	2011-03-11 16:03:26.236652171 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-wifi.c	2011-03-11 16:03:26.336652171 -0500
@@ -347,6 +347,57 @@
 	return NULL;
 }
 
+#ifdef ENABLE_INDICATOR
+static gchar *
+get_best_icon_name_for_ap (NMAccessPoint *ap, gboolean need_sec, gboolean encrypted)
+{
+	GString *icon_name = NULL;
+	gchar *tmp = NULL;
+	guint32 strength;
+
+	g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
+
+	strength = nm_access_point_get_strength (ap);
+	strength = CLAMP (strength, 0, 100);
+
+	icon_name = g_string_new ("");
+	if (strength > 80)
+                icon_name = g_string_assign (icon_name, "nm-signal-100");
+        else if (strength > 55)
+                icon_name = g_string_assign (icon_name, "nm-signal-75");
+        else if (strength > 30)
+                icon_name = g_string_assign (icon_name, "nm-signal-50");
+        else if (strength > 5)
+                icon_name = g_string_assign (icon_name, "nm-signal-25");
+        else
+                icon_name = g_string_assign (icon_name, "nm-signal-00");
+
+        if (nm_access_point_get_mode (ap) == NM_802_11_MODE_ADHOC) {
+                icon_name = g_string_assign (icon_name, "nm-adhoc");
+		goto out;
+	}
+
+	if (need_sec && encrypted)
+		icon_name = g_string_append (icon_name, "-secure");
+
+out:
+	tmp = icon_name->str;
+	g_string_free (icon_name, FALSE);
+
+	return tmp;
+}
+
+static char *
+escape_mnemonics (const char *ssid)
+{
+	gchar **split_ssid = g_strsplit (ssid, "_", 0);
+	gchar *clean_ssid = g_strjoinv ("__", split_ssid);
+	g_strfreev (split_ssid);
+
+	return clean_ssid;
+}
+#endif
+
 static void
 clamp_ap_to_bssid (NMAccessPoint *ap, NMSettingWireless *s_wifi)
 {
@@ -571,6 +622,10 @@
 			info->ap = g_object_ref (G_OBJECT (ap));
 			info->connection = g_object_ref (G_OBJECT (connection));
 
+#ifdef ENABLE_INDICATOR
+			g_object_set_data_full (G_OBJECT (subitem), "connection", G_OBJECT (connection), (GDestroyNotify) g_free);
+#endif
+
 			g_signal_connect_data (subitem, "activate",
 			                       G_CALLBACK (wireless_menu_item_activate),
 			                       info,
@@ -591,6 +646,9 @@
 		if (g_slist_length (ap_connections) == 1) {
 			connection = NM_CONNECTION (g_slist_nth_data (ap_connections, 0));
 			info->connection = g_object_ref (G_OBJECT (connection));
+#ifdef ENABLE_INDICATOR
+			g_object_set_data_full (G_OBJECT (item), "connection", G_OBJECT (connection), (GDestroyNotify) g_free);
+#endif
 		}
 
 		g_signal_connect_data (GTK_WIDGET (item),
@@ -629,13 +687,21 @@
 	 */
 	dup_data.found = NULL;
 	dup_data.hash = g_object_get_data (G_OBJECT (ap), "hash");
+#ifndef ENABLE_INDICATOR
 	g_return_val_if_fail (dup_data.hash != NULL, NULL);
+#else
+	/* heh, not much choice here, otherwise on startup we get tons of errors
+         * because g_return_val_if_fail prints assertion errors.
+         */
+	if (dup_data.hash == NULL)
+		return NULL;
+#endif
 
 	dup_data.device = NM_DEVICE (device);
 	g_slist_foreach (menu_list, find_duplicate, &dup_data);
 
 	if (dup_data.found) {
-		nm_network_menu_item_best_strength (dup_data.found, nm_access_point_get_strength (ap), applet);
+		//nm_network_menu_item_best_strength (dup_data.found, nm_access_point_get_strength (ap), applet);
 		nm_network_menu_item_add_dupe (dup_data.found, ap);
 		return NULL;
 	}
@@ -746,6 +812,12 @@
 	gboolean wireless_hw_enabled = TRUE;
 	GSList *menu_items = NULL;  /* All menu items we'll be adding */
 	NMNetworkMenuItem *item, *active_item = NULL;
+#if ENABLE_INDICATOR
+	GtkWidget *imi, *icon_image;
+	WirelessMenuItemInfo *info;
+	gboolean is_encrypted;
+	gchar *best_icon_name;
+#endif
 	GtkWidget *widget;
 
 	wdev = NM_DEVICE_WIFI (device);
@@ -769,7 +841,9 @@
 	widget = applet_menu_item_create_device_item_helper (device, applet, text);
 	g_free (text);
 
+#ifndef ENABLE_INDICATOR
 	gtk_widget_set_sensitive (widget, FALSE);
+#endif
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), widget);
 	gtk_widget_show (widget);
 
@@ -786,8 +860,37 @@
 				nm_network_menu_item_set_active (item, TRUE);
 				menu_items = g_slist_append (menu_items, item);
 
+#if ENABLE_INDICATOR
+				text = escape_mnemonics (nm_network_menu_item_get_ssid (item));
+				imi = gtk_image_menu_item_new_with_label (text);
+				g_free (text);
+
+				is_encrypted = nm_network_menu_item_get_is_encrypted(item);
+
+				best_icon_name = get_best_icon_name_for_ap (active_ap, TRUE, is_encrypted);
+				icon_image = gtk_image_new_from_icon_name (best_icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR);
+				g_free (best_icon_name);
+				gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (imi), icon_image);
+				gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (imi), TRUE);
+
+				info = g_slice_new0 (WirelessMenuItemInfo);
+				info->applet = applet;
+				info->device = g_object_ref (G_OBJECT (device));
+				info->ap = g_object_ref (G_OBJECT (active_ap));
+				info->connection = g_object_get_data (G_OBJECT (item), "connection");
+
+				g_signal_connect_data (GTK_WIDGET (imi),
+		                       "activate",
+		                       G_CALLBACK (wireless_menu_item_activate),
+		                       info,
+		                       (GClosureNotify) wireless_menu_item_info_destroy,
+		                       0);
+
+				gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (imi));
+#else
 				gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
 				gtk_widget_show_all (GTK_WIDGET (item));
+#endif
 			}
 		}
 	}
@@ -814,7 +917,39 @@
 
 		item = get_menu_item_for_ap (wdev, ap, connections, menu_items, applet);
 		if (item)
+#if ENABLE_INDICATOR
+		{
+			text = escape_mnemonics (nm_network_menu_item_get_ssid (item));
+			imi = gtk_image_menu_item_new_with_label (text);
+			g_free (text);
+
+			is_encrypted = nm_network_menu_item_get_is_encrypted(item);
+
+			best_icon_name = get_best_icon_name_for_ap (ap, TRUE, is_encrypted);
+			icon_image = gtk_image_new_from_icon_name (best_icon_name, GTK_ICON_SIZE_MENU);
+			g_free (best_icon_name);
+			gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (imi), icon_image);
+			gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (imi), TRUE);
+
+			info = g_slice_new0 (WirelessMenuItemInfo);
+			info->applet = applet;
+			info->device = g_object_ref (G_OBJECT (device));
+			info->ap = g_object_ref (G_OBJECT (ap));
+			info->connection = g_object_get_data (G_OBJECT (item), "connection");
+
+			g_signal_connect_data (GTK_WIDGET (imi),
+	                       "activate",
+	                       G_CALLBACK (wireless_menu_item_activate),
+	                       info,
+	                       (GClosureNotify) wireless_menu_item_info_destroy,
+	                       0);
+
+			g_object_set_data_full (G_OBJECT (item), "nm-network-menu-item", imi, (GDestroyNotify) g_free);
+			menu_items = g_slist_append (menu_items, item);
+		}
+#else
 			menu_items = g_slist_append (menu_items, item);
+#endif
 	}
 
 	/* Now remove the active AP item from the list, as we've already dealt with
@@ -848,8 +983,12 @@
 		topmenu_items = g_slist_sort (topmenu_items, sort_by_name);
 
 		for (iter = topmenu_items; iter; iter = g_slist_next (iter)) {
+#if ENABLE_INDICATOR
+			gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (g_object_get_data(iter->data, "nm-network-menu-item")));
+#else
 			gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (iter->data));
 			gtk_widget_show_all (GTK_WIDGET (iter->data));
+#endif
 		}
 		g_slist_free (topmenu_items);
 		topmenu_items = NULL;
@@ -869,7 +1008,11 @@
 
 			/* And add the rest to the submenu */
 			for (iter = sorted_subitems; iter; iter = g_slist_next (iter))
+#if ENABLE_INDICATOR
+				gtk_menu_shell_append (GTK_MENU_SHELL (submenu), GTK_WIDGET (g_object_get_data(iter->data, "nm-network-menu-item")));
+#else
 				gtk_menu_shell_append (GTK_MENU_SHELL (submenu), GTK_WIDGET (iter->data));
+#endif
 			g_slist_free (sorted_subitems);
 
 			gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
@@ -1106,6 +1249,10 @@
 	                  applet);
 	
 	queue_avail_access_point_notification (NM_DEVICE (device));
+
+#ifdef ENABLE_INDICATOR
+	applet_schedule_update_menu (applet);
+#endif
 }
 
 static void
@@ -1124,6 +1271,10 @@
 		g_object_set_data (G_OBJECT (device), ACTIVE_AP_TAG, NULL);
 		applet_schedule_update_icon (applet);
 	}
+
+#ifdef ENABLE_INDICATOR
+	applet_schedule_update_menu (applet);
+#endif
 }
 
 static void
@@ -1282,16 +1433,17 @@
 	g_free (esc_ssid);
 }
 
-static GdkPixbuf *
+static void
 wireless_get_icon (NMDevice *device,
                    NMDeviceState state,
                    NMConnection *connection,
+                   GdkPixbuf **out_pixbuf,
+                   char **out_indicator_icon,
                    char **tip,
                    NMApplet *applet)
 {
 	NMSettingConnection *s_con;
 	NMAccessPoint *ap;
-	GdkPixbuf *pixbuf = NULL;
 	const char *id;
 	char *ssid = NULL;
 
@@ -1334,20 +1486,23 @@
 			strength = CLAMP (strength, 0, 100);
 
 			if (strength > 80)
-				pixbuf = nma_icon_check_and_load ("nm-signal-100", &applet->wireless_100_icon, applet);
+				*out_pixbuf = nma_icon_check_and_load ("nm-signal-100", &applet->wireless_100_icon, applet);
 			else if (strength > 55)
-				pixbuf = nma_icon_check_and_load ("nm-signal-75", &applet->wireless_75_icon, applet);
+				*out_pixbuf = nma_icon_check_and_load ("nm-signal-75", &applet->wireless_75_icon, applet);
 			else if (strength > 30)
-				pixbuf = nma_icon_check_and_load ("nm-signal-50", &applet->wireless_50_icon, applet);
+				*out_pixbuf = nma_icon_check_and_load ("nm-signal-50", &applet->wireless_50_icon, applet);
 			else if (strength > 5)
-				pixbuf = nma_icon_check_and_load ("nm-signal-25", &applet->wireless_25_icon, applet);
+				*out_pixbuf = nma_icon_check_and_load ("nm-signal-25", &applet->wireless_25_icon, applet);
 			else
-				pixbuf = nma_icon_check_and_load ("nm-signal-00", &applet->wireless_00_icon, applet);
+				*out_pixbuf = nma_icon_check_and_load ("nm-signal-00", &applet->wireless_00_icon, applet);
+
+			*out_indicator_icon = get_best_icon_name_for_ap (ap, FALSE, FALSE);
 
 			*tip = g_strdup_printf (_("Wireless network connection '%s' active: %s (%d%%)"),
 			                        id, ssid, strength);
 		} else {
-			pixbuf = nma_icon_check_and_load ("nm-signal-00", &applet->wireless_00_icon, applet);
+			*out_indicator_icon = g_strdup_printf ("nm-signal-00");
+			*out_pixbuf = nma_icon_check_and_load (*out_indicator_icon, &applet->wireless_00_icon, applet);
 			*tip = g_strdup_printf (_("Wireless network connection '%s' active"), id);
 		}
 		break;
@@ -1356,7 +1511,6 @@
 	}
 
 	g_free (ssid);
-	return pixbuf;
 }
 
 static void
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-wired.c
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/applet-device-wired.c	2011-03-11 16:03:26.196652171 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet-device-wired.c	2011-03-11 16:03:26.336652171 -0500
@@ -222,7 +222,9 @@
  	if (nm_device_get_capabilities (device) & NM_DEVICE_CAP_CARRIER_DETECT)
 		carrier = nm_device_ethernet_get_carrier (NM_DEVICE_ETHERNET (device));
 
+#ifndef ENABLE_INDICATOR
 	gtk_widget_set_sensitive (item, FALSE);
+#endif
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	gtk_widget_show (item);
 
@@ -275,15 +277,16 @@
 	}
 }
 
-static GdkPixbuf *
+static void
 wired_get_icon (NMDevice *device,
                 NMDeviceState state,
                 NMConnection *connection,
+                GdkPixbuf **out_pixbuf,
+                char **out_indicator_icon,
                 char **tip,
                 NMApplet *applet)
 {
 	NMSettingConnection *s_con;
-	GdkPixbuf *pixbuf = NULL;
 	const char *id;
 
 	id = nm_device_get_iface (NM_DEVICE (device));
@@ -306,14 +309,13 @@
 		*tip = g_strdup_printf (_("Requesting a wired network address for '%s'..."), id);
 		break;
 	case NM_DEVICE_STATE_ACTIVATED:
-		pixbuf = nma_icon_check_and_load ("nm-device-wired", &applet->wired_icon, applet);
+		*out_indicator_icon = g_strdup_printf ("nm-device-wired");
+		*out_pixbuf = nma_icon_check_and_load (*out_indicator_icon, &applet->wired_icon, applet);
 		*tip = g_strdup_printf (_("Wired network connection '%s' active"), id);
 		break;
 	default:
 		break;
 	}
-
-	return pixbuf;
 }
 
 /* PPPoE */
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet.c
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/applet.c	2011-03-11 16:03:26.316652171 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet.c	2011-03-11 16:48:57.376651063 -0500
@@ -438,6 +438,7 @@
                                                int pos)
 {
 	GtkWidget *menu_item = gtk_image_menu_item_new ();
+#ifndef ENABLE_INDICATOR
 	GtkWidget *box = gtk_hbox_new (FALSE, 0);
 	GtkWidget *xlabel = NULL;
 
@@ -455,6 +456,9 @@
 	              "child", box,
 	              "sensitive", FALSE,
 	              NULL);
+#else
+	menu_item = gtk_separator_menu_item_new ();
+#endif
 	if (pos < 0)
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
 	else
@@ -469,10 +473,14 @@
 {
 	GtkWidget *item;
 	NMSettingConnection *s_con;
+#ifndef ENABLE_INDICATOR
 	char *markup;
 	GtkWidget *label;
+#endif
 
 	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+
+#ifndef ENABLE_INDICATOR
 	item = gtk_image_menu_item_new_with_label ("");
 	if (add_active && (active == connection)) {
 		/* Pure evil */
@@ -485,9 +493,13 @@
 		gtk_menu_item_set_label (GTK_MENU_ITEM (item), nm_setting_connection_get_id (s_con));
 
 	gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+#else
+	item = gtk_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+#endif
 	return item;
 }
 
+#ifndef ENABLE_INDICATOR
 #define TITLE_TEXT_R ((double) 0x5e / 255.0 )
 #define TITLE_TEXT_G ((double) 0x5e / 255.0 )
 #define TITLE_TEXT_B ((double) 0x5e / 255.0 )
@@ -567,7 +579,7 @@
 	gtk_widget_set_size_request (widget, width + 2 * xpadding, height + ypadding + postpadding);
 	return TRUE;
 }
-
+#endif
 
 GtkWidget *
 applet_menu_item_create_device_item_helper (NMDevice *device,
@@ -578,7 +590,9 @@
 
 	item = gtk_menu_item_new_with_mnemonic (text);
 	gtk_widget_set_sensitive (item, FALSE);
+#ifndef ENABLE_INDICATOR
 	g_signal_connect (item, "expose-event", G_CALLBACK (menu_title_item_expose), NULL);
+#endif
 	return item;
 }
 
@@ -620,7 +634,11 @@
 	g_return_if_fail (summary != NULL);
 	g_return_if_fail (message != NULL);
 
+#ifndef ENABLE_INDICATOR
 	if (!gtk_status_icon_is_embedded (applet->status_icon))
+#else
+	if (app_indicator_get_status (applet->status_icon) == APP_INDICATOR_STATUS_PASSIVE)
+#endif
 		return;
 
 	escaped = utils_escape_notify_message (message);
@@ -646,9 +664,11 @@
 
 	g_free (escaped);
 
+#ifndef ENABLE_INDICATOR
 #if !HAVE_LIBNOTIFY_07
 	notify_notification_attach_to_status_icon (notify, applet->status_icon);
 #endif
+#endif
 	notify_notification_set_urgency (notify, urgency);
 	notify_notification_set_timeout (notify, NOTIFY_EXPIRES_DEFAULT);
 
@@ -930,6 +950,7 @@
 		clear_animation_timeout (applet);
 
 	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 static const char *
@@ -951,6 +972,38 @@
 	char *vpn_name;
 } VPNActivateInfo;
 
+static NMActiveConnection *
+applet_get_first_active_vpn_connection (NMApplet *applet,
+                                        NMVPNConnectionState *out_state)
+{
+	const GPtrArray *active_list;
+	int i;
+
+	active_list = nm_client_get_active_connections (applet->nm_client);
+	for (i = 0; active_list && (i < active_list->len); i++) {
+		NMActiveConnection *candidate;
+		NMConnection *connection;
+		NMSettingConnection *s_con;
+
+		candidate = g_ptr_array_index (active_list, i);
+
+		connection = applet_get_connection_for_active (applet, candidate);
+		if (!connection)
+			continue;
+
+		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		g_assert (s_con);
+
+		if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
+			if (out_state)
+				*out_state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (candidate));
+			return candidate;
+		}
+	}
+
+	return NULL;
+}
+
 static void
 activate_vpn_cb (gpointer user_data, const char *path, GError *error)
 {
@@ -986,6 +1039,27 @@
 	g_free (info);
 }
 
+/*
+ * nma_menu_disconnect_vpn_item_activate
+ *
+ * Signal function called when user clicks "Disconnect VPN"
+ *
+ */
+static void
+nma_menu_disconnect_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
+{
+	NMApplet *applet = NM_APPLET (user_data);
+	NMActiveConnection *active_vpn = NULL;
+	NMVPNConnectionState state = NM_VPN_CONNECTION_STATE_UNKNOWN;
+
+	active_vpn = applet_get_first_active_vpn_connection (applet, &state);
+	if (active_vpn)
+		nm_client_deactivate_connection (applet->nm_client, active_vpn);
+	else
+		g_warning ("%s: deactivate clicked but no active VPN connection could be found.", __func__);
+//	nmi_dbus_signal_user_interface_activated (applet->connection);
+}
+
 static void
 nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
 {
@@ -1009,9 +1083,14 @@
 		return;
 	}
 
-	if (applet_get_active_for_connection (applet, connection))
+	if (applet_get_active_for_connection (applet, connection)) {
+#ifndef ENABLE_INDICATOR
 		/* Connection already active; do nothing */
+#else
+		nma_menu_disconnect_vpn_item_activate (item, applet);
+#endif
 		return;
+	}
 
 	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
 	info = g_malloc0 (sizeof (VPNActivateInfo));
@@ -1049,59 +1128,6 @@
 //	nmi_dbus_signal_user_interface_activated (applet->connection);
 }
 
-static NMActiveConnection *
-applet_get_first_active_vpn_connection (NMApplet *applet,
-                                        NMVPNConnectionState *out_state)
-{
-	const GPtrArray *active_list;
-	int i;
-
-	active_list = nm_client_get_active_connections (applet->nm_client);
-	for (i = 0; active_list && (i < active_list->len); i++) {
-		NMActiveConnection *candidate;
-		NMConnection *connection;
-		NMSettingConnection *s_con;
-
-		candidate = g_ptr_array_index (active_list, i);
-
-		connection = applet_get_connection_for_active (applet, candidate);
-		if (!connection)
-			continue;
-
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
-		g_assert (s_con);
-
-		if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
-			if (out_state)
-				*out_state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (candidate));
-			return candidate;
-		}
-	}
-
-	return NULL;
-}
-
-/*
- * nma_menu_disconnect_vpn_item_activate
- *
- * Signal function called when user clicks "Disconnect VPN"
- *
- */
-static void
-nma_menu_disconnect_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
-{
-	NMApplet *applet = NM_APPLET (user_data);
-	NMActiveConnection *active_vpn = NULL;
-	NMVPNConnectionState state = NM_VPN_CONNECTION_STATE_UNKNOWN;
-
-	active_vpn = applet_get_first_active_vpn_connection (applet, &state);
-	if (active_vpn)
-		nm_client_deactivate_connection (applet->nm_client, active_vpn);
-	else
-		g_warning ("%s: deactivate clicked but no active VPN connection could be found.", __func__);
-//	nmi_dbus_signal_user_interface_activated (applet->connection);
-}
-
 /*
  * nma_menu_add_separator_item
  *
@@ -1116,7 +1142,6 @@
 	gtk_widget_show (menu_item);
 }
 
-
 /*
  * nma_menu_add_text_item
  *
@@ -1429,6 +1454,8 @@
 		dclass = get_device_class (device, applet);
 		if (dclass)
 			dclass->add_menu_item (device, n_devices, active, menu, applet);
+
+		nma_menu_add_separator_item (menu);
 	}
 
  out:
@@ -1486,8 +1513,6 @@
 	GSList *list, *iter;
 	int num_vpn_active = 0;
 
-	nma_menu_add_separator_item (menu);
-
 	vpn_menu = GTK_MENU (gtk_menu_new ());
 
 	item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_VPN Connections")));
@@ -1506,12 +1531,19 @@
 		NMConnection *connection = NM_CONNECTION (iter->data);
 		NMActiveConnection *active;
 		const char *name;
+#ifndef ENABLE_INDICATOR
 		GtkWidget *image;
+#endif
 
 		name = get_connection_id (connection);
 
+#ifndef ENABLE_INDICATOR
 		item = GTK_MENU_ITEM (gtk_image_menu_item_new_with_label (name));
 		gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
+#else
+		item = GTK_MENU_ITEM (gtk_check_menu_item_new_with_label (name));
+		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item), FALSE);
+#endif
 
 		/* If no VPN connections are active, draw all menu items enabled. If
 		 * >= 1 VPN connections are active, only the active VPN menu item is
@@ -1527,8 +1559,12 @@
 			gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
 
 		if (active) {
+#ifndef ENABLE_INDICATOR
 			image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, GTK_ICON_SIZE_MENU);
 			gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+#else
+			gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item), TRUE);
+#endif
 		}
 
 		g_object_set_data_full (G_OBJECT (item), "connection", 
@@ -1556,7 +1592,6 @@
 	g_slist_free (list);
 }
 
-
 static void
 nma_set_wireless_enabled_cb (GtkWidget *widget, NMApplet *applet)
 {
@@ -1574,6 +1609,7 @@
 	gboolean state;
 
 	g_return_if_fail (applet != NULL);
+	g_return_if_fail (widget != NULL);
 
 	state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
 	nm_client_wwan_set_enabled (applet->nm_client, state);
@@ -1585,12 +1621,13 @@
 	gboolean state;
 
 	g_return_if_fail (applet != NULL);
+	g_return_if_fail (widget != NULL);
 
 	state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
 	nm_client_networking_set_enabled (applet->nm_client, state);
 }
 
-
+#ifndef ENABLE_INDICATOR
 static void
 nma_set_notifications_enabled_cb (GtkWidget *widget, NMApplet *applet)
 {
@@ -1617,6 +1654,7 @@
 	                       !state,
 	                       NULL);
 }
+#endif
 
 /*
  * nma_menu_show_cb
@@ -1631,12 +1669,16 @@
 	g_return_if_fail (menu != NULL);
 	g_return_if_fail (applet != NULL);
 
+#ifndef ENABLE_INDICATOR /* indicators don't get tooltips */
+
 #if GTK_CHECK_VERSION(2, 15, 0)
 	gtk_status_icon_set_tooltip_text (applet->status_icon, NULL);
 #else
 	gtk_status_icon_set_tooltip (applet->status_icon, NULL);
 #endif
 
+#endif /* ENABLE_INDICATOR */
+
 	if (!nm_client_get_manager_running (applet->nm_client)) {
 		nma_menu_add_text_item (menu, _("NetworkManager is not running..."));
 		return;
@@ -1665,6 +1707,7 @@
 
 static gboolean nma_menu_clear (NMApplet *applet);
 
+#ifndef ENABLE_INDICATOR
 static void
 nma_menu_deactivate_cb (GtkWidget *widget, NMApplet *applet)
 {
@@ -1674,13 +1717,16 @@
 	 */
 	g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc) nma_menu_clear, applet, NULL);
 
+
 	/* Re-set the tooltip */
 #if GTK_CHECK_VERSION(2, 15, 0)
 	gtk_status_icon_set_tooltip_text (applet->status_icon, applet->tip);
 #else
 	gtk_status_icon_set_tooltip (applet->status_icon, applet->tip);
 #endif
+
 }
+#endif /* ENABLE_INDICATOR */
 
 /*
  * nma_menu_create
@@ -1697,8 +1743,10 @@
 
 	menu = gtk_menu_new ();
 	gtk_container_set_border_width (GTK_CONTAINER (menu), 0);
+#ifndef ENABLE_INDICATOR
 	g_signal_connect (menu, "show", G_CALLBACK (nma_menu_show_cb), applet);
 	g_signal_connect (menu, "deactivate", G_CALLBACK (nma_menu_deactivate_cb), applet);
+#endif
 	return menu;
 }
 
@@ -1735,12 +1783,14 @@
 nma_context_menu_update (NMApplet *applet)
 {
 	NMState state;
+	gboolean wireless_hw_enabled;
 	gboolean net_enabled = TRUE;
 	gboolean have_wireless = FALSE;
 	gboolean have_wwan = FALSE;
-	gboolean wireless_hw_enabled;
 	gboolean wwan_hw_enabled;
+#ifndef ENABLE_INDICATOR
 	gboolean notifications_enabled = TRUE;
+#endif
 
 	state = nm_client_get_state (applet->nm_client);
 
@@ -1785,6 +1835,7 @@
 	gtk_widget_set_sensitive (GTK_WIDGET (applet->wwan_enabled_item),
 	                          wwan_hw_enabled && is_permission_yes (applet, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN));
 
+#ifndef ENABLE_INDICATOR
 	/* Enabled notifications */
 	g_signal_handler_block (G_OBJECT (applet->notifications_enabled_item),
 	                        applet->notifications_enabled_toggled_id);
@@ -1796,6 +1847,7 @@
 	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);
+#endif
 
 	/* Don't show wifi-specific stuff if wireless is off */
 	if (state != NM_STATE_ASLEEP) {
@@ -1861,17 +1913,16 @@
  * Generate the contextual popup menu.
  *
  */
-static GtkWidget *nma_context_menu_create (NMApplet *applet)
+static GtkWidget *nma_context_menu_create (NMApplet *applet, GtkMenuShell *menu)
 {
-	GtkMenuShell *menu;
+#ifndef ENABLE_INDICATOR
 	GtkWidget *menu_item;
+#endif
 	GtkWidget *image;
 	guint id;
 
 	g_return_val_if_fail (applet != NULL, NULL);
 
-	menu = GTK_MENU_SHELL (gtk_menu_new ());
-
 	/* 'Enable Networking' item */
 	applet->networking_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable _Networking"));
 	id = g_signal_connect (applet->networking_enabled_item,
@@ -1901,6 +1952,7 @@
 
 	nma_menu_add_separator_item (GTK_WIDGET (menu));
 
+#ifndef ENABLE_INDICATOR
 	/* 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,
@@ -1911,6 +1963,7 @@
 	gtk_menu_shell_append (menu, applet->notifications_enabled_item);
 
 	nma_menu_add_separator_item (GTK_WIDGET (menu));
+#endif /* ifndef ENABLE_INDICATOR */
 
 	/* 'Connection Information' item */
 	applet->info_menu_item = gtk_image_menu_item_new_with_mnemonic (_("Connection _Information"));
@@ -1932,25 +1985,17 @@
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (applet->connections_menu_item), image);
 	gtk_menu_shell_append (menu, applet->connections_menu_item);
 
+#ifndef ENABLE_INDICATOR
 	/* Separator */
 	nma_menu_add_separator_item (GTK_WIDGET (menu));
 
-#if 0	/* FIXME: Implement the help callback, nma_help_cb()! */
-	/* Help item */
-	menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Help"));
-	g_signal_connect (menu_item, "activate", G_CALLBACK (nma_help_cb), applet);
-	image = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_MENU);
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
-	gtk_menu_shell_append (menu, menu_item);
-	gtk_widget_set_sensitive (menu_item, FALSE);
-#endif
-
 	/* About item */
 	menu_item = gtk_image_menu_item_new_with_mnemonic (_("_About"));
 	g_signal_connect_swapped (menu_item, "activate", G_CALLBACK (applet_about_dialog_show), applet);
 	image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
 	gtk_menu_shell_append (menu, menu_item);
+#endif
 
 	gtk_widget_show_all (GTK_WIDGET (menu));
 
@@ -1961,15 +2006,45 @@
 /*****************************************************************************/
 
 static void
-foo_set_icon (NMApplet *applet, GdkPixbuf *pixbuf, guint32 layer)
+foo_set_icon (NMApplet *applet, guint32 layer, GdkPixbuf *pixbuf, char *icon_name, char *new_tip)
 {
+	GString *tip = NULL;
+#ifndef ENABLE_INDICATOR
 	int i;
+#endif
 
 	if (layer > ICON_LAYER_MAX) {
 		g_warning ("Tried to icon to invalid layer %d", layer);
 		return;
 	}
 
+	switch (layer) {
+		case ICON_LAYER_LINK:
+			if (new_tip == NULL)
+                		new_tip = g_strdup (_("No network connection"));
+			tip = g_string_new (new_tip);
+			break;
+		case ICON_LAYER_VPN:
+			tip = g_string_new (applet->tip);
+
+			if (new_tip)
+				g_string_append_printf (tip, "%s%s", tip->len ? "\n" : "", new_tip);
+			break;
+		default:
+			tip = g_string_new ("");
+			break;
+	}
+
+	if (tip->len) {
+		g_free (applet->tip);
+		applet->tip = tip->str;
+	}
+
+	g_free (new_tip);
+	g_string_free (tip, FALSE);
+
+#ifndef ENABLE_INDICATOR
+
 	/* Ignore setting of the same icon as is already displayed */
 	if (applet->icon_layers[layer] == pixbuf)
 		return;
@@ -2003,8 +2078,26 @@
 
 	gtk_status_icon_set_from_pixbuf (applet->status_icon, pixbuf);
 	g_object_unref (pixbuf);
-}
 
+#if GTK_CHECK_VERSION(2, 15, 0)
+	gtk_status_icon_set_tooltip_text (applet->status_icon, applet->tip);
+#else
+	gtk_status_icon_set_tooltip (applet->status_icon, applet->tip);
+#endif
+
+#else /* ENABLE_INDICATOR */
+
+	if (icon_name == NULL && layer == ICON_LAYER_LINK) {
+                icon_name = g_strdup ("nm-no-connection");
+	}
+
+	if (icon_name != NULL && g_strcmp0 (app_indicator_get_icon (applet->status_icon), icon_name) != 0) {
+		app_indicator_set_icon_full (applet->status_icon, icon_name, applet->tip);
+		g_free (icon_name);
+	}
+
+#endif /* ENABLE_INDICATOR */
+}
 
 NMSettingsConnectionInterface *
 applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet)
@@ -2206,7 +2299,19 @@
 	applet_common_device_state_changed (device, new_state, old_state, reason, applet);
 
 	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
+}
+
+#ifdef ENABLE_INDICATOR
+static void
+foo_device_removed_cb (NMClient *client, NMDevice *device, gpointer user_data)
+{
+	NMApplet *applet = NM_APPLET (user_data);
+
+	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
+#endif
 
 static void
 foo_device_added_cb (NMClient *client, NMDevice *device, gpointer user_data)
@@ -2261,6 +2366,7 @@
 	}
 
 	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 static void
@@ -2355,6 +2461,11 @@
 	g_signal_connect (applet->nm_client, "device-added",
 	                  G_CALLBACK (foo_device_added_cb),
 	                  applet);
+#ifdef ENABLE_INDICATOR
+	g_signal_connect (applet->nm_client, "device-removed",
+			  G_CALLBACK (foo_device_removed_cb),
+			  applet);
+#endif
 	g_signal_connect (applet->nm_client, "notify::manager-running",
 	                  G_CALLBACK (foo_manager_running_cb),
 	                  applet);
@@ -2374,10 +2485,12 @@
 	applet_schedule_update_icon (applet);
 }
 
-static GdkPixbuf *
-applet_common_get_device_icon (NMDeviceState state, NMApplet *applet)
+static void
+applet_common_get_device_icon (NMDeviceState state,
+				GdkPixbuf **out_pixbuf,
+				char **out_indicator_icon,
+				NMApplet *applet)
 {
-	GdkPixbuf *pixbuf = NULL;
 	int stage = -1;
 
 	switch (state) {
@@ -2396,25 +2509,30 @@
 	}
 
 	if (stage >= 0) {
-		int i, j;
-
-		for (i = 0; i < NUM_CONNECTING_STAGES; i++) {
-			for (j = 0; j < NUM_CONNECTING_FRAMES; j++) {
-				char *name;
-
-				name = g_strdup_printf ("nm-stage%02d-connecting%02d", i+1, j+1);
-				nma_icon_check_and_load (name, &applet->network_connecting_icons[i][j], applet);
-				g_free (name);
+		/* Don't overwrite pixbufs or names given by specific device classes */
+		if (out_pixbuf && !*out_pixbuf) {
+			int i, j;
+			for (i = 0; i < NUM_CONNECTING_STAGES; i++) {
+				for (j = 0; j < NUM_CONNECTING_FRAMES; j++) {
+					char *name;
+
+					name = g_strdup_printf ("nm-stage%02d-connecting%02d", i+1, j+1);
+					nma_icon_check_and_load (name, &applet->network_connecting_icons[i][j], applet);
+					g_free (name);
+				}
 			}
+			*out_pixbuf = applet->network_connecting_icons[stage][applet->animation_step];
+		}
+		if (out_indicator_icon && !*out_indicator_icon) {
+			*out_indicator_icon = g_strdup_printf ("nm-stage%02d-connecting%02d",
+								stage + 1,
+								applet->animation_step + 1);
 		}
 
-		pixbuf = applet->network_connecting_icons[stage][applet->animation_step];
 		applet->animation_step++;
 		if (applet->animation_step >= NUM_CONNECTING_FRAMES)
 			applet->animation_step = 0;
 	}
-
-	return pixbuf;
 }
 
 static char *
@@ -2453,12 +2571,14 @@
 	return tip;
 }
 
-static GdkPixbuf *
-applet_get_device_icon_for_state (NMApplet *applet, char **tip)
+static void
+applet_get_device_icon_for_state (NMApplet *applet,
+                                  GdkPixbuf **out_pixbuf,
+                                  char **out_indicator_icon,
+                                  char **out_tip)
 {
 	NMActiveConnection *active;
 	NMDevice *device = NULL;
-	GdkPixbuf *pixbuf = NULL;
 	NMDeviceState state = NM_DEVICE_STATE_UNKNOWN;
 	NMADeviceClass *dclass;
 
@@ -2482,17 +2602,13 @@
 		NMConnection *connection;
 
 		connection = applet_find_active_connection_for_device (device, applet, NULL);
-		pixbuf = dclass->get_icon (device, state, connection, tip, applet);
-		if (!*tip)
-			*tip = get_tip_for_device_state (device, state, connection);
+		dclass->get_icon (device, state, connection, out_pixbuf, out_indicator_icon, out_tip, applet);
+		if (out_tip && !*out_tip)
+			*out_tip = get_tip_for_device_state (device, state, connection);
 	}
 
 out:
-	if (!pixbuf)
-		pixbuf = applet_common_get_device_icon (state, applet);
-	if (!pixbuf)
-		pixbuf = applet->no_connection_icon;
-	return pixbuf;
+	applet_common_get_device_icon (state, out_pixbuf, out_indicator_icon, applet);
 }
 
 static char *
@@ -2551,7 +2667,7 @@
 	NMApplet *applet = NM_APPLET (user_data);
 	GdkPixbuf *pixbuf = NULL;
 	NMState state;
-	char *dev_tip = NULL, *vpn_tip = NULL;
+	char *dev_tip = NULL, *vpn_tip = NULL, *icon_name = NULL;
 	NMVPNConnectionState vpn_state = NM_VPN_SERVICE_STATE_UNKNOWN;
 	gboolean nm_running;
 	NMActiveConnection *active_vpn = NULL;
@@ -2566,87 +2682,95 @@
 	if (!nm_running)
 		state = NM_STATE_UNKNOWN;
 
+#ifdef ENABLE_INDICATOR
+	if (nm_running)
+		app_indicator_set_status (applet->status_icon, APP_INDICATOR_STATUS_ACTIVE);
+	else
+		app_indicator_set_status (applet->status_icon, APP_INDICATOR_STATUS_PASSIVE);
+#endif
+
 	switch (state) {
 	case NM_STATE_UNKNOWN:
 	case NM_STATE_ASLEEP:
-		pixbuf = nma_icon_check_and_load ("nm-no-connection", &applet->no_connection_icon, applet);
+		icon_name = g_strdup ("nm-no-connection");
+		pixbuf = nma_icon_check_and_load (icon_name, &applet->no_connection_icon, applet);
 		dev_tip = g_strdup (_("Networking disabled"));
 		break;
 	case NM_STATE_DISCONNECTED:
-		pixbuf = nma_icon_check_and_load ("nm-no-connection", &applet->no_connection_icon, applet);
+		icon_name = g_strdup ("nm-no-connection");
+		pixbuf = nma_icon_check_and_load (icon_name, &applet->no_connection_icon, applet);
 		dev_tip = g_strdup (_("No network connection"));
 		break;
 	default:
-		pixbuf = applet_get_device_icon_for_state (applet, &dev_tip);
+		applet_get_device_icon_for_state (applet, &pixbuf, &icon_name, &dev_tip);
 		break;
 	}
 
-	foo_set_icon (applet, pixbuf, ICON_LAYER_LINK);
+	foo_set_icon (applet, ICON_LAYER_LINK, pixbuf, icon_name, dev_tip);
 
 	/* VPN state next */
 	pixbuf = NULL;
+	icon_name = NULL;
 	active_vpn = applet_get_first_active_vpn_connection (applet, &vpn_state);
 	if (active_vpn) {
-		int i;
+
+		vpn_tip = get_tip_for_vpn (active_vpn, vpn_state, applet);
 
 		switch (vpn_state) {
 		case NM_VPN_CONNECTION_STATE_ACTIVATED:
-			pixbuf = nma_icon_check_and_load ("nm-vpn-active-lock", &applet->vpn_lock_icon, applet);
+#ifndef ENABLE_INDICATOR
+			icon_name = g_strdup_printf ("nm-vpn-active-lock");
+			pixbuf = nma_icon_check_and_load (icon_name, &applet->vpn_lock_icon, applet);
+#else
+			icon_name = g_strdup_printf ("%s-secure", app_indicator_get_icon (applet->status_icon));
+#endif
 			break;
 		case NM_VPN_CONNECTION_STATE_PREPARE:
 		case NM_VPN_CONNECTION_STATE_NEED_AUTH:
 		case NM_VPN_CONNECTION_STATE_CONNECT:
 		case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:
-			for (i = 0; i < NUM_VPN_CONNECTING_FRAMES; i++) {
-				char *name;
-
-				name = g_strdup_printf ("nm-vpn-connecting%02d", i+1);
-				nma_icon_check_and_load (name, &applet->vpn_connecting_icons[i], applet);
-				g_free (name);
+#ifndef ENABLE_INDICATOR
+			for (int i = 0; i < NUM_VPN_CONNECTING_FRAMES; i++) {
+				icon_name = g_strdup_printf ("nm-vpn-connecting%02d", i+1);
+				nma_icon_check_and_load (icon_name, &applet->vpn_connecting_icons[i], applet);
+				g_free (icon_name);
 			}
+#endif
 
 			pixbuf = applet->vpn_connecting_icons[applet->animation_step];
 			applet->animation_step++;
 			if (applet->animation_step >= NUM_VPN_CONNECTING_FRAMES)
 				applet->animation_step = 0;
+
+#ifdef ENABLE_INDICATOR
+			icon_name = g_strdup_printf ("nm-vpn-connecting%02d", applet->animation_step+1);
+#endif
 			break;
 		default:
 			break;
 		}
 
-		vpn_tip = get_tip_for_vpn (active_vpn, vpn_state, applet);
-	}
-	foo_set_icon (applet, pixbuf, ICON_LAYER_VPN);
-
-	if (applet->tip) {
-		g_free (applet->tip);
-		applet->tip = NULL;
 	}
+	foo_set_icon (applet, ICON_LAYER_VPN, pixbuf, icon_name, vpn_tip);
 
-	if (dev_tip || vpn_tip) {
-		GString *tip;
-
-		tip = g_string_new (dev_tip);
-
-		if (vpn_tip)
-			g_string_append_printf (tip, "%s%s", tip->len ? "\n" : "", vpn_tip);
-
-		if (tip->len)
-			applet->tip = tip->str;
-
-		g_free (vpn_tip);
-		g_free (dev_tip);
-		g_string_free (tip, FALSE);
-	}
+	return FALSE;
+}
 
-#if GTK_CHECK_VERSION(2, 15, 0)
-	gtk_status_icon_set_tooltip_text (applet->status_icon, applet->tip);
-#else
-	gtk_status_icon_set_tooltip (applet->status_icon, applet->tip);
-#endif
+#ifdef ENABLE_INDICATOR
+static gboolean
+indicator_update_menu (NMApplet *applet)
+{
+	nma_menu_clear (applet);
+	nma_menu_show_cb (applet->menu, applet);
+	nma_menu_add_separator_item (applet->menu);
+	applet->menu = nma_context_menu_create (applet, GTK_MENU_SHELL(applet->menu));
+	nma_context_menu_update (applet);
+	app_indicator_set_menu (applet->status_icon, GTK_MENU(applet->menu));
+	applet->menu_update_id = 0;
 
 	return FALSE;
 }
+#endif /* ENABLE_INDICATOR */
 
 void
 applet_schedule_update_icon (NMApplet *applet)
@@ -2655,6 +2779,21 @@
 		applet->update_icon_id = g_idle_add (applet_update_icon, applet);
 }
 
+void
+applet_schedule_update_menu (NMApplet *applet)
+#ifdef ENABLE_INDICATOR
+{
+	if (!applet->menu_update_id)
+		applet->menu_update_id = g_idle_add_full (G_PRIORITY_LOW,
+							  (GSourceFunc) indicator_update_menu,
+							  applet, NULL);
+}
+#else  /* if ENABLE_INDICATOR is false */
+{
+}
+#endif /* ENABLE_INDICATOR */
+
+
 static NMDevice *
 find_active_device (NMAGConfConnection *connection,
                     NMApplet *applet,
@@ -2974,7 +3113,11 @@
 		g_object_unref (G_OBJECT (applet->icon_theme));
 	}
 
+#ifdef ENABLE_INDICATOR
+	screen = gdk_screen_get_default();
+#else
 	screen = gtk_status_icon_get_screen (applet->status_icon);
+#endif
 	g_assert (screen);
 	applet->icon_theme = gtk_icon_theme_get_for_screen (screen);
 
@@ -2991,6 +3134,7 @@
 	g_signal_connect (applet->icon_theme, "changed", G_CALLBACK (nma_icon_theme_changed), applet);
 }
 
+#ifndef ENABLE_INDICATOR
 static void
 status_icon_screen_changed_cb (GtkStatusIcon *icon,
                                GParamSpec *pspec,
@@ -3016,20 +3160,23 @@
 
 	return TRUE;
 }
+#endif
 
+#ifndef ENABLE_INDICATOR
 static void
 status_icon_activate_cb (GtkStatusIcon *icon, NMApplet *applet)
 {
 	/* Have clicking on the applet act also as acknowledgement
 	 * of the notification. 
 	 */
-
 	nma_menu_clear (applet);
 	gtk_menu_popup (GTK_MENU (applet->menu), NULL, NULL,
 			gtk_status_icon_position_menu, icon,
 			1, gtk_get_current_event_time ());
 }
+#endif /* ENABLE_INDICATOR */
 
+#ifndef ENABLE_INDICATOR
 static void
 status_icon_popup_menu_cb (GtkStatusIcon *icon,
                            guint button,
@@ -3045,36 +3192,69 @@
 			gtk_status_icon_position_menu, icon,
 			button, activate_time);
 }
+#endif
+
+#ifdef ENABLE_INDICATOR
 
 static gboolean
-setup_widgets (NMApplet *applet)
+setup_indicator_menu (NMApplet *applet)
 {
 	g_return_val_if_fail (NM_IS_APPLET (applet), FALSE);
 
-	applet->status_icon = gtk_status_icon_new ();
-	if (!applet->status_icon)
+	nma_menu_clear (applet);  /* calls create too */
+	if (!applet->menu)
 		return FALSE;
 
-	g_signal_connect (applet->status_icon, "notify::screen",
-			  G_CALLBACK (status_icon_screen_changed_cb), applet);
-	g_signal_connect (applet->status_icon, "size-changed",
-			  G_CALLBACK (status_icon_size_changed_cb), applet);
-	g_signal_connect (applet->status_icon, "activate",
-			  G_CALLBACK (status_icon_activate_cb), applet);
-	g_signal_connect (applet->status_icon, "popup-menu",
-			  G_CALLBACK (status_icon_popup_menu_cb), applet);
+	applet->menu = nma_context_menu_create (applet, GTK_MENU_SHELL(applet->menu));
+	nma_context_menu_update(applet);
+
+	app_indicator_set_menu(applet->status_icon, GTK_MENU(applet->menu));
+
+	return TRUE;
+}
+
+#else
+
+static gboolean
+setup_statusicon_menu (NMApplet *applet)
+{
+	g_return_val_if_fail (NM_IS_APPLET (applet), FALSE);
+	g_return_val_if_fail (applet->status_icon, FALSE);
 
 	applet->menu = nma_menu_create (applet);
 	if (!applet->menu)
 		return FALSE;
 
-	applet->context_menu = nma_context_menu_create (applet);
+	applet->context_menu = GTK_MENU_SHELL (gtk_menu_new ());
+	applet->context_menu = nma_context_menu_create (applet, GTK_MENU_SHELL (applet->context_menu));
 	if (!applet->context_menu)
 		return FALSE;
 
 	return TRUE;
 }
 
+#endif /* ENABLE_INDICATOR */
+
+static gboolean
+setup_widgets (NMApplet *applet)
+{
+	gboolean success = FALSE;
+
+	g_return_val_if_fail (NM_IS_APPLET (applet), FALSE);
+#if 0
+	if (!applet->status_icon)
+		return FALSE;
+#endif
+
+#ifdef ENABLE_INDICATOR
+	success = setup_indicator_menu (applet);
+#else
+	success = setup_statusicon_menu (applet);
+#endif
+
+	return success;
+}
+
 static void
 applet_pre_keyring_callback (gpointer user_data)
 {
@@ -3139,6 +3319,7 @@
 	g_main_loop_quit (applet->loop);
 }
 
+#ifndef ENABLE_INDICATOR
 static void
 applet_embedded_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
 {
@@ -3147,6 +3328,7 @@
 	g_message ("applet now %s the notification area",
 	           embedded ? "embedded in" : "removed from");
 }
+#endif
 
 static GObject *
 constructor (GType type,
@@ -3189,11 +3371,6 @@
 	                      GCONF_CLIENT_PRELOAD_ONELEVEL,
 	                      NULL);
 
-	/* Load pixmaps and create applet widgets */
-	if (!setup_widgets (applet))
-		goto error;
-	nma_icons_init (applet);
-
 	if (!notify_is_initted ())
 		notify_init ("NetworkManager");
 
@@ -3238,18 +3415,43 @@
 
 	foo_client_setup (applet);
 
-	/* timeout to update connection timestamps every 5 minutes */
-	applet->update_timestamps_id = g_timeout_add_seconds (300,
-			(GSourceFunc) periodic_update_active_connection_timestamps, applet);
+#ifdef ENABLE_INDICATOR
+	applet->status_icon = app_indicator_new
+				("nm-applet", "nm-no-connection",
+				 APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+#else
+	applet->status_icon = gtk_status_icon_new ();
 
-	nm_gconf_set_pre_keyring_callback (applet_pre_keyring_callback, applet);
+	g_signal_connect (applet->status_icon, "notify::screen",
+			  G_CALLBACK (status_icon_screen_changed_cb), applet);
+	g_signal_connect (applet->status_icon, "size-changed",
+			  G_CALLBACK (status_icon_size_changed_cb), applet);
+	g_signal_connect (applet->status_icon, "activate",
+			  G_CALLBACK (status_icon_activate_cb), applet);
+	g_signal_connect (applet->status_icon, "popup-menu",
+			  G_CALLBACK (status_icon_popup_menu_cb), applet);
 
 	/* Track embedding to help debug issues where user has removed the
 	 * notification area applet from the panel, and thus nm-applet too.
 	 */
 	g_signal_connect (applet->status_icon, "notify::embedded",
 	                  G_CALLBACK (applet_embedded_cb), NULL);
+#endif
+
+	/* Load pixmaps and create applet widgets */
+	if (!setup_widgets (applet))
+		goto error;
+	nma_icons_init (applet);
+
+	/* timeout to update connection timestamps every 5 minutes */
+	applet->update_timestamps_id = g_timeout_add_seconds (300,
+			(GSourceFunc) periodic_update_active_connection_timestamps, applet);
+
+	nm_gconf_set_pre_keyring_callback (applet_pre_keyring_callback, applet);
+
+#ifndef ENABLE_INDICATOR
 	applet_embedded_cb (G_OBJECT (applet->status_icon), NULL, NULL);
+#endif
 
 	applet->notify_actions = applet_notify_server_has_actions ();
 
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet.h
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/applet.h	2011-03-11 16:03:26.246652171 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/applet.h	2011-03-11 16:03:26.346652171 -0500
@@ -38,6 +38,10 @@
 
 #include <libnotify/notify.h>
 
+#if ENABLE_INDICATOR
+#include <libappindicator/app-indicator.h>
+#endif
+
 #include <nm-connection.h>
 #include <nm-client.h>
 #include <nm-access-point.h>
@@ -144,7 +148,12 @@
 	guint			animation_id;
 
 	/* Direct UI elements */
+#if ENABLE_INDICATOR
+	AppIndicator *status_icon;
+	guint		menu_update_id;
+#else
 	GtkStatusIcon * status_icon;
+#endif
 	int             icon_size;
 
 	GtkWidget *		menu;
@@ -197,9 +206,11 @@
 	                                        NMDeviceStateReason reason,
 	                                        NMApplet *applet);
 
-	GdkPixbuf *    (*get_icon)             (NMDevice *device,
+	void           (*get_icon)             (NMDevice *device,
 	                                        NMDeviceState state,
 	                                        NMConnection *connection,
+						GdkPixbuf **out_pixbuf,
+						char **out_indicator_icon,
 	                                        char **tip,
 	                                        NMApplet *applet);
 
@@ -225,6 +236,10 @@
 
 void applet_schedule_update_icon (NMApplet *applet);
 
+#ifdef ENABLE_INDICATOR
+void applet_schedule_update_menu (NMApplet *applet);
+#endif
+
 NMSettingsInterface *applet_get_settings (NMApplet *applet);
 
 GSList *applet_get_all_connections (NMApplet *applet);
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/gconf-helpers/Makefile.am
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/gconf-helpers/Makefile.am	2011-03-04 11:01:16.000000000 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/gconf-helpers/Makefile.am	2011-03-11 16:03:26.346652171 -0500
@@ -12,6 +12,7 @@
 
 libgconf_helpers_la_CPPFLAGS = \
 	$(NMA_CFLAGS) \
+	$(APPINDICATOR_CFLAGS) \
 	$(DISABLE_DEPRECATED) \
 	-I${top_srcdir}/src \
 	-I${top_builddir}/src/marshallers \
@@ -19,6 +20,7 @@
 
 libgconf_helpers_la_LIBADD = \
 	$(NMA_LIBS) \
+	$(APPINDICATOR_LIBS) \
 	${top_builddir}/src/marshallers/libmarshallers.la \
 	${top_builddir}/src/utils/libutils.la
 
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/mobile-helpers.c
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/mobile-helpers.c	2011-03-04 11:01:16.000000000 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/mobile-helpers.c	2011-03-11 16:03:26.346652171 -0500
@@ -21,6 +21,7 @@
  */
 
 #include "mobile-helpers.h"
+#include <glib/gi18n.h>
 
 GdkPixbuf *
 mobile_helper_get_status_pixbuf (guint32 quality,
@@ -35,7 +36,11 @@
 
 	if (!quality_valid)
 		quality = 0;
+#ifndef ENABLE_INDICATOR
 	qual_pixbuf = mobile_helper_get_quality_icon (quality, applet);
+#else
+	qual_pixbuf = wwan_pixbuf;
+#endif
 
 	pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
 	                         TRUE,
@@ -80,9 +85,14 @@
 	return pixbuf;
 }
 
+#ifndef ENABLE_INDICATOR
 GdkPixbuf *
+#else
+char *
+#endif
 mobile_helper_get_quality_icon (guint32 quality, NMApplet *applet)
 {
+#ifndef ENABLE_INDICATOR
 	if (quality > 80)
 		return nma_icon_check_and_load ("nm-signal-100", &applet->wireless_100_icon, applet);
 	else if (quality > 55)
@@ -93,7 +103,132 @@
 		return nma_icon_check_and_load ("nm-signal-25", &applet->wireless_25_icon, applet);
 
 	return nma_icon_check_and_load ("nm-signal-00", &applet->wireless_00_icon, applet);
+#else
+	char *icon_name;
+
+	if (quality > 80)
+		icon_name = g_strdup_printf ("gsm-3g-full");
+	else if (quality > 55)
+		icon_name = g_strdup_printf ("gsm-3g-high");
+	else if (quality > 30)
+		icon_name = g_strdup_printf ("gsm-3g-medium");
+	else if (quality > 5)
+		icon_name = g_strdup_printf ("gsm-3g-low");
+	else
+		icon_name = g_strdup_printf ("gsm-3g-none");
+
+	return icon_name;
+#endif
+}
+
+#ifdef ENABLE_INDICATOR
+static const char *
+get_tech_name (guint32 tech)
+{
+        switch (tech) {
+        case MB_TECH_1XRTT:
+                return _("CDMA");
+        case MB_TECH_EVDO_REV0:
+        case MB_TECH_EVDO_REVA:
+                return _("EVDO");
+        case MB_TECH_GSM:
+                return _("GSM");
+        case MB_TECH_GPRS:
+                return _("GPRS");
+        case MB_TECH_EDGE:
+                return _("EDGE");
+        case MB_TECH_UMTS:
+                return _("UMTS");
+        case MB_TECH_HSDPA:
+                return _("HSDPA");
+        case MB_TECH_HSUPA:
+                return _("HSUPA");
+        case MB_TECH_HSPA:
+                return _("HSPA");
+        default:
+                break;
+        }
+        return NULL;
+}
+
+char *
+mobile_helper_get_connection_label (const char *connection_name,
+				    const char *provider,
+				    guint32 technology,
+				    guint32 state)
+{
+	const char *tech_name;
+	char *desc_string;
+
+        /* Construct the description string */
+        tech_name = get_tech_name (technology);
+        switch (state) {
+        default:
+        case MB_STATE_UNKNOWN:
+                desc_string = g_strdup (_("not enabled"));
+                break;
+        case MB_STATE_IDLE:
+                if (connection_name)
+                        desc_string = g_strdup (connection_name);
+                else
+                        desc_string = g_strdup (_("not registered"));
+                break;
+        case MB_STATE_HOME:
+                if (connection_name) {
+                        if (provider && tech_name)
+                                desc_string = g_strdup_printf ("%s (%s %s)", connection_name, provider, tech_name);
+                        else if (provider || tech_name)
+                                desc_string = g_strdup_printf ("%s (%s)", connection_name, provider ? provider : tech_name);
+                        else
+                                desc_string = g_strdup_printf ("%s", connection_name);
+                } else {
+                        if (provider) {
+                                if (tech_name)
+                                        desc_string = g_strdup_printf ("%s %s", provider, tech_name);
+                                else
+                                        desc_string = g_strdup_printf ("%s", provider);
+                        } else {
+                                if (tech_name)
+                                        desc_string = g_strdup_printf (_("Home network (%s)"), tech_name);
+                                else
+                                        desc_string = g_strdup_printf (_("Home network"));
+                        }
+                }
+                break;
+        case MB_STATE_SEARCHING:
+                if (connection_name)
+                        desc_string = g_strdup (connection_name);
+                else
+                        desc_string = g_strdup (_("searching"));
+                break;
+        case MB_STATE_DENIED:
+                desc_string = g_strdup (_("registration denied"));
+                break;
+        case MB_STATE_ROAMING:
+                if (connection_name) {
+                        if (tech_name)
+                                desc_string = g_strdup_printf (_("%s (%s roaming)"), connection_name, tech_name);
+                        else
+                                desc_string = g_strdup_printf (_("%s (roaming)"), connection_name);
+                } else {
+                        if (provider) {
+                                if (tech_name)
+                                        desc_string = g_strdup_printf (_("%s (%s roaming)"), provider, tech_name);
+                                else
+                                        desc_string = g_strdup_printf (_("%s (roaming)"), provider);
+                        } else {
+                                if (tech_name)
+                                        desc_string = g_strdup_printf (_("Roaming network (%s)"), tech_name);
+                                else
+                                        desc_string = g_strdup_printf (_("Roaming network"));
+                        }
+                }
+                break;
+        }
+
+	return desc_string;
 }
+#endif
 
 GdkPixbuf *
 mobile_helper_get_tech_icon (guint32 tech, NMApplet *applet)
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/mobile-helpers.h
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/mobile-helpers.h	2011-03-04 11:01:16.000000000 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/mobile-helpers.h	2011-03-11 16:03:26.346652171 -0500
@@ -55,9 +55,20 @@
                                             guint32 access_tech,
                                             NMApplet *applet);
 
+#ifndef ENABLE_INDICATOR
 GdkPixbuf *mobile_helper_get_quality_icon (guint32 quality, NMApplet *applet);
+#else
+char *mobile_helper_get_quality_icon (guint32 quality, NMApplet *applet);
+#endif
 
 GdkPixbuf *mobile_helper_get_tech_icon (guint32 tech, NMApplet *applet);
 
+#ifdef ENABLE_INDICATOR
+char *mobile_helper_get_connection_label (const char *connection_name,
+					  const char *provider,
+					  guint32 technology,
+					  guint32 state);
+#endif
+
 #endif  /* APPLET_MOBILE_HELPERS_H */
 
Index: network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/mb-menu-item.c
===================================================================
--- network-manager-applet-0.8.4~git.20110228t141430.abba62f.orig/src/mb-menu-item.c	2011-03-04 11:01:16.000000000 -0500
+++ network-manager-applet-0.8.4~git.20110228t141430.abba62f/src/mb-menu-item.c	2011-03-11 16:03:26.346652171 -0500
@@ -178,11 +178,14 @@
 		gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
 	}
 
+/* Disabling this for indicators only because it won't build otherwise. */
+#ifndef ENABLE_INDICATOR
 	/* And the strength icon, if we have strength information at all */
 	if (enabled && strength) {
 		gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength),
 		                           mobile_helper_get_quality_icon (strength, applet));
 	}
+#endif
 
 	return GTK_WIDGET (item);
 }


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