RE: How to create submenus using UIManager

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

 



This just creates the menubar with the pull-down menus for the 
File and Edit menus. That much I know. But I am trying to creating
submenus of the pull-down menus, and nothing I have tried works.
For example, like in a View menu, suppose I want a menu item 
labelled "Toolbars" that brings up a menu with various toolabrs in it.

I have Emmanuele Bassi's recent-uimanager code and I am trying
to use that as a guide, but it seems absurd to have to go down so
far as to create GObjects just to do this.

Stewart


> -----Original Message-----
> From: Sergio Perticone [mailto:g4ll0ws@xxxxxxxxx]
> Sent: Sunday, November 04, 2007 3:16 PM
> To: stewart.weiss@xxxxxxx
> Cc: gtk+ maling list
> Subject: Re: How to create submenus using UIManager
> 
> 
> On Sun, 2007-11-04 at 12:48 -0500, Stewart Weiss wrote:
> > I am trying to create a menu that contains a submenu using the
> > GtkUIManager, but none of the attempts has been successful. 
> > Is there a way to do this, or do I have to use the "by hand"
> > methods?
> > 
> 
> Just an example:
> 
>    GtkActionGroup* action_group;
>    GtkUIManager*   ui_mngr;
>    GError*         error = NULL;
> 
>     gchar ui_info[] =  ""
>         "<ui>"
>         "  <menubar>"
>         "    <menu action='MenuFile'>"
>         "      <menuitem action='New' />"
>         "      <menuitem action='Open' />"
>         "    </menu>"
>         "    <menu action='MenuEdit'>"
>         "      <menuitem action='Undo' />"
>         "      <menuitem action='Redo' />"
>         "    </menu>"
>         "  </menubar>"
>         "</ui>";
> 
>     gtk_init(&argc, &argv);
> 
>     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> 
>     action_group = gtk_action_group_new(NULL);
>     gtk_action_group_add_action(action_group,
>                                 gtk_action_new("MenuFile", "_File",
>                                                NULL, NULL));
> 
>     gtk_action_group_add_action(action_group,
>                                 gtk_action_new("New", NULL,
>                                                NULL, GTK_STOCK_NEW)); 
>     gtk_action_group_add_action(action_group, 
> 				gtk_action_new("Open", NULL,
>                                                NULL, GTK_STOCK_OPEN));
> 
>     gtk_action_group_add_action(action_group,
>                                 gtk_action_new("MenuEdit", "_Edit",
>                                                NULL, NULL));
> 
>     gtk_action_group_add_action(action_group,
>                                 gtk_action_new("Undo", NULL,
>                                                NULL, GTK_STOCK_UNDO));
> 
>     gtk_action_group_add_action(action_group,
>                                 gtk_action_new("Redo", NULL,
>                                                NULL, GTK_STOCK_REDO));
> 
>     ui_mngr = gtk_ui_manager_new();
>     gtk_ui_manager_insert_action_group(ui_mngr, action_group, 0);
>     gtk_ui_manager_add_ui_from_string(ui_mngr, ui_info,
>                                       strlen(ui_info), &error);
> 
>     if (error)
>         g_error(error->message);
> 
>      /* ... */
> 
>     gtk_box_pack_start(GTK_BOX(vbox),
>                        gtk_ui_manager_get_widget(ui_mngr, "/menubar"),
>                        FALSE, FALSE, 0);
> 
> 
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux