File nm-applet-app-indicator.patch of Package NetworkManager-gnome

diff --git a/configure.ac b/configure.ac
index d930ff7..76dfc8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,6 +156,13 @@
 	    with_firewalld="$withval",with_firewalld=yes)
 AM_CONDITIONAL(HAVE_FIREWALLD, test x"with_firewalld" = "xyes")
 
+AC_ARG_WITH([appindicator], AS_HELP_STRING([--with-appindicator|--without-appindicator], [Build with libappindicator support instead of xembed systray support.]))
+if test "$with_appindicator" == "yes"; then
+       PKG_CHECK_MODULES(APPINDICATOR, appindicator3-0.1)
+       AC_DEFINE([ENABLE_INDICATOR], 1, [Enable using libappindicator])
+fi
+
+
 dnl ModemManager1 with libmm-glib
 AC_ARG_WITH(modem-manager-1, AS_HELP_STRING([--with-modem-manager-1], [Enable new ModemManager1 interface support]),,[with_modem_manager_1=auto])
 if (test "${with_modem_manager_1}" != "no"); then
diff --git a/src/Makefile.am b/src/Makefile.am
index 1986b3e..098a5b3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am								\
@@ -7,6 +7,7 @@
 	$(NMA_CFLAGS) \
 	$(LIBSECRET_CFLAGS) \
 	$(NOTIFY_CFLAGS) \
+	$(APPINDICATOR_CFLAGS) \
 	-DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_0 \
 	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_0 \
 	-DICONDIR=\""$(datadir)/icons"\"						\
@@ -78,6 +79,7 @@
 	$(NMA_LIBS) \
 	$(LIBSECRET_LIBS) \
 	$(NOTIFY_LIBS) \
+	$(APPINDICATOR_LIBS) \
 	${top_builddir}/src/marshallers/libmarshallers.la \
 	${top_builddir}/src/utils/libutils.la \
 	${top_builddir}/src/wireless-security/libwireless-security.la \
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index 1f096c7..b2f0ab4 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -36,9 +36,28 @@
 
 G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, GTK_TYPE_IMAGE_MENU_ITEM);
 
+#define NM_NETWORK_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_NETWORK_MENU_ITEM, NMNetworkMenuItemPrivate))
+
+typedef struct {
+#ifndef ENABLE_INDICATOR
+	GtkWidget * ssid;
+	GtkWidget * strength;
+	GtkWidget * hbox;
+#endif
+
+	char      * ssid_string;
+	guint32     int_strength;
+	gchar *     hash;
+	GSList *    dupes;
+	gboolean    has_connections;
+	gboolean    is_adhoc;
+	gboolean    is_encrypted;
+} NMNetworkMenuItemPrivate;
+
 static void
 nm_network_menu_item_init (NMNetworkMenuItem * item)
 {
+#ifndef ENABLE_INDICATOR
 	item->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
 	item->ssid = gtk_label_new (NULL);
 	gtk_misc_set_alignment (GTK_MISC (item->ssid), 0.0, 0.5);
@@ -52,10 +71,16 @@ nm_network_menu_item_init (NMNetworkMenuItem * item)
 	item->strength = gtk_image_new ();
 	gtk_box_pack_end (GTK_BOX (item->hbox), item->strength, FALSE, TRUE, 0);
 
-	gtk_widget_show (item->ssid);
-	gtk_widget_show (item->strength);
-	gtk_widget_show (item->detail);
-	gtk_widget_show (item->hbox);
+	priv->strength = gtk_image_new ();
+	gtk_box_pack_end (GTK_BOX (priv->hbox), priv->strength, FALSE, TRUE, 0);
+	gtk_widget_show (priv->strength);
+
+	gtk_widget_show (priv->ssid);
+	gtk_widget_show (priv->detail);
+	gtk_widget_show (priv->hbox);
+#else
+	gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+#endif
 }
 
 GtkWidget*
@@ -82,11 +107,6 @@ nm_network_menu_item_dispose (GObject *object)
 		return;
 	}
 
-	gtk_widget_destroy (item->ssid);
-	gtk_widget_destroy (item->strength);
-	gtk_widget_destroy (item->detail);
-	gtk_widget_destroy (item->hbox);
-
 	item->destroyed = TRUE;
 	g_free (item->hash);
 	g_free (item->ssid_string);
@@ -116,11 +136,16 @@ nm_network_menu_item_set_ssid (NMNetworkMenuItem *item, GByteArray *ssid)
 	g_free (item->ssid_string);
 
 	item->ssid_string = nm_utils_ssid_to_utf8 (ssid);
+	
 	if (!item->ssid_string) {
 		// FIXME: shouldn't happen; always coerce the SSID to _something_
 		item->ssid_string = g_strdup ("<unknown>");
 	}
+#ifndef ENABLE_INDICATOR
 	gtk_label_set_text (GTK_LABEL (item->ssid), item->ssid_string);
+#else
+	nm_network_menu_item_set_active(item, FALSE);
+#endif
 }
 
 const char *
