Re: GtkMenu doesn't recognize it's parents?



"Jim George" <jimgeorge gmail com> writes:

Am I doing something wrong? Is this a glade bug? I noticed this in
programs which use glade code-generation as well as libglade. Or could
it be because the popup menu is a top-level window in it's own
right?

Yes, the menu is a toplevel window in its own right, so it doesn't
have a parent. 

You can get at the parent menubar this way:

        GTK_MENU_SHELL (menu)->parent_menu_shell

but see below for a better way.

I need a pointer to the parent window to which this menu belongs,
since the window has a structure with information, added using
g_object_set_data. Is there some other way to do this?

The usual way to pass data to a callback is to pass it at signal
connection time:

   g_signal_connect (menu_item, "activated", 
                     G_CALLBACK (on_about_cb),
                     main_window);

The main window will then be passed as "data" in the on_about_cb
function. I am not sure you can do this when adding event handlers
through glade, so you'll have to not do that.

Instead use libglade and manually connec whatever signal connections
you need.


Soren



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