Re: GTK MenuShell Nested Menu's



Hello.

> I'm trying to nest a menu using menu_shell,
> 
> GtkWidget *tray_menu;
> GtkWidget *child_menu;
> tray_menu = gtk_menu_new ();
> child_menu = gtk_menu_new ();
> gtk_menu_shell_append(GTK_MENU_SHELL(tray_menu), child_menu);
> 
> but i get an error:
> Gtk-CRITICAL **: gtk_menu_shell_insert: assertion `GTK_IS_MENU_ITEM
> (child)' failed
> 
> so i guess my question is, how do i set one menu to be another menu's child?

You need to attach submenu to GtkMenuItem. Something like this:

GtkWidget *menu,
          *submenu,
          *item;

menu = gtk_menu_new ();

item = gtk_menu_item_new_with_label ("Submenu");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

submenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);

Cheers,
Tadej

-- 
Tadej Borovšak
00386 (0)40 613 131
tadeboro.blogspot.com
tadeboro gmail com
tadej borovsak gmail com



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