@@ -147,6 +172,7 @@ nm_network_menu_item_best_strength (NMNetworkMenuItem * item,
                                     NMApplet *applet)
 {
 	GdkPixbuf *icon = NULL, *pixbuf, *top;
+	const char *icon_name = NULL;
 
 	g_return_if_fail (item != NULL);
 	g_return_if_fail (NM_IS_NETWORK_MENU_ITEM (item));
@@ -158,17 +184,19 @@ nm_network_menu_item_best_strength (NMNetworkMenuItem * item,
 		return;
 
 	item->int_strength = strength;
-
+	
 	if (strength > 80)
-		icon = nma_icon_check_and_load ("nm-signal-100", applet);
+		icon_name = "nm-signal-100";
 	else if (strength > 55)
-		icon = nma_icon_check_and_load ("nm-signal-75", applet);
+		icon_name = "nm-signal-75";
 	else if (strength > 30)
-		icon = nma_icon_check_and_load ("nm-signal-50", applet);
+		icon_name = "nm-signal-50";
 	else if (strength > 5)
-		icon = nma_icon_check_and_load ("nm-signal-25", applet);
+		icon_name = "nm-signal-25";
 	else
-		icon = nma_icon_check_and_load ("nm-signal-00", applet);
+		icon_name = "nm-signal-00";
+	
+	icon = nma_icon_check_and_load (icon_name, applet);
 
 	pixbuf = gdk_pixbuf_copy (icon);
 
@@ -182,16 +210,28 @@ nm_network_menu_item_best_strength (NMNetworkMenuItem * item,
 	}
 
 	/* Scale to menu size if larger so the menu doesn't look awful */
-	if (gdk_pixbuf_get_height (pixbuf) > 24 || gdk_pixbuf_get_width (pixbuf) > 24) {
+	if (gdk_pixbuf_get_height (pixbuf) > 40 || gdk_pixbuf_get_width (pixbuf) > 40) {
 		GdkPixbuf *scaled;
 
-		scaled = gdk_pixbuf_scale_simple (pixbuf, 24, 24, GDK_INTERP_BILINEAR);
+		scaled = gdk_pixbuf_scale_simple (pixbuf, 40, 40, GDK_INTERP_BILINEAR);
 		g_object_unref (pixbuf);
 		pixbuf = scaled;
 	}
-
+#ifdef ENABLE_INDICATOR
+#ifdef DBUSMENU_PIXMAP_SUPPORT
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), gtk_image_new_from_pixbuf (icon));
+#else
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
+	                               gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU));
+#endif
+	/* For some reason we must always re-set always-show after setting the image */
+	gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+#else
 	gtk_image_set_from_pixbuf (GTK_IMAGE (item->strength), pixbuf);
+#endif
+	
 	g_object_unref (pixbuf);
+
 }
 
 const char *
