Re: popup_menu Question



Emmanuel Julien wrote:

Hi everyone,

Is there a way to popup (as in popup menu) in GTK+ (C) the application menu (or the menubar)? I'm asking because it's really not practical for me to popup a custom menu as my menus are very dynamic.


gtk_menu_popup() takes any menu as parameter, so in theory should work if you pass your main menu in (never tried myself, though).


Well, unless I'm mistaken a menubar is containing only menu items and no menu,
at least I could not find one.
Both menubar and menu derivate from menushell yet poping the menubar fails on GTK_IS_MENU assertion, the same happens when trying to popup a getsubmenu from an item, it seems the gtk_menu object is really special and not used in
a traditional menu.


Hm, you are right. You can pop up individual menus with this code:

gboolean
on_MainWindow_button_press_event           (GtkWidget       *widget,
                                       GdkEventButton  *event,
                                       gpointer         user_data)
{
   GList *l;
   l = gtk_container_get_children(MenuBar);
gtk_menu_popup(gtk_menu_item_get_submenu(l->data), NULL, NULL, NULL, NULL, event->button, event->time);
}

The easy solution would be to dynamically create the top menu by scanning the menubar children and then set the various menus as submenus. You will then have to set the menus back to the menubar on popdown. A bit convoluted, but it avoids duplicating your menus.

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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