sillv0r
December 14th, 2007, 03:07 AM
I'm trying to have a menu pop-up from when the user right clicks on the status icon. The icon shows up fine in gnome but the menu doesn't show. The console write works, so i know the event is getting fired.
Perhaps this has to do with the click event being perform async to the gui thread? If so, anyone know a good solution?
namespace Tempo.Client
{
public class Program
{
public static void Main()
{
Gtk.Application.Init ();
//
// Creating status icon.
//
Program.notification = Gtk.StatusIcon.NewFromStock(Gtk.Stock.Info);
//
// Registering method for callback.
//
Program.notification.PopupMenu += Program.onRightClick;
//
// Creating menu and adding items to it.
//
Program.contextMenu = new Gtk.Menu();
Program.contextMenu.Add(new Gtk.MenuItem("option one"));
Program.contextMenu.Add(new Gtk.MenuItem("option two"));
Gtk.Application.Run ();
}
private static void onRightClick(object sender, Gtk.PopupMenuArgs evt)
{
System.Console.WriteLine("testing");
//
// Args[0] == button clicked && Args[1] == Active Time?
//
Program.notification.PresentMenu(Program.contextMe nu, (uint)evt.Args[0], (uint)evt.Args[1]);
}
private static Gtk.StatusIcon notification;
private static Gtk.Menu contextMenu;
}
}
EDIT: Gtk# 2.10
Perhaps this has to do with the click event being perform async to the gui thread? If so, anyone know a good solution?
namespace Tempo.Client
{
public class Program
{
public static void Main()
{
Gtk.Application.Init ();
//
// Creating status icon.
//
Program.notification = Gtk.StatusIcon.NewFromStock(Gtk.Stock.Info);
//
// Registering method for callback.
//
Program.notification.PopupMenu += Program.onRightClick;
//
// Creating menu and adding items to it.
//
Program.contextMenu = new Gtk.Menu();
Program.contextMenu.Add(new Gtk.MenuItem("option one"));
Program.contextMenu.Add(new Gtk.MenuItem("option two"));
Gtk.Application.Run ();
}
private static void onRightClick(object sender, Gtk.PopupMenuArgs evt)
{
System.Console.WriteLine("testing");
//
// Args[0] == button clicked && Args[1] == Active Time?
//
Program.notification.PresentMenu(Program.contextMe nu, (uint)evt.Args[0], (uint)evt.Args[1]);
}
private static Gtk.StatusIcon notification;
private static Gtk.Menu contextMenu;
}
}
EDIT: Gtk# 2.10