@@ -223,9 +263,10 @@ nm_network_menu_item_set_detail (NMNetworkMenuItem *item,
 		item->is_encrypted = TRUE;
 
 	if (nm_access_point_get_mode (ap) == NM_802_11_MODE_ADHOC) {
-		GdkPixbuf *scaled = NULL;
 
 		item->is_adhoc = is_adhoc = TRUE;
+#ifndef ENABLE_INDICATOR
+		GdkPixbuf *scaled = NULL;
 
 		if (gdk_pixbuf_get_height (adhoc_icon) > 24 || gdk_pixbuf_get_width (adhoc_icon) > 24)
 			scaled = gdk_pixbuf_scale_simple (adhoc_icon, 24, 24, GDK_INTERP_BILINEAR);
@@ -233,6 +274,7 @@ nm_network_menu_item_set_detail (NMNetworkMenuItem *item,
 		gtk_image_set_from_pixbuf (GTK_IMAGE (item->detail), scaled ? scaled : adhoc_icon);
 
 		g_clear_object (&scaled);
+#endif
 	} else
 		gtk_image_set_from_stock (GTK_IMAGE (item->detail), NULL, GTK_ICON_SIZE_MENU);
 
@@ -267,21 +309,29 @@ nm_network_menu_item_find_dupe (NMNetworkMenuItem *item, NMAccessPoint *ap)
 	return FALSE;
 }
 
-void
-nm_network_menu_item_set_active (NMNetworkMenuItem *item, gboolean active)
+static void
+update_label (NMNetworkMenuItem *item, gboolean use_bold)
 {
-	char *markup;
 
-	g_return_if_fail (item != NULL);
-	g_return_if_fail (NM_IS_NETWORK_MENU_ITEM (item));
+#ifdef ENABLE_INDICATOR
+	gtk_menu_item_set_label (GTK_MENU_ITEM (item), item->ssid_string);
+#else
+	NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
+	gtk_label_set_use_markup (GTK_LABEL (priv->ssid), use_bold);
+	if (use_bold) {
+		char *markup = g_markup_printf_escaped ("<b>%s</b>", priv->ssid_string);
 
-	gtk_label_set_use_markup (GTK_LABEL (item->ssid), active);
-	if (active) {
-		markup = g_markup_printf_escaped ("<b>%s</b>", item->ssid_string);
-		gtk_label_set_markup (GTK_LABEL (item->ssid), markup);
+		gtk_label_set_markup (GTK_LABEL (priv->ssid), markup);
 		g_free (markup);
 	} else
-		gtk_label_set_text (GTK_LABEL (item->ssid), item->ssid_string);
+		gtk_label_set_text (GTK_LABEL (priv->ssid), priv->ssid_string);
+#endif
+}
+
+void
+nm_network_menu_item_set_active (NMNetworkMenuItem *item, gboolean active)
+{
+	update_label (item, active);
 }
 
 void
diff --git a/src/applet-device-broadband.c b/src/applet-device-broadband.c
index b302608..e453251 100644
--- a/src/applet-device-broadband.c
+++ b/src/applet-device-broadband.c
@@ -829,6 +829,7 @@ signal_quality_updated (GObject *object,
                         BroadbandDeviceInfo *info)
 {
 	applet_schedule_update_icon (info->applet);
+	applet_schedule_update_menu (info->applet);
 }
 
 static void
@@ -837,6 +838,7 @@ access_technologies_updated (GObject *object,
                              BroadbandDeviceInfo *info)
 {
 	applet_schedule_update_icon (info->applet);
+	applet_schedule_update_menu (info->applet);
 }
 
 static void
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 0ae44ad..1078feb 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -550,12 +550,12 @@ create_new_ap_item (NMDeviceWifi *device,
 
 	item = NM_NETWORK_MENU_ITEM (nm_network_menu_item_new (dup_data->hash,
 	                                                       !!g_slist_length (ap_connections)));
-	gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
 
 	ssid = nm_access_point_get_ssid (ap);
 	nm_network_menu_item_set_ssid (item, (GByteArray *) ssid);
 
 	dev_caps = nm_device_wifi_get_capabilities (device);
+	gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
 	nm_network_menu_item_set_detail (item, ap, nma_icon_check_and_load ("nm-adhoc", applet), dev_caps);
 	nm_network_menu_item_best_strength (item, nm_access_point_get_strength (ap), applet);
 	nm_network_menu_item_add_dupe (item, ap);
@@ -1081,6 +1081,7 @@ access_point_added_cb (NMDeviceWifi *device,
 	                  applet);
 	
 	queue_avail_access_point_notification (NM_DEVICE (device));
+	applet_schedule_update_menu (applet);
 }
 
 static void
@@ -1098,6 +1099,7 @@ access_point_removed_cb (NMDeviceWifi *device,
 	if (old == ap) {
 		g_object_set_data (G_OBJECT (device), ACTIVE_AP_TAG, NULL);
 		applet_schedule_update_icon (applet);
+		applet_schedule_update_menu (applet);
 	}
 }
 
diff --git a/src/applet-device-wimax.c b/src/applet-device-wimax.c
index 1741b2f..a23cecd 100644
--- a/src/applet-device-wimax.c
+++ b/src/applet-device-wimax.c
@@ -296,7 +296,10 @@ wimax_add_menu_item (NMDevice *device,
 static void
 nsp_quality_changed (NMWimaxNsp *nsp, GParamSpec *pspec, gpointer user_data)
 {
-	applet_schedule_update_icon (NM_APPLET (user_data));
+	NMApplet *applet = NM_APPLET (user_data);
+
+	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 static NMWimaxNsp *
@@ -358,8 +361,11 @@ active_nsp_changed_cb (NMDeviceWimax *device,
 	if (!s_wimax)
 		return;
 
-	if (g_strcmp0 (nm_wimax_nsp_get_name (new), nm_setting_wimax_get_network_name (s_wimax)) != 0)
-		applet_schedule_update_icon (applet);
+	if (g_strcmp0 (nm_wimax_nsp_get_name (new), nm_setting_wimax_get_network_name (s_wimax)) == 0)
+		return;
+
+	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 static void
@@ -367,15 +373,16 @@ nsp_removed_cb (NMDeviceWimax *device,
                 NMWimaxNsp *nsp,
                 gpointer user_data)
 {
-	NMApplet *applet = NM_APPLET  (user_data);
-	NMWimaxNsp *old;
+	NMApplet *applet = NM_APPLET (user_data);
+
+	/* Ignore unkown nsp */
+	if (g_object_get_data (G_OBJECT (device), ACTIVE_NSP_TAG) != nsp)
+		return;
 
 	/* Clear the ACTIVE_NSP_TAG if the active NSP just got removed */
-	old = g_object_get_data (G_OBJECT (device), ACTIVE_NSP_TAG);
-	if (old == nsp) {
-		g_object_set_data (G_OBJECT (device), ACTIVE_NSP_TAG, NULL);
-		applet_schedule_update_icon (applet);
-	}
+	g_object_set_data (G_OBJECT (device), ACTIVE_NSP_TAG, NULL);
+	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 static void
diff --git a/src/applet.c b/src/applet.c
index 39ea8e4..be4b68d 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -570,6 +570,8 @@ add_and_activate_cb (NMClient *client,
                      GError *error,
                      gpointer user_data)
 {
+	NMApplet *applet = NM_APPLET (user_data);
+
 	if (error) {
 		const char *text = _("Failed to add/activate connection");
 		char *err_text = g_strdup_printf ("(%d) %s", error->code,
@@ -580,7 +582,8 @@ add_and_activate_cb (NMClient *client,
 		g_free (err_text);
 	}
 
-	applet_schedule_update_icon (NM_APPLET (user_data));
+	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 static void
@@ -614,6 +617,8 @@ applet_menu_item_activate_helper_new_connection (NMConnection *connection,
 static void
 disconnect_cb (NMDevice *device, GError *error, gpointer user_data)
 {
+	NMApplet *applet = NM_APPLET (user_data);
+
 	if (error) {
 		const char *text = _("Device disconnect failed");
 		char *err_text = g_strdup_printf ("(%d) %s", error->code,
@@ -623,6 +628,9 @@ disconnect_cb (NMDevice *device, GError *error, gpointer user_data)
 		utils_show_error_dialog (_("Disconnect failure"), text, err_text, FALSE, NULL);
 		g_free (err_text);
 	}
+
+	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 void
@@ -631,7 +639,7 @@ applet_menu_item_disconnect_helper (NMDevice *device,
 {
 	g_return_if_fail (NM_IS_DEVICE (device));
 
-	nm_device_disconnect (device, disconnect_cb, NULL);
+	nm_device_disconnect (device, disconnect_cb, applet);
 }
 
 static void
@@ -701,6 +709,9 @@ applet_menu_item_add_complex_separator_helper (GtkWidget *menu,
                                                NMApplet *applet,
                                                const gchar* label)
 {
+#ifdef ENABLE_INDICATOR
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
+#else
 	GtkWidget *menu_item = gtk_image_menu_item_new ();
 	GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 	GtkWidget *xlabel = NULL;
@@ -720,6 +731,7 @@ applet_menu_item_add_complex_separator_helper (GtkWidget *menu,
 	              "sensitive", FALSE,
 	              NULL);
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+#endif
 }
 
 GtkWidget *
@@ -727,14 +739,14 @@ applet_new_menu_item_helper (NMConnection *connection,
                              NMConnection *active,
                              gboolean add_active)
 {
-	GtkWidget *item;
-	NMSettingConnection *s_con;
-	char *markup;
-	GtkWidget *label;
+	NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
+	GtkWidget *item = gtk_image_menu_item_new_with_label ("");
 
-	s_con = nm_connection_get_setting_connection (connection);
-	item = gtk_image_menu_item_new_with_label ("");
+#ifndef ENABLE_INDICATOR
 	if (add_active && (active == connection)) {
+		char *markup;
+		GtkWidget *label;
+
 		/* Pure evil */
 		label = gtk_bin_get_child (GTK_BIN (item));
 		gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
@@ -742,12 +754,14 @@ applet_new_menu_item_helper (NMConnection *connection,
 		gtk_label_set_markup (GTK_LABEL (label), markup);
 		g_free (markup);
 	} else
+#endif
 		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);
 	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 )
@@ -811,6 +825,7 @@ menu_title_item_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 	menu_item_draw_generic (widget, cr);
 	return TRUE;
 }
+#endif /* ENABLE_INDICATOR */
 
 GtkWidget *
 applet_menu_item_create_device_item_helper (NMDevice *device,
@@ -821,7 +836,9 @@ applet_menu_item_create_device_item_helper (NMDevice *device,
 
 	item = gtk_menu_item_new_with_label (text);
 	gtk_widget_set_sensitive (item, FALSE);
+#ifndef ENABLE_INDICATOR
 	g_signal_connect (item, "draw", G_CALLBACK (menu_title_item_draw), NULL);
+#endif
 	return item;
 }
 
@@ -879,8 +896,13 @@ applet_do_notify (NMApplet *applet,
 	g_return_if_fail (summary != NULL);
 	g_return_if_fail (message != NULL);
 
+#ifdef ENABLE_INDICATOR
+	if (app_indicator_get_status (applet->app_indicator) == APP_INDICATOR_STATUS_PASSIVE)
+		return;
+#else
 	if (!gtk_status_icon_is_embedded (applet->status_icon))
 		return;
+#endif
 
 	/* if we're not acting as a secret agent, don't notify either */
 	if (!applet->agent)
@@ -1159,6 +1181,7 @@ vpn_connection_state_changed (NMVPNConnection *vpn,
 		clear_animation_timeout (applet);
 
 	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 static const char *
@@ -1214,10 +1237,15 @@ activate_vpn_cb (NMClient *client,
 	}
 
 	applet_schedule_update_icon (info->applet);
+	applet_schedule_update_menu (info->applet);
 	g_free (info->vpn_name);
 	g_free (info);
 }
 
+#ifdef ENABLE_INDICATOR
+static void nma_menu_disconnect_vpn_item_activate (GtkMenuItem *item, gpointer user_data);
+#endif
+
 static void
 nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
 {
@@ -1240,9 +1268,13 @@ nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
 		return;
 	}
 
-	if (applet_get_active_for_connection (applet, connection))
+	if (applet_get_active_for_connection (applet, connection)) {
+#ifdef ENABLE_INDICATOR
+		nma_menu_disconnect_vpn_item_activate (item, applet);
+#endif
 		/* Connection already active; do nothing */
 		return;
+	}
 
 	s_con = nm_connection_get_setting_connection (connection);
 	info = g_malloc0 (sizeof (VPNActivateInfo));
@@ -1788,6 +1820,7 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
 	item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_VPN Connections")));
 	gtk_menu_item_set_submenu (item, GTK_WIDGET (vpn_menu));
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
+	gtk_widget_show (GTK_WIDGET (item));
 
 	list = get_vpn_connections (applet);
 	for (iter = list; iter; iter = g_slist_next (iter)) {
@@ -1801,13 +1834,11 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
 		NMConnection *connection = NM_CONNECTION (iter->data);
 		NMActiveConnection *active;
 		const char *name;
-		GtkWidget *image;
 		NMState state;
 
 		name = get_connection_id (connection);
 
-		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);
+		item = GTK_MENU_ITEM (gtk_check_menu_item_new_with_label (name));
 
 		/* If no VPN connections are active, draw all menu items enabled. If
 		 * >= 1 VPN connections are active, only the active VPN menu item is
@@ -1825,10 +1856,7 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
 		else
 			gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
 
-		if (active) {
-			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);
-		}
+		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), !!active);
 
 		g_object_set_data_full (G_OBJECT (item), "connection", 
 						    g_object_ref (connection),
@@ -1836,6 +1864,7 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
 
 		g_signal_connect (item, "activate", G_CALLBACK (nma_menu_vpn_item_clicked), applet);
 		gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item));
+		gtk_widget_show (GTK_WIDGET (item));
 	}
 
 	/* Draw a seperator, but only if we have VPN connections above it */
@@ -1845,12 +1874,14 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
 	item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Configure VPN...")));
 	g_signal_connect (item, "activate", G_CALLBACK (nma_menu_configure_vpn_item_activate), applet);
 	gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item));
+	gtk_widget_show (GTK_WIDGET (item));
 
 	item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Disconnect VPN")));
 	g_signal_connect (item, "activate", G_CALLBACK (nma_menu_disconnect_vpn_item_activate), applet);
 	gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item));
 	if (num_vpn_active == 0)
 		gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
+	gtk_widget_show (GTK_WIDGET (item));
 
 	g_slist_free (list);
 }
@@ -1901,6 +1932,7 @@ nma_set_networking_enabled_cb (GtkWidget *widget, NMApplet *applet)
 }
 
 
+#ifndef ENABLE_INDICATOR
 static void
 nma_set_notifications_enabled_cb (GtkWidget *widget, NMApplet *applet)
 {
@@ -1923,6 +1955,7 @@ nma_set_notifications_enabled_cb (GtkWidget *widget, NMApplet *applet)
 	                        PREF_SUPPRESS_WIFI_NETWORKS_AVAILABLE,
 	                        !state);
 }
+#endif /* ENABLE_INDICATOR */
 
 static gboolean
 has_usable_wifi (NMApplet *applet)
@@ -1959,7 +1992,9 @@ static void nma_menu_show_cb (GtkWidget *menu, NMApplet *applet)
 	g_return_if_fail (menu != NULL);
 	g_return_if_fail (applet != NULL);
 
+#ifndef ENABLE_INDICATOR
 	gtk_status_icon_set_tooltip_text (applet->status_icon, NULL);
+#endif
 
 	if (!nm_client_get_manager_running (applet->nm_client)) {
 		nma_menu_add_text_item (menu, _("NetworkManager is not running..."));
@@ -1981,11 +2016,14 @@ static void nma_menu_show_cb (GtkWidget *menu, NMApplet *applet)
 		nma_menu_add_create_network_item (menu, applet);
 	}
 
+#ifndef ENABLE_INDICATOR
 	gtk_widget_show_all (menu);
+#endif
 
 //	nmi_dbus_signal_user_interface_activated (applet->connection);
 }
 
+#ifndef ENABLE_INDICATOR
 static gboolean
 destroy_old_menu (gpointer user_data)
 {
@@ -2007,6 +2045,7 @@ nma_menu_deactivate_cb (GtkWidget *widget, NMApplet *applet)
 	/* Re-set the tooltip */
 	gtk_status_icon_set_tooltip_text (applet->status_icon, applet->tip);
 }
+#endif
 
 static gboolean
 is_permission_yes (NMApplet *applet, NMClientPermission perm)
@@ -2032,7 +2071,9 @@ nma_context_menu_update (NMApplet *applet)
 	gboolean wifi_hw_enabled;
 	gboolean wwan_hw_enabled;
 	gboolean wimax_hw_enabled;
+#ifndef ENABLE_INDICATOR
 	gboolean notifications_enabled = TRUE;
+#endif
 	gboolean sensitive = FALSE;
 
 	state = nm_client_get_state (applet->nm_client);
@@ -2092,6 +2133,7 @@ nma_context_menu_update (NMApplet *applet)
 	gtk_widget_set_sensitive (GTK_WIDGET (applet->wimax_enabled_item),
 	                          wimax_hw_enabled && is_permission_yes (applet, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX));
 
+#ifndef ENABLE_INDICATOR
 	/* Enabled notifications */
 	g_signal_handler_block (G_OBJECT (applet->notifications_enabled_item),
 	                        applet->notifications_enabled_toggled_id);
@@ -2103,6 +2145,7 @@ nma_context_menu_update (NMApplet *applet)
 	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 wifi is off */
 	if (state != NM_STATE_ASLEEP) {
@@ -2178,7 +2221,9 @@ applet_connection_info_cb (NMApplet *applet)
 static GtkWidget *nma_context_menu_create (NMApplet *applet)
 {
 	GtkMenuShell *menu;
+#ifndef ENABLE_INDICATOR
 	GtkWidget *menu_item;
+#endif
 	GtkWidget *image;
 	guint id;
 
@@ -2224,6 +2269,7 @@ static GtkWidget *nma_context_menu_create (NMApplet *applet)
 
 	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,
@@ -2234,6 +2280,7 @@ static GtkWidget *nma_context_menu_create (NMApplet *applet)
 	gtk_menu_shell_append (menu, applet->notifications_enabled_item);
 
 	nma_menu_add_separator_item (GTK_WIDGET (menu));
+#endif
 
 	/* 'Connection Information' item */
 	applet->info_menu_item = gtk_image_menu_item_new_with_mnemonic (_("Connection _Information"));
@@ -2258,6 +2305,7 @@ static GtkWidget *nma_context_menu_create (NMApplet *applet)
 	/* Separator */
 	nma_menu_add_separator_item (GTK_WIDGET (menu));
 
+#ifndef ENABLE_INDICATOR
 #if 0	/* FIXME: Implement the help callback, nma_help_cb()! */
 	/* Help item */
 	menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Help"));
@@ -2274,6 +2322,7 @@ static GtkWidget *nma_context_menu_create (NMApplet *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));
 
@@ -2376,16 +2425,50 @@ applet_add_default_connection_item (NMDevice *device,
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 }
 
+#ifdef ENABLE_INDICATOR
+static gboolean
+applet_update_indicator_menu (gpointer user_data)
+{
+	NMApplet *applet = NM_APPLET (user_data);
+	GtkWidget *menu = nma_context_menu_create (applet);
+
+	nma_menu_show_cb (menu, applet);
+	nma_menu_add_separator_item (menu);
+	nma_context_menu_update (applet);
+
+	app_indicator_set_menu (applet->app_indicator, GTK_MENU (menu));
+
+	applet->update_menu_id = 0;
+	return FALSE;
+}
+#endif /* ENABLE_INDICATOR */
+
+void
+applet_schedule_update_menu (NMApplet *applet)
+{
+#ifdef ENABLE_INDICATOR
+	if (!applet->update_menu_id)
+		applet->update_menu_id = g_idle_add (applet_update_indicator_menu, applet);
+#endif
+}
 
 /*****************************************************************************/
 
 static void
 foo_set_icon (NMApplet *applet, guint32 layer, GdkPixbuf *pixbuf, char *icon_name)
 {
-	int i;
-
 	g_return_if_fail (layer == ICON_LAYER_LINK || layer == ICON_LAYER_VPN);
 
+#ifdef ENABLE_INDICATOR
+	/* FIXME: We rely on the fact that VPN icon gets drawn later and therefore
+	 * wins but we cannot currently set a combined pixmap made of both the link
+	 * icon and the VPN icon.
+	 */
+	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->app_indicator), icon_name) != 0)
+		app_indicator_set_icon_full (applet->app_indicator, icon_name, applet->tip);
+#else
 	/* Ignore setting of the same icon as is already displayed */
 	if (applet->icon_layers[layer] == pixbuf)
 		return;
@@ -2414,10 +2497,12 @@ foo_set_icon (NMApplet *applet, guint32 layer, GdkPixbuf *pixbuf, char *icon_nam
 							  0, 0, 1.0, 1.0,
 							  GDK_INTERP_NEAREST, 255);
 		}
-	}
+	} else
+		pixbuf = g_object_ref (nma_icon_check_and_load ("nm-no-connection", applet));
 
 	gtk_status_icon_set_from_pixbuf (applet->status_icon, pixbuf);
 	g_object_unref (pixbuf);
+#endif
 }
 
 NMRemoteConnection *
@@ -2525,6 +2610,7 @@ foo_device_state_changed_cb (NMDevice *device,
 	}
 
 	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 static void
@@ -2568,7 +2654,19 @@ foo_client_state_changed_cb (NMClient *client, GParamSpec *pspec, gpointer user_
 	}
 
 	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_manager_running_cb (NMClient *client,
@@ -2585,6 +2683,7 @@ foo_manager_running_cb (NMClient *client,
 	}
 
 	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 #define VPN_STATE_ID_TAG "vpn-state-id"
@@ -2614,6 +2713,7 @@ foo_active_connections_changed_cb (NMClient *client,
 	}
 
 	applet_schedule_update_icon (applet);
+	applet_schedule_update_menu (applet);
 }
 
 static void
@@ -2664,6 +2764,11 @@ foo_client_setup (NMApplet *applet)
 	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);
