Re: How to create submenus using UIManager
- From: Sergio Perticone <g4ll0ws gmail com>
- To: stewart weiss acm org
- Cc: gtk+ maling list <gtk-list gnome org>
- Subject: Re: How to create submenus using UIManager
- Date: Sun, 04 Nov 2007 21:15:54 +0100
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]