Re: Getting menu to show



Post script: in order to make it work more like the tutorial, I changed the end to follow the manual menu example in the tutorial. I put:

void gtk_specific_init(int *argc, char ***argv)
    {
    GtkItemFactory *factory;
    GtkWidget *vbox, *root_menu;
    gtk_init(argc, argv);
    main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_accelerators = gtk_accel_group_new();
    factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>",
      gtk_accelerators);
    gtk_item_factory_create_items(factory, 125, menu_entries, NULL);
    gtk_window_add_accel_group(main_window, gtk_accelerators);
    /*
    gtk_check_menu_item_set_active(GTK_TYPE_MENU_BAR
      (gtk_item_factory_get_item(factory, "<main>")), TRUE);
    gtk_widget_show(gtk_item_factory_get_item(factory, "<main>"));
    */
    printf("Reached 1!\n");
    vbox = gtk_vbox_new(FALSE, 0);
    printf("Reached 2!\n");
    gtk_container_add(GTK_CONTAINER (main_window), vbox);
    printf("Reached 3!\n");
    gtk_widget_show(vbox);
    printf("Reached 4!\n");
    root_menu = gtk_item_factory_get_item
(factory, "<main>");
    printf("Reached 5!\n");
    gtk_box_pack_start(GTK_BOX (vbox), root_menu, FALSE, FALSE, 2);
    printf("Reached 6!\n");
    gtk_widget_show(root_menu);
    printf("Reached 7!\n");
    gtk_widget_show(main_window);
    };

It gave the following output:

Reached 1!
Reached 2!
Reached 3!
Reached 4!
Reached 5!

(test:23283): Gtk-CRITICAL **: gtk_box_pack_start: assertion `GTK_IS_WIDGET (child)' failed
Reached 6!
Segmentation fault


--
++ Jonathan Hayward, jonathan hayward pobox com
** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com

** If you'd like a Google Mail (gmail.com) account, please tell me!

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