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

Michael Hutchinson m.j.hutchinson at gmail.com
Wed Aug 4 18:58:31 EDT 2010


On Wed, Aug 4, 2010 at 4:46 PM, Matthew Pirocchi
<matthew.pirocchi at gmail.com> wrote:
> 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?

The ApplicationIndicator object will be garbage-collected any time
after the GmailAppIndicator ctor ends. You should keep a reference,
e.g. on a field in GmailAppIndicator.

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Gtk-sharp-list mailing list