--- netapplet-1.0.8/src/netapplet.c	2006-11-21 00:32:35.000000000 -0500
+++ netapplet-1.0.8d/src/netapplet.c	2006-11-21 02:46:07.000000000 -0500
@@ -73,10 +73,7 @@
 	gboolean authorized;
 	gboolean active_scanning;
 
-	EggTrayIcon *tray_icon;
-	GtkWidget *button;
-	GtkWidget *icon;
-	GtkTooltips *tooltips;
+	GtkStatusIcon *tray_icon;
 	GtkWidget *popup_menu;
 	const char *default_keyring;
 	const char *icon_name;
@@ -102,53 +99,29 @@
 {
 	GdkPixbuf *pixbuf;
 	char *tip;
-	int panel_w;
 	int panel_h;
 	int icon_size;
 
-	gtk_window_get_size (
-		GTK_WINDOW (gtk_widget_get_toplevel (netapplet->button)),
-		&panel_w, &panel_h);
-
 	if (netapplet->icon_name != NULL &&
-	    strcmp (netapplet->icon_name, icon_name) == 0 &&
-	    panel_h == netapplet->last_panel_h)
+	    strcmp (netapplet->icon_name, icon_name) == 0)
 		return;
 
 	netapplet->icon_name = icon_name;
-	netapplet->last_panel_h = panel_h;
+	panel_h = gtk_status_icon_get_size (netapplet->tray_icon);
 
-	if (panel_h < 30)
+	/* Assuming that our users have a standard panel */
+	if (panel_h < 30 || !gtk_status_icon_is_embedded (netapplet->tray_icon))
 		icon_size = 16;
 	else
 		icon_size = 24;
+	g_print ("icon_name: %s; panel_h: %d; icon_size: %d\n\n", icon_name, panel_h, icon_size);
 
 	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
 					   icon_name, icon_size, 0, NULL);
 	
-	/*
-	 * Scale the icon rather than clip it if our allocation just isn't
-	 * what we want it to be.
-	 */
-	if (GTK_WIDGET_REALIZED (netapplet->icon) &&
-	    netapplet->icon->allocation.height < icon_size) {
-		int new_size = netapplet->icon->allocation.height;
-		GdkPixbuf *new_pixbuf;
-
-		new_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
-						      new_size, new_size,
-						      GDK_INTERP_BILINEAR);
-
-		g_object_unref (pixbuf);
-		pixbuf = new_pixbuf;
-	}
-
-	gtk_image_set_from_pixbuf (GTK_IMAGE (netapplet->icon), pixbuf);
+	gtk_status_icon_set_from_pixbuf (netapplet->tray_icon, pixbuf);
 	g_object_unref (pixbuf);
 
-	if (netapplet->tooltips == NULL)
-		netapplet->tooltips = gtk_tooltips_new ();
-
 	if (netapplet->active == NULL)
 		tip = g_strdup (_("Disconnected"));
 	else if (strcmp (netapplet->active->type, "Ethernet") == 0)
@@ -170,8 +143,7 @@
 		return; /* bleh */
 	}
 
-	gtk_tooltips_set_tip (netapplet->tooltips, netapplet->button,
-			      tip, NULL);
+	gtk_status_icon_set_tooltip (netapplet->tray_icon, tip);
 	g_free (tip);
 }
 
@@ -1272,43 +1244,6 @@
 }
 
 static void
