Getting menu to show

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

 



I'm trying to get a menu bar to show. The code I have at present is segfaulting:

void gtk_specific_init(int *argc, char ***argv)
    {
    GtkItemFactory *factory;
    gtk_init(argc, argv);
    main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_show(main_window);
    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>"));
    };

I suspect that there's a problem with the last call, and I'd like to be told what I should do instead to get menus to display.

The source file reads (did I handle the submenu at "/Movement/Alternate and Expanded" correctly by declaring it to be of type "<Branch>")?:

/***************************************************************************/
/* The Minstrel's Song is (c) 1998-2005 by Jonathan Hayward.  See the file */
/* lib/copyrigh.txt for a copyright and license statement.                 */
/***************************************************************************/

#include <gtk/gtk.h>
#include "tms.h"

struct request_queue_struct *user_requests;
GtkAccelGroup *gtk_accelerators;
GtkWindow *main_window;

#ifdef GTK

GtkItemFactoryEntry menu_entries[] =
    {
    { "/_File", "<ALT>F", NULL, 0, "<Branch>" },
    { "/File/_New Game", "<ALT>N", menu_file_new_game, 0, "<Item>" },
    { "/File/_Open Game", "<ALT>O", menu_file_open_game, 0, "<Item>" },
    { "/File/Save Game (S)", "S", menu_file_save_game, 0, "<Item>" },
    { "/File/_End Game", "<ALT>E", menu_file_end_game, 0, "<Item>" },
    { "/File/Quit The Minstrel's Song (Q)", "Q",
      menu_file_quit_the_minstrels_song, 0, "<Item>" },
    { "/_Movement", "<ALT>M", NULL, 0, "<Branch>" },
    { "/Movement/Left (4)", "4", menu_movement_left, 0, "<Item>" },
    { "/Movement/Right (6)", "6", menu_movement_right, 0, "<Item>" },
    { "/Movement/Up (2)", "2", menu_movement_up, 0, "<Item>" },
    { "/Movement/Down (8)", "8", menu_movement_down, 0, "<Item>" },
    { "/Movement/Up and Left (1)", "1", menu_movement_up_and_left, 0, "<Item>"
      },
    { "/Movement/Up and Right (3)", "3", menu_movement_up_and_right, 0,
      "<Item>" },
    { "/Movement/Down and Left (7)", "7", menu_movement_down_and_left, 0,
      "<Item>" },
    { "/Movement/Down and Right (9)", "9", menu_movement_down_and_right, 0,
      "<Item>" },
    { "/Movement/Alternate and Expanded", NULL, NULL, 0, "<Branch>" },
    { "/Movement/Alternate and Expanded/Left (h)", "h", menu_movement_left, 0,
      "<Item>" },
    { "/Movement/Alternate and Expanded/Right (l)", "l", menu_movement_right,
      0, "<Item>" },
    { "/Movement/Alternate and Expanded/Up (k)", "k", menu_movement_up, 0,
      "<Item>" },
    { "/Movement/Alternate and Expanded/Down (j)", "j", menu_movement_down, 0,
      "<Item>" },
    { "/Movement/Alternate and Expanded/Up and Left (y)", "y",
      menu_movement_up_and_left, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Up and Right (u)", "u",
      menu_movement_up_and_right, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Down and Left (b)", "b",
      menu_movement_down_and_left, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Down and Right (n)", "n",
      menu_movement_down_and_right, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Jog Left (Control-H)", "<CONTROL>H",
      menu_movement_jog_left, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Jog Right (Control-L)", "<CONTROL>L",
      menu_movement_jog_right, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Jog Up (Control-K)", "<CONTROL>K",
      menu_movement_jog_up, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Jog Down (Control-J)", "<CONTROL>J",
      menu_movement_jog_down, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Jog Up and Left (Control-Y)",
      "<CONTROL>Y", menu_movement_jog_up_and_left, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Jog Up and Right (Control-U)",
      "<CONTROL>U", menu_movement_jog_up_and_right, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Jog Down and Left (Control-B)",
      "<CONTROL>B", menu_movement_jog_down_and_left, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Jog Down and Right (Control-N)",
      "<CONTROL>N", menu_movement_jog_down_and_right, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Run Left (H)", "H",
      menu_movement_run_left, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Run Right (L)", "L",
      menu_movement_run_right, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Run Up (K)", "K", menu_movement_run_up,
      0, "<Item>" },
    { "/Movement/Alternate and Expanded/Run Down (J)", "J",
      menu_movement_run_down, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Run Up and Left (Y)", "Y",
      menu_movement_run_up_and_left, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Run Up and Right (U)", "U",
      menu_movement_run_up_and_right, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Run Down and Left (B)", "B",
      menu_movement_run_down_and_left, 0, "<Item>" },
    { "/Movement/Alternate and Expanded/Run Down and Right (N)", "N",
      menu_movement_run_down_and_right, 0, "<Item>" },
    { "/_Actions", "<ALT>A", NULL, 0, "<Branch>" },
    { "/Actions/Activate an Item (a)", "a", menu_actions_activate_an_item, 0,
      "<Item>" },
    { "/Actions/Activate Your Location (@)", "@",
      menu_actions_activate_your_location, 0, "<Item>" },
    { "/Actions/Clean an Animal's Carcass", NULL,
      menu_actions_clean_an_animals_carcass, 0, "<Item>" },
    { "/Actions/Close a Door (C)", "C", menu_actions_close_a_door, 0, "<Item>"
      },
    { "/Actions/Close an Item (c)", "c", menu_actions_close_an_item, 0,
      "<Item>" },
    { "/Actions/Cover with Poison", NULL, menu_actions_cover_with_poison, 0,
      "<Item>" },
    { "/Actions/Dismount Your Steed", NULL, menu_actions_dismount_your_steed,
      0, "<Item>" },
    { "/Actions/Drink (Quaff) a Liquid (q)", "q",
      menu_actions_drink_quaff_a_liquid, 0, "<Item>" },
    { "/Actions/Drop an Item (d)", "d", menu_actions_drop_an_item, 0, "<Item>"
      },
    { "/Actions/Drop Money", NULL, menu_actions_drop_money, 0, "<Item>" },
    { "/Actions/Eat (Munch) food (m)", "m", menu_actions_eat_munch_food, 0,
      "<Item>" },
    { "/Actions/Enter or Exit a Level (>)", ">",
      menu_actions_enter_or_exit_a_level, 0, "<Item>" },
    { "/Actions/Examine an Item in Your Possession More Closely (x)", "x",
      menu_actions_examine_an_item_in_your_possession_more_closely, 0,
      "<Item>" },
    { "/Actions/Examine Your Surroundings More Closely (X)", "X",
      menu_actions_examine_your_surroundings_more_closely, 0, "<Item>" },
    { "/Actions/Fill an Item with Oil", NULL,
      menu_actions_fill_an_item_with_oil, 0, "<Item>" },
    { "/Actions/Fill an Item with Water", NULL,
      menu_actions_fill_an_item_with_water, 0, "<Item>" },
    { "/Actions/Fire or Throw a Missle Weapon (f)", NULL,
      menu_actions_fire_or_throw_a_missle_weapon, 0, "<Item>" },
    { "/Actions/Fly or Land (F)", NULL, menu_actions_fly_or_land, 0, "<Item>"
      },
    { "/Actions/Gather Fruit or Wood from a Tree", NULL,
      menu_actions_gather_fruit_or_wood_from_a_tree, 0, "<Item>" },
    { "/Actions/Give a Name to Another Creature", NULL,
      menu_actions_give_a_name_to_another_creature, 0, "<Item>" },
    { "/Actions/Give an Item to Another Creature", NULL,
      menu_actions_give_a_name_to_another_creature, 0, "<Item>" },
    { "/Actions/Go to Sleep (G)", NULL, menu_actions_go_to_sleep, 0, "<Item>"
      },
    { "/Actions/Insert One Item into Another", NULL,
      menu_actions_insert_one_item_into_another, 0, "<Item>" },
    { "/Actions/Jump (Vault) from One Location to Another (v)", "v",
      menu_actions_jump_vault_from_one_location_to_another, 0, "<Item>" },
    { "/Actions/Mount a Steed", NULL, menu_actions_mount_a_steed, 0, "<Item>"
      },
    { "/Actions/Move to a City Location (M)", "M",
      menu_actions_move_to_a_city_location, 0, "<Item>" },
    { "/Actions/Open a Door (O)", "O", menu_actions_open_a_door, 0, "<Item>" },
    { "/Actions/Open an Item (o)", "o", menu_actions_open_an_item, 0, "<Item>"
      },
    { "/Actions/Pet an Animal", NULL, menu_actions_pet_an_animal, 0, "<Item>"
      },
    { "/Actions/Push a Creature in a Direction", NULL,
      menu_actions_push_a_creature_in_a_direction, 0, "<Item>", },
    { "/Actions/Read an Item (r)", "r", menu_actions_read_an_item, 0, "<Item>"
      },
    { "/Actions/Rest a Moment (.)", ".", menu_actions_rest_a_moment, 0,
      "<Item>" },
    { "/Actions/Rest or Wait for a While (,)", ",",
      menu_actions_rest_or_wait_for_a_while, 0, "<Item>" },
    { "/Actions/Remove an Item from a Container", NULL,
      menu_actions_remove_an_item_from_a_container, 0, "<Item>" },
    { "/Actions/Remove (Unequip) an Item in Use (E)", "E",
      menu_actions_unequip_ie_remove_an_item_in_use, 0, "<Item>" },
    { "/Actions/Search (Inspect) the Surrounding Area (I)", "I",
      menu_actions_search_inspect_the_surrounding_area, 0, "<Item>" },
    { "/Actions/Start Running", NULL, menu_actions_start_running, 0, "<Item>"
      },
    { "/Actions/Start Using (Equip) an Item (e)", "e",
      menu_actions_equip_ie_start_using_an_item, 0, "<Item>" },
    { "/Actions/Start Walking", NULL, menu_actions_start_walking, 0, "<Item>"
      },
    { "/Actions/Swap Places with a Creature", NULL,
      menu_actions_swap_places_with_a_creature, 0, "<Item>" },
    { "/Actions/Take a Nap", NULL, menu_actions_take_a_nap, 0, "<Item>" },
    { "/Actions/Talk to Another Person (t)", "t",
      menu_actions_talk_to_another_person, 0, "<Item>" },
    { "/_Skills", "<ALT>S", NULL, 0, "<Branch>" },
    { "/Skills/Animal Handling", NULL, menu_skills_animal_handling, 0,
      "<Item>", },
    { "/Skills/Chemistry", NULL, menu_skills_chemistry, 0, "<Item>", },
    { "/Skills/Fishing", NULL, menu_skills_fishing, 0, "<Item>" },
    { "/Skills/Geography", NULL, menu_skills_geography, 0, "<Item>" },
    { "/Skills/Guess Actions", NULL, menu_skills_guess_actions, 0, "<Item>" },
    { "/Skills/Herbalism", NULL, menu_skills_herbalism, 0, "<Item>" },
    { "/Skills/Medicine", NULL, menu_skills_medicine, 0, "<Item>" },
    /*
    { "/Skills/Music (Flute)", NULL, menu_skills_music_flute, 0, "<Item>" },
    { "/Skills/Music (Harp)", NULL, menu_skills_music_harp, 0, "<Item>" },
    { "/Skills/Music (Lute)", NULL, menu_skills_music_lute, 0, "<Item>" },
    { "/Skills/Music (Organ)", NULL, menu_skills_music_organ, 0, "<Item>" },
    { "/Skills/Music (Singing)", NULL, menu_skills_music_singing, 0, "<Item>"
      },
    */
    { "/Skills/Navigation", NULL, menu_skills_navigation, 0, "<Item>" },
    /*
    { "/Skills/Repair", NULL, menu_skills_repair, 0, "<Item>" },
    */
    { "/Skills/Technology Identification", NULL,
      menu_skills_technology_identification, 0, "<Item>" },
    { "/Skills/Tinkering", NULL, menu_skills_tinkering, 0, "<Item>" },
    { "/Skills/Tracking", NULL, menu_skills_tracking, 0, "<Item>" },
    { "/_Prayers", "<ALT>P", NULL, 0, "<Branch>" },
    { "/Prayers/Aegis of God", NULL, menu_prayers_aegis_of_God, 0, "<Item>" },
    { "/Prayers/Divine Sustenance", NULL, menu_prayers_divine_sustenance, 0,
      "<Item>" },
    { "/Prayers/Favor with Man", NULL, menu_prayers_favor_with_man, 0, "<Item>"
      },
    { "/Prayers/Fire from Heaven", NULL, menu_prayers_fire_from_heaven, 0,
      "<Item>" },
    { "/Prayers/Flying", NULL, menu_prayers_flying, 0, "<Item>" },
    { "/Prayers/Guardian Angel", NULL, menu_prayers_guardian_angel, 0, "<Item>"
      },
    { "/Prayers/Healing", NULL, menu_prayers_healing, 0, "<Item>" },
    { "/Prayers/Increase Attribute", NULL, menu_prayers_increase_attribute, 0,
      "<Item>" },
    { "/Prayers/Increase Faith", NULL, menu_prayers_increase_faith, 0, "<Item>"
      },
    { "/Prayers/Increase Skill", NULL, menu_prayers_increase_skill, 0, "<Item>"
      },
    { "/Prayers/Persuasion", NULL, menu_prayers_persuasion, 0, "<Item>" },
    { "/Prayers/Providence", NULL, menu_prayers_providence, 0, "<Item>" },
    { "/Prayers/Raise Dead", NULL, menu_prayers_raise_dead, 0, "<Item>" },
    { "/Prayers/Restoration", NULL, menu_prayers_restoration, 0, "<Item>" },
    { "/Prayers/Reveal Terrain", NULL, menu_prayers_reveal_terrain, 0, "<Item>"
      },
    /*
    { "/Prayers/Sanctuary", NULL, menu_prayers_sanctuary, 0, "<Item>" },
    */
    { "/Prayers/Shining Light", NULL, menu_prayers_shining_light, 0, "<Item>" },    /*
    { "/Prayers/Walk on Water", NULL, menu_prayers_walk_on_water, 0, "<Item>" },    */
    { "/_Other", "<ALT>O", NULL, 0, "<Branch>" },
    { "/Other/Allocate Experience (A)", "A", menu_other_allocate_experience, 0,
      "<Item>" },
    { "/Other/Become Combat Happy", NULL, menu_other_become_bellicose, 0,
      "<Item>" },
    { "/Other/Charity Contact Information", NULL, menu_other_charity_contact, 0,      "<Item>" },
    { "/Other/Display an Inventory of Items in Your Possession (i)", "i",
      menu_other_display_an_inventory_of_items_in_your_possession, 0, "<Item>"
      },
    { "/Other/Display License Statement", NULL,
      menu_other_display_license_statement, 0, "<Item>" },
    { "/Other/Display Skill Values", NULL, menu_other_display_skill_values, 0,
      "<Item>" },
    { "/Other/Set Options (O)", "O", menu_other_set_options, 0, "<Item>" },
    { "/Other/Set Your Haste Level", NULL, menu_other_set_your_haste_level, 0,
      "<Item>" },
    { "/_Role Play", "<ALT>H", NULL, 0, "<Branch>" },
    { "/Role Play/Espiriticthus: The Cultures", NULL,
      menu_role_play_espiriticthus_the_cultures, 0, "<Item>" },
    { "/Role Play/Game Master's Introduction", NULL,
      menu_role_play_game_masters_introduction, 0, "<Item>" },
    { "/Role Play/A Mathematical Model", NULL,
      menu_role_play_a_mathematical_model, 0, "<Item>" },
    { "/Role Play/Player's Introduction", NULL,
      menu_role_play_players_introduction, 0, "<Item>" }
    };

void gtk_specific_init(int *argc, char ***argv)
    {
    GtkItemFactory *factory;
    gtk_init(argc, argv);
    main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_show(main_window);
    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>"));
    };

#endif



--
++ Jonathan Hayward, jonathan.hayward@xxxxxxxxx
** 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!
_______________________________________________

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