Index: configure.in
===================================================================
--- configure.in	(revision 1967)
+++ configure.in	(working copy)
@@ -46,8 +46,8 @@
 #
 # Gdk and Atk are needed for libtrayicon
 #
-GDK20_MINIMUM_VERSION=2.6.0
-GTK20_MINIMUM_VERSION=2.6.0
+GDK20_MINIMUM_VERSION=2.10.0
+GTK20_MINIMUM_VERSION=2.10.0
 ATK_MINIMUM_VERSION=1.2.4
 
 PKG_CHECK_MODULES(LIBTOMBOY, 
Index: libtomboy/Makefile.am
===================================================================
--- libtomboy/Makefile.am	(revision 1967)
+++ libtomboy/Makefile.am	(working copy)
@@ -19,9 +19,7 @@
 	tomboyutil.h		\
 	tomboyutil.c		\
 	eggaccelerators.h	\
-	eggaccelerators.c	\
-	eggtrayicon.h		\
-	eggtrayicon.c
+	eggaccelerators.c
 
 libtomboy_la_CFLAGS = $(X_CFLAGS)
 libtomboy_la_LDFLAGS = -export-dynamic -module -avoid-version
Index: Tomboy/Applet.cs
===================================================================
--- Tomboy/Applet.cs	(revision 1967)
+++ Tomboy/Applet.cs	(working copy)
@@ -1,6 +1,7 @@
 
 using System;
 using System.IO;
+using System.Text;
 using System.Reflection;
 using System.Runtime.InteropServices;
 using Mono.Unix;
@@ -14,7 +15,7 @@
 	public class TomboyApplet : PanelApplet
 	{
 		NoteManager manager;
-		TomboyTray tray;
+		TomboyAppletEventBox applet_event_box;
 		TomboyGConfXKeybinder keybinder;
 
 		// Keep referenced so our callbacks don't get reaped.
@@ -44,13 +45,13 @@
 			Logger.Log ("Applet Created...");
 
 			manager = Tomboy.DefaultNoteManager;
-			tray = new TomboyTray (manager);
-			keybinder = new TomboyGConfXKeybinder (manager, tray);
+			applet_event_box = new TomboyAppletEventBox (manager);
+			keybinder = new TomboyGConfXKeybinder (manager, applet_event_box);
 
 			Flags |= PanelAppletFlags.ExpandMinor;
 
-			Add (tray);
-			Tomboy.Tray = tray;
+			Add (applet_event_box);
+			Tomboy.AppletEventBox = applet_event_box;
 			OnChangeSize (Size);
 			ShowAll ();
 
@@ -104,137 +105,291 @@
 		                Gdk.Color                 color,
 		                Gdk.Pixmap                pixmap)
 		{
-			if (tray == null)
+			if (applet_event_box == null)
 				return;
 
 			Gtk.RcStyle rc_style = new Gtk.RcStyle ();
-			tray.Style = null;
-			tray.ModifyStyle (rc_style);
+			applet_event_box.Style = null;
+			applet_event_box.ModifyStyle (rc_style);
 
 			switch (type) {
 			case PanelAppletBackgroundType.ColorBackground:
-				tray.ModifyBg (Gtk.StateType.Normal, color);
+				applet_event_box.ModifyBg (Gtk.StateType.Normal, color);
 				break;
 			case PanelAppletBackgroundType.NoBackground:
 				break;
 			case PanelAppletBackgroundType.PixmapBackground:
-				Gtk.Style copy = tray.Style.Copy();
+				Gtk.Style copy = applet_event_box.Style.Copy();
 				copy.SetBgPixmap (Gtk.StateType.Normal, pixmap);
-				tray.Style = copy;
+				applet_event_box.Style = copy;
 				break;
 			}
 		}
 
 		protected override void OnChangeSize (uint size)
 		{
-			if (tray == null)
+			if (applet_event_box == null)
 				return;
 
-			tray.SetSizeRequest ((int) size, (int) size);
+			applet_event_box.SetSizeRequest ((int) size, (int) size);
 		}
 	}