-menu_position_func (GtkMenu *menu G_GNUC_UNUSED, int *x, int *y,
-		    gboolean *push_in, gpointer user_data G_GNUC_UNUSED)
-{
-	GdkScreen *screen;
-	int screen_w, screen_h;
-	int button_x, button_y;
-	int panel_w, panel_h;
-	GtkRequisition requisition;
-
-	screen = gtk_widget_get_screen (netapplet->button);
-	screen_w = gdk_screen_get_width (screen);
-	screen_h = gdk_screen_get_height (screen);
-
-	gdk_window_get_origin (netapplet->button->window,
-			       &button_x, &button_y);
-
-	gtk_window_get_size (
-		GTK_WINDOW (gtk_widget_get_toplevel (netapplet->button)),
-		&panel_w, &panel_h);
-
-	*x = button_x;
-
-	/*
-	 * Check to see if we would be placing the menu off the
-	 * end of the screen.
-	 */
-	gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
-	
-	if (button_y + panel_h + requisition.height >= screen_h)
-		*y = button_y - requisition.height;
-	else
-		*y = button_y + panel_h;
-
-	*push_in = TRUE;
-}
-
-static void
 active_scan_on (void)
 {
 	netapplet->active_scanning = TRUE;
@@ -1327,15 +1262,13 @@
 }
 
 static void
-button_toggled_cb (GtkToggleButton *button G_GNUC_UNUSED,
+tray_icon_activate_cb (GtkStatusIcon *status_icon G_GNUC_UNUSED,
 		   gpointer user_data G_GNUC_UNUSED)
 {
-	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (netapplet->button))) {
-		active_scan_on ();
-		gtk_menu_popup (GTK_MENU (netapplet->popup_menu), NULL, NULL,
-				menu_position_func, NULL, 0,
-				gtk_get_current_event_time ());
-	}
+	active_scan_on ();
+	gtk_menu_popup (GTK_MENU (netapplet->popup_menu), NULL, NULL,
+			NULL, NULL, 0,
+			gtk_get_current_event_time ());
 }
 
 static void
@@ -1343,8 +1276,6 @@
 		    gpointer user_data G_GNUC_UNUSED)
 {
 	active_scan_off ();
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (netapplet->button),
-				      FALSE);
 	gtk_menu_popdown (GTK_MENU (netapplet->popup_menu));
 }
 
@@ -1693,16 +1624,6 @@
 	}
 }
 
-static void
-size_changed_cb (void)
-{
-	if (netapplet->icon_name == NULL)
-		return;
-
-	/* If the panel changed size, we might need to change the icon. */
-	netapplet_set_icon (netapplet->icon_name);
-}
-
 static NetApplet *
 netapplet_new (void)
 {
@@ -1710,25 +1631,12 @@
 
 	/* Widgetry */
 	applet = g_new0 (NetApplet, 1);
-	applet->tray_icon = egg_tray_icon_new ("applet");
+	applet->tray_icon = gtk_status_icon_new ();
 
 	applet->active_scanning = FALSE;
 
-	applet->button = gtk_toggle_button_new ();
-	gtk_button_set_relief (GTK_BUTTON (applet->button),
-			       GTK_RELIEF_NONE);
-	gtk_container_add (GTK_CONTAINER (applet->tray_icon),
-			   applet->button);
-	gtk_widget_show (applet->button);
-
-	g_signal_connect (applet->button, "toggled",
-			  G_CALLBACK (button_toggled_cb), NULL);
-	g_signal_connect (applet->button, "size-allocate",
-			  G_CALLBACK (size_changed_cb), NULL);
-
-	applet->icon = gtk_image_new ();
-	gtk_container_add (GTK_CONTAINER (applet->button), applet->icon);
-	gtk_widget_show (applet->icon);
+	g_signal_connect (applet->tray_icon, "activate",
+			  G_CALLBACK (tray_icon_activate_cb), NULL);
 
 	applet->popup_menu = gtk_menu_new ();
 	g_signal_connect (applet->popup_menu, "deactivate",
@@ -1784,12 +1692,13 @@
 	}
 
 	netapplet = netapplet_new ();
-	netapplet_set_icon (DISCONNECT_ICON);
+	
 	populate_popup_menu ();
 
 	netapplet_connect ();
 
-	gtk_widget_show (GTK_WIDGET (netapplet->tray_icon));
+	gtk_status_icon_set_visible (netapplet->tray_icon, TRUE);
+	netapplet_set_icon (DISCONNECT_ICON);
 
 	gtk_main ();
 