@@ -2936,7 +3041,11 @@ applet_update_icon (gpointer user_data)
 	if (!nm_running)
 		state = NM_STATE_UNKNOWN;
 
+#ifdef ENABLE_INDICATOR
+	app_indicator_set_status (applet->app_indicator, nm_running ? APP_INDICATOR_STATUS_ACTIVE : APP_INDICATOR_STATUS_PASSIVE);
+#else
 	gtk_status_icon_set_visible (applet->status_icon, applet->visible);
+#endif
 
 	switch (state) {
 	case NM_STATE_UNKNOWN:
@@ -3005,7 +3114,13 @@ applet_update_icon (gpointer user_data)
 	/* update tooltip */
 	g_free (applet->tip);
 	applet->tip = g_strdup (vpn_tip ? vpn_tip : dev_tip);
+#ifdef ENABLE_INDICATOR
+	/* FIXME: The applet->tip attribute seems to only be picked up by
+	 * the next call to foo_set_icon() which is not particularly nice.
+	 */
+#else
 	gtk_status_icon_set_tooltip_text (applet->status_icon, applet->tip);
+#endif
 	g_free (vpn_tip);
 	g_free (dev_tip);
 
@@ -3279,13 +3394,13 @@ GdkPixbuf *
 nma_icon_check_and_load (const char *name, NMApplet *applet)
 {
 	GError *error = NULL;
-	GdkPixbuf *icon = g_hash_table_lookup (applet->icon_cache, name);
+	GdkPixbuf *icon;
 
 	g_assert (name != NULL);
 	g_assert (applet != NULL);
 
 	/* icon already loaded successfully */
-	if (icon)
+	if ((icon = g_hash_table_lookup (applet->icon_cache, name)))
 		return icon;
 
 	/* Try to load the icon; if the load fails, log the problem, and set
@@ -3349,26 +3464,22 @@ error:
 	return FALSE;
 }
 
-static void nma_icon_theme_changed (GtkIconTheme *icon_theme, NMApplet *applet)
-{
-	nma_icons_reload (applet);
-}
-
 static void nma_icons_init (NMApplet *applet)
 {
-	GdkScreen *screen;
 	gboolean path_appended;
 
 	if (applet->icon_theme) {
 		g_signal_handlers_disconnect_by_func (applet->icon_theme,
-						      G_CALLBACK (nma_icon_theme_changed),
+						      G_CALLBACK (nma_icons_reload),
 						      applet);
 		g_object_unref (G_OBJECT (applet->icon_theme));
 	}
 
-	screen = gtk_status_icon_get_screen (applet->status_icon);
-	g_assert (screen);
-	applet->icon_theme = gtk_icon_theme_get_for_screen (screen);
+#ifdef ENABLE_INDICATOR
+	applet->icon_theme = gtk_icon_theme_get_default ();
+#else
+	applet->icon_theme = gtk_icon_theme_get_for_screen (gtk_status_icon_get_screen (applet->status_icon));
+#endif
 
 	/* If not done yet, append our search path */
 	path_appended = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (applet->icon_theme),
@@ -3380,16 +3491,17 @@ static void nma_icons_init (NMApplet *applet)
 				   GINT_TO_POINTER (TRUE));
 	}
 
