I'm trying to create a simple menu for my app with the new UIManager functions under GTK+ 2.6. I've copied most of my code for it from the the gtk-demo.exe app and I still can't get it to work. Compiles fine, but I get a long list of errors, all of which are like these (same error for similar code fragments):
Gtk-WARNING **: FileMenu: missing action Gtk-CRITICAL **: gtk_container_foreach: assertion 'GTK_IS_CONTAINER(container)' failed Gtk-CRITICAL **: gtk_menu_shell_insert: assertion 'GTK_IS_MENU_SHELL(menu_shell)' failed Gtk-CRITICAL **: find_menu_position: assertion 'GTK_IS_MENU_SHELL(menushell)' failed Glib-GObject-WARNING **: invalid (NULL) pointer instance Glib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE(instance)' failed I've been over the example and the API docs and I can't work out why this is happening. My code is below. If anyone can help I'd be very appreciative. -Nick ****************************************************************************** static GtkActionEntry entries[] = { { "Filemenu", NULL, "_File" }, { "Editmenu", NULL, "_Edit" }, { "Helpmenu", NULL, "_Help" }, { "New", GTK_STOCK_NEW, "_New", "<control>n", "Create New File", G_CALLBACK(function_pendingm) }, { "Open", GTK_STOCK_OPEN, "_Open", "<control>o", "Open File", G_CALLBACK(function_pendingm) }, { "Save", GTK_STOCK_SAVE, "_Save", "<control>s", "Save File", G_CALLBACK(function_pendingm) }, { "SaveAs", GTK_STOCK_SAVE, "Save As", NULL, "Save a Copy", G_CALLBACK(function_pendingm) }, { "Quit", GTK_STOCK_QUIT, "_Quit", "<control>q", "Quit ClearSky", G_CALLBACK(function_pendingm) }, { "Cut", GTK_STOCK_CUT, "Cut", "<control>x", "Cut Text", G_CALLBACK(function_pendingm) }, { "Copy", GTK_STOCK_COPY, "Copy", "<control>c", "Copy Text", G_CALLBACK(function_pendingm) }, { "Paste", GTK_STOCK_PASTE, "Paste", "<control>v", "Paste Text", G_CALLBACK(function_pendingm) }, { "SelectAll", NULL, "Select _All", "<control>a", "Select All Text", G_CALLBACK(function_pendingm) }, { "Find", GTK_STOCK_FIND_AND_REPLACE, "_Find and Replace", "<control>f", "Find and Replace Text", G_CALLBACK(function_pendingm) }, { "Preferences", GTK_STOCK_PREFERENCES, "Preferences", NULL, "Set Viewing Preferences", G_CALLBACK(function_pendingm) }, { "HelpContents", GTK_STOCK_HELP, "_Help Contents", "<control>h", "View Help File Contents", G_CALLBACK(function_pendingm) }, { "About", GTK_STOCK_ABOUT, "_About", "<control>a", "About ClearSky", G_CALLBACK(function_pendingm) } }; static guint n_entries = G_N_ELEMENTS (entries); static const gchar *ui_info = "<ui>" " <menubar name='MenuBar'>" " <menu action='FileMenu'>" " <menuitem action='New'/>" " <menuitem action='Open'/>" " <menuitem action='Save'/>" " <menuitem action='SaveAs'/>" " <separator/>" " <menuitem action='Quit'/>" " </menu>" " <menu action='EditMenu'>" " <menuitem action='Cut'/>" " <menuitem action='Copy'/>" " <menuitem action='Paste'/>" " <menuitem action='SelectAll'/>" " <menuitem action='Find'/>" " <separator/>" " <menuitem action='Preferences'/>" " </menu>" " <menu action='HelpMenu'>" " <menuitem action='HelpContents'/>" " <separator/>" " <menuitem action='About'/>" " </menu>" " </menubar>" "</ui>"; GtkUIManager *ui; GtkActionGroup *actions; GError *error = NULL; actions = gtk_action_group_new ("Actions"); gtk_action_group_add_actions (actions, entries, n_entries, NULL); ui = gtk_ui_manager_new (); gtk_ui_manager_insert_action_group (ui, actions, 0); gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (ui)); if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error)) { g_message ("building menus failed: %s", error->message); g_error_free (error); } gtk_box_pack_start (GTK_BOX(mainbox), gtk_ui_manager_get_widget(ui, "/MenuBar"), FALSE, FALSE, 0); ****************************************************************************** _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list