-
-	public class TomboyTrayIcon : Gtk.Plug
+	
+	public enum PanelOrientation { Horizontal, Vertical };
+	
+	public class TomboyAppletEventBox : Gtk.EventBox
 	{
 		NoteManager manager;
 		TomboyTray tray;
-		TomboyGConfXKeybinder keybinder;
+		Gtk.Tooltips tips;
+		Gtk.Image image;
+		int panel_size;
 
-		[DllImport ("libtomboy")]
-		private static extern IntPtr egg_tray_icon_new (string name);
-
-		public TomboyTrayIcon ()
-: this (Tomboy.DefaultNoteManager)
+		public TomboyAppletEventBox (NoteManager manager)
+: base ()
 		{
-		}
-
-		public TomboyTrayIcon (NoteManager manager)
-		{
-			this.Raw = egg_tray_icon_new (Catalog.GetString ("Tomboy Notes"));
 			this.manager = manager;
+			tray = new TomboyTray (manager, this);
 
-			tray = new TomboyTray (manager);
-			tray.ButtonPressEvent += ButtonPress;
+			// Load a 16x16-sized icon to ensure we don't end up with a
+			// 1x1 pixel.
+			panel_size = 16;
+			this.image = new Gtk.Image (GuiUtils.GetIcon ("tomboy", panel_size));
 
-			keybinder = new TomboyGConfXKeybinder (manager, tray);
+			this.CanFocus = true;
+			this.ButtonPressEvent += ButtonPress;
+			this.Add (image);
+			this.ShowAll ();
 
-			Add (tray);
-			ShowAll ();
+			string tip_text = TomboyTrayUtils.GetToolTipText ();
+
+			tips = new Gtk.Tooltips ();
+			tips.SetTip (this, tip_text, null);
+			tips.Enable ();
+			tips.Sink ();
+
+			SetupDragAndDrop ();
 		}
 
 		void ButtonPress (object sender, Gtk.ButtonPressEventArgs args)
 		{
 			Gtk.Widget parent = (Gtk.Widget) sender;
 
-			if (args.Event.Button == 3) {
-				Gtk.Menu menu = MakeRightClickMenu (parent);
-				GuiUtils.PopupMenu (menu, args.Event);
+			switch (args.Event.Button) {
+			case 1:
+				TomboyTrayUtils.UpdateTomboyTrayMenu (tray, parent);
+				GuiUtils.PopupMenu (tray.TomboyTrayMenu, args.Event);
 				args.RetVal = true;
+				break;
+			case 2:
+				if ((bool) Preferences.Get (Preferences.ENABLE_ICON_PASTE)) {
+					// Give some visual feedback
+					Gtk.Drag.Highlight (this);
+					args.RetVal = PastePrimaryClipboard ();
+					Gtk.Drag.Unhighlight (this);
+				}
+				break;
 			}
 		}
 
-		Gtk.Menu MakeRightClickMenu (Gtk.Widget parent)
+		void PrependTimestampedText (Note note, DateTime timestamp, string text)
 		{
-			Gtk.Menu menu = new Gtk.Menu ();
-			menu.AttachToWidget (parent, GuiUtils.DetachMenu);
+			NoteBuffer buffer = note.Buffer;
+			StringBuilder insert_text = new StringBuilder ();
 
-			Gtk.AccelGroup accel_group = new Gtk.AccelGroup ();
-			menu.AccelGroup = accel_group;
+			insert_text.Append ("\n"); // initial newline
+			string date_format = Catalog.GetString ("dddd, MMMM d, h:mm tt");
+			insert_text.Append (timestamp.ToString (date_format));
+			insert_text.Append ("\n"); // begin content
+			insert_text.Append (text);
+			insert_text.Append ("\n"); // trailing newline
 
-			Gtk.ImageMenuItem item;
+			buffer.Undoer.FreezeUndo ();
 
-			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Preferences"));
-			item.Image = new Gtk.Image (Gtk.Stock.Preferences, Gtk.IconSize.Menu);
-			item.Activated += ShowPreferences;
-			menu.Append (item);
+			// Insert the date and list of links...
+			Gtk.TextIter cursor = buffer.StartIter;
+			cursor.ForwardLines (1); // skip title
 
-			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Help"));
-			item.Image = new Gtk.Image (Gtk.Stock.Help, Gtk.IconSize.Menu);
-			item.Activated += ShowHelpContents;
-			menu.Append (item);
+			buffer.Insert (ref cursor, insert_text.ToString ());
 
-			item = new Gtk.ImageMenuItem (Catalog.GetString ("_About Tomboy"));
-			item.Image = new Gtk.Image (Gtk.Stock.About, Gtk.IconSize.Menu);
-			item.Activated += ShowAbout;
-			menu.Append (item);
+			// Make the date string a small font...
+			cursor = buffer.StartIter;
+			cursor.ForwardLines (2); // skip title & leading newline
 
-			menu.Append (new Gtk.SeparatorMenuItem ());
+			Gtk.TextIter end = cursor;
+			end.ForwardToLineEnd (); // end of date
 
-			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Quit"));
-			item.Image = new Gtk.Image (Gtk.Stock.Quit, Gtk.IconSize.Menu);
-			item.Activated += Quit;
-			menu.Append (item);
+			buffer.ApplyTag ("datetime", cursor, end);
 
-			menu.ShowAll ();
-			return menu;
+			// Select the text we've inserted (avoid trailing newline)...
+			end = cursor;
+			end.ForwardChars (insert_text.Length - 1);
+
+			buffer.MoveMark (buffer.SelectionBound, cursor);
+			buffer.MoveMark (buffer.InsertMark, end);
+
+			buffer.Undoer.ThawUndo ();
 		}
 
-		void ShowPreferences (object sender, EventArgs args)
+		bool PastePrimaryClipboard ()
 		{
-			Tomboy.ActionManager ["ShowPreferencesAction"].Activate ();
+			Gtk.Clipboard clip = GetClipboard (Gdk.Selection.Primary);
+			string text = clip.WaitForText ();
+
+			if (text == null || text.Trim() == string.Empty)
+				return false;
+
+			Note link_note = manager.FindByUri (NoteManager.StartNoteUri);
+			if (link_note == null)
+				return false;
+
+			link_note.Window.Present ();
+			PrependTimestampedText (link_note,
+			                        DateTime.Now,
+			                        text);
+
+			return true;
 		}
 
-		void ShowHelpContents (object sender, EventArgs args)
+		// Used by TomboyApplet to modify the icon background.
+		public Gtk.Image Image
 		{
-			Tomboy.ActionManager ["ShowHelpAction"].Activate ();
+			get {
+				return image;
+			}
 		}
 
-		void ShowAbout (object sender, EventArgs args)
+		public void ShowMenu (bool select_first_item)
 		{
-			Tomboy.ActionManager ["ShowAboutAction"].Activate ();
+			TomboyTrayUtils.UpdateTomboyTrayMenu (tray, this);
+			if (select_first_item)
+				tray.TomboyTrayMenu.SelectFirst (false);
+
+			GuiUtils.PopupMenu (tray.TomboyTrayMenu, null);
 		}
 
-		void Quit (object sender, EventArgs args)
+		// Support dropping text/uri-lists and _NETSCAPE_URLs currently.
+		void SetupDragAndDrop ()
 		{
-			Tomboy.ActionManager ["QuitTomboyAction"].Activate ();
+			Gtk.TargetEntry [] targets =
+			new Gtk.TargetEntry [] {
+				new Gtk.TargetEntry ("text/uri-list", 0, 0),
+				new Gtk.TargetEntry ("_NETSCAPE_URL", 0, 0)
+			};
+
+			Gtk.Drag.DestSet (this,
+			                  Gtk.DestDefaults.All,
+			                  targets,
+			                  Gdk.DragAction.Copy);
+
+			DragDataReceived += OnDragDataReceived;
 		}
 
-		public TomboyTray TomboyTray
+		// Pop up Start Here and insert dropped links, in the form:
+		// Wednesday, December 8, 6:45 AM
+		// http://luna/kwiki/index.cgi?AdelaideUniThoughts
+		// http://www.beatniksoftware.com/blog/
+		// And select the inserted text.
+		//
+		// FIXME: Make undoable, make sure our date-sizing tag never "bleeds".
+		//
+		void OnDragDataReceived (object sender, Gtk.DragDataReceivedArgs args)
 		{
-			get {
-				return tray;
+			UriList uri_list = new UriList (args.SelectionData);
+			if (uri_list.Count == 0)
+				return;
+
+			StringBuilder insert_text = new StringBuilder ();
+			bool more_than_one = false;
+
+			foreach (Uri uri in uri_list) {
+				if (more_than_one)
+					insert_text.Append ("\n");
+
+				if (uri.IsFile)
+					insert_text.Append (uri.LocalPath);
+				else
+					insert_text.Append (uri.ToString ());
+
+				more_than_one = true;
 			}
+
+			Note link_note = manager.FindByUri (NoteManager.StartNoteUri);
+			if (link_note != null) {
+				link_note.Window.Present ();
+				PrependTimestampedText (link_note,
+				                        DateTime.Now,
+				                        insert_text.ToString ());
+			}
 		}
+
+		void InitPixbuf ()
+		{
+			// For some reason, the first time we ask for the allocation,
+			// it's a 1x1 pixel.  Prevent against this by returning a
+			// reasonable default.  Setting the icon causes OnSizeAllocated
+			// to be called again anyhow.
+			int icon_size = panel_size;
+			if (icon_size < 16)
+				icon_size = 16;
+
+
+			// Control specifically which icon is used at the smaller sizes
+			// so that no scaling occurs.  In the case of the panel applet,
+			// add a couple extra pixels of padding so it matches the behavior
+			// of the notification area tray icon.  See bug #403500 for more
+			// info.
+			if (Tomboy.IsPanelApplet)
+				icon_size = icon_size - 2; // padding
+			if (icon_size <= 21)
+				icon_size = 16;
+			else if (icon_size <= 31)
+				icon_size = 22;
+			else if (icon_size <= 47)
+				icon_size = 32;
+
+			Gdk.Pixbuf new_icon = GuiUtils.GetIcon ("tomboy", icon_size);
+			image.Pixbuf = new_icon;
+		}
+
+		///
+		/// Determine whether the tray is inside a horizontal or vertical
+		/// panel so the size of the icon can adjust correctly.
+		///
+		PanelOrientation GetPanelOrientation ()
+		{
+			if (this.ParentWindow == null) {
+				return PanelOrientation.Horizontal;
+			}
+
+			Gdk.Window top_level_window = this.ParentWindow.Toplevel;
+
+			Gdk.Rectangle rect = top_level_window.FrameExtents;
+			if (rect.Width < rect.Height)
+				return PanelOrientation.Vertical;
+
+			return PanelOrientation.Horizontal;
+		}
+
+		protected override void OnSizeAllocated (Gdk.Rectangle rect)
+		{
+			base.OnSizeAllocated (rect);
+
+			// Determine the orientation
+			if (GetPanelOrientation () == PanelOrientation.Horizontal) {
+				if (panel_size == Allocation.Height)
+					return;
+
+				panel_size = Allocation.Height;
+			} else {
+				if (panel_size == Allocation.Width)
+					return;
+
+				panel_size = Allocation.Width;
+			}
+
+			InitPixbuf ();
+		}
 	}
 }
 
Index: Tomboy/Utils.cs
===================================================================
--- Tomboy/Utils.cs	(revision 1967)
+++ Tomboy/Utils.cs	(working copy)
@@ -72,6 +72,20 @@
 				menu.AttachWidget.State = Gtk.StateType.Selected;
 		}
 