-	g_signal_connect (applet->icon_theme, "changed", G_CALLBACK (nma_icon_theme_changed), applet);
+	g_signal_connect (applet->icon_theme, "changed", G_CALLBACK (nma_icons_reload), applet);
 }
 
+#ifndef ENABLE_INDICATOR
 static void
 status_icon_screen_changed_cb (GtkStatusIcon *icon,
                                GParamSpec *pspec,
                                NMApplet *applet)
 {
 	nma_icons_init (applet);
-	nma_icon_theme_changed (NULL, applet);
+	nma_icons_reload (applet);
 }
 
 static gboolean
@@ -3454,15 +3566,20 @@ status_icon_popup_menu_cb (GtkStatusIcon *icon,
 			gtk_status_icon_position_menu, icon,
 			button, activate_time);
 }
+#endif /* ENABLE_INDICATOR */
 
 static gboolean
 setup_widgets (NMApplet *applet)
 {
-	g_return_val_if_fail (NM_IS_APPLET (applet), FALSE);
-
+#ifdef ENABLE_INDICATOR
+	applet->app_indicator = app_indicator_new
+				("nm-applet", "nm-no-connection",
+				 APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+	app_indicator_set_title(applet->app_indicator, _("Network"));
+	applet_schedule_update_menu (applet);
+#else
 	applet->status_icon = gtk_status_icon_new ();
-	if (!applet->status_icon)
-		return FALSE;
+
 	if (shell_debug)
 		gtk_status_icon_set_name (applet->status_icon, "adsfasdfasdfadfasdf");
 
@@ -3478,10 +3595,20 @@ setup_widgets (NMApplet *applet)
 	applet->context_menu = nma_context_menu_create (applet);
 	if (!applet->context_menu)
 		return FALSE;
+#endif
 
 	return TRUE;
 }
 
+#ifdef ENABLE_INDICATOR
+static void
+new_connection_cb (NMRemoteSettings *settings, NMRemoteConnection *connection, gpointer user_data)
+{
+	NMApplet *applet = NM_APPLET (user_data);
+
+	applet_schedule_update_menu (applet);
+}
+#else
 static void
 applet_embedded_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
 {
@@ -3490,6 +3617,7 @@ applet_embedded_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
 	g_debug ("applet now %s the notification area",
 	         embedded ? "embedded in" : "removed from");
 }
+#endif
 
 static void
 register_agent (NMApplet *applet)
@@ -3502,6 +3630,12 @@ register_agent (NMApplet *applet)
 	                  G_CALLBACK (applet_agent_get_secrets_cb), applet);
 	g_signal_connect (applet->agent, APPLET_AGENT_CANCEL_SECRETS,
 	                  G_CALLBACK (applet_agent_cancel_secrets_cb), applet);
