Replaced deprecated gtk_menu_popup() calls with modern constructs in gtk3.22-client
[freeciv.git] / client / gui-gtk-3.0 / menu.c
blobb1acd82ae7e23aaa616260178954d48a363c5f21
1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 #include <stdlib.h>
20 #include <gtk/gtk.h>
22 /* utility */
23 #include "fcintl.h"
24 #include "log.h"
25 #include "shared.h"
26 #include "support.h"
28 /* common */
29 #include "game.h"
30 #include "government.h"
31 #include "road.h"
32 #include "unit.h"
34 /* client */
35 #include "client_main.h"
36 #include "clinet.h"
37 #include "connectdlg_common.h"
38 #include "control.h"
39 #include "mapview_common.h"
40 #include "options.h"
41 #include "tilespec.h"
43 /* client/gui-gtk-3.0 */
44 #include "chatline.h"
45 #include "cityrep.h"
46 #include "dialogs.h"
47 #include "editgui.h"
48 #include "editprop.h"
49 #include "finddlg.h"
50 #include "gamedlgs.h"
51 #include "gotodlg.h"
52 #include "gui_main.h"
53 #include "gui_stuff.h"
54 #include "helpdlg.h"
55 #include "luaconsole.h"
56 #include "mapctrl.h" /* center_on_unit(). */
57 #include "messagedlg.h"
58 #include "messagewin.h"
59 #include "optiondlg.h"
60 #include "pages.h"
61 #include "plrdlg.h"
62 #include "ratesdlg.h"
63 #include "repodlgs.h"
64 #include "sprite.h"
65 #include "spaceshipdlg.h"
66 #include "transportdlg.h"
67 #include "unitselect.h"
68 #include "wldlg.h"
70 #include "menu.h"
72 #ifndef GTK_STOCK_EDIT
73 #define GTK_STOCK_EDIT NULL
74 #endif
76 static GtkUIManager *ui_manager = NULL;
78 static GtkActionGroup *get_safe_group(void);
79 static GtkActionGroup *get_edit_group(void);
80 static GtkActionGroup *get_unit_group(void);
81 static GtkActionGroup *get_playing_group(void);
82 static GtkActionGroup *get_player_group(void);
84 static void menus_set_active(GtkActionGroup *group,
85 const gchar *action_name,
86 gboolean is_active);
87 static void menus_set_sensitive(GtkActionGroup *group,
88 const gchar *action_name,
89 gboolean is_sensitive);
90 #ifndef DEBUG
91 static void menus_set_visible(GtkActionGroup *group,
92 const gchar *action_name,
93 gboolean is_visible,
94 gboolean is_sensitive);
95 #endif /* DEBUG */
97 static void view_menu_update_sensitivity(void);
99 /****************************************************************
100 Action "CLEAR_CHAT_LOGS" callback.
101 *****************************************************************/
102 static void clear_chat_logs_callback(GtkAction *action, gpointer data)
104 clear_output_window();
107 /****************************************************************
108 Action "SAVE_CHAT_LOGS" callback.
109 *****************************************************************/
110 static void save_chat_logs_callback(GtkAction *action, gpointer data)
112 log_output_window();
115 /****************************************************************
116 Action "LOCAL_OPTIONS" callback.
117 *****************************************************************/
118 static void local_options_callback(GtkAction *action, gpointer data)
120 option_dialog_popup(_("Set local options"), client_optset);
123 /****************************************************************
124 Action "MESSAGE_OPTIONS" callback.
125 *****************************************************************/
126 static void message_options_callback(GtkAction *action, gpointer data)
128 popup_messageopt_dialog();
131 /****************************************************************
132 Action "SERVER_OPTIONS" callback.
133 *****************************************************************/
134 static void server_options_callback(GtkAction *action, gpointer data)
136 option_dialog_popup(_("Game Settings"), server_optset);
139 /****************************************************************
140 Action "SAVE_OPTIONS" callback.
141 *****************************************************************/
142 static void save_options_callback(GtkAction *action, gpointer data)
144 options_save(NULL);
147 /****************************************************************
148 Action "RELOAD_TILESET" callback.
149 *****************************************************************/
150 static void reload_tileset_callback(GtkAction *action, gpointer data)
152 tilespec_reread(NULL, TRUE);
155 /****************************************************************
156 Action "SAVE_GAME" callback.
157 *****************************************************************/
158 static void save_game_callback(GtkAction *action, gpointer data)
160 send_save_game(NULL);
163 /****************************************************************
164 Action "SAVE_GAME_AS" callback.
165 *****************************************************************/
166 static void save_game_as_callback(GtkAction *action, gpointer data)
168 save_game_dialog_popup();
171 /****************************************************************************
172 Action "SAVE_MAPIMG" callback.
173 ****************************************************************************/
174 static void save_mapimg_callback(GtkAction *action, gpointer data)
176 mapimg_client_save(NULL);
179 /****************************************************************************
180 Action "SAVE_MAPIMG_AS" callback.
181 ****************************************************************************/
182 static void save_mapimg_as_callback(GtkAction *action, gpointer data)
184 save_mapimg_dialog_popup();
187 /****************************************************************
188 This is the response callback for the dialog with the message:
189 Leaving a local game will end it!
190 ****************************************************************/
191 static void leave_local_game_response(GtkWidget *dialog, gint response)
193 gtk_widget_destroy(dialog);
194 if (response == GTK_RESPONSE_OK) {
195 /* It might be killed already */
196 if (client.conn.used) {
197 /* It will also kill the server */
198 disconnect_from_server();
203 /****************************************************************
204 Action "LEAVE" callback.
205 *****************************************************************/
206 static void leave_callback(GtkAction *action, gpointer data)
208 if (is_server_running()) {
209 GtkWidget* dialog =
210 gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_WARNING,
211 GTK_BUTTONS_OK_CANCEL,
212 _("Leaving a local game will end it!"));
213 setup_dialog(dialog, toplevel);
214 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
215 g_signal_connect(dialog, "response",
216 G_CALLBACK(leave_local_game_response), NULL);
217 gtk_window_present(GTK_WINDOW(dialog));
218 } else {
219 disconnect_from_server();
223 /****************************************************************
224 Action "QUIT" callback.
225 *****************************************************************/
226 static void quit_callback(GtkAction *action, gpointer data)
228 popup_quit_dialog();
231 /****************************************************************
232 Action "FIND_CITY" callback.
233 *****************************************************************/
234 static void find_city_callback(GtkAction *action, gpointer data)
236 popup_find_dialog();
239 /****************************************************************
240 Action "WORKLISTS" callback.
241 *****************************************************************/
242 static void worklists_callback(GtkAction *action, gpointer data)
244 popup_worklists_report();
247 /****************************************************************
248 Action "MAP_VIEW" callback.
249 *****************************************************************/
250 static void map_view_callback(GtkAction *action, gpointer data)
252 map_canvas_focus();
255 /****************************************************************
256 Action "REPORT_NATIONS" callback.
257 *****************************************************************/
258 static void report_nations_callback(GtkAction *action, gpointer data)
260 popup_players_dialog(TRUE);
263 /****************************************************************
264 Action "REPORT_WOW" callback.
265 *****************************************************************/
266 static void report_wow_callback(GtkAction *action, gpointer data)
268 send_report_request(REPORT_WONDERS_OF_THE_WORLD);
271 /****************************************************************
272 Action "REPORT_TOP_CITIES" callback.
273 *****************************************************************/
274 static void report_top_cities_callback(GtkAction *action, gpointer data)
276 send_report_request(REPORT_TOP_5_CITIES);
279 /****************************************************************
280 Action "REPORT_MESSAGES" callback.
281 *****************************************************************/
282 static void report_messages_callback(GtkAction *action, gpointer data)
284 meswin_dialog_popup(TRUE);
287 /****************************************************************
288 Action "CLIENT_LUA_SCRIPT" callback.
289 *****************************************************************/
290 static void client_lua_script_callback(GtkAction *action, gpointer data)
292 luaconsole_dialog_popup(TRUE);
295 /****************************************************************
296 Action "REPORT_DEMOGRAPHIC" callback.
297 *****************************************************************/
298 static void report_demographic_callback(GtkAction *action, gpointer data)
300 send_report_request(REPORT_DEMOGRAPHIC);
303 /****************************************************************
304 Action "REPORT_ACHIEVEMENTS" callback.
305 *****************************************************************/
306 static void report_achievements_callback(GtkAction *action, gpointer data)
308 send_report_request(REPORT_ACHIEVEMENTS);
311 /****************************************************************
312 Action "HELP_LANGUAGE" callback.
313 *****************************************************************/
314 static void help_language_callback(GtkAction *action, gpointer data)
316 popup_help_dialog_string(HELP_LANGUAGES_ITEM);
319 /****************************************************************
320 Action "HELP_POLICIES" callback.
321 *****************************************************************/
322 static void help_policies_callback(GtkAction *action, gpointer data)
324 popup_help_dialog_string(HELP_MULTIPLIER_ITEM);
327 /****************************************************************
328 Action "HELP_CONNECTING" callback.
329 *****************************************************************/
330 static void help_connecting_callback(GtkAction *action, gpointer data)
332 popup_help_dialog_string(HELP_CONNECTING_ITEM);
335 /****************************************************************
336 Action "HELP_CONTROLS" callback.
337 *****************************************************************/
338 static void help_controls_callback(GtkAction *action, gpointer data)
340 popup_help_dialog_string(HELP_CONTROLS_ITEM);
343 /****************************************************************
344 Action "HELP_CHATLINE" callback.
345 *****************************************************************/
346 static void help_chatline_callback(GtkAction *action, gpointer data)
348 popup_help_dialog_string(HELP_CHATLINE_ITEM);
351 /****************************************************************
352 Action "HELP_WORKLIST_EDITOR" callback.
353 *****************************************************************/
354 static void help_worklist_editor_callback(GtkAction *action, gpointer data)
356 popup_help_dialog_string(HELP_WORKLIST_EDITOR_ITEM);
359 /****************************************************************
360 Action "HELP_CMA" callback.
361 *****************************************************************/
362 static void help_cma_callback(GtkAction *action, gpointer data)
364 popup_help_dialog_string(HELP_CMA_ITEM);
367 /****************************************************************
368 Action "HELP_OVERVIEW" callback.
369 *****************************************************************/
370 static void help_overview_callback(GtkAction *action, gpointer data)
372 popup_help_dialog_string(HELP_OVERVIEW_ITEM);
375 /****************************************************************
376 Action "HELP_PLAYING" callback.
377 *****************************************************************/
378 static void help_playing_callback(GtkAction *action, gpointer data)
380 popup_help_dialog_string(HELP_PLAYING_ITEM);
383 /****************************************************************
384 Action "HELP_RULESET" callback.
385 *****************************************************************/
386 static void help_ruleset_callback(GtkAction *action, gpointer data)
388 popup_help_dialog_string(HELP_RULESET_ITEM);
391 /****************************************************************
392 Action "HELP_TILESET" callback.
393 *****************************************************************/
394 static void help_tileset_callback(GtkAction *action, gpointer data)
396 popup_help_dialog_string(HELP_TILESET_ITEM);
399 /****************************************************************
400 Action "HELP_ECONOMY" callback.
401 *****************************************************************/
402 static void help_economy_callback(GtkAction *action, gpointer data)
404 popup_help_dialog_string(HELP_ECONOMY_ITEM);
407 /****************************************************************
408 Action "HELP_CITIES" callback.
409 *****************************************************************/
410 static void help_cities_callback(GtkAction *action, gpointer data)
412 popup_help_dialog_string(HELP_CITIES_ITEM);
415 /****************************************************************
416 Action "HELP_IMPROVEMENTS" callback.
417 *****************************************************************/
418 static void help_improvements_callback(GtkAction *action, gpointer data)
420 popup_help_dialog_string(HELP_IMPROVEMENTS_ITEM);
423 /****************************************************************
424 Action "HELP_UNITS" callback.
425 *****************************************************************/
426 static void help_units_callback(GtkAction *action, gpointer data)
428 popup_help_dialog_string(HELP_UNITS_ITEM);
431 /****************************************************************
432 Action "HELP_COMBAT" callback.
433 *****************************************************************/
434 static void help_combat_callback(GtkAction *action, gpointer data)
436 popup_help_dialog_string(HELP_COMBAT_ITEM);
439 /****************************************************************
440 Action "HELP_ZOC" callback.
441 *****************************************************************/
442 static void help_zoc_callback(GtkAction *action, gpointer data)
444 popup_help_dialog_string(HELP_ZOC_ITEM);
447 /****************************************************************
448 Action "HELP_TECH" callback.
449 *****************************************************************/
450 static void help_tech_callback(GtkAction *action, gpointer data)
452 popup_help_dialog_string(HELP_TECHS_ITEM);
455 /****************************************************************
456 Action "HELP_TERRAIN" callback.
457 *****************************************************************/
458 static void help_terrain_callback(GtkAction *action, gpointer data)
460 popup_help_dialog_string(HELP_TERRAIN_ITEM);
463 /****************************************************************
464 Action "HELP_WONDERS" callback.
465 *****************************************************************/
466 static void help_wonders_callback(GtkAction *action, gpointer data)
468 popup_help_dialog_string(HELP_WONDERS_ITEM);
471 /****************************************************************
472 Action "HELP_GOVERNMENT" callback.
473 *****************************************************************/
474 static void help_government_callback(GtkAction *action, gpointer data)
476 popup_help_dialog_string(HELP_GOVERNMENT_ITEM);
479 /****************************************************************
480 Action "HELP_DIPLOMACY" callback.
481 *****************************************************************/
482 static void help_diplomacy_callback(GtkAction *action, gpointer data)
484 popup_help_dialog_string(HELP_DIPLOMACY_ITEM);
487 /****************************************************************
488 Action "HELP_SPACE_RACE" callback.
489 *****************************************************************/
490 static void help_space_rate_callback(GtkAction *action, gpointer data)
492 popup_help_dialog_string(HELP_SPACE_RACE_ITEM);
495 /****************************************************************
496 Action "HELP_NATIONS" callback.
497 *****************************************************************/
498 static void help_nations_callback(GtkAction *action, gpointer data)
500 popup_help_dialog_string(HELP_NATIONS_ITEM);
503 /****************************************************************
504 Action "HELP_COPYING" callback.
505 *****************************************************************/
506 static void help_copying_callback(GtkAction *action, gpointer data)
508 popup_help_dialog_string(HELP_COPYING_ITEM);
511 /****************************************************************
512 Action "HELP_ABOUT" callback.
513 *****************************************************************/
514 static void help_about_callback(GtkAction *action, gpointer data)
516 popup_help_dialog_string(HELP_ABOUT_ITEM);
519 /****************************************************************
520 Action "SAVE_OPTIONS_ON_EXIT" callback.
521 *****************************************************************/
522 static void save_options_on_exit_callback(GtkToggleAction *action,
523 gpointer data)
525 gui_options.save_options_on_exit = gtk_toggle_action_get_active(action);
528 /****************************************************************
529 Action "EDIT_MODE" callback.
530 *****************************************************************/
531 static void edit_mode_callback(GtkToggleAction *action, gpointer data)
533 if (game.info.is_edit_mode ^ gtk_toggle_action_get_active(action)) {
534 key_editor_toggle();
535 /* Unreachbale techs in reqtree on/off */
536 science_report_dialog_popdown();
540 /****************************************************************
541 Action "SHOW_CITY_OUTLINES" callback.
542 *****************************************************************/
543 static void show_city_outlines_callback(GtkToggleAction *action,
544 gpointer data)
546 if (gui_options.draw_city_outlines ^ gtk_toggle_action_get_active(action)) {
547 key_city_outlines_toggle();
551 /****************************************************************
552 Action "SHOW_CITY_OUTPUT" callback.
553 *****************************************************************/
554 static void show_city_output_callback(GtkToggleAction *action, gpointer data)
556 if (gui_options.draw_city_output ^ gtk_toggle_action_get_active(action)) {
557 key_city_output_toggle();
561 /****************************************************************
562 Action "SHOW_MAP_GRID" callback.
563 *****************************************************************/
564 static void show_map_grid_callback(GtkToggleAction *action, gpointer data)
566 if (gui_options.draw_map_grid ^ gtk_toggle_action_get_active(action)) {
567 key_map_grid_toggle();
571 /****************************************************************
572 Action "SHOW_NATIONAL_BORDERS" callback.
573 *****************************************************************/
574 static void show_national_borders_callback(GtkToggleAction *action,
575 gpointer data)
577 if (gui_options.draw_borders ^ gtk_toggle_action_get_active(action)) {
578 key_map_borders_toggle();
582 /****************************************************************
583 Action "SHOW_NATIVE_TILES" callback.
584 *****************************************************************/
585 static void show_native_tiles_callback(GtkToggleAction *action,
586 gpointer data)
588 if (gui_options.draw_native ^ gtk_toggle_action_get_active(action)) {
589 key_map_native_toggle();
593 /****************************************************************
594 Action "SHOW_CITY_FULL_BAR" callback.
595 *****************************************************************/
596 static void show_city_full_bar_callback(GtkToggleAction *action,
597 gpointer data)
599 if (gui_options.draw_full_citybar ^ gtk_toggle_action_get_active(action)) {
600 key_city_full_bar_toggle();
601 view_menu_update_sensitivity();
605 /****************************************************************
606 Action "SHOW_CITY_NAMES" callback.
607 *****************************************************************/
608 static void show_city_names_callback(GtkToggleAction *action, gpointer data)
610 if (gui_options.draw_city_names ^ gtk_toggle_action_get_active(action)) {
611 key_city_names_toggle();
612 view_menu_update_sensitivity();
616 /****************************************************************
617 Action "SHOW_CITY_GROWTH" callback.
618 *****************************************************************/
619 static void show_city_growth_callback(GtkToggleAction *action, gpointer data)
621 if (gui_options.draw_city_growth ^ gtk_toggle_action_get_active(action)) {
622 key_city_growth_toggle();
626 /****************************************************************
627 Action "SHOW_CITY_PRODUCTIONS" callback.
628 *****************************************************************/
629 static void show_city_productions_callback(GtkToggleAction *action,
630 gpointer data)
632 if (gui_options.draw_city_productions ^ gtk_toggle_action_get_active(action)) {
633 key_city_productions_toggle();
634 view_menu_update_sensitivity();
638 /****************************************************************
639 Action "SHOW_CITY_BUY_COST" callback.
640 *****************************************************************/
641 static void show_city_buy_cost_callback(GtkToggleAction *action,
642 gpointer data)
644 if (gui_options.draw_city_buycost ^ gtk_toggle_action_get_active(action)) {
645 key_city_buycost_toggle();
649 /****************************************************************
650 Action "SHOW_CITY_TRADE_ROUTES" callback.
651 *****************************************************************/
652 static void show_city_trade_routes_callback(GtkToggleAction *action,
653 gpointer data)
655 if (gui_options.draw_city_trade_routes ^ gtk_toggle_action_get_active(action)) {
656 key_city_trade_routes_toggle();
660 /****************************************************************
661 Action "SHOW_TERRAIN" callback.
662 *****************************************************************/
663 static void show_terrain_callback(GtkToggleAction *action, gpointer data)
665 if (gui_options.draw_terrain ^ gtk_toggle_action_get_active(action)) {
666 key_terrain_toggle();
667 view_menu_update_sensitivity();
671 /****************************************************************
672 Action "SHOW_COASTLINE" callback.
673 *****************************************************************/
674 static void show_coastline_callback(GtkToggleAction *action, gpointer data)
676 if (gui_options.draw_coastline ^ gtk_toggle_action_get_active(action)) {
677 key_coastline_toggle();
681 /****************************************************************
682 Action "SHOW_ROAD_RAILS" callback.
683 *****************************************************************/
684 static void show_road_rails_callback(GtkToggleAction *action, gpointer data)
686 if (gui_options.draw_roads_rails ^ gtk_toggle_action_get_active(action)) {
687 key_roads_rails_toggle();
691 /****************************************************************
692 Action "SHOW_IRRIGATION" callback.
693 *****************************************************************/
694 static void show_irrigation_callback(GtkToggleAction *action, gpointer data)
696 if (gui_options.draw_irrigation ^ gtk_toggle_action_get_active(action)) {
697 key_irrigation_toggle();
701 /****************************************************************
702 Action "SHOW_MINE" callback.
703 *****************************************************************/
704 static void show_mine_callback(GtkToggleAction *action, gpointer data)
706 if (gui_options.draw_mines ^ gtk_toggle_action_get_active(action)) {
707 key_mines_toggle();
711 /****************************************************************
712 Action "SHOW_BASES" callback.
713 *****************************************************************/
714 static void show_bases_callback(GtkToggleAction *action, gpointer data)
716 if (gui_options.draw_fortress_airbase ^ gtk_toggle_action_get_active(action)) {
717 key_bases_toggle();
721 /****************************************************************
722 Action "SHOW_RESOURCES" callback.
723 *****************************************************************/
724 static void show_resources_callback(GtkToggleAction *action, gpointer data)
726 if (gui_options.draw_specials ^ gtk_toggle_action_get_active(action)) {
727 key_resources_toggle();
731 /****************************************************************
732 Action "SHOW_HUTS" callback.
733 *****************************************************************/
734 static void show_huts_callback(GtkToggleAction *action, gpointer data)
736 if (gui_options.draw_huts ^ gtk_toggle_action_get_active(action)) {
737 key_huts_toggle();
741 /****************************************************************
742 Action "SHOW_POLLUTION" callback.
743 *****************************************************************/
744 static void show_pollution_callback(GtkToggleAction *action, gpointer data)
746 if (gui_options.draw_pollution ^ gtk_toggle_action_get_active(action)) {
747 key_pollution_toggle();
751 /****************************************************************
752 Action "SHOW_CITIES" callback.
753 *****************************************************************/
754 static void show_cities_callback(GtkToggleAction *action, gpointer data)
756 if (gui_options.draw_cities ^ gtk_toggle_action_get_active(action)) {
757 key_cities_toggle();
761 /****************************************************************
762 Action "SHOW_UNITS" callback.
763 *****************************************************************/
764 static void show_units_callback(GtkToggleAction *action, gpointer data)
766 if (gui_options.draw_units ^ gtk_toggle_action_get_active(action)) {
767 key_units_toggle();
768 view_menu_update_sensitivity();
772 /****************************************************************
773 Action "SHOW_UNIT_SOLID_BG" callback.
774 *****************************************************************/
775 static void show_unit_solid_bg_callback(GtkToggleAction *action,
776 gpointer data)
778 if (gui_options.solid_color_behind_units ^ gtk_toggle_action_get_active(action)) {
779 key_unit_solid_bg_toggle();
783 /****************************************************************
784 Action "SHOW_UNIT_SHIELDS" callback.
785 *****************************************************************/
786 static void show_unit_shields_callback(GtkToggleAction *action,
787 gpointer data)
789 if (gui_options.draw_unit_shields ^ gtk_toggle_action_get_active(action)) {
790 key_unit_shields_toggle();
794 /****************************************************************
795 Action "SHOW_FOCUS_UNIT" callback.
796 *****************************************************************/
797 static void show_focus_unit_callback(GtkToggleAction *action, gpointer data)
799 if (gui_options.draw_focus_unit ^ gtk_toggle_action_get_active(action)) {
800 key_focus_unit_toggle();
801 view_menu_update_sensitivity();
805 /****************************************************************
806 Action "SHOW_FOG_OF_WAR" callback.
807 *****************************************************************/
808 static void show_fog_of_war_callback(GtkToggleAction *action, gpointer data)
810 if (gui_options.draw_fog_of_war ^ gtk_toggle_action_get_active(action)) {
811 key_fog_of_war_toggle();
812 view_menu_update_sensitivity();
816 /****************************************************************
817 Action "FULL_SCREEN" callback.
818 *****************************************************************/
819 static void full_screen_callback(GtkToggleAction *action, gpointer data)
821 if (gui_options.gui_gtk3_fullscreen ^ gtk_toggle_action_get_active(action)) {
822 gui_options.gui_gtk3_fullscreen ^= 1;
824 if (gui_options.gui_gtk3_fullscreen) {
825 gtk_window_fullscreen(GTK_WINDOW(toplevel));
826 } else {
827 gtk_window_unfullscreen(GTK_WINDOW(toplevel));
832 /****************************************************************
833 Action "RECALC_BORDERS" callback.
834 *****************************************************************/
835 static void recalc_borders_callback(GtkAction *action, gpointer data)
837 key_editor_recalculate_borders();
840 /****************************************************************
841 Action "TOGGLE_FOG" callback.
842 *****************************************************************/
843 static void toggle_fog_callback(GtkAction *action, gpointer data)
845 key_editor_toggle_fogofwar();
848 /****************************************************************
849 Action "SCENARIO_PROPERTIES" callback.
850 *****************************************************************/
851 static void scenario_properties_callback(GtkAction *action, gpointer data)
853 struct property_editor *pe;
855 pe = editprop_get_property_editor();
856 property_editor_reload(pe, OBJTYPE_GAME);
857 property_editor_popup(pe, OBJTYPE_GAME);
860 /****************************************************************
861 Action "SAVE_SCENARIO" callback.
862 *****************************************************************/
863 static void save_scenario_callback(GtkAction *action, gpointer data)
865 save_scenario_dialog_popup();
868 /****************************************************************
869 Action "SELECT_SINGLE" callback.
870 *****************************************************************/
871 static void select_single_callback(GtkAction *action, gpointer data)
873 request_unit_select(get_units_in_focus(), SELTYPE_SINGLE, SELLOC_TILE);
876 /****************************************************************
877 Action "SELECT_ALL_ON_TILE" callback.
878 *****************************************************************/
879 static void select_all_on_tile_callback(GtkAction *action, gpointer data)
881 request_unit_select(get_units_in_focus(), SELTYPE_ALL, SELLOC_TILE);
884 /****************************************************************
885 Action "SELECT_SAME_TYPE_TILE" callback.
886 *****************************************************************/
887 static void select_same_type_tile_callback(GtkAction *action, gpointer data)
889 request_unit_select(get_units_in_focus(), SELTYPE_SAME, SELLOC_TILE);
892 /****************************************************************
893 Action "SELECT_SAME_TYPE_CONT" callback.
894 *****************************************************************/
895 static void select_same_type_cont_callback(GtkAction *action, gpointer data)
897 request_unit_select(get_units_in_focus(), SELTYPE_SAME, SELLOC_CONT);
900 /****************************************************************
901 Action "SELECT_SAME_TYPE" callback.
902 *****************************************************************/
903 static void select_same_type_callback(GtkAction *action, gpointer data)
905 request_unit_select(get_units_in_focus(), SELTYPE_SAME, SELLOC_WORLD);
908 /*****************************************************************************
909 Open unit selection dialog.
910 *****************************************************************************/
911 static void select_dialog_callback(GtkAction *action, gpointer data)
913 unit_select_dialog_popup(NULL);
916 /****************************************************************
917 Action "UNIT_WAIT" callback.
918 *****************************************************************/
919 static void unit_wait_callback(GtkAction *action, gpointer data)
921 key_unit_wait();
924 /****************************************************************
925 Action "UNIT_DONE" callback.
926 *****************************************************************/
927 static void unit_done_callback(GtkAction *action, gpointer data)
929 key_unit_done();
932 /****************************************************************
933 Action "UNIT_GOTO" callback.
934 *****************************************************************/
935 static void unit_goto_callback(GtkAction *action, gpointer data)
937 key_unit_goto();
940 /****************************************************************
941 Action "UNIT_GOTO_CITY" callback.
942 *****************************************************************/
943 static void unit_goto_city_callback(GtkAction *action, gpointer data)
945 if (get_num_units_in_focus() > 0) {
946 popup_goto_dialog();
950 /****************************************************************
951 Action "UNIT_RETURN" callback.
952 *****************************************************************/
953 static void unit_return_callback(GtkAction *action, gpointer data)
955 unit_list_iterate(get_units_in_focus(), punit) {
956 request_unit_return(punit);
957 } unit_list_iterate_end;
960 /****************************************************************
961 Action "UNIT_EXPLORE" callback.
962 *****************************************************************/
963 static void unit_explore_callback(GtkAction *action, gpointer data)
965 key_unit_auto_explore();
968 /****************************************************************
969 Action "UNIT_PATROL" callback.
970 *****************************************************************/
971 static void unit_patrol_callback(GtkAction *action, gpointer data)
973 key_unit_patrol();
976 /****************************************************************
977 Action "UNIT_SENTRY" callback.
978 *****************************************************************/
979 static void unit_sentry_callback(GtkAction *action, gpointer data)
981 key_unit_sentry();
984 /****************************************************************
985 Action "UNIT_UNSENTRY" callback.
986 *****************************************************************/
987 static void unit_unsentry_callback(GtkAction *action, gpointer data)
989 key_unit_wakeup_others();
992 /****************************************************************
993 Action "UNIT_LOAD" callback.
994 *****************************************************************/
995 static void unit_load_callback(GtkAction *action, gpointer data)
997 unit_list_iterate(get_units_in_focus(), punit) {
998 request_transport(punit, unit_tile(punit));
999 } unit_list_iterate_end;
1002 /****************************************************************
1003 Action "UNIT_UNLOAD" callback.
1004 *****************************************************************/
1005 static void unit_unload_callback(GtkAction *action, gpointer data)
1007 unit_list_iterate(get_units_in_focus(), punit) {
1008 request_unit_unload(punit);
1009 } unit_list_iterate_end;
1012 /****************************************************************
1013 Action "UNIT_UNLOAD_TRANSPORTER" callback.
1014 *****************************************************************/
1015 static void unit_unload_transporter_callback(GtkAction *action,
1016 gpointer data)
1018 key_unit_unload_all();
1021 /****************************************************************
1022 Action "UNIT_HOMECITY" callback.
1023 *****************************************************************/
1024 static void unit_homecity_callback(GtkAction *action, gpointer data)
1026 key_unit_homecity();
1029 /****************************************************************
1030 Action "UNIT_UPGRADE" callback.
1031 *****************************************************************/
1032 static void unit_upgrade_callback(GtkAction *action, gpointer data)
1034 popup_upgrade_dialog(get_units_in_focus());
1037 /****************************************************************
1038 Action "UNIT_CONVERT" callback.
1039 *****************************************************************/
1040 static void unit_convert_callback(GtkAction *action, gpointer data)
1042 key_unit_convert();
1045 /****************************************************************
1046 Action "UNIT_DISBAND" callback.
1047 *****************************************************************/
1048 static void unit_disband_callback(GtkAction *action, gpointer data)
1050 popup_disband_dialog(get_units_in_focus());
1053 /****************************************************************
1054 Action "BUILD_CITY" callback.
1055 *****************************************************************/
1056 static void build_city_callback(GtkAction *action, gpointer data)
1058 unit_list_iterate(get_units_in_focus(), punit) {
1059 /* FIXME: this can provide different actions for different units...
1060 * not good! */
1061 /* Enable the button for adding to a city in all cases, so we
1062 get an eventual error message from the server if we try. */
1063 if (unit_can_add_or_build_city(punit)) {
1064 request_unit_build_city(punit);
1065 } else if (utype_can_do_action(unit_type_get(punit),
1066 ACTION_HELP_WONDER)) {
1067 request_unit_caravan_action(punit, ACTION_HELP_WONDER);
1069 } unit_list_iterate_end;
1072 /****************************************************************
1073 Action "GO_BUILD_CITY" callback.
1074 *****************************************************************/
1075 static void go_build_city_callback(GtkAction *action, gpointer data)
1077 request_unit_goto(ORDER_BUILD_CITY);
1080 /****************************************************************
1081 Action "AUTO_SETTLE" callback.
1082 *****************************************************************/
1083 static void auto_settle_callback(GtkAction *action, gpointer data)
1085 key_unit_auto_settle();
1088 /****************************************************************
1089 Action "BUILD_ROAD" callback.
1090 *****************************************************************/
1091 static void build_road_callback(GtkAction *action, gpointer data)
1093 unit_list_iterate(get_units_in_focus(), punit) {
1094 /* FIXME: this can provide different actions for different units...
1095 * not good! */
1096 struct extra_type *tgt = next_extra_for_tile(unit_tile(punit),
1097 EC_ROAD,
1098 unit_owner(punit),
1099 punit);
1100 bool building_road = FALSE;
1102 if (tgt != NULL
1103 && can_unit_do_activity_targeted(punit, ACTIVITY_GEN_ROAD, tgt)) {
1104 request_new_unit_activity_targeted(punit, ACTIVITY_GEN_ROAD, tgt);
1105 building_road = TRUE;
1108 if (!building_road && unit_can_est_trade_route_here(punit)) {
1109 request_unit_caravan_action(punit, ACTION_TRADE_ROUTE);
1111 } unit_list_iterate_end;
1114 /****************************************************************
1115 Action "BUILD_IRRIGATION" callback.
1116 *****************************************************************/
1117 static void build_irrigation_callback(GtkAction *action, gpointer data)
1119 key_unit_irrigate();
1122 /****************************************************************
1123 Action "BUILD_MINE" callback.
1124 *****************************************************************/
1125 static void build_mine_callback(GtkAction *action, gpointer data)
1127 key_unit_mine();
1130 /****************************************************************
1131 Action "CONNECT_ROAD" callback.
1132 *****************************************************************/
1133 static void connect_road_callback(GtkAction *action, gpointer data)
1135 struct road_type *proad = road_by_compat_special(ROCO_ROAD);
1137 if (proad != NULL) {
1138 struct extra_type *tgt;
1140 tgt = road_extra_get(proad);
1142 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
1146 /****************************************************************
1147 Action "CONNECT_RAIL" callback.
1148 *****************************************************************/
1149 static void connect_rail_callback(GtkAction *action, gpointer data)
1151 struct road_type *prail = road_by_compat_special(ROCO_RAILROAD);
1153 if (prail != NULL) {
1154 struct extra_type *tgt;
1156 tgt = road_extra_get(prail);
1158 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
1162 /****************************************************************
1163 Action "CONNECT_IRRIGATION" callback.
1164 *****************************************************************/
1165 static void connect_irrigation_callback(GtkAction *action, gpointer data)
1167 struct extra_type_list *extras = extra_type_list_by_cause(EC_IRRIGATION);
1169 if (extra_type_list_size(extras) > 0) {
1170 struct extra_type *pextra;
1172 pextra = extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION), 0);
1174 key_unit_connect(ACTIVITY_IRRIGATE, pextra);
1178 /****************************************************************
1179 Action "TRANSFORM_TERRAIN" callback.
1180 *****************************************************************/
1181 static void transform_terrain_callback(GtkAction *action, gpointer data)
1183 key_unit_transform();
1186 /****************************************************************
1187 Action "CLEAN_POLLUTION" callback.
1188 *****************************************************************/
1189 static void clean_pollution_callback(GtkAction *action, gpointer data)
1191 unit_list_iterate(get_units_in_focus(), punit) {
1192 /* FIXME: this can provide different actions for different units...
1193 * not good! */
1194 struct extra_type *pextra;
1196 pextra = prev_extra_in_tile(unit_tile(punit), ERM_CLEANPOLLUTION,
1197 unit_owner(punit), punit);
1199 if (pextra != NULL) {
1200 request_new_unit_activity_targeted(punit, ACTIVITY_POLLUTION, pextra);
1201 } else if (can_unit_paradrop(punit)) {
1202 /* FIXME: This is getting worse, we use a key_unit_*() function
1203 * which assign the order for all units! Very bad! */
1204 key_unit_paradrop();
1206 } unit_list_iterate_end;
1209 /****************************************************************
1210 Action "CLEAN_FALLOUT" callback.
1211 *****************************************************************/
1212 static void clean_fallout_callback(GtkAction *action, gpointer data)
1214 key_unit_fallout();
1217 /****************************************************************
1218 Action "BUILD_FORTRESS" callback.
1219 *****************************************************************/
1220 static void build_fortress_callback(GtkAction *action, gpointer data)
1222 key_unit_fortress();
1225 /****************************************************************
1226 Action "FORTIFY" callback.
1227 *****************************************************************/
1228 static void fortify_callback(GtkAction *action, gpointer data)
1230 unit_list_iterate(get_units_in_focus(), punit) {
1231 request_unit_fortify(punit);
1232 } unit_list_iterate_end;
1235 /****************************************************************
1236 Action "BUILD_AIRBASE" callback.
1237 *****************************************************************/
1238 static void build_airbase_callback(GtkAction *action, gpointer data)
1240 key_unit_airbase();
1243 /****************************************************************
1244 Action "DO_PILLAGE" callback.
1245 *****************************************************************/
1246 static void do_pillage_callback(GtkAction *action, gpointer data)
1248 key_unit_pillage();
1251 /****************************************************************
1252 Action "DIPLOMAT_ACTION" callback.
1253 *****************************************************************/
1254 static void diplomat_action_callback(GtkAction *action, gpointer data)
1256 key_unit_action_select_tgt();
1259 /****************************************************************
1260 Action "EXPLODE_NUKE" callback.
1261 *****************************************************************/
1262 static void explode_nuke_callback(GtkAction *action, gpointer data)
1264 key_unit_nuke();
1267 /****************************************************************
1268 Action "TAX_RATE" callback.
1269 *****************************************************************/
1270 static void tax_rate_callback(GtkAction *action, gpointer data)
1272 popup_rates_dialog();
1275 /****************************************************************
1276 Action "MULTIPLIERS" callback.
1277 *****************************************************************/
1278 static void multiplier_callback(GtkAction *action, gpointer data)
1280 popup_multiplier_dialog();
1283 /****************************************************************
1284 The player has chosen a government from the menu.
1285 *****************************************************************/
1286 static void government_callback(GtkMenuItem *item, gpointer data)
1288 popup_revolution_dialog((struct government *) data);
1291 /****************************************************************************
1292 The player has chosen a base to build from the menu.
1293 ****************************************************************************/
1294 static void base_callback(GtkMenuItem *item, gpointer data)
1296 struct extra_type *pextra = data;
1298 unit_list_iterate(get_units_in_focus(), punit) {
1299 request_new_unit_activity_targeted(punit, ACTIVITY_BASE, pextra);
1300 } unit_list_iterate_end;
1303 /****************************************************************************
1304 The player has chosen a road to build from the menu.
1305 ****************************************************************************/
1306 static void road_callback(GtkMenuItem *item, gpointer data)
1308 struct extra_type *pextra = data;
1310 unit_list_iterate(get_units_in_focus(), punit) {
1311 request_new_unit_activity_targeted(punit, ACTIVITY_GEN_ROAD,
1312 pextra);
1313 } unit_list_iterate_end;
1316 /****************************************************************
1317 Action "CENTER_VIEW" callback.
1318 *****************************************************************/
1319 static void center_view_callback(GtkAction *action, gpointer data)
1321 center_on_unit();
1324 /****************************************************************
1325 Action "REPORT_UNITS" callback.
1326 *****************************************************************/
1327 static void report_units_callback(GtkAction *action, gpointer data)
1329 units_report_dialog_popup(TRUE);
1332 /****************************************************************
1333 Action "REPORT_CITIES" callback.
1334 *****************************************************************/
1335 static void report_cities_callback(GtkAction *action, gpointer data)
1337 city_report_dialog_popup(TRUE);
1340 /****************************************************************
1341 Action "REPORT_ECONOMY" callback.
1342 *****************************************************************/
1343 static void report_economy_callback(GtkAction *action, gpointer data)
1345 economy_report_dialog_popup(TRUE);
1348 /****************************************************************
1349 Action "REPORT_RESEARCH" callback.
1350 *****************************************************************/
1351 static void report_research_callback(GtkAction *action, gpointer data)
1353 science_report_dialog_popup(TRUE);
1356 /****************************************************************
1357 Action "REPORT_SPACESHIP" callback.
1358 *****************************************************************/
1359 static void report_spaceship_callback(GtkAction *action, gpointer data)
1361 if (NULL != client.conn.playing) {
1362 popup_spaceship_dialog(client.conn.playing);
1366 /****************************************************************
1367 Returns the group of the actions which are always available for
1368 the user in anycase. Create it if not existent.
1369 *****************************************************************/
1370 static GtkActionGroup *get_safe_group(void)
1372 static GtkActionGroup *group = NULL;
1374 if (!group) {
1375 const GtkActionEntry menu_entries[] = {
1376 {"MENU_GAME", NULL, _("_Game"), NULL, NULL, NULL},
1377 {"MENU_OPTIONS", NULL, _("_Options"), NULL, NULL, NULL},
1378 {"MENU_EDIT", NULL, _("_Edit"), NULL, NULL, NULL},
1379 {"MENU_VIEW", NULL, Q_("?verb:_View"), NULL, NULL, NULL},
1380 {"MENU_IMPROVEMENTS", NULL, _("_Improvements"), NULL, NULL, NULL},
1381 {"MENU_CIVILIZATION", NULL, _("C_ivilization"), NULL, NULL, NULL},
1382 {"MENU_HELP", NULL, _("_Help"), NULL, NULL, NULL},
1384 /* A special case to make empty menu. */
1385 {"NULL", NULL, "NULL", NULL, NULL, NULL}
1388 const GtkActionEntry action_entries[] = {
1389 /* Game menu. */
1390 {"CLEAR_CHAT_LOGS", GTK_STOCK_CLEAR, _("_Clear Chat Log"),
1391 NULL, NULL, G_CALLBACK(clear_chat_logs_callback)},
1392 {"SAVE_CHAT_LOGS", GTK_STOCK_SAVE_AS, _("Save Chat _Log"),
1393 NULL, NULL, G_CALLBACK(save_chat_logs_callback)},
1395 {"LOCAL_OPTIONS", GTK_STOCK_PREFERENCES, _("_Local Client"),
1396 NULL, NULL, G_CALLBACK(local_options_callback)},
1397 {"MESSAGE_OPTIONS", GTK_STOCK_PREFERENCES, _("_Message"),
1398 NULL, NULL, G_CALLBACK(message_options_callback)},
1399 {"SERVER_OPTIONS", GTK_STOCK_PREFERENCES, _("_Remote Server"),
1400 NULL, NULL, G_CALLBACK(server_options_callback)},
1401 {"SAVE_OPTIONS", GTK_STOCK_SAVE_AS, _("Save Options _Now"),
1402 NULL, NULL, G_CALLBACK(save_options_callback)},
1404 {"RELOAD_TILESET", GTK_STOCK_REVERT_TO_SAVED, _("_Reload Tileset"),
1405 "<Control><Alt>r", NULL, G_CALLBACK(reload_tileset_callback)},
1406 {"GAME_SAVE", GTK_STOCK_SAVE, _("_Save Game"),
1407 NULL, NULL, G_CALLBACK(save_game_callback)},
1408 {"GAME_SAVE_AS", GTK_STOCK_SAVE_AS, _("Save Game _As..."),
1409 NULL, NULL, G_CALLBACK(save_game_as_callback)},
1410 {"MAPIMG_SAVE", NULL, _("Save Map _Image"),
1411 NULL, NULL, G_CALLBACK(save_mapimg_callback)},
1412 {"MAPIMG_SAVE_AS", NULL, _("Save _Map Image As..."),
1413 NULL, NULL, G_CALLBACK(save_mapimg_as_callback)},
1414 {"LEAVE", NULL, _("_Leave"),
1415 NULL, NULL, G_CALLBACK(leave_callback)},
1416 {"QUIT", GTK_STOCK_QUIT, _("_Quit"),
1417 NULL, NULL, G_CALLBACK(quit_callback)},
1419 /* Edit menu. */
1420 {"FIND_CITY", GTK_STOCK_FIND, _("_Find City"),
1421 "<Control>f", NULL, G_CALLBACK(find_city_callback)},
1422 {"WORKLISTS", NULL, _("Work_lists"),
1423 "<Control>l", NULL, G_CALLBACK(worklists_callback)},
1425 {"CLIENT_LUA_SCRIPT", NULL, _("Client _Lua Script"),
1426 NULL, NULL, G_CALLBACK(client_lua_script_callback)},
1428 /* Civilization menu. */
1429 {"MAP_VIEW", NULL, Q_("?noun:_View"),
1430 "F1", NULL, G_CALLBACK(map_view_callback)},
1431 {"REPORT_UNITS", NULL, _("_Units"),
1432 "F2", NULL, G_CALLBACK(report_units_callback)},
1433 {"REPORT_NATIONS", NULL, _("_Nations"),
1434 "F3", NULL, G_CALLBACK(report_nations_callback)},
1435 {"REPORT_CITIES", NULL, _("_Cities"),
1436 "F4", NULL, G_CALLBACK(report_cities_callback)},
1438 {"REPORT_WOW", NULL, _("_Wonders of the World"),
1439 "F7", NULL, G_CALLBACK(report_wow_callback)},
1440 {"REPORT_TOP_CITIES", NULL, _("Top _Five Cities"),
1441 "F8", NULL, G_CALLBACK(report_top_cities_callback)},
1442 {"REPORT_MESSAGES", NULL, _("_Messages"),
1443 "F9", NULL, G_CALLBACK(report_messages_callback)},
1444 {"REPORT_DEMOGRAPHIC", NULL, _("_Demographics"),
1445 "F11", NULL, G_CALLBACK(report_demographic_callback)},
1447 /* Help menu. */
1448 /* TRANS: "Overview" topic in built-in help */
1449 {"HELP_OVERVIEW", NULL, Q_("?help:Overview"),
1450 NULL, NULL, G_CALLBACK(help_overview_callback)},
1451 {"HELP_PLAYING", NULL, _("Strategy and Tactics"),
1452 NULL, NULL, G_CALLBACK(help_playing_callback)},
1453 {"HELP_POLICIES", NULL, _("Policies"),
1454 NULL, NULL, G_CALLBACK(help_policies_callback)},
1455 {"HELP_TERRAIN", NULL, _("Terrain"),
1456 NULL, NULL, G_CALLBACK(help_terrain_callback)},
1457 {"HELP_ECONOMY", NULL, _("Economy"),
1458 NULL, NULL, G_CALLBACK(help_economy_callback)},
1459 {"HELP_CITIES", NULL, _("Cities"),
1460 NULL, NULL, G_CALLBACK(help_cities_callback)},
1461 {"HELP_IMPROVEMENTS", NULL, _("City Improvements"),
1462 NULL, NULL, G_CALLBACK(help_improvements_callback)},
1463 {"HELP_WONDERS", NULL, _("Wonders of the World"),
1464 NULL, NULL, G_CALLBACK(help_wonders_callback)},
1465 {"HELP_UNITS", NULL, _("Units"),
1466 NULL, NULL, G_CALLBACK(help_units_callback)},
1467 {"HELP_COMBAT", NULL, _("Combat"),
1468 NULL, NULL, G_CALLBACK(help_combat_callback)},
1469 {"HELP_ZOC", NULL, _("Zones of Control"),
1470 NULL, NULL, G_CALLBACK(help_zoc_callback)},
1471 {"HELP_GOVERNMENT", NULL, _("Government"),
1472 NULL, NULL, G_CALLBACK(help_government_callback)},
1473 {"HELP_DIPLOMACY", NULL, _("Diplomacy"),
1474 NULL, NULL, G_CALLBACK(help_diplomacy_callback)},
1475 {"HELP_TECH", NULL, _("Technology"),
1476 NULL, NULL, G_CALLBACK(help_tech_callback)},
1477 {"HELP_SPACE_RACE", NULL, _("Space Race"),
1478 NULL, NULL, G_CALLBACK(help_space_rate_callback)},
1479 {"HELP_RULESET", NULL, _("About Current Ruleset"),
1480 NULL, NULL, G_CALLBACK(help_ruleset_callback)},
1481 {"HELP_TILESET", NULL, _("About Current Tileset"),
1482 NULL, NULL, G_CALLBACK(help_tileset_callback)},
1483 {"HELP_NATIONS", NULL, _("About Nations"),
1484 NULL, NULL, G_CALLBACK(help_nations_callback)},
1486 {"HELP_CONNECTING", NULL, _("Connecting"),
1487 NULL, NULL, G_CALLBACK(help_connecting_callback)},
1488 {"HELP_CONTROLS", NULL, _("Controls"),
1489 NULL, NULL, G_CALLBACK(help_controls_callback)},
1490 {"HELP_CMA", NULL, _("Citizen Governor"),
1491 NULL, NULL, G_CALLBACK(help_cma_callback)},
1492 {"HELP_CHATLINE", NULL, _("Chatline"),
1493 NULL, NULL, G_CALLBACK(help_chatline_callback)},
1494 {"HELP_WORKLIST_EDITOR", NULL, _("Worklist Editor"),
1495 NULL, NULL, G_CALLBACK(help_worklist_editor_callback)},
1497 {"HELP_LANGUAGES", NULL, _("Languages"),
1498 NULL, NULL, G_CALLBACK(help_language_callback)},
1499 {"HELP_COPYING", NULL, _("Copying"),
1500 NULL, NULL, G_CALLBACK(help_copying_callback)},
1501 {"HELP_ABOUT", NULL, _("About Freeciv"),
1502 NULL, NULL, G_CALLBACK(help_about_callback)}
1505 const GtkToggleActionEntry toggle_entries[] = {
1506 /* Game menu. */
1507 {"SAVE_OPTIONS_ON_EXIT", NULL, _("Save Options on _Exit"),
1508 NULL, NULL, G_CALLBACK(save_options_on_exit_callback), TRUE},
1510 /* Edit menu. */
1511 {"EDIT_MODE", GTK_STOCK_EDIT, _("_Editing Mode"),
1512 "<Control>e", NULL, G_CALLBACK(edit_mode_callback), FALSE},
1514 /* View menu. */
1515 {"SHOW_CITY_OUTLINES", NULL, _("Cit_y Outlines"),
1516 "<Control>y", NULL, G_CALLBACK(show_city_outlines_callback), FALSE},
1517 {"SHOW_CITY_OUTPUT", NULL, _("City Output"),
1518 "<Control>w", NULL, G_CALLBACK(show_city_output_callback), FALSE},
1519 {"SHOW_MAP_GRID", NULL, _("Map _Grid"),
1520 "<Control>g", NULL, G_CALLBACK(show_map_grid_callback), FALSE},
1521 {"SHOW_NATIONAL_BORDERS", NULL, _("National _Borders"),
1522 "<Control>b", NULL,
1523 G_CALLBACK(show_national_borders_callback), FALSE},
1524 {"SHOW_NATIVE_TILES", NULL, _("Native Tiles"),
1525 "<Shift><Control>n", NULL,
1526 G_CALLBACK(show_native_tiles_callback), FALSE},
1527 {"SHOW_CITY_FULL_BAR", NULL, _("City Full Bar"),
1528 NULL, NULL, G_CALLBACK(show_city_full_bar_callback), FALSE},
1529 {"SHOW_CITY_NAMES", NULL, _("City _Names"),
1530 "<Control>n", NULL, G_CALLBACK(show_city_names_callback), FALSE},
1531 {"SHOW_CITY_GROWTH", NULL, _("City G_rowth"),
1532 "<Control>r", NULL, G_CALLBACK(show_city_growth_callback), FALSE},
1533 {"SHOW_CITY_PRODUCTIONS", NULL, _("City _Production Levels"),
1534 "<Control>p", NULL,
1535 G_CALLBACK(show_city_productions_callback), FALSE},
1536 {"SHOW_CITY_BUY_COST", NULL, _("City Buy Cost"),
1537 NULL, NULL, G_CALLBACK(show_city_buy_cost_callback), FALSE},
1538 {"SHOW_CITY_TRADE_ROUTES", NULL, _("City Tra_deroutes"),
1539 "<Control>d", NULL,
1540 G_CALLBACK(show_city_trade_routes_callback), FALSE},
1542 {"SHOW_TERRAIN", NULL, _("_Terrain"),
1543 NULL, NULL, G_CALLBACK(show_terrain_callback), FALSE},
1544 {"SHOW_COASTLINE", NULL, _("C_oastline"),
1545 NULL, NULL, G_CALLBACK(show_coastline_callback), FALSE},
1547 {"SHOW_PATHS", NULL, _("_Paths"),
1548 NULL, NULL, G_CALLBACK(show_road_rails_callback), FALSE},
1549 {"SHOW_IRRIGATION", NULL, _("_Irrigation"),
1550 NULL, NULL, G_CALLBACK(show_irrigation_callback), FALSE},
1551 {"SHOW_MINES", NULL, _("_Mines"),
1552 NULL, NULL, G_CALLBACK(show_mine_callback), FALSE},
1553 {"SHOW_BASES", NULL, _("_Bases"),
1554 NULL, NULL, G_CALLBACK(show_bases_callback), FALSE},
1556 {"SHOW_RESOURCES", NULL, _("_Resources"),
1557 NULL, NULL, G_CALLBACK(show_resources_callback), FALSE},
1558 {"SHOW_HUTS", NULL, _("_Huts"),
1559 NULL, NULL, G_CALLBACK(show_huts_callback), FALSE},
1560 {"SHOW_POLLUTION", NULL, _("Po_llution & Fallout"),
1561 NULL, NULL, G_CALLBACK(show_pollution_callback), FALSE},
1562 {"SHOW_CITIES", NULL, _("Citi_es"),
1563 NULL, NULL, G_CALLBACK(show_cities_callback), FALSE},
1564 {"SHOW_UNITS", NULL, _("_Units"),
1565 NULL, NULL, G_CALLBACK(show_units_callback), FALSE},
1566 {"SHOW_UNIT_SOLID_BG", NULL, _("Unit Solid Background"),
1567 NULL, NULL, G_CALLBACK(show_unit_solid_bg_callback), FALSE},
1568 {"SHOW_UNIT_SHIELDS", NULL, _("Unit shields"),
1569 NULL, NULL, G_CALLBACK(show_unit_shields_callback), FALSE},
1570 {"SHOW_FOCUS_UNIT", NULL, _("Focu_s Unit"),
1571 NULL, NULL, G_CALLBACK(show_focus_unit_callback), FALSE},
1572 {"SHOW_FOG_OF_WAR", NULL, _("Fog of _War"),
1573 NULL, NULL, G_CALLBACK(show_fog_of_war_callback), FALSE},
1575 {"FULL_SCREEN", NULL, _("_Fullscreen"),
1576 "<Alt>Return", NULL, G_CALLBACK(full_screen_callback), FALSE}
1579 group = gtk_action_group_new("SafeGroup");
1580 gtk_action_group_add_actions(group, menu_entries,
1581 G_N_ELEMENTS(menu_entries), NULL);
1582 gtk_action_group_add_actions(group, action_entries,
1583 G_N_ELEMENTS(action_entries), NULL);
1584 gtk_action_group_add_toggle_actions(group, toggle_entries,
1585 G_N_ELEMENTS(toggle_entries), NULL);
1588 return group;
1591 /****************************************************************
1592 Returns the group of the actions which are available only
1593 when the edit mode is enabled. Create it if not existent.
1594 *****************************************************************/
1595 static GtkActionGroup *get_edit_group(void)
1597 static GtkActionGroup *group = NULL;
1599 if (!group) {
1600 const GtkActionEntry action_entries[] = {
1601 /* Edit menu. */
1602 {"RECALC_BORDERS", NULL, _("Recalculate _Borders"),
1603 NULL, NULL, G_CALLBACK(recalc_borders_callback)},
1604 {"TOGGLE_FOG", NULL, _("Toggle Fog of _War"),
1605 "<Control>m", NULL, G_CALLBACK(toggle_fog_callback)},
1606 {"SCENARIO_PROPERTIES", NULL, _("Game/Scenario Properties"),
1607 NULL, NULL, G_CALLBACK(scenario_properties_callback)},
1608 {"SAVE_SCENARIO", GTK_STOCK_SAVE_AS, _("Save Scenario"),
1609 NULL, NULL, G_CALLBACK(save_scenario_callback)}
1612 group = gtk_action_group_new("EditGroup");
1613 gtk_action_group_add_actions(group, action_entries,
1614 G_N_ELEMENTS(action_entries), NULL);
1617 return group;
1620 /****************************************************************
1621 Returns the group of the actions which are available only
1622 when units are selected. Create it if not existent.
1623 *****************************************************************/
1624 static GtkActionGroup *get_unit_group(void)
1626 static GtkActionGroup *group = NULL;
1628 if (!group) {
1629 const GtkActionEntry menu_entries[] = {
1630 {"MENU_SELECT", NULL, _("_Select"), NULL, NULL, NULL},
1631 {"MENU_UNIT", NULL, _("_Unit"), NULL, NULL, NULL},
1632 {"MENU_WORK", NULL, _("_Work"), NULL, NULL, NULL},
1633 {"MENU_COMBAT", NULL, _("_Combat"), NULL, NULL, NULL},
1634 {"MENU_BUILD_BASE", NULL, _("Build _Base"), NULL, NULL, NULL},
1635 {"MENU_BUILD_PATH", NULL, _("Build _Path"), NULL, NULL, NULL}
1638 const GtkActionEntry action_entries[] = {
1639 /* Select menu. */
1640 {"SELECT_SINGLE", NULL, _("_Single Unit (Unselect Others)"),
1641 "z", NULL, G_CALLBACK(select_single_callback)},
1642 {"SELECT_ALL_ON_TILE", NULL, _("_All On Tile"),
1643 "v", NULL, G_CALLBACK(select_all_on_tile_callback)},
1645 {"SELECT_SAME_TYPE_TILE", NULL, _("Same Type on _Tile"),
1646 "<shift>v", NULL, G_CALLBACK(select_same_type_tile_callback)},
1647 {"SELECT_SAME_TYPE_CONT", NULL, _("Same Type on _Continent"),
1648 "<shift>c", NULL, G_CALLBACK(select_same_type_cont_callback)},
1649 {"SELECT_SAME_TYPE", NULL, _("Same Type _Everywhere"),
1650 "<shift>x", NULL, G_CALLBACK(select_same_type_callback)},
1652 {"SELECT_DLG", NULL, _("Unit selection dialog"),
1653 NULL, NULL, G_CALLBACK(select_dialog_callback)},
1655 {"UNIT_WAIT", NULL, _("_Wait"),
1656 "w", NULL, G_CALLBACK(unit_wait_callback)},
1657 {"UNIT_DONE", NULL, _("_Done"),
1658 "space", NULL, G_CALLBACK(unit_done_callback)},
1660 /* Unit menu. */
1661 {"UNIT_GOTO", NULL, _("_Go to"),
1662 "g", NULL, G_CALLBACK(unit_goto_callback)},
1663 {"UNIT_GOTO_CITY", NULL, _("Go _to/Airlift to City..."),
1664 "t", NULL, G_CALLBACK(unit_goto_city_callback)},
1665 {"UNIT_RETURN", NULL, _("_Return to Nearest City"),
1666 "<Shift>g", NULL, G_CALLBACK(unit_return_callback)},
1667 {"UNIT_EXPLORE", NULL, _("Auto E_xplore"),
1668 "x", NULL, G_CALLBACK(unit_explore_callback)},
1669 {"UNIT_PATROL", NULL, _("_Patrol"),
1670 "q", NULL, G_CALLBACK(unit_patrol_callback)},
1672 {"UNIT_SENTRY", NULL, _("_Sentry"),
1673 "s", NULL, G_CALLBACK(unit_sentry_callback)},
1674 {"UNIT_UNSENTRY", NULL, _("Uns_entry All On Tile"),
1675 "<Shift>s", NULL, G_CALLBACK(unit_unsentry_callback)},
1677 {"UNIT_LOAD", NULL, _("_Load"),
1678 "l", NULL, G_CALLBACK(unit_load_callback)},
1679 {"UNIT_UNLOAD", NULL, _("_Unload"),
1680 "u", NULL, G_CALLBACK(unit_unload_callback)},
1681 {"UNIT_UNLOAD_TRANSPORTER", NULL, _("U_nload All From Transporter"),
1682 "<Shift>t", NULL, G_CALLBACK(unit_unload_transporter_callback)},
1684 {"UNIT_HOMECITY", NULL, _("Set _Home City"),
1685 "h", NULL, G_CALLBACK(unit_homecity_callback)},
1686 {"UNIT_UPGRADE", NULL, _("Upgr_ade"),
1687 "<Shift>u", NULL, G_CALLBACK(unit_upgrade_callback)},
1688 {"UNIT_CONVERT", NULL, _("C_onvert"),
1689 "<Shift>o", NULL, G_CALLBACK(unit_convert_callback)},
1690 {"UNIT_DISBAND", NULL, _("_Disband"),
1691 "<Shift>d", NULL, G_CALLBACK(unit_disband_callback)},
1693 /* Work menu. */
1694 {"BUILD_CITY", NULL, _("_Build City"),
1695 "b", NULL, G_CALLBACK(build_city_callback)},
1696 {"GO_BUILD_CITY", NULL, _("Go _to and Build city"),
1697 "<Shift>b", NULL, G_CALLBACK(go_build_city_callback)},
1698 {"AUTO_SETTLER", NULL, _("_Auto Settler"),
1699 "a", NULL, G_CALLBACK(auto_settle_callback)},
1701 {"BUILD_ROAD", NULL, _("Build _Road"),
1702 "r", NULL, G_CALLBACK(build_road_callback)},
1703 {"BUILD_IRRIGATION", NULL, _("Build _Irrigation"),
1704 "i", NULL, G_CALLBACK(build_irrigation_callback)},
1705 {"BUILD_MINE", NULL, _("Build _Mine"),
1706 "m", NULL, G_CALLBACK(build_mine_callback)},
1708 {"CONNECT_ROAD", NULL, _("Connect With Roa_d"),
1709 "<Shift>r", NULL, G_CALLBACK(connect_road_callback)},
1710 {"CONNECT_RAIL", NULL, _("Connect With Rai_l"),
1711 "<Shift>l", NULL, G_CALLBACK(connect_rail_callback)},
1712 {"CONNECT_IRRIGATION", NULL, _("Connect With Irri_gation"),
1713 "<Shift>i", NULL, G_CALLBACK(connect_irrigation_callback)},
1715 {"TRANSFORM_TERRAIN", NULL, _("Transf_orm Terrain"),
1716 "o", NULL, G_CALLBACK(transform_terrain_callback)},
1717 {"CLEAN_POLLUTION", NULL, _("Clean _Pollution"),
1718 "p", NULL, G_CALLBACK(clean_pollution_callback)},
1719 {"CLEAN_FALLOUT", NULL, _("Clean _Nuclear Fallout"),
1720 "n", NULL, G_CALLBACK(clean_fallout_callback)},
1722 /* Combat menu. */
1723 {"FORTIFY", NULL, _("Fortify"),
1724 "f", NULL, G_CALLBACK(fortify_callback)},
1725 {"BUILD_FORTRESS", NULL, _("Build Fortress"),
1726 "<Shift>f", NULL, G_CALLBACK(build_fortress_callback)},
1727 {"BUILD_AIRBASE", NULL, _("Build Airbase"),
1728 "<Shift>e", NULL, G_CALLBACK(build_airbase_callback)},
1730 {"DO_PILLAGE", NULL, _("_Pillage"),
1731 "<Shift>p", NULL, G_CALLBACK(do_pillage_callback)},
1732 /* TRANS: Menu item to bring up the action selection dialog. */
1733 {"DIPLOMAT_ACTION", NULL, _("_Do..."),
1734 "d", NULL, G_CALLBACK(diplomat_action_callback)},
1735 {"EXPLODE_NUKE", NULL, _("Explode _Nuclear"),
1736 "<Shift>n", NULL, G_CALLBACK(explode_nuke_callback)},
1739 group = gtk_action_group_new("UnitGroup");
1740 gtk_action_group_add_actions(group, menu_entries,
1741 G_N_ELEMENTS(menu_entries), NULL);
1742 gtk_action_group_add_actions(group, action_entries,
1743 G_N_ELEMENTS(action_entries), NULL);
1746 return group;
1749 /****************************************************************
1750 Returns the group of the actions which are available only
1751 when the user is really playing, not observing. Create it
1752 if not existent.
1753 *****************************************************************/
1754 static GtkActionGroup *get_playing_group(void)
1756 static GtkActionGroup *group = NULL;
1758 if (!group) {
1759 const GtkActionEntry menu_entries[] = {
1760 {"MENU_GOVERNMENT", NULL, _("_Government"), NULL, NULL, NULL},
1763 const GtkActionEntry action_entries[] = {
1764 /* Civilization menu. */
1765 {"TAX_RATE", NULL, _("_Tax Rates..."),
1766 "<Control>t", NULL, G_CALLBACK(tax_rate_callback)},
1767 /* Civilization/Government menu. */
1768 {"START_REVOLUTION", NULL, _("_Revolution..."),
1769 "<Shift><Control>r", NULL, G_CALLBACK(government_callback)},
1772 group = gtk_action_group_new("PlayingGroup");
1773 gtk_action_group_add_actions(group, menu_entries,
1774 G_N_ELEMENTS(menu_entries), NULL);
1775 /* NULL for user_data parameter is required by government_callback() */
1776 gtk_action_group_add_actions(group, action_entries,
1777 G_N_ELEMENTS(action_entries), NULL);
1780 return group;
1783 /****************************************************************
1784 Returns the group of the actions which are available only
1785 when the user is attached to a particular player, playing or
1786 observing (but not global observing). Create it if not existent.
1787 *****************************************************************/
1788 static GtkActionGroup *get_player_group(void)
1790 static GtkActionGroup *group = NULL;
1792 if (!group) {
1793 const GtkActionEntry action_entries[] = {
1794 /* View menu. */
1795 {"CENTER_VIEW", NULL, _("_Center View"),
1796 "c", NULL, G_CALLBACK(center_view_callback)},
1798 /* Civilization menu. */
1799 {"REPORT_ECONOMY", NULL, _("_Economy"),
1800 "F5", NULL, G_CALLBACK(report_economy_callback)},
1801 {"REPORT_RESEARCH", NULL, _("_Research"),
1802 "F6", NULL, G_CALLBACK(report_research_callback)},
1804 /* Civilization/Policies menu */
1805 {"POLICIES", NULL, _("_Policies..."),
1806 "<Shift><Control>p", NULL, G_CALLBACK(multiplier_callback)},
1808 {"REPORT_SPACESHIP", NULL, _("_Spaceship"),
1809 "F12", NULL, G_CALLBACK(report_spaceship_callback)},
1810 {"REPORT_ACHIEVEMENTS", NULL, _("_Achievements"),
1811 "asterisk", NULL, G_CALLBACK(report_achievements_callback)}
1814 group = gtk_action_group_new("PlayerGroup");
1815 gtk_action_group_add_actions(group, action_entries,
1816 G_N_ELEMENTS(action_entries), NULL);
1819 return group;
1822 /****************************************************************
1823 Returns the name of the file readable by the GtkUIManager.
1824 *****************************************************************/
1825 static const gchar *get_ui_filename(void)
1827 static char filename[256];
1828 const char *name;
1830 if ((name = getenv("FREECIV_MENUS"))
1831 || (name = fileinfoname(get_data_dirs(), "gtk3_menus.xml"))) {
1832 sz_strlcpy(filename, name);
1833 } else {
1834 log_error("Gtk menus: file definition not found");
1835 filename[0] = '\0';
1838 log_verbose("ui menu file is \"%s\".", filename);
1839 return filename;
1842 /****************************************************************
1843 Called when a main widget is added by the GtkUIManager.
1844 *****************************************************************/
1845 static void add_widget_callback(GtkUIManager *mgr, GtkWidget *widget,
1846 gpointer data)
1848 gtk_container_add(GTK_CONTAINER(data), widget);
1849 gtk_widget_show(widget);
1852 /****************************************************************
1853 Creates the menu bar.
1854 *****************************************************************/
1855 GtkWidget *setup_menus(GtkWidget *window)
1857 GtkWidget *menubar = gtk_grid_new();
1858 GError *error = NULL;
1860 /* Creates the UI manager. */
1861 ui_manager = gtk_ui_manager_new();
1862 /* FIXME - following line commented out due to Gna bug #17162 */
1863 /* gtk_ui_manager_set_add_tearoffs(ui_manager, TRUE); */
1864 g_signal_connect(ui_manager, "add_widget",
1865 G_CALLBACK(add_widget_callback), menubar);
1867 /* Creates the actions. */
1868 gtk_ui_manager_insert_action_group(ui_manager, get_safe_group(), -1);
1869 gtk_ui_manager_insert_action_group(ui_manager, get_edit_group(), -1);
1870 gtk_ui_manager_insert_action_group(ui_manager, get_unit_group(), -1);
1871 gtk_ui_manager_insert_action_group(ui_manager, get_playing_group(), -1);
1872 gtk_ui_manager_insert_action_group(ui_manager, get_player_group(), -1);
1874 /* Enable shortcuts. */
1875 gtk_window_add_accel_group(GTK_WINDOW(window),
1876 gtk_ui_manager_get_accel_group(ui_manager));
1878 /* Load the menus. */
1879 if (0 == gtk_ui_manager_add_ui_from_file(ui_manager,
1880 get_ui_filename(), &error)) {
1881 log_error("Gtk menus: %s", error->message);
1882 g_error_free(error);
1885 #ifndef DEBUG
1886 menus_set_visible(get_safe_group(), "RELOAD_TILESET", FALSE, FALSE);
1887 #endif /* DEBUG */
1889 return menubar;
1892 /****************************************************************
1893 Sets an action active.
1894 *****************************************************************/
1895 static void menus_set_active(GtkActionGroup *group,
1896 const gchar *action_name,
1897 gboolean is_active)
1899 GtkAction *action = gtk_action_group_get_action(group, action_name);
1901 if (!action) {
1902 log_error("Can't set active for non-existent "
1903 "action \"%s\" in group \"%s\".",
1904 action_name, gtk_action_group_get_name(group));
1905 return;
1908 if (!GTK_IS_TOGGLE_ACTION(action)) {
1909 log_error("Can't set active for non-togglable "
1910 "action \"%s\" in group \"%s\".",
1911 action_name, gtk_action_group_get_name(group));
1912 return;
1915 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), is_active);
1918 /****************************************************************
1919 Sets an action sensitive.
1920 *****************************************************************/
1921 static void menus_set_sensitive(GtkActionGroup *group,
1922 const gchar *action_name,
1923 gboolean is_sensitive)
1925 GtkAction *action = gtk_action_group_get_action(group, action_name);
1927 if (!action) {
1928 log_error("Can't set active for non-existent "
1929 "action \"%s\" in group \"%s\".",
1930 action_name, gtk_action_group_get_name(group));
1931 return;
1934 gtk_action_set_sensitive(action, is_sensitive);
1937 /****************************************************************
1938 Sets an action visible.
1939 *****************************************************************/
1940 #ifndef DEBUG
1941 static void menus_set_visible(GtkActionGroup *group,
1942 const gchar *action_name,
1943 gboolean is_visible,
1944 gboolean is_sensitive)
1946 GtkAction *action = gtk_action_group_get_action(group, action_name);
1948 if (!action) {
1949 log_error("Can't set visible for non-existent "
1950 "action \"%s\" in group \"%s\".",
1951 action_name, gtk_action_group_get_name(group));
1952 return;
1955 gtk_action_set_visible(action, is_visible);
1956 gtk_action_set_sensitive(action, is_sensitive);
1958 #endif /* DEBUG */
1960 /****************************************************************
1961 Renames an action.
1962 *****************************************************************/
1963 static void menus_rename(GtkActionGroup *group,
1964 const gchar *action_name,
1965 const gchar *new_label)
1967 GtkAction *action = gtk_action_group_get_action(group, action_name);
1969 if (!action) {
1970 log_error("Can't rename non-existent "
1971 "action \"%s\" in group \"%s\".",
1972 action_name, gtk_action_group_get_name(group));
1973 return;
1976 gtk_action_set_label(action, new_label);
1979 /****************************************************************
1980 Find the child menu of an action.
1981 *****************************************************************/
1982 static GtkMenu *find_action_menu(GtkActionGroup *group,
1983 const gchar *action_name)
1985 GtkAction *action = gtk_action_group_get_action(group, action_name);
1986 GSList *iter;
1988 if (!action) {
1989 return NULL;
1992 for (iter = gtk_action_get_proxies(action); iter;
1993 iter = g_slist_next(iter)) {
1994 if (GTK_IS_MENU_ITEM(iter->data)) {
1995 return GTK_MENU(gtk_menu_item_get_submenu(GTK_MENU_ITEM(iter->data)));
1999 return NULL;
2002 /****************************************************************
2003 Update the sensitivity of the items in the view menu.
2004 *****************************************************************/
2005 static void view_menu_update_sensitivity(void)
2007 GtkActionGroup *safe_group = get_safe_group();
2009 /* The "full" city bar (i.e. the new way of drawing the
2010 * city name), can draw the city growth even without drawing
2011 * the city name. But the old method cannot. */
2012 if (gui_options.draw_full_citybar) {
2013 menus_set_sensitive(safe_group, "SHOW_CITY_GROWTH", TRUE);
2014 menus_set_sensitive(safe_group, "SHOW_CITY_TRADE_ROUTES", TRUE);
2015 } else {
2016 menus_set_sensitive(safe_group, "SHOW_CITY_GROWTH", gui_options.draw_city_names);
2017 menus_set_sensitive(safe_group, "SHOW_CITY_TRADE_ROUTES",
2018 gui_options.draw_city_names);
2021 menus_set_sensitive(safe_group, "SHOW_CITY_BUY_COST",
2022 gui_options.draw_city_productions);
2023 menus_set_sensitive(safe_group, "SHOW_COASTLINE", !gui_options.draw_terrain);
2024 menus_set_sensitive(safe_group, "SHOW_UNIT_SOLID_BG",
2025 gui_options.draw_units || gui_options.draw_focus_unit);
2026 menus_set_sensitive(safe_group, "SHOW_UNIT_SHIELDS",
2027 gui_options.draw_units || gui_options.draw_focus_unit);
2028 menus_set_sensitive(safe_group, "SHOW_FOCUS_UNIT", !gui_options.draw_units);
2031 /****************************************************************************
2032 Return the text for the tile, changed by the activity.
2034 Should only be called for irrigation, mining, or transformation, and
2035 only when the activity changes the base terrain type.
2036 ****************************************************************************/
2037 static const char *get_tile_change_menu_text(struct tile *ptile,
2038 enum unit_activity activity)
2040 struct tile *newtile = tile_virtual_new(ptile);
2041 const char *text;
2043 tile_apply_activity(newtile, activity, NULL);
2044 text = tile_get_info_text(newtile, FALSE, 0);
2045 tile_virtual_destroy(newtile);
2046 return text;
2049 /****************************************************************
2050 Updates the menus.
2051 *****************************************************************/
2052 void real_menus_update(void)
2054 GtkActionGroup *safe_group;
2055 GtkActionGroup *edit_group;
2056 GtkActionGroup *unit_group;
2057 GtkActionGroup *playing_group;
2058 struct unit_list *punits = NULL;
2059 bool units_all_same_tile = TRUE, units_all_same_type = TRUE;
2060 GtkMenu *menu;
2061 char acttext[128], irrtext[128], mintext[128], transtext[128];
2062 struct terrain *pterrain;
2063 bool conn_possible;
2064 struct road_type *proad;
2065 struct extra_type_list *extras;
2067 if (NULL == ui_manager && !can_client_change_view()) {
2068 return;
2071 safe_group = get_safe_group();
2072 edit_group = get_edit_group();
2073 unit_group = get_unit_group();
2074 playing_group = get_playing_group();
2076 if (get_num_units_in_focus() > 0) {
2077 const struct tile *ptile = NULL;
2078 const struct unit_type *ptype = NULL;
2079 punits = get_units_in_focus();
2080 unit_list_iterate(punits, punit) {
2081 fc_assert((ptile==NULL) == (ptype==NULL));
2082 if (ptile || ptype) {
2083 if (unit_tile(punit) != ptile) {
2084 units_all_same_tile = FALSE;
2086 if (unit_type_get(punit) != ptype) {
2087 units_all_same_type = FALSE;
2089 } else {
2090 ptile = unit_tile(punit);
2091 ptype = unit_type_get(punit);
2093 } unit_list_iterate_end;
2096 gtk_action_group_set_sensitive(edit_group,
2097 editor_is_active());
2098 gtk_action_group_set_sensitive(playing_group, can_client_issue_orders()
2099 && !editor_is_active());
2100 gtk_action_group_set_sensitive(unit_group, can_client_issue_orders()
2101 && !editor_is_active() && punits != NULL);
2103 menus_set_active(safe_group, "EDIT_MODE", game.info.is_edit_mode);
2104 menus_set_sensitive(safe_group, "EDIT_MODE",
2105 can_conn_enable_editing(&client.conn));
2106 editgui_refresh();
2109 char road_buf[500];
2111 proad = road_by_compat_special(ROCO_ROAD);
2112 if (proad != NULL) {
2113 /* TRANS: Connect with some road type (Road/Railroad) */
2114 snprintf(road_buf, sizeof(road_buf), _("Connect With %s"),
2115 extra_name_translation(road_extra_get(proad)));
2116 menus_rename(unit_group, "CONNECT_ROAD", road_buf);
2119 proad = road_by_compat_special(ROCO_RAILROAD);
2120 if (proad != NULL) {
2121 snprintf(road_buf, sizeof(road_buf), _("Connect With %s"),
2122 extra_name_translation(road_extra_get(proad)));
2123 menus_rename(unit_group, "CONNECT_RAIL", road_buf);
2127 if (!can_client_issue_orders()) {
2128 return;
2131 /* Set government sensitivity. */
2132 if ((menu = find_action_menu(playing_group, "MENU_GOVERNMENT"))) {
2133 GList *list, *iter;
2134 struct government *pgov;
2136 list = gtk_container_get_children(GTK_CONTAINER(menu));
2137 for (iter = list; NULL != iter; iter = g_list_next(iter)) {
2138 pgov = g_object_get_data(G_OBJECT(iter->data), "government");
2139 if (NULL != pgov) {
2140 gtk_widget_set_sensitive(GTK_WIDGET(iter->data),
2141 can_change_to_government(client_player(),
2142 pgov));
2143 } else {
2144 /* Revolution without target government */
2145 gtk_widget_set_sensitive(GTK_WIDGET(iter->data),
2146 untargeted_revolution_allowed());
2149 g_list_free(list);
2152 if (!punits) {
2153 return;
2156 /* Remaining part of this function: Update Unit, Work, and Combat menus */
2158 /* Set base sensitivity. */
2159 if ((menu = find_action_menu(unit_group, "MENU_BUILD_BASE"))) {
2160 GList *list, *iter;
2161 struct extra_type *pextra;
2163 list = gtk_container_get_children(GTK_CONTAINER(menu));
2164 for (iter = list; NULL != iter; iter = g_list_next(iter)) {
2165 pextra = g_object_get_data(G_OBJECT(iter->data), "base");
2166 if (NULL != pextra) {
2167 gtk_widget_set_sensitive(GTK_WIDGET(iter->data),
2168 can_units_do_activity_targeted(punits,
2169 ACTIVITY_BASE,
2170 pextra));
2173 g_list_free(list);
2176 /* Set road sensitivity. */
2177 if ((menu = find_action_menu(unit_group, "MENU_BUILD_PATH"))) {
2178 GList *list, *iter;
2179 struct extra_type *pextra;
2181 list = gtk_container_get_children(GTK_CONTAINER(menu));
2182 for (iter = list; NULL != iter; iter = g_list_next(iter)) {
2183 pextra = g_object_get_data(G_OBJECT(iter->data), "road");
2184 if (NULL != pextra) {
2185 gtk_widget_set_sensitive(GTK_WIDGET(iter->data),
2186 can_units_do_activity_targeted(punits,
2187 ACTIVITY_GEN_ROAD,
2188 pextra));
2191 g_list_free(list);
2194 /* Enable the button for adding to a city in all cases, so we
2195 * get an eventual error message from the server if we try. */
2196 menus_set_sensitive(unit_group, "BUILD_CITY",
2197 (can_units_do(punits, unit_can_add_or_build_city)
2198 || can_units_do(punits, unit_can_help_build_wonder_here)));
2199 menus_set_sensitive(unit_group, "GO_BUILD_CITY",
2200 units_contain_cityfounder(punits));
2201 menus_set_sensitive(unit_group, "BUILD_ROAD",
2202 (can_units_do_any_road(punits)
2203 || can_units_do(punits,
2204 unit_can_est_trade_route_here)));
2205 menus_set_sensitive(unit_group, "BUILD_IRRIGATION",
2206 can_units_do_activity(punits, ACTIVITY_IRRIGATE));
2207 menus_set_sensitive(unit_group, "BUILD_MINE",
2208 can_units_do_activity(punits, ACTIVITY_MINE));
2209 menus_set_sensitive(unit_group, "TRANSFORM_TERRAIN",
2210 can_units_do_activity(punits, ACTIVITY_TRANSFORM));
2211 menus_set_sensitive(unit_group, "FORTIFY",
2212 can_units_do_activity(punits,
2213 ACTIVITY_FORTIFYING));
2214 menus_set_sensitive(unit_group, "BUILD_FORTRESS",
2215 can_units_do_base_gui(punits, BASE_GUI_FORTRESS));
2216 menus_set_sensitive(unit_group, "BUILD_AIRBASE",
2217 can_units_do_base_gui(punits, BASE_GUI_AIRBASE));
2218 menus_set_sensitive(unit_group, "CLEAN_POLLUTION",
2219 (can_units_do_activity(punits, ACTIVITY_POLLUTION)
2220 || can_units_do(punits, can_unit_paradrop)));
2221 menus_set_sensitive(unit_group, "CLEAN_FALLOUT",
2222 can_units_do_activity(punits, ACTIVITY_FALLOUT));
2223 menus_set_sensitive(unit_group, "UNIT_SENTRY",
2224 can_units_do_activity(punits, ACTIVITY_SENTRY));
2225 /* FIXME: should conditionally rename "Pillage" to "Pillage..." in cases where
2226 * selecting the command results in a dialog box listing options of what to pillage */
2227 menus_set_sensitive(unit_group, "DO_PILLAGE",
2228 can_units_do_activity(punits, ACTIVITY_PILLAGE));
2229 menus_set_sensitive(unit_group, "UNIT_DISBAND",
2230 units_have_type_flag(punits, UTYF_UNDISBANDABLE, FALSE));
2231 menus_set_sensitive(unit_group, "UNIT_UPGRADE",
2232 units_can_upgrade(punits));
2233 /* "UNIT_CONVERT" dealt with below */
2234 menus_set_sensitive(unit_group, "UNIT_HOMECITY",
2235 can_units_do(punits, can_unit_change_homecity));
2236 menus_set_sensitive(unit_group, "UNIT_UNLOAD_TRANSPORTER",
2237 units_are_occupied(punits));
2238 menus_set_sensitive(unit_group, "UNIT_LOAD",
2239 units_can_load(punits));
2240 menus_set_sensitive(unit_group, "UNIT_UNLOAD",
2241 units_can_unload(punits));
2242 menus_set_sensitive(unit_group, "UNIT_UNSENTRY",
2243 units_have_activity_on_tile(punits,
2244 ACTIVITY_SENTRY));
2245 menus_set_sensitive(unit_group, "AUTO_SETTLER",
2246 can_units_do(punits, can_unit_do_autosettlers));
2247 menus_set_sensitive(unit_group, "UNIT_EXPLORE",
2248 can_units_do_activity(punits, ACTIVITY_EXPLORE));
2250 proad = road_by_compat_special(ROCO_ROAD);
2251 if (proad != NULL) {
2252 struct extra_type *tgt;
2254 tgt = road_extra_get(proad);
2256 conn_possible = can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt);
2257 } else {
2258 conn_possible = FALSE;
2260 menus_set_sensitive(unit_group, "CONNECT_ROAD", conn_possible);
2262 proad = road_by_compat_special(ROCO_RAILROAD);
2263 if (proad != NULL) {
2264 struct extra_type *tgt;
2266 tgt = road_extra_get(proad);
2268 conn_possible = can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt);
2269 } else {
2270 conn_possible = FALSE;
2272 menus_set_sensitive(unit_group, "CONNECT_RAIL", conn_possible);
2274 extras = extra_type_list_by_cause(EC_IRRIGATION);
2276 if (extra_type_list_size(extras) > 0) {
2277 struct extra_type *tgt;
2279 tgt = extra_type_list_get(extras, 0);
2280 conn_possible = can_units_do_connect(punits, ACTIVITY_IRRIGATE, tgt);
2281 } else {
2282 conn_possible = FALSE;
2284 menus_set_sensitive(unit_group, "CONNECT_IRRIGATION", conn_possible);
2286 menus_set_sensitive(unit_group, "DIPLOMAT_ACTION",
2287 units_can_do_action(punits, ACTION_ANY, TRUE));
2288 menus_set_sensitive(unit_group, "EXPLODE_NUKE",
2289 units_have_type_flag(punits, UTYF_NUCLEAR, TRUE));
2291 if (units_can_do_action(punits, ACTION_HELP_WONDER, TRUE)) {
2292 menus_rename(unit_group, "BUILD_CITY",
2293 action_get_ui_name_mnemonic(ACTION_HELP_WONDER, "_"));
2294 } else {
2295 bool city_on_tile = FALSE;
2297 /* FIXME: this overloading doesn't work well with multiple focus
2298 * units. */
2299 unit_list_iterate(punits, punit) {
2300 if (tile_city(unit_tile(punit))) {
2301 city_on_tile = TRUE;
2302 break;
2304 } unit_list_iterate_end;
2306 if (city_on_tile && units_have_type_flag(punits, UTYF_ADD_TO_CITY, TRUE)) {
2307 menus_rename(unit_group, "BUILD_CITY", _("Add to City"));
2308 } else {
2309 /* refresh default order */
2310 menus_rename(unit_group, "BUILD_CITY", _("_Build City"));
2314 if (units_can_do_action(punits, ACTION_TRADE_ROUTE, TRUE)) {
2315 menus_rename(unit_group, "BUILD_ROAD",
2316 action_get_ui_name_mnemonic(ACTION_TRADE_ROUTE, "_"));
2317 } else if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) {
2318 char road_item[500];
2319 struct extra_type *pextra = NULL;
2321 /* FIXME: this overloading doesn't work well with multiple focus
2322 * units. */
2323 unit_list_iterate(punits, punit) {
2324 pextra = next_extra_for_tile(unit_tile(punit), EC_ROAD,
2325 unit_owner(punit), punit);
2326 if (pextra != NULL) {
2327 break;
2329 } unit_list_iterate_end;
2331 if (pextra != NULL) {
2332 /* TRANS: Build road of specific type (Road/Railroad) */
2333 snprintf(road_item, sizeof(road_item), _("Build %s"),
2334 extra_name_translation(pextra));
2335 menus_rename(unit_group, "BUILD_ROAD", road_item);
2337 } else {
2338 menus_rename(unit_group, "BUILD_ROAD", _("Build _Road"));
2341 if (units_all_same_type) {
2342 struct unit *punit = unit_list_get(punits, 0);
2343 struct unit_type *to_unittype =
2344 can_upgrade_unittype(client_player(), unit_type_get(punit));
2345 if (to_unittype) {
2346 /* TRANS: %s is a unit type. */
2347 fc_snprintf(acttext, sizeof(acttext), _("Upgr_ade to %s"),
2348 utype_name_translation(
2349 can_upgrade_unittype(client_player(),
2350 unit_type_get(punit))));
2351 } else {
2352 acttext[0] = '\0';
2354 } else {
2355 acttext[0] = '\0';
2357 if ('\0' != acttext[0]) {
2358 menus_rename(unit_group, "UNIT_UPGRADE", acttext);
2359 } else {
2360 menus_rename(unit_group, "UNIT_UPGRADE", _("Upgr_ade"));
2363 if (units_can_convert(punits)) {
2364 menus_set_sensitive(unit_group, "UNIT_CONVERT", TRUE);
2365 if (units_all_same_type) {
2366 struct unit *punit = unit_list_get(punits, 0);
2367 /* TRANS: %s is a unit type. */
2368 fc_snprintf(acttext, sizeof(acttext), _("C_onvert to %s"),
2369 utype_name_translation(unit_type_get(punit)->converted_to));
2370 } else {
2371 acttext[0] = '\0';
2373 } else {
2374 menus_set_sensitive(unit_group, "UNIT_CONVERT", FALSE);
2375 acttext[0] = '\0';
2377 if ('\0' != acttext[0]) {
2378 menus_rename(unit_group, "UNIT_CONVERT", acttext);
2379 } else {
2380 menus_rename(unit_group, "UNIT_CONVERT", _("C_onvert"));
2383 if (units_all_same_tile) {
2384 struct unit *first = unit_list_get(punits, 0);
2386 pterrain = tile_terrain(unit_tile(first));
2387 if (pterrain->irrigation_result != T_NONE
2388 && pterrain->irrigation_result != pterrain) {
2389 fc_snprintf(irrtext, sizeof(irrtext), _("Change to %s"),
2390 get_tile_change_menu_text(unit_tile(first),
2391 ACTIVITY_IRRIGATE));
2392 } else if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) {
2393 struct extra_type *pextra = NULL;
2395 /* FIXME: this overloading doesn't work well with multiple focus
2396 * units. */
2397 unit_list_iterate(punits, punit) {
2398 pextra = next_extra_for_tile(unit_tile(punit), EC_IRRIGATION,
2399 unit_owner(punit), punit);
2400 if (pextra != NULL) {
2401 break;
2403 } unit_list_iterate_end;
2405 if (pextra != NULL) {
2406 /* TRANS: Build irrigation of specific type */
2407 snprintf(irrtext, sizeof(irrtext), _("Build %s"),
2408 extra_name_translation(pextra));
2409 } else {
2410 sz_strlcpy(irrtext, _("Build _Irrigation"));
2412 } else {
2413 sz_strlcpy(irrtext, _("Build _Irrigation"));
2416 if (pterrain->mining_result != T_NONE
2417 && pterrain->mining_result != pterrain) {
2418 fc_snprintf(mintext, sizeof(mintext), _("Change to %s"),
2419 get_tile_change_menu_text(unit_tile(first), ACTIVITY_MINE));
2420 } else if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) {
2421 struct extra_type *pextra = NULL;
2423 /* FIXME: this overloading doesn't work well with multiple focus
2424 * units. */
2425 unit_list_iterate(punits, punit) {
2426 pextra = next_extra_for_tile(unit_tile(punit), EC_MINE,
2427 unit_owner(punit), punit);
2428 if (pextra != NULL) {
2429 break;
2431 } unit_list_iterate_end;
2433 if (pextra != NULL) {
2434 /* TRANS: Build mine of specific type */
2435 snprintf(mintext, sizeof(mintext), _("Build %s"),
2436 extra_name_translation(pextra));
2437 } else {
2438 sz_strlcpy(mintext, _("Build _Mine"));
2440 } else {
2441 sz_strlcpy(mintext, _("Build _Mine"));
2444 if (pterrain->transform_result != T_NONE
2445 && pterrain->transform_result != pterrain) {
2446 fc_snprintf(transtext, sizeof(transtext), _("Transf_orm to %s"),
2447 get_tile_change_menu_text(unit_tile(first),
2448 ACTIVITY_TRANSFORM));
2449 } else {
2450 sz_strlcpy(transtext, _("Transf_orm Terrain"));
2452 } else {
2453 sz_strlcpy(irrtext, _("Build _Irrigation"));
2454 sz_strlcpy(mintext, _("Build _Mine"));
2455 sz_strlcpy(transtext, _("Transf_orm Terrain"));
2458 menus_rename(unit_group, "BUILD_IRRIGATION", irrtext);
2459 menus_rename(unit_group, "BUILD_MINE", mintext);
2460 menus_rename(unit_group, "TRANSFORM_TERRAIN", transtext);
2462 if (units_have_type_flag(punits, UTYF_PARATROOPERS, TRUE)) {
2463 menus_rename(unit_group, "CLEAN_POLLUTION", _("Drop _Paratrooper"));
2464 } else {
2465 menus_rename(unit_group, "CLEAN_POLLUTION", _("Clean _Pollution"));
2469 /**************************************************************************
2470 Initialize menus (sensitivity, name, etc.) based on the
2471 current state and current ruleset, etc. Call menus_update().
2472 **************************************************************************/
2473 void real_menus_init(void)
2475 GtkActionGroup *safe_group;
2476 GtkActionGroup *edit_group;
2477 GtkActionGroup *unit_group;
2478 GtkActionGroup *playing_group;
2479 GtkActionGroup *player_group;
2480 GtkMenu *menu;
2482 if (NULL == ui_manager) {
2483 return;
2486 safe_group = get_safe_group();
2487 edit_group = get_edit_group();
2488 unit_group = get_unit_group();
2489 playing_group = get_playing_group();
2490 player_group = get_player_group();
2492 menus_set_sensitive(safe_group, "GAME_SAVE_AS",
2493 can_client_access_hack()
2494 && C_S_RUNNING <= client_state());
2495 menus_set_sensitive(safe_group, "GAME_SAVE",
2496 can_client_access_hack()
2497 && C_S_RUNNING <= client_state());
2499 menus_set_active(safe_group, "SAVE_OPTIONS_ON_EXIT",
2500 gui_options.save_options_on_exit);
2501 menus_set_sensitive(safe_group, "SERVER_OPTIONS", client.conn.established);
2503 menus_set_sensitive(safe_group, "LEAVE",
2504 client.conn.established);
2506 if (!can_client_change_view()) {
2507 gtk_action_group_set_sensitive(safe_group, FALSE);
2508 gtk_action_group_set_sensitive(edit_group, FALSE);
2509 gtk_action_group_set_sensitive(unit_group, FALSE);
2510 gtk_action_group_set_sensitive(player_group, FALSE);
2511 gtk_action_group_set_sensitive(playing_group, FALSE);
2512 return;
2515 menus_rename(unit_group, "BUILD_FORTRESS", Q_(terrain_control.gui_type_base0));
2516 menus_rename(unit_group, "BUILD_AIRBASE", Q_(terrain_control.gui_type_base1));
2518 if ((menu = find_action_menu(playing_group, "MENU_GOVERNMENT"))) {
2519 GList *list, *iter;
2520 GtkWidget *item;
2521 char buf[256];
2523 /* Remove previous government entries. */
2524 list = gtk_container_get_children(GTK_CONTAINER(menu));
2525 for (iter = list; NULL != iter; iter = g_list_next(iter)) {
2526 if (g_object_get_data(G_OBJECT(iter->data), "government") != NULL
2527 || GTK_IS_SEPARATOR_MENU_ITEM(iter->data)) {
2528 gtk_widget_destroy(GTK_WIDGET(iter->data));
2531 g_list_free(list);
2533 /* Add new government entries. */
2534 item = gtk_separator_menu_item_new();
2535 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
2536 gtk_widget_show(item);
2538 governments_iterate(g) {
2539 if (g != game.government_during_revolution) {
2540 struct sprite *gsprite;
2542 /* TRANS: %s is a government name */
2543 fc_snprintf(buf, sizeof(buf), _("%s..."),
2544 government_name_translation(g));
2545 item = gtk_image_menu_item_new_with_label(buf);
2546 g_object_set_data(G_OBJECT(item), "government", g);
2548 if ((gsprite = get_government_sprite(tileset, g))) {
2549 GtkWidget *image;
2550 GdkPixbuf *pb = sprite_get_pixbuf(gsprite);
2552 image = gtk_image_new_from_pixbuf(pb);
2553 g_object_unref(pb);
2554 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
2555 gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
2556 gtk_widget_show(image);
2559 g_signal_connect(item, "activate",
2560 G_CALLBACK(government_callback), g);
2561 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
2562 gtk_widget_show(item);
2564 } governments_iterate_end;
2567 if ((menu = find_action_menu(unit_group, "MENU_BUILD_BASE"))) {
2568 GList *list, *iter;
2569 GtkWidget *item;
2571 /* Remove previous base entries. */
2572 list = gtk_container_get_children(GTK_CONTAINER(menu));
2573 for (iter = list; NULL != iter; iter = g_list_next(iter)) {
2574 gtk_widget_destroy(GTK_WIDGET(iter->data));
2576 g_list_free(list);
2578 /* Add new base entries. */
2579 extra_type_by_cause_iterate(EC_BASE, pextra) {
2580 if (pextra->buildable) {
2581 item = gtk_menu_item_new_with_label(extra_name_translation(pextra));
2582 g_object_set_data(G_OBJECT(item), "base", pextra);
2583 g_signal_connect(item, "activate", G_CALLBACK(base_callback), pextra);
2584 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
2585 gtk_widget_show(item);
2587 } extra_type_by_cause_iterate_end;
2590 if ((menu = find_action_menu(unit_group, "MENU_BUILD_PATH"))) {
2591 GList *list, *iter;
2592 GtkWidget *item;
2594 /* Remove previous road entries. */
2595 list = gtk_container_get_children(GTK_CONTAINER(menu));
2596 for (iter = list; NULL != iter; iter = g_list_next(iter)) {
2597 gtk_widget_destroy(GTK_WIDGET(iter->data));
2599 g_list_free(list);
2601 /* Add new road entries. */
2602 extra_type_by_cause_iterate(EC_ROAD, pextra) {
2603 if (pextra->buildable) {
2604 item = gtk_menu_item_new_with_label(extra_name_translation(pextra));
2605 g_object_set_data(G_OBJECT(item), "road", pextra);
2606 g_signal_connect(item, "activate", G_CALLBACK(road_callback), pextra);
2607 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
2608 gtk_widget_show(item);
2610 } extra_type_by_cause_iterate_end;
2613 gtk_action_group_set_sensitive(safe_group, TRUE);
2614 gtk_action_group_set_sensitive(player_group, client_has_player());
2616 menus_set_sensitive(playing_group, "TAX_RATE",
2617 game.info.changable_tax
2618 && can_client_issue_orders());
2619 menus_set_sensitive(player_group, "POLICIES",
2620 multiplier_count() > 0);
2622 menus_set_active(safe_group, "SHOW_CITY_OUTLINES",
2623 gui_options.draw_city_outlines);
2624 menus_set_active(safe_group, "SHOW_CITY_OUTPUT",
2625 gui_options.draw_city_output);
2626 menus_set_active(safe_group, "SHOW_MAP_GRID",
2627 gui_options.draw_map_grid);
2628 menus_set_active(safe_group, "SHOW_NATIONAL_BORDERS",
2629 gui_options.draw_borders);
2630 menus_set_sensitive(safe_group, "SHOW_NATIONAL_BORDERS",
2631 BORDERS_DISABLED != game.info.borders);
2632 menus_set_active(safe_group, "SHOW_NATIVE_TILES",
2633 gui_options.draw_native);
2634 menus_set_active(safe_group, "SHOW_CITY_FULL_BAR",
2635 gui_options.draw_full_citybar);
2636 menus_set_active(safe_group, "SHOW_CITY_NAMES",
2637 gui_options.draw_city_names);
2638 menus_set_active(safe_group, "SHOW_CITY_GROWTH",
2639 gui_options.draw_city_growth);
2640 menus_set_active(safe_group, "SHOW_CITY_PRODUCTIONS",
2641 gui_options.draw_city_productions);
2642 menus_set_active(safe_group, "SHOW_CITY_BUY_COST",
2643 gui_options.draw_city_buycost);
2644 menus_set_active(safe_group, "SHOW_CITY_TRADE_ROUTES",
2645 gui_options.draw_city_trade_routes);
2646 menus_set_active(safe_group, "SHOW_TERRAIN",
2647 gui_options.draw_terrain);
2648 menus_set_active(safe_group, "SHOW_COASTLINE",
2649 gui_options.draw_coastline);
2650 menus_set_active(safe_group, "SHOW_PATHS",
2651 gui_options.draw_roads_rails);
2652 menus_set_active(safe_group, "SHOW_IRRIGATION",
2653 gui_options.draw_irrigation);
2654 menus_set_active(safe_group, "SHOW_MINES",
2655 gui_options.draw_mines);
2656 menus_set_active(safe_group, "SHOW_BASES",
2657 gui_options.draw_fortress_airbase);
2658 menus_set_active(safe_group, "SHOW_RESOURCES",
2659 gui_options.draw_specials);
2660 menus_set_active(safe_group, "SHOW_HUTS",
2661 gui_options.draw_huts);
2662 menus_set_active(safe_group, "SHOW_POLLUTION",
2663 gui_options.draw_pollution);
2664 menus_set_active(safe_group, "SHOW_CITIES",
2665 gui_options.draw_cities);
2666 menus_set_active(safe_group, "SHOW_UNITS",
2667 gui_options.draw_units);
2668 menus_set_active(safe_group, "SHOW_UNIT_SOLID_BG",
2669 gui_options.solid_color_behind_units);
2670 menus_set_active(safe_group, "SHOW_UNIT_SHIELDS",
2671 gui_options.draw_unit_shields);
2672 menus_set_active(safe_group, "SHOW_FOCUS_UNIT",
2673 gui_options.draw_focus_unit);
2674 menus_set_active(safe_group, "SHOW_FOG_OF_WAR",
2675 gui_options.draw_fog_of_war);
2677 view_menu_update_sensitivity();
2679 menus_set_active(safe_group, "FULL_SCREEN", gui_options.gui_gtk3_fullscreen);