--- client/gui-gtk-2.0/dialogs.c 1 Jan 2003 11:51:33 -0000 1.30 +++ client/gui-gtk-2.0/dialogs.c 3 Jan 2003 23:27:15 -0000 @@ -43,6 +43,7 @@ #include "gui_main.h" #include "gui_stuff.h" #include "mapview.h" +#include "menu.h" #include "options.h" #include "tilespec.h" @@ -1168,6 +1169,9 @@ { int i; GtkWidget *dshell, *dlabel, *vbox; + + if (government_chosen()) + return; if(!is_showing_government_dialog) { is_showing_government_dialog=1; --- client/gui-gtk-2.0/menu.c 1 Jan 2003 11:51:33 -0000 1.10 +++ client/gui-gtk-2.0/menu.c 3 Jan 2003 23:27:17 -0000 @@ -24,6 +24,7 @@ #include "astring.h" #include "fcintl.h" #include "log.h" +#include "government.h" #include "map.h" #include "mem.h" #include "support.h" @@ -555,8 +556,6 @@ NULL, 0, "" }, { "/" N_("Game") "/tearoff1", NULL, NULL, 0, "" }, - { "/" N_("Game") "/sep1", NULL, - NULL, 0, "" }, { "/" N_("Game") "/" N_("_Local Options"), NULL, game_menu_callback, MENU_GAME_OPTIONS }, { "/" N_("Game") "/" N_("Messa_ge Options"), NULL, @@ -596,8 +595,13 @@ kingdom_menu_callback, MENU_KINGDOM_WORKLISTS }, { "/" N_("Kingdom") "/sep2", NULL, NULL, 0, "" }, - { "/" N_("Kingdom") "/" N_("_Revolution"), "r", + { "/" N_("_Kingdom") "/" N_("_Government"), NULL, + NULL, 0, "" }, + { "/" N_("Kingdom") "/" N_("_Government") "/" N_("_Revolution"), + "r", kingdom_menu_callback, MENU_KINGDOM_REVOLUTION }, + { "/" N_("_Kingdom") "/" N_("_Government") "/sep1", NULL, + NULL, 0, "" }, /* View menu ... */ { "/" N_("_View"), NULL, NULL, 0, "" }, @@ -957,6 +961,38 @@ gtk_label_set_text_with_mnemonic(GTK_LABEL(GTK_BIN(item)->child), s); } +/**************************************************************** +... +*****************************************************************/ +static bool government_selected = FALSE; +static int government_choice = -1; + +void government_callback(GtkMenuItem *item, gpointer data) +{ + struct packet_player_request packet; + + send_packet_player_request(&aconnection, &packet, PACKET_PLAYER_REVOLUTION); + + government_choice = GPOINTER_TO_INT(data); + government_selected = TRUE; +} + +/**************************************************************** +... +*****************************************************************/ +bool government_chosen(void) +{ + if (government_selected) { + struct packet_player_request packet; + + packet.government = government_choice; + send_packet_player_request(&aconnection, &packet, PACKET_PLAYER_GOVERNMENT); + + government_selected = FALSE; + return TRUE; + } + return FALSE; +} /**************************************************************** Note: the menu strings should contain underscores as in the @@ -972,6 +1008,43 @@ menus_set_sensitive("
/_Orders", FALSE); } else { struct unit *punit; + + GtkWidget *parent, *item; + const char *path; + + path = translate_menu_path("
/_Kingdom/_Government", 1); + + if((parent=gtk_item_factory_get_widget(item_factory, path))) { + int i; + GList *iter, *iter_next; + + /* remove previous government entries. */ + iter = gtk_container_get_children(GTK_CONTAINER(parent)); + for (iter = g_list_nth(iter, 3); iter; iter = iter_next) { + iter_next = iter->next; + + gtk_container_remove(GTK_CONTAINER(parent), GTK_WIDGET(iter->data)); + } + + /* add new government entries. */ + for (i=0; iname); + + g_signal_connect(item, "activate", + G_CALLBACK(government_callback), GINT_TO_POINTER(g->index)); + + if (!can_change_to_government(game.player_ptr, i)) + gtk_widget_set_sensitive(item, FALSE); + + gtk_menu_shell_append(GTK_MENU_SHELL(parent), item); + gtk_widget_show(item); + } + } + } + menus_set_sensitive("
/_Reports", TRUE); menus_set_sensitive("
/_Kingdom", TRUE); menus_set_sensitive("
/_View", TRUE); @@ -981,7 +1054,7 @@ can_client_issue_orders()); menus_set_sensitive("
/_Kingdom/Work_lists", can_client_issue_orders()); - menus_set_sensitive("
/_Kingdom/_Revolution", + menus_set_sensitive("
/_Kingdom/_Government", can_client_issue_orders()); menus_set_sensitive("
/_Reports/S_paceship", --- client/gui-gtk-2.0/menu.h 11 Mar 2002 23:19:27 -0000 1.2 +++ client/gui-gtk-2.0/menu.h 3 Jan 2003 23:27:17 -0000 @@ -18,6 +18,7 @@ #include "menu_g.h" void setup_menus(GtkWidget *window, GtkWidget **menubar); +bool government_chosen(void); extern GtkAccelGroup * toplevel_accel;