+#ifdef ENABLE_INDICATOR
+	/* Watch for new connections */
+	g_signal_connect (applet->settings, "new-connection",
+	                  G_CALLBACK (new_connection_cb),
+	                  applet);
+#endif
 }
 
 static gboolean
@@ -3546,7 +3680,9 @@ applet_gsettings_show_changed (GSettings *settings,
 
 	applet->visible = g_settings_get_boolean (settings, key);
 
+#ifndef ENABLE_INDICATOR
 	gtk_status_icon_set_visible (applet->status_icon, applet->visible);
+#endif
 }
 
 static gboolean
@@ -3569,6 +3705,7 @@ initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
 	g_signal_connect (applet->gsettings, "changed::show-applet",
 	                  G_CALLBACK (applet_gsettings_show_changed), applet);
 
+	foo_client_setup (applet);
 
 	/* Load pixmaps and create applet widgets */
 	if (!setup_widgets (applet)) {
@@ -3648,18 +3785,18 @@ initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
 	applet->infiniband_class = applet_device_infiniband_get_class (applet);
 	g_assert (applet->infiniband_class);
 
-	foo_client_setup (applet);
-
 #if WITH_MODEM_MANAGER_1
 	mm1_client_setup (applet);
 #endif
 
+#ifndef ENABLE_INDICATOR
 	/* 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);
 	applet_embedded_cb (G_OBJECT (applet->status_icon), NULL, NULL);
+#endif
 
 	register_agent (applet);
 
@@ -3688,12 +3825,18 @@ static void finalize (GObject *object)
 	if (applet->update_icon_id)
 		g_source_remove (applet->update_icon_id);
 
-	if (applet->menu)
-		g_object_unref (applet->menu);
+#ifdef ENABLE_INDICATOR
+	g_clear_object (&applet->app_indicator);
+	if (applet->update_menu_id)
+		g_source_remove (applet->update_menu_id);
+#else
+	g_clear_object (&applet->status_icon);
+	g_clear_object (&applet->menu);
 	g_clear_pointer (&applet->icon_cache, g_hash_table_destroy);
-	nma_icons_free (applet);
-
+	g_clear_object (&applet->fallback_icon);
 	g_free (applet->tip);
+	nma_icons_free (applet);
+#endif
 
 	while (g_slist_length (applet->secrets_reqs))
 		applet_secrets_request_free ((SecretsRequest *) applet->secrets_reqs->data);
@@ -3703,45 +3846,24 @@ static void finalize (GObject *object)
 		g_object_unref (applet->notification);
 	}
 
-	if (applet->info_dialog_ui)
-		g_object_unref (applet->info_dialog_ui);
-
-	if (applet->gsettings)
-		g_object_unref (applet->gsettings);
-
-	if (applet->status_icon)
-		g_object_unref (applet->status_icon);
-
-	if (applet->nm_client)
-		g_object_unref (applet->nm_client);
+	g_clear_object (&applet->info_dialog_ui);
+	g_clear_object (&applet->gsettings);
+	g_clear_object (&applet->nm_client);
 
 #if WITH_MODEM_MANAGER_1
-	if (applet->mm1)
-		g_object_unref (applet->mm1);
+	g_clear_object (&applet->mm1);
 #endif
 
-	if (applet->fallback_icon)
-		g_object_unref (applet->fallback_icon);
-
-	if (applet->agent)
-		g_object_unref (applet->agent);
-
-	if (applet->settings)
-		g_object_unref (applet->settings);
-
-	if (applet->session_bus)
-		dbus_g_connection_unref (applet->session_bus);
+	g_clear_object (&applet->agent);
+	g_clear_object (&applet->settings);
+	g_clear_pointer (&applet->session_bus, dbus_g_connection_unref);
 
 	G_OBJECT_CLASS (nma_parent_class)->finalize (object);
 }
 
 static void nma_init (NMApplet *applet)
 {
-	applet->animation_id = 0;
-	applet->animation_step = 0;
-	applet->icon_theme = NULL;
-	applet->notification = NULL;
-	applet->icon_size = 16;
+	applet->icon_size = 40;
 }
 
 static void nma_class_init (NMAppletClass *klass)
diff --git a/src/applet.h b/src/applet.h
index 66ca945..649af35 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -36,6 +36,10 @@
 
 #include <libnotify/notify.h>
 
+#ifdef ENABLE_INDICATOR
+#include <libappindicator/app-indicator.h>
+#endif
+
 #include <nm-connection.h>
 #include <nm-client.h>
 #include <nm-access-point.h>
@@ -120,28 +124,37 @@ typedef struct
 
 	/* Data model elements */
 	guint			update_icon_id;
+	char *			tip;
 
-	GtkIconTheme *	icon_theme;
-	GHashTable *	icon_cache;
+	/* Animation stuff */
+	int				animation_step;
+	guint			animation_id;
 #define NUM_CONNECTING_FRAMES 11
 #define NUM_VPN_CONNECTING_FRAMES 14
+
+	GtkIconTheme *	icon_theme;
+	GHashTable *	icon_cache;
 	GdkPixbuf *		fallback_icon;
 
 	/* Active status icon pixbufs */
 	GdkPixbuf *		icon_layers[ICON_LAYER_MAX + 1];
 
-	/* Animation stuff */
-	int				animation_step;
-	guint			animation_id;
-
+	
 	/* Direct UI elements */
-	GtkStatusIcon * status_icon;
 	int             icon_size;
+#ifdef ENABLE_INDICATOR
+	AppIndicator *  app_indicator;
+	guint           update_menu_id;
+#else
+	GtkStatusIcon * status_icon;
 
 	GtkWidget *		menu;
-	char *          tip;
-
 	GtkWidget *		context_menu;
+
+	GtkWidget *		notifications_enabled_item;
+	guint			notifications_enabled_toggled_id;
+#endif
+
 	GtkWidget *		networking_enabled_item;
 	guint           networking_enabled_toggled_id;
 	GtkWidget *		wifi_enabled_item;
@@ -151,9 +164,6 @@ typedef struct
 	GtkWidget *		wimax_enabled_item;
 	guint           wimax_enabled_toggled_id;
 
-	GtkWidget *     notifications_enabled_item;
-	guint           notifications_enabled_toggled_id;
-
 	GtkWidget *		info_menu_item;
 	GtkWidget *		connections_menu_item;
 
@@ -244,6 +254,7 @@ GType nma_get_type (void);
 NMApplet *nm_applet_new (void);
 
 void applet_schedule_update_icon (NMApplet *applet);
+void applet_schedule_update_menu (NMApplet *applet);
 
 NMRemoteSettings *applet_get_settings (NMApplet *applet);
 
diff --git a/src/mb-menu-item.c b/src/mb-menu-item.c
index ee471e2..61d7d96 100644
--- a/src/mb-menu-item.c
+++ b/src/mb-menu-item.c
@@ -36,13 +36,17 @@ G_DEFINE_TYPE (NMMbMenuItem, nm_mb_menu_item, GTK_TYPE_IMAGE_MENU_ITEM);
 #define NM_MB_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MB_MENU_ITEM, NMMbMenuItemPrivate))
 
 typedef struct {
+#ifndef ENABLE_INDICATOR
 	GtkWidget *desc;
 	char *desc_string;
 	GtkWidget *strength;
 	guint32    int_strength;
 	GtkWidget *detail;
 	GtkWidget *hbox;
+#endif
 
+	char *desc_string;
+	guint32    int_strength;
 	gboolean   destroyed;
 } NMMbMenuItemPrivate;
 
@@ -80,6 +84,25 @@ get_tech_name (guint32 tech)
 	return NULL;
 }
 