+		public static void PopupMenu (Gtk.Menu menu, Gdk.EventButton ev, Gtk.MenuPositionFunc mpf)
+		{
+			menu.Deactivated += DeactivateMenu;
+			menu.Popup (null,
+			            null,
+			            mpf,
+			            (ev == null) ? 0 : ev.Button,
+			            (ev == null) ? Gtk.Global.CurrentEventTime : ev.Time);
+
+			// Highlight the parent
+			if (menu.AttachWidget != null)
+				menu.AttachWidget.State = Gtk.StateType.Selected;
+		}
+
 		public static Gdk.Pixbuf GetIcon (string resource_name, int size)
 		{
 			return GetIcon (null, resource_name, size);
Index: Tomboy/Tomboy.cs
===================================================================
--- Tomboy/Tomboy.cs	(revision 1967)
+++ Tomboy/Tomboy.cs	(working copy)
@@ -12,7 +12,7 @@
 	{
 		static NoteManager manager;
 		static TomboyTrayIcon tray_icon;
-		static TomboyTray tomboy_tray = null;
+		static TomboyAppletEventBox applet_event_box = null;
 		static bool tray_icon_showing = false;
 		static bool is_panel_applet = false;
 		static PreferencesDialog prefs_dlg;
@@ -113,13 +113,12 @@
 		static void StartTrayIcon ()
 		{
 			// Create the tray icon and run the main loop
-			tray_icon = new TomboyTrayIcon (DefaultNoteManager);
+			tray_icon = new TomboyTrayIcon (manager);
 
 			// Give the TrayIcon 2 seconds to appear.  If it
 			// doesn't by then, open the SearchAllNotes window.
-			tray_icon.Embedded += TrayIconEmbedded;
-			GLib.Timeout.Add (2000, CheckTrayIconShowing);
-			tray_icon.Show ();
+			tray_icon_showing = tray_icon.Visible;
+			CheckTrayIconShowing ();
 
 			StartMainLoop ();
 		}
@@ -132,7 +131,7 @@
 			tray_icon_showing = true;
 		}
 
-		static bool CheckTrayIconShowing ()
+		static void CheckTrayIconShowing ()
 		{
 			// Check to make sure the tray icon is showing.  If it's not,
 			// it's likely that the Notification Area isn't available.  So
@@ -140,8 +139,6 @@
 			// can still use Tomboy.
 			if (tray_icon_showing == false)
 				ActionManager ["ShowSearchAllNotesAction"].Activate ();
-
-			return false; // prevent GLib.Timeout from calling this method again
 		}
 
 		static void RegisterRemoteControl (NoteManager manager)
@@ -246,10 +243,8 @@
 
 		static void OnShowHelpAction (object sender, EventArgs args)
 		{
-			// Pass in null for the screen when we're running as a panel applet
-			GuiUtils.ShowHelp("tomboy.xml", null,
-			                  tray_icon == null ? null : tray_icon.TomboyTray.Screen,
-			                  null);
+			GuiUtils.ShowHelp("tomboy.xml", null, null, null);
+
 		}
 
 		static void OnShowAboutAction (object sender, EventArgs args)
@@ -322,16 +317,13 @@
 			}
 		}
 
