blam r671 - trunk/src



Author: cmartin
Date: Sun Mar  8 14:44:24 2009
New Revision: 671
URL: http://svn.gnome.org/viewvc/blam?rev=671&view=rev

Log:
Add a context menu to the tray icon.

Patch based on the one sent by regis <r floret laposte net>.

Modified:
   trunk/src/Application.cs
   trunk/src/TrayIcon.cs

Modified: trunk/src/Application.cs
==============================================================================
--- trunk/src/Application.cs	(original)
+++ trunk/src/Application.cs	Sun Mar  8 14:44:24 2009
@@ -212,6 +212,11 @@
 
             trayIcon = new TrayIcon (Catalog.GetString ("Blam News Reader"));
             trayIcon.ButtonPressEvent += TrayIconButtonPressCb;
+            trayIcon.RefreshAllEvent += RefreshAllActivated;
+            trayIcon.PreferencesEvent += PreferencesActivated;
+            trayIcon.AboutEvent += AboutActivated;
+            trayIcon.QuitEvent += QuitActivated;
+
             channelsLabelText = channelsLabel.Text;
             UpdateTotalNumberOfUnread ();
 

Modified: trunk/src/TrayIcon.cs
==============================================================================
--- trunk/src/TrayIcon.cs	(original)
+++ trunk/src/TrayIcon.cs	Sun Mar  8 14:44:24 2009
@@ -11,6 +11,12 @@
 namespace Imendio.Blam {
     public class TrayIcon {
     private Gtk.StatusIcon mIcon = null;
+	private Application mParent = null;
+
+	public event EventHandler RefreshAllEvent;
+	public event EventHandler PreferencesEvent;
+	public event EventHandler AboutEvent;
+	public event EventHandler QuitEvent;
 
 	public event EventHandler ButtonPressEvent;
 
@@ -22,10 +28,12 @@
 
 	public TrayIcon (string name)
 	{
+        mParent = Application.TheApp;
         mIcon = new Gtk.StatusIcon();
         mIcon.IconName = "blam";
         mIcon.Tooltip = name;
         mIcon.Activate += ButtonPressedCb;
+        mIcon.PopupMenu += PopupCb;
 	}
 	
     public void Hide()
@@ -44,6 +52,36 @@
 		this.ButtonPressEvent (o, args);
 	    }
 	}
-
+	/*
+	 * Create a popup menu
+	 */
+	public void PopupCb(object o, EventArgs args)
+	{
+		Gtk.Menu menu = new Gtk.Menu();
+		Gtk.ImageMenuItem refreshItem = new Gtk.ImageMenuItem("Refresh");
+		refreshItem.Image = new Gtk.Image(Stock.Refresh,IconSize.Menu);
+		refreshItem.Activated += RefreshAllEvent;
+
+		Gtk.ImageMenuItem prefItem = new Gtk.ImageMenuItem("Preferences...");
+		prefItem.Image = new Gtk.Image(Stock.Preferences,IconSize.Menu);
+		prefItem.Activated += PreferencesEvent;
+
+		Gtk.ImageMenuItem aboutItem = new Gtk.ImageMenuItem("About Blam!");
+		aboutItem.Image = new Gtk.Image(Stock.About,IconSize.Menu);
+		aboutItem.Activated += AboutEvent;
+
+		Gtk.ImageMenuItem quitItem = new Gtk.ImageMenuItem("Quit");
+		quitItem.Image = new Gtk.Image(Stock.Quit,IconSize.Menu);
+		quitItem.Activated += QuitEvent;
+
+		menu.Add(refreshItem);
+		menu.Add(prefItem);
+		menu.Add(new Gtk.SeparatorMenuItem());
+		menu.Add(aboutItem);
+		menu.Add(new Gtk.SeparatorMenuItem());
+		menu.Add(quitItem);
+		menu.ShowAll();
+		menu.Popup();
+	}
     }
 }



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