+static void
+update_label (NMMbMenuItem *item, gboolean use_bold)
+{
+	NMMbMenuItemPrivate *priv = NM_MB_MENU_ITEM_GET_PRIVATE (item);
+
+#ifdef ENABLE_INDICATOR
+	gtk_menu_item_set_label (GTK_MENU_ITEM (item), priv->desc_string);
+#else
+	gtk_label_set_use_markup (GTK_LABEL (priv->desc), use_bold);
+	if (use_bold) {
+		char *markup = g_markup_printf_escaped ("<b>%s</b>", priv->desc_string);
+
+		gtk_label_set_markup (GTK_LABEL (priv->desc), markup);
+		g_free (markup);
+	} else
+		gtk_label_set_text (GTK_LABEL (priv->desc), priv->desc_string);
+#endif
+}
+
 GtkWidget *
 nm_mb_menu_item_new (const char *connection_name,
                      guint32 strength,
@@ -170,24 +193,26 @@ nm_mb_menu_item_new (const char *connection_name,
 		break;
 	}
 
-	if (enabled && connection_name && active) {
-		char *markup;
-
-		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);
-	}
+	update_label (item, (enabled && connection_name && active));
 
 	/* And the strength icon, if we have strength information at all */
-	if (enabled && strength) {
-		GdkPixbuf *pixbuf = nma_icon_check_and_load (mobile_helper_get_quality_icon_name (strength), applet);
-
+	if (enabled && strength) { 
+		const char *icon_name = mobile_helper_get_quality_icon_name (strength);
+		GdkPixbuf *pixbuf = nma_icon_check_and_load (icon_name, applet);
+
+#ifdef ENABLE_INDICATOR
+#ifdef DBUSMENU_PIXMAP_SUPPORT
+		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), gtk_image_new_from_pixbuf (pixbuf));
+#else
+		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
+		                               gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU));
+		pixbuf = NULL;
+#endif
+		/* For some reason we must always re-set always-show after setting the image */
+		gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+#else
 		gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), pixbuf);
