Problem with GtkUIManager


In my XML definition string, I set up a <menu name="View"> element in a
menubar, but did not define any <menuitems> inside.

Then, I created GtkCheckMenuItems and tried to append them to the View
submenu (using gtk_ui_manager_get_widget and gtk_menu_item_get_submenu).

However, when I start the application, the View item doesn't appear in
the menubar. It's only visible if I define menuitems inside.

Here is the code:

static gchar *uis =
"<menubar name=\"Menubar\">"
"<menu name=\"File\" action=\"file\">"
"<menuitem name=\"New\" action=\"new\"/>"
"<menuitem name=\"Open\" action=\"open\"/>"
"<placeholder name=\"Recent\"/>"
"<menuitem name=\"Save\" action=\"save\"/>"
"<menuitem name=\"SaveAs\" action=\"save_as\"/>"
"<menuitem name=\"Close\" action=\"close\"/>"
"<menuitem name=\"Print\" action=\"print\"/>"
"<menuitem name=\"Exit\" action=\"exit\"/>"
"<menu name=\"View\" action=\"view\">"

  /* View menu Checkmenuitems */
  view_show_toolbar = gtk_check_menu_item_new();
  view_show_statusbar = gtk_check_menu_item_new();
gtk_action_connect_proxy(gtk_action_group_get_action(action_group, "show_toolbar"), view_show_toolbar); gtk_action_connect_proxy(gtk_action_group_get_action(action_group, "show_statusbar"), view_show_statusbar);
  GtkWidget *view_item = gtk_ui_manager_get_widget(uim, "/Menubar/View");
  GtkMenu *view_menu = gtk_menu_new();
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view_item), view_menu);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_show_toolbar);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_show_statusbar);

I can't find out why the menuitem and its submenu don't appear.

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