tags:

views:

17

answers:

1

I'm still working on the example at this link: http://stackoverflow.com/questions/3547548/gtkmm-statusicon-quits-after-creation I changed the function in this way to open the traybar different windows, but does not show anything.

void Tray::on_statusicon_popup(guint button, guint activate_time) {
    printf("popup!\n");
    Gtk::Window w;
    w.show();
}

I tried to run every window with "Gtk::Main::run(w);" and it works, but I would like to not run a main loop for each window.

+1  A: 

You're creating the window object on the stack, so it gets destroyed immediately after on_statusicon_popup() returns. If you want the window to outlast the function call, you'll need to create it on the heap and connect to its 'hide' signal (or similar) and delete the object from there.

jonner
I did not understand ... how do I create them on the heap from my function?
Syco
`Gtk::Window *w = new Gtk::Window()` ??
jonner