-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Emmanuel saracco wrote:
> Hi,
> 
> I have a problem with popup submenus callbacks. The following code display 
> the 
> popup, but the callback is not called:
> 
> -----
> GtkWidget *menu, *submenu, *item;
> 
> menu = gtk_menu_new ();
> 
> item = gtk_menu_item_new_with_label ("Submenu 1");
> gtk_container_add (GTK_CONTAINER (menu), item);
> 
> submenu = gtk_menu_new ();
> gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
> 
> item = gtk_menu_item_new_with_label ("Item 1");
> g_signal_connect (G_OBJECT (item), "activate", 
>   G_CALLBACK (test_callback), NULL);
> gtk_container_add (GTK_CONTAINER (submenu), item);
> 
> gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
>   event->button, event->time);
> 
> gtk_widget_show_all (menu);
> -----
> 
> - If I do not use submenu, all run as expected.
> 
> - When using submenu, if I use the "button_release_event" signal instead of 
> "activate", it is more or less ok (callback is called), but the popup do not 
> disappear anymore.
> 
> Does anybody see what's wrong here?
> 
> -> GNU/Linux with libgtk 2.6.8 on Debian/sid.

I'm not sure if it matters or not (would have to look at the gtk source,
and I'm lazy), but you should be using gtk_menu_shell_append() instead
of gtk_container_add() to add menu items to the menu.

        -brian

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)

iD8DBQFDA85c6XyW6VEeAnsRAk1GAJ0RcQi5+7XcjbtRzvrlbWhk3EJj4gCgnLo4
XqX9xSrTc1QSi02ZvvXmKIQ=
=h/iz
-----END PGP SIGNATURE-----
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to