+#endif
 	}
 
 	return GTK_WIDGET (item);
@@ -198,6 +223,7 @@ nm_mb_menu_item_new (const char *connection_name,
 static void
 nm_mb_menu_item_init (NMMbMenuItem *self)
 {
+#ifndef ENABLE_INDICATOR
 	NMMbMenuItemPrivate *priv = NM_MB_MENU_ITEM_GET_PRIVATE (self);
 
 	priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -213,11 +239,15 @@ nm_mb_menu_item_init (NMMbMenuItem *self)
 	gtk_widget_show (priv->desc);
 	gtk_widget_show (priv->strength);
 	gtk_widget_show (priv->hbox);
+#else
+	gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (self), TRUE);
+#endif
 }
 
 static void
-dispose (GObject *object)
+finalize (GObject *object)
 {
+#ifndef ENABLE_INDICATOR
 	NMMbMenuItem *self = NM_MB_MENU_ITEM (object);
 	NMMbMenuItemPrivate *priv = NM_MB_MENU_ITEM_GET_PRIVATE (self);
 
@@ -230,9 +260,11 @@ dispose (GObject *object)
 	gtk_widget_destroy (priv->desc);
 	gtk_widget_destroy (priv->strength);
 	gtk_widget_destroy (priv->hbox);
-	g_free (priv->desc_string);
 
 	G_OBJECT_CLASS (nm_mb_menu_item_parent_class)->dispose (object);
+#endif
+	g_free (NM_MB_MENU_ITEM_GET_PRIVATE (object)->desc_string);
+
 }
 
 static void
@@ -243,6 +275,6 @@ nm_mb_menu_item_class_init (NMMbMenuItemClass *klass)
 	g_type_class_add_private (klass, sizeof (NMMbMenuItemPrivate));
 
 	/* virtual methods */
-	object_class->dispose = dispose;
+	object_class->finalize = finalize;
 }
 
openSUSE Build Service is sponsored by