-		public static TomboyTray Tray
+		public static TomboyAppletEventBox AppletEventBox
 		{
 			get {
-				if (tray_icon != null)
-					return tray_icon.TomboyTray;
-				else
-					return tomboy_tray;
+				return applet_event_box;
 			}
 			set {
-				tomboy_tray = value;
+				applet_event_box = value;
 			}
 		}
 
Index: Tomboy/Tray.cs
===================================================================
--- Tomboy/Tray.cs	(revision 1967)
+++ Tomboy/Tray.cs	(working copy)
@@ -2,267 +2,165 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
-using System.Text;
 using Mono.Unix;
 using System.Runtime.InteropServices;
 
 namespace Tomboy
 {
-	public class NoteMenuItem : Gtk.ImageMenuItem
+	public class TomboyTrayIcon : Gtk.StatusIcon
 	{
-		Note note;
-		Gtk.Image pin_img;
-		bool pinned;
-		bool inhibit_activate;
+		TomboyTray tray;
+		TomboyGConfXKeybinder keybinder;
 
-		static Gdk.Pixbuf note_icon;
-		static Gdk.Pixbuf pinup;
-		static Gdk.Pixbuf pinup_active;
-		static Gdk.Pixbuf pindown;
+		public TomboyTrayIcon (NoteManager manager)
+		{
+			tray = new TomboyTray(manager, this);
+			keybinder = new TomboyGConfXKeybinder (manager, this);
+			int panel_size = 22;
+			Pixbuf = GuiUtils.GetIcon ("tomboy", panel_size);
 
-		static NoteMenuItem ()
+			Tooltip = TomboyTrayUtils.GetToolTipText ();
+		}
+		
+		protected override void OnActivate()
 		{
-			// Cache this since we use it a lot.
-			note_icon = GuiUtils.GetIcon ("note", 16);
-			pinup = GuiUtils.GetIcon ("pin-up", 16);
-			pinup_active = GuiUtils.GetIcon ("pin-active", 16);
-			pindown = GuiUtils.GetIcon ("pin-down", 16);
+			ShowMenu (false);
 		}
-
-		public NoteMenuItem (Note note, bool show_pin)
-: base (GetDisplayName(note))
+		
+		protected override void OnPopupMenu (uint button, uint activate_time)
 		{
-			this.note = note;
-			Image = new Gtk.Image (note_icon);
-
-			if (show_pin) {
-				Gtk.HBox box = new Gtk.HBox (false, 0);
-				Gtk.Widget child = Child;
-				Remove (child);
-				box.PackStart (child, true, true, 0);
-				Add (box);
-				box.Show();
-
-				pinned = note.IsPinned;
-				pin_img = new Gtk.Image(pinned ? pindown : pinup);
-				pin_img.Show();
-				box.PackStart (pin_img, false, false, 0);
-			}
+			if (button == 3)
+				GuiUtils.PopupMenu (MakeRightClickMenu (),
+				                    null, 
+				                    new Gtk.MenuPositionFunc (GetTrayMenuPosition));
+				
 		}
+		
+		public void ShowMenu (bool select_first_item)
+		{
+			TomboyTrayUtils.UpdateTomboyTrayMenu (tray, null);
+			if (select_first_item)
+				tray.TomboyTrayMenu.SelectFirst (false);
 
-		static string FormatForLabel (string name)
+			
+				
+			GuiUtils.PopupMenu (tray.TomboyTrayMenu, null, 
+				new Gtk.MenuPositionFunc (GetTrayMenuPosition));
+		}
+		
+		public void GetTrayMenuPosition (Gtk.Menu menu,
+		                             out int  x,
+		                             out int  y,
+		                             out bool push_in)
 		{
-			// Replace underscores ("_") with double-underscores ("__")
-			// so Note menuitems are not created with mnemonics.
-			return name.Replace ("_", "__");
+			// some default values in case something goes wrong
+			push_in = true;
+			x = 0;
+			y = 0;
+			
+			Gdk.Screen screen;
+			Gdk.Rectangle area;
+			Gtk.Orientation orientation;
+			GetGeometry (out screen, out area, out orientation);
+			
+			x = area.X;
+			y = area.Y;
+			
+			Gtk.Requisition menu_req = menu.SizeRequest ();
+			if (y + menu_req.Height >= screen.Height)
+				y -= menu_req.Height;
+			else
+				y += area.Height;
 		}
-
-		static string GetDisplayName (Note note)
+		
+		Gtk.Menu MakeRightClickMenu ()
 		{
-			string display_name = note.Title;
-            int max_length = 40;
+			Gtk.Menu menu = new Gtk.Menu ();
 
-			if (note.IsNew) {
-                string new_string = Catalog.GetString(" (new)");
-                max_length -= new_string.Length;
-				display_name = Ellipsify (display_name, max_length)
-                    + new_string;
-            } else {
-                display_name = Ellipsify (display_name, max_length);
-            }
+			Gtk.AccelGroup accel_group = new Gtk.AccelGroup ();
+			menu.AccelGroup = accel_group;
 
-			return FormatForLabel (display_name);
-		}
+			Gtk.ImageMenuItem item;
 
-        static string Ellipsify (string str, int max)
-        {
-            if(str.Length > max)
-                return str.Substring(0, max - 1) + "...";
-            return str;
-        }
+			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Preferences"));
+			item.Image = new Gtk.Image (Gtk.Stock.Preferences, Gtk.IconSize.Menu);
+			item.Activated += ShowPreferences;
+			menu.Append (item);
 
-		protected override void OnActivated ()
-		{
-			if (!inhibit_activate) {
-				if (note != null)
-					note.Window.Present ();
-			}
+			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Help"));
+			item.Image = new Gtk.Image (Gtk.Stock.Help, Gtk.IconSize.Menu);
+			item.Activated += ShowHelpContents;
+			menu.Append (item);
+
+			item = new Gtk.ImageMenuItem (Catalog.GetString ("_About Tomboy"));
+			item.Image = new Gtk.Image (Gtk.Stock.About, Gtk.IconSize.Menu);
+			item.Activated += ShowAbout;
+			menu.Append (item);
+
+			menu.Append (new Gtk.SeparatorMenuItem ());
+
+			item = new Gtk.ImageMenuItem (Catalog.GetString ("_Quit"));
+			item.Image = new Gtk.Image (Gtk.Stock.Quit, Gtk.IconSize.Menu);
+			item.Activated += Quit;
+			menu.Append (item);
+
+			menu.ShowAll ();
+			return menu;
 		}
 
-		protected override bool OnButtonPressEvent (Gdk.EventButton ev)
+		void ShowPreferences (object sender, EventArgs args)
 		{
-			if (pin_img != null &&
-			                ev.X >= pin_img.Allocation.X &&
-			                ev.X < pin_img.Allocation.X + pin_img.Allocation.Width) {
-				pinned = note.IsPinned = !pinned;
-				pin_img.Pixbuf = pinned ? pindown : pinup;
-				inhibit_activate = true;
-				return true;
-			}
-			return base.OnButtonPressEvent (ev);
+			Tomboy.ActionManager ["ShowPreferencesAction"].Activate ();
 		}
 
-		protected override bool OnButtonReleaseEvent (Gdk.EventButton ev)
+		void ShowHelpContents (object sender, EventArgs args)
 		{
-			if (inhibit_activate) {
-				inhibit_activate = false;
-				return true;
-			}
-			return base.OnButtonReleaseEvent (ev);
+			Tomboy.ActionManager ["ShowHelpAction"].Activate ();
 		}
 
-		protected override bool OnMotionNotifyEvent (Gdk.EventMotion ev)
+		void ShowAbout (object sender, EventArgs args)
 		{
-			if (!pinned && pin_img != null) {
-				if (ev.X >= pin_img.Allocation.X &&
-				                ev.X < pin_img.Allocation.X + pin_img.Allocation.Width) {
-					if (pin_img.Pixbuf != pinup_active)
-						pin_img.Pixbuf = pinup_active;
-				} else if (pin_img.Pixbuf != pinup) {
-					pin_img.Pixbuf = pinup;
-				}
-			}
-			return base.OnMotionNotifyEvent (ev);
+			Tomboy.ActionManager ["ShowAboutAction"].Activate ();
 		}
 
-		protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing ev)
+		void Quit (object sender, EventArgs args)
 		{
-			if (!pinned && pin_img != null) {
-				pin_img.Pixbuf = pinup;
-			}
-			return base.OnLeaveNotifyEvent (ev);
+			Tomboy.ActionManager ["QuitTomboyAction"].Activate ();
 		}
-	}
 
