Re: GTK MenuShell Nested Menu's



Thanks, that helped alot, but now i'm suck again
i'm populating the submenu's like this:
if (!(g_strcmp0(progType,menu1))){
                        GtkWidget *item;
                        item = gtk_menu_item_new_with_label(progName);
                        gtk_menu_shell_append(GTK_MENU_SHELL (menu1), item);
                        printf("%s\n",sptr);

g_signal_connect_swapped(item,"activate",G_CALLBACK(callback1),(gpointer)"Callback1");
                }else if (!(g_strcmp0(progType,menu2))){
                        GtkWidget *item2;
                        item2 = gtk_menu_item_new_with_label(progName);
                        gtk_menu_shell_append(GTK_MENU_SHELL (menu2), item2);

g_signal_connect_swapped(item2,"activate",G_CALLBACK(callback2),NULL);
                }

void callback1(GtkWidget *widget, gpointer data){
      printf("callback called\n,%s\n",(char*) data);
}
and data is garbage.
i read in a bunch of file names in the format progName.progType.xml.
but if i have more then one of a given progType, i need full file
name, it's stored in sptr, but it gets freed at the end of this loop.
so i tired gtk_widget_set_name(item,sptr) but when in callback1, i
called gtk_widget_get_name, it falled assert is widget.

what's the proper way of doing this?

Thanks
Kevin

On Wed, Mar 16, 2011 at 5:13 PM, Tadej Borovšak <tadeboro gmail com> wrote:
> 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
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>



-- 
Thanks
Kevin Anthony
www.NoSideRacing.com


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