[Gtk-sharp-list] Why does my AppIndicator disappear when I create it outside of my main method?

Matthew Pirocchi matthew.pirocchi at gmail.com
Wed Aug 4 16:46:40 EDT 2010


I'm playing around with AppIndicator in Ubuntu Lucid. This code works:

public static void Main (string[] args)
{
Gtk.Application.Init ();

ApplicationIndicator indicator = new ApplicationIndicator ("gmail-notifier",
                                                            "gmail",

Category.ApplicationStatus);

Gtk.Menu menu = new Gtk.Menu ();
 Gtk.MenuItem testMenuItem = new Gtk.ImageMenuItem (Gtk.Stock.About, null);
 menu.Add (testMenuItem);
menu.ShowAll ();
 indicator.Menu = menu;
indicator.Status = Status.Active;
 Gtk.Application.Run ();
}


However, it fails when I try to factor it out into a separate class. The app
indicator briefly appears, then disappears after a split second. The code
for creating the app indicator is exactly the same. The application
continues execution, but the indicator isn't there. I see no error or
warning.

public class GmailAppIndicator {
 public GmailAppIndicator ()
 {
 ApplicationIndicator indicator = new ApplicationIndicator
("gmail-notifier",
                                                           "gmail",

Category.ApplicationStatus);
 Gtk.Menu menu = new Gtk.Menu ();
 Gtk.MenuItem testMenuItem = new Gtk.ImageMenuItem (Gtk.Stock.About, null);
 menu.Add (testMenuItem);
 menu.ShowAll ();
 indicator.Menu = menu;
 indicator.Status = Status.Active;
 }
}

...

public static void Main (string[] args)
{
 Gtk.Application.Init ();

GmailAppIndicator indicator = new GmailAppIndicator ();
 Gtk.Application.Run ();
}

Any idea why this is happening?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20100804/bb729a9b/attachment-0001.html 


More information about the Gtk-sharp-list mailing list