-	public enum PanelOrientation { Horizontal, Vertical };
-
-	public class TomboyTray : Gtk.EventBox
+	}
+	
+	public class TomboyTray
 	{
 		NoteManager manager;
-		Gtk.Tooltips tips;
-		Gtk.Image image;
-		Gtk.Menu recent_menu;
+		TomboyTrayIcon tray_icon = null;
+		TomboyAppletEventBox applet_event_box = null;
 		bool menu_added = false;
 		List<Gtk.MenuItem> recent_notes = new List<Gtk.MenuItem> ();
-		int panel_size;
-
-		public TomboyTray (NoteManager manager)
-: base ()
+		Gtk.Menu tray_menu;
+		
+		protected TomboyTray (NoteManager manager)
 		{
 			this.manager = manager;
-			// Load a 16x16-sized icon to ensure we don't end up with a
-			// 1x1 pixel.
-			panel_size = 16;
-			this.image = new Gtk.Image (GuiUtils.GetIcon ("tomboy", panel_size));
-
-			this.CanFocus = true;
-			this.ButtonPressEvent += ButtonPress;
-			this.Add (image);
-			this.ShowAll ();
-
-			string tip_text = Catalog.GetString ("Tomboy Notes");
-
-			if ((bool) Preferences.Get (Preferences.ENABLE_KEYBINDINGS)) {
-				string shortcut =
-				        GConfKeybindingToAccel.GetShortcut (
-				                Preferences.KEYBINDING_SHOW_NOTE_MENU);
-				if (shortcut != null)
-					tip_text += String.Format (" ({0})", shortcut);
-			}
-
-			tips = new Gtk.Tooltips ();
-			tips.SetTip (this, tip_text, null);
-			tips.Enable ();
-			tips.Sink ();
-
-			SetupDragAndDrop ();
-
-			recent_menu = MakeRecentNotesMenu ();
-			recent_menu.Hidden += MenuHidden;
+			
+			tray_menu = MakeTrayNotesMenu ();
+			tray_menu.Hidden += MenuHidden;
 		}
-
-		void ButtonPress (object sender, Gtk.ButtonPressEventArgs args)
+		
+		public TomboyTray (NoteManager manager, TomboyTrayIcon tray_icon)
+			: this (manager)
 		{
-			Gtk.Widget parent = (Gtk.Widget) sender;
-
-			switch (args.Event.Button) {
-			case 1:
-				UpdateRecentNotesMenu (parent);
-				GuiUtils.PopupMenu (recent_menu, args.Event);
-				args.RetVal = true;
-				break;
-			case 2:
-				if ((bool) Preferences.Get (Preferences.ENABLE_ICON_PASTE)) {
-					// Give some visual feedback
-					Gtk.Drag.Highlight (this);
-					args.RetVal = PastePrimaryClipboard ();
-					Gtk.Drag.Unhighlight (this);
-				}
-				break;
-			}
+			this.tray_icon = tray_icon;
 		}
-
-		void PrependTimestampedText (Note note, DateTime timestamp, string text)
+		
+		public TomboyTray (NoteManager manager, TomboyAppletEventBox applet_event_box)
+			: this (manager)
 		{
-			NoteBuffer buffer = note.Buffer;
-			StringBuilder insert_text = new StringBuilder ();
-
-			insert_text.Append ("\n"); // initial newline
-			string date_format = Catalog.GetString ("dddd, MMMM d, h:mm tt");
-			insert_text.Append (timestamp.ToString (date_format));
-			insert_text.Append ("\n"); // begin content
-			insert_text.Append (text);
-			insert_text.Append ("\n"); // trailing newline
-
-			buffer.Undoer.FreezeUndo ();
-
-			// Insert the date and list of links...
-			Gtk.TextIter cursor = buffer.StartIter;
-			cursor.ForwardLines (1); // skip title
-
-			buffer.Insert (ref cursor, insert_text.ToString ());
-
-			// Make the date string a small font...
-			cursor = buffer.StartIter;
-			cursor.ForwardLines (2); // skip title & leading newline
-
-			Gtk.TextIter end = cursor;
-			end.ForwardToLineEnd (); // end of date
-
-			buffer.ApplyTag ("datetime", cursor, end);
-
-			// Select the text we've inserted (avoid trailing newline)...
-			end = cursor;
-			end.ForwardChars (insert_text.Length - 1);
-
-			buffer.MoveMark (buffer.SelectionBound, cursor);
-			buffer.MoveMark (buffer.InsertMark, end);
-
-			buffer.Undoer.ThawUndo ();
+			this.applet_event_box = applet_event_box;
 		}
-
-		bool PastePrimaryClipboard ()
+		
+		Gtk.Menu MakeTrayNotesMenu ()
 		{
-			Gtk.Clipboard clip = GetClipboard (Gdk.Selection.Primary);
-			string text = clip.WaitForText ();
-
-			if (text == null || text.Trim() == string.Empty)
-				return false;
-
-			Note link_note = manager.FindByUri (NoteManager.StartNoteUri);
-			if (link_note == null)
-				return false;
-
-			link_note.Window.Present ();
-			PrependTimestampedText (link_note,
-			                        DateTime.Now,
-			                        text);
-
-			return true;
-		}
-
-		Gtk.Menu MakeRecentNotesMenu ()
-		{
 			Gtk.Menu menu =
 			        Tomboy.ActionManager.GetWidget ("/TrayIconMenu") as Gtk.Menu;
 
@@ -299,14 +197,23 @@
 
 			return menu;
 		}
-
+		
 		void MenuHidden (object sender, EventArgs args)
 		{
 			// Remove the old dynamic items
 			RemoveRecentlyChangedNotes ();
 		}
+		
+		void RemoveRecentlyChangedNotes ()
+		{
+			foreach (Gtk.Widget item in recent_notes) {
+				tray_menu.Remove (item);
+			}
 
-		void AddRecentlyChangedNotes ()
+			recent_notes.Clear ();
+		}
+		
+		public void AddRecentlyChangedNotes ()
 		{
 			int min_size = (int) Preferences.Get (Preferences.MENU_NOTE_COUNT);
 			int max_size = 18;
@@ -319,7 +226,7 @@
 			                                   "/TrayIconMenu/TrayNewNotePlaceholder/TrayNewNote") as Gtk.MenuItem;
 			Gtk.MenuItem searchNotesItem = Tomboy.ActionManager.GetWidget (
 			                                       "/TrayIconMenu/ShowSearchAllNotes") as Gtk.MenuItem;
-			recent_menu.ReorderChild (newNoteItem, 0);
+			tray_menu.ReorderChild (newNoteItem, 0);
 			int insertion_point = 1; // If menu opens downward
 			
 			// Find all child widgets under the TrayNewNotePlaceholder
@@ -332,12 +239,12 @@
 				if (child is Gtk.MenuItem &&
 				    child != newNoteItem) {
 					newNotePlaceholderWidgets.Add (child);
-					recent_menu.ReorderChild (child, insertion_point);
+					tray_menu.ReorderChild (child, insertion_point);
 					insertion_point++;
 				}
 			}
 			
-			recent_menu.ReorderChild (searchNotesItem, insertion_point);
+			tray_menu.ReorderChild (searchNotesItem, insertion_point);
 			insertion_point++;
 
 			DateTime days_ago = DateTime.Today.AddDays (-3);
@@ -345,7 +252,7 @@
 			// Prevent template notes from appearing in the menu
 			Tag template_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag);
 
-			// List the i most recently changed notes, any currently
+			// List the most recently changed notes, any currently
 			// opened notes, and any pinned notes...
 			foreach (Note note in manager.Notes) {
 				if (note.IsSpecial)
@@ -372,7 +279,7 @@
 				if (show) {
 					item = new NoteMenuItem (note, true);
 					// Add this widget to the menu (+insertion_point to add after new+search+...)
-					recent_menu.Insert (item, list_size + insertion_point);
+					tray_menu.Insert (item, list_size + insertion_point);
 					// Keep track of this item so we can remove it later
 					recent_notes.Add (item);
 
@@ -384,9 +291,9 @@
 			if (start != null) {
 				item = new NoteMenuItem (start, false);
 				if (menuOpensUpward)
-					recent_menu.Insert (item, list_size + insertion_point);
+					tray_menu.Insert (item, list_size + insertion_point);
 				else
-					recent_menu.Insert (item, insertion_point);
+					tray_menu.Insert (item, insertion_point);
 				recent_notes.Add (item);
 
 				list_size++;
@@ -404,184 +311,216 @@
 			if (menuOpensUpward) {
 				// Relocate common items to bottom of menu
 				insertion_point -= 1;
-				recent_menu.ReorderChild (searchNotesItem, list_size + insertion_point);
+				tray_menu.ReorderChild (searchNotesItem, list_size + insertion_point);
 				foreach (Gtk.Widget widget in newNotePlaceholderWidgets)
-					recent_menu.ReorderChild (widget, list_size + insertion_point);
-				recent_menu.ReorderChild (newNoteItem, list_size + insertion_point);
+					tray_menu.ReorderChild (widget, list_size + insertion_point);
+				tray_menu.ReorderChild (newNoteItem, list_size + insertion_point);
 				insertion_point = list_size;
 			}
 
 			Gtk.SeparatorMenuItem separator = new Gtk.SeparatorMenuItem ();
-			recent_menu.Insert (separator, insertion_point);
+			tray_menu.Insert (separator, insertion_point);
 			recent_notes.Add (separator);
 		}
-
+		
 		bool MenuOpensUpward ()
 		{
-			int x, y;
-			this.GdkWindow.GetOrigin (out x, out y);
-			return y > 100; // FIXME: This can be better, I'm sure
+			bool open_upwards = false;
+			int val = 0;
+			Gdk.Screen screen = null;
+			
+			if (applet_event_box != null) {
+				int x, y;
+				applet_event_box.GdkWindow.GetOrigin (out x, out y);
+				val = y;
+				screen = applet_event_box.Screen;
+			} else if (tray_icon != null) {
+				Gdk.Rectangle area;
+				Gtk.Orientation orientation;
+				tray_icon.GetGeometry(out screen, out area, out orientation);
+				val = area.Y;
+			}
+			
+			Gtk.Requisition menu_req = tray_menu.SizeRequest ();
+			if (val + menu_req.Height >= screen.Height)
+				open_upwards = true;
+
+			return open_upwards;
 		}
 
-		void RemoveRecentlyChangedNotes ()
+		public bool IsMenuAdded
 		{
-			foreach (Gtk.Widget item in recent_notes) {
-				recent_menu.Remove (item);
-			}
+			get { return menu_added; }
+			set { menu_added = value; }
+		}
 
-			recent_notes.Clear ();
+		public Gtk.Menu TomboyTrayMenu
+		{
+			get { return tray_menu; }
 		}
+		
+		public NoteManager NoteManager
+		{
+			get { return manager; }
+		}
+	}
+	
+	public class TomboyTrayUtils
+	{
+	
+		public static string GetToolTipText ()
+		{
+			string tip_text = Catalog.GetString ("Tomboy Notes");
 
-		void UpdateRecentNotesMenu (Gtk.Widget parent)
+			if ((bool) Preferences.Get (Preferences.ENABLE_KEYBINDINGS)) {
+				string shortcut =
+				        GConfKeybindingToAccel.GetShortcut (
+				                Preferences.KEYBINDING_SHOW_NOTE_MENU);
+				if (shortcut != null)
+					tip_text += String.Format (" ({0})", shortcut);
+			}
+			
+			return tip_text;
+		}
+		
+		public static void UpdateTomboyTrayMenu (TomboyTray tray, Gtk.Widget parent)
 		{
-			if (!menu_added) {
-				recent_menu.AttachToWidget (parent, GuiUtils.DetachMenu);
-				menu_added = true;
+			if (!tray.IsMenuAdded) {
+				if (parent != null)
+					tray.TomboyTrayMenu.AttachToWidget (parent, GuiUtils.DetachMenu);
+				tray.IsMenuAdded = true;
 			}
 
-			AddRecentlyChangedNotes ();
+			tray.AddRecentlyChangedNotes ();
 
-			recent_menu.ShowAll ();
+			tray.TomboyTrayMenu.ShowAll ();
 		}
+	
+	}
+	
+	public class NoteMenuItem : Gtk.ImageMenuItem
+	{
+		Note note;
+		Gtk.Image pin_img;
+		bool pinned;
+		bool inhibit_activate;
 
-		// Used by TomboyApplet to modify the icon background.
-		public Gtk.Image Image
+		static Gdk.Pixbuf note_icon;
+		static Gdk.Pixbuf pinup;
+		static Gdk.Pixbuf pinup_active;
+		static Gdk.Pixbuf pindown;
+
+		static NoteMenuItem ()
 		{
-			get {
-				return image;
-			}
+			// Cache this since we use it a lot.
+			note_icon = GuiUtils.GetIcon ("note", 16);
+			pinup = GuiUtils.GetIcon ("pin-up", 16);
+			pinup_active = GuiUtils.GetIcon ("pin-active", 16);
+			pindown = GuiUtils.GetIcon ("pin-down", 16);
 		}
 
-		public void ShowMenu (bool select_first_item)
+		public NoteMenuItem (Note note, bool show_pin)
+: base (GetDisplayName(note))
 		{
-			UpdateRecentNotesMenu (this);
-			if (select_first_item)
-				recent_menu.SelectFirst (false);
+			this.note = note;
+			Image = new Gtk.Image (note_icon);
 
-			GuiUtils.PopupMenu (recent_menu, null);
+			if (show_pin) {
+				Gtk.HBox box = new Gtk.HBox (false, 0);
+				Gtk.Widget child = Child;
+				Remove (child);
+				box.PackStart (child, true, true, 0);
+				Add (box);
+				box.Show();
+
+				pinned = note.IsPinned;
+				pin_img = new Gtk.Image(pinned ? pindown : pinup);
+				pin_img.Show();
+				box.PackStart (pin_img, false, false, 0);
+			}
 		}
 
-		// Support dropping text/uri-lists and _NETSCAPE_URLs currently.
-		void SetupDragAndDrop ()
+		static string FormatForLabel (string name)
 		{
-			Gtk.TargetEntry [] targets =
-			new Gtk.TargetEntry [] {
-				new Gtk.TargetEntry ("text/uri-list", 0, 0),
-				new Gtk.TargetEntry ("_NETSCAPE_URL", 0, 0)
-			};
-
-			Gtk.Drag.DestSet (this,
-			                  Gtk.DestDefaults.All,
-			                  targets,
-			                  Gdk.DragAction.Copy);
-
-			DragDataReceived += OnDragDataReceived;
+			// Replace underscores ("_") with double-underscores ("__")
+			// so Note menuitems are not created with mnemonics.
+			return name.Replace ("_", "__");
 		}
 
-		// Pop up Start Here and insert dropped links, in the form:
-		// Wednesday, December 8, 6:45 AM
-		// http://luna/kwiki/index.cgi?AdelaideUniThoughts
-		// http://www.beatniksoftware.com/blog/
-		// And select the inserted text.
-		//
-		// FIXME: Make undoable, make sure our date-sizing tag never "bleeds".
-		//
-		void OnDragDataReceived (object sender, Gtk.DragDataReceivedArgs args)
+		static string GetDisplayName (Note note)
 		{
-			UriList uri_list = new UriList (args.SelectionData);
-			if (uri_list.Count == 0)
-				return;
+			string display_name = note.Title;
+            int max_length = 40;
 
-			StringBuilder insert_text = new StringBuilder ();
-			bool more_than_one = false;
+			if (note.IsNew) {
+                string new_string = Catalog.GetString(" (new)");
+                max_length -= new_string.Length;
+				display_name = Ellipsify (display_name, max_length)
+                    + new_string;
+            } else {
+                display_name = Ellipsify (display_name, max_length);
+            }
 
-			foreach (Uri uri in uri_list) {
-				if (more_than_one)
-					insert_text.Append ("\n");
+			return FormatForLabel (display_name);
+		}
 
-				if (uri.IsFile)
-					insert_text.Append (uri.LocalPath);
-				else
-					insert_text.Append (uri.ToString ());
+        static string Ellipsify (string str, int max)
+        {
+            if(str.Length > max)
+                return str.Substring(0, max - 1) + "...";
+            return str;
+        }
 
-				more_than_one = true;
+		protected override void OnActivated ()
+		{
+			if (!inhibit_activate) {
+				if (note != null)
+					note.Window.Present ();
 			}
+		}
 
-			Note link_note = manager.FindByUri (NoteManager.StartNoteUri);
-			if (link_note != null) {
-				link_note.Window.Present ();
-				PrependTimestampedText (link_note,
-				                        DateTime.Now,
-				                        insert_text.ToString ());
+		protected override bool OnButtonPressEvent (Gdk.EventButton ev)
+		{
+			if (pin_img != null &&
+			                ev.X >= pin_img.Allocation.X &&
+			                ev.X < pin_img.Allocation.X + pin_img.Allocation.Width) {
+				pinned = note.IsPinned = !pinned;
+				pin_img.Pixbuf = pinned ? pindown : pinup;
+				inhibit_activate = true;
+				return true;
 			}
+			return base.OnButtonPressEvent (ev);
 		}
 
-		void InitPixbuf ()
+		protected override bool OnButtonReleaseEvent (Gdk.EventButton ev)
 		{
-			// For some reason, the first time we ask for the allocation,
-			// it's a 1x1 pixel.  Prevent against this by returning a
-			// reasonable default.  Setting the icon causes OnSizeAllocated
-			// to be called again anyhow.
-			int icon_size = panel_size;
-			if (icon_size < 16)
-				icon_size = 16;
-
-
-			// Control specifically which icon is used at the smaller sizes
-			// so that no scaling occurs.  In the case of the panel applet,
-			// add a couple extra pixels of padding so it matches the behavior
-			// of the notification area tray icon.  See bug #403500 for more
-			// info.
-			if (Tomboy.IsPanelApplet)
-				icon_size = icon_size - 2; // padding
-			if (icon_size <= 21)
-				icon_size = 16;
-			else if (icon_size <= 31)
-				icon_size = 22;
-			else if (icon_size <= 47)
-				icon_size = 32;
-
-			Gdk.Pixbuf new_icon = GuiUtils.GetIcon ("tomboy", icon_size);
-			image.Pixbuf = new_icon;
+			if (inhibit_activate) {
+				inhibit_activate = false;
+				return true;
+			}
+			return base.OnButtonReleaseEvent (ev);
 		}
 
-		///
-		/// Determine whether the tray is inside a horizontal or vertical
-		/// panel so the size of the icon can adjust correctly.
-		///
-		PanelOrientation GetPanelOrientation ()
+		protected override bool OnMotionNotifyEvent (Gdk.EventMotion ev)
 		{
-			if (this.ParentWindow == null) {
-				return PanelOrientation.Horizontal;
+			if (!pinned && pin_img != null) {
+				if (ev.X >= pin_img.Allocation.X &&
+				                ev.X < pin_img.Allocation.X + pin_img.Allocation.Width) {
+					if (pin_img.Pixbuf != pinup_active)
+						pin_img.Pixbuf = pinup_active;
+				} else if (pin_img.Pixbuf != pinup) {
+					pin_img.Pixbuf = pinup;
+				}
 			}
-
-			Gdk.Window top_level_window = this.ParentWindow.Toplevel;
-
-			Gdk.Rectangle rect = top_level_window.FrameExtents;
-			if (rect.Width < rect.Height)
-				return PanelOrientation.Vertical;
-
-			return PanelOrientation.Horizontal;
+			return base.OnMotionNotifyEvent (ev);
 		}
 
-		protected override void OnSizeAllocated (Gdk.Rectangle rect)
+		protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing ev)
 		{
-			base.OnSizeAllocated (rect);
-
-			// Determine the orientation
-			if (GetPanelOrientation () == PanelOrientation.Horizontal) {
-				if (panel_size == Allocation.Height)
-					return;
-
-				panel_size = Allocation.Height;
-			} else {
-				if (panel_size == Allocation.Width)
-					return;
-
-				panel_size = Allocation.Width;
+			if (!pinned && pin_img != null) {
+				pin_img.Pixbuf = pinup;
 			}
-
-			InitPixbuf ();
+			return base.OnLeaveNotifyEvent (ev);
 		}
 	}
 
Index: Tomboy/Addins/Tasks/TasksApplicationAddin.cs
===================================================================
--- Tomboy/Addins/Tasks/TasksApplicationAddin.cs	(revision 1967)
+++ Tomboy/Addins/Tasks/TasksApplicationAddin.cs	(working copy)
@@ -152,7 +152,7 @@
 			// Determine whether the icon is near the top/bottom of the screen
 			// TODO: Do this better!
 			int x, y;
-			Tomboy.Tray.GdkWindow.GetOrigin (out x, out y);
+			Tomboy.AppletEventBox.GdkWindow.GetOrigin (out x, out y);
 			int position;
 			if (y < 24)
 				position = 2;
Index: Tomboy/XKeybinder.cs
===================================================================
--- Tomboy/XKeybinder.cs	(revision 1967)
+++ Tomboy/XKeybinder.cs	(working copy)
@@ -195,19 +195,31 @@
 	public class TomboyGConfXKeybinder : GConfXKeybinder
 	{
 		NoteManager manager;
-		TomboyTray  tray;
+		TomboyAppletEventBox applet_event_box;
+		TomboyTrayIcon tray_icon;
 
-		public TomboyGConfXKeybinder (NoteManager manager, TomboyTray tray)
-: base ()
+		protected TomboyGConfXKeybinder (NoteManager manager)
+			: base ()
 		{
 			this.manager = manager;
-			this.tray = tray;
 
 			EnableDisable ((bool) Preferences.Get (Preferences.ENABLE_KEYBINDINGS));
 
 			Preferences.SettingChanged += EnableKeybindingsChanged;
 		}
+		
+		public TomboyGConfXKeybinder (NoteManager manager, TomboyTrayIcon tray_icon)
+			: this (manager)
+		{
+			this.tray_icon = tray_icon;
+		}
 
+		public TomboyGConfXKeybinder (NoteManager manager, TomboyAppletEventBox applet_event_box)
+			: this (manager)
+		{
+			this.applet_event_box = applet_event_box;
+		}
+		
 		void EnableKeybindingsChanged (object sender, GConf.NotifyEventArgs args)
 		{
 			if (args.Key == Preferences.ENABLE_KEYBINDINGS) {
@@ -251,7 +263,10 @@
 			// Show the notes menu, highlighting the first item.
 			// This matches the behavior of GTK for
 			// accelerator-shown menus.
-			tray.ShowMenu (true);
+			if (tray_icon != null) 
+				tray_icon.ShowMenu (true);
+			else if (applet_event_box != null) 
+				applet_event_box.ShowMenu (true);
 		}
 
 		void KeyOpenStartHere (object sender, EventArgs args)
