Fixed 'might be used uninitialized' error from qt-client update_units().
[freeciv.git] / client / gui-xaw / xaw_actions.c
blob4afe4f16e8d71001ac64f03c48bb2003fe7a5011
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.
13 ***********************************************************************/
15 #ifdef HAVE_CONFIG_H
16 #include <fc_config.h>
17 #endif
19 /* utility */
20 #include "log.h"
22 /* common */
23 #include "unitlist.h"
25 /* client */
26 #include "client_main.h"
27 #include "control.h"
29 /* gui-xaw */
30 #include "chatline.h"
31 #include "citydlg.h"
32 #include "cityrep.h"
33 #include "connectdlg.h"
34 #include "dialogs.h"
35 #include "diplodlg.h"
36 #include "finddlg.h"
37 #include "gotodlg.h"
38 #include "gui_main.h"
39 #include "helpdlg.h"
40 #include "inputdlg.h"
41 #include "mapctrl.h"
42 #include "menu.h"
43 #include "messagewin.h"
44 #include "pages.h"
45 #include "plrdlg.h"
46 #include "inteldlg.h"
47 #include "ratesdlg.h"
48 #include "repodlgs.h"
49 #include "spaceshipdlg.h"
50 #include "wldlg.h"
52 #include "xaw_actions.h"
54 /*******************************************************************************
55 Action Routines!!
56 *******************************************************************************/
57 static void xaw_mouse_moved(Widget w, XEvent *event, String *argv, Cardinal *argc)
59 XButtonEvent *ev=&event->xbutton;
60 update_line(ev->x, ev->y);
63 static void xaw_btn_adjust_workers(Widget w, XEvent *event, String *argv, Cardinal *argc)
65 adjust_workers_button_pressed(event->xbutton.x, event->xbutton.y);
68 static void xaw_btn_select_citymap(Widget w, XEvent *event, String *argv, Cardinal *argc)
70 citydlg_btn_select_citymap(w, event);
73 static void xaw_btn_select_mapcanvas(Widget w, XEvent *event, String *argv, Cardinal *argc)
75 mapctrl_btn_mapcanvas(event);
78 static void xaw_btn_select_overviewcanvas(Widget w, XEvent *event, String *argv, Cardinal *argc)
80 mapctrl_btn_overviewcanvas(event);
83 static void xaw_btn_show_info_popup(Widget w, XEvent *event, String *argv, Cardinal *argc)
85 main_show_info_popup(event);
88 static void xaw_key_cancel_action(Widget w, XEvent *event, String *argv, Cardinal *argc)
90 key_cancel_action();
93 static void xaw_key_center_on_unit(Widget w, XEvent *event, String *argv, Cardinal *argc)
95 center_on_unit();
98 static void xaw_key_chatline_send(Widget w, XEvent *event, String *argv, Cardinal *argc)
100 chatline_key_send(w);
103 static void xaw_key_city_names_toggle(Widget w, XEvent *event, String *argv, Cardinal *argc)
105 key_city_names_toggle();
108 static void xaw_key_city_productions_toggle(Widget w, XEvent *event, String *argv, Cardinal *argc)
110 key_city_productions_toggle();
113 static void xaw_key_city_workers(Widget w, XEvent *event, String *argv, Cardinal *argc)
115 mapctrl_key_city_workers(event);
118 static void xaw_key_dialog_city_close(Widget w, XEvent *event, String *argv, Cardinal *argc)
120 citydlg_key_close(w);
123 static void xaw_key_dialog_connect_connect(Widget w, XEvent *event, String *argv, Cardinal *argc)
125 connectdlg_key_connect(w);
128 static void xaw_key_dialog_diplo_gold(Widget w, XEvent *event, String *argv, Cardinal *argc)
130 diplodlg_key_gold(w);
133 static void xaw_key_dialog_input_ok(Widget w, XEvent *event, String *argv, Cardinal *argc)
135 inputdlg_key_ok(w);
138 static void xaw_key_dialog_races_ok(Widget w, XEvent *event, String *argv, Cardinal *argc)
140 racesdlg_key_ok(w);
143 static void xaw_key_dialog_spaceship_close(Widget w, XEvent *event, String *argv, Cardinal *argc)
145 spaceshipdlg_key_close(w);
148 static void xaw_key_end_turn(Widget w, XEvent *event, String *argv, Cardinal *argc)
150 key_end_turn();
153 static void xaw_key_focus_to_next_unit(Widget w, XEvent *event, String *argv, Cardinal *argc)
155 unit_focus_advance();
158 static void xaw_key_map_grid_toggle(Widget w, XEvent *event, String *argv, Cardinal *argc)
160 key_map_grid_toggle();
163 /*************************************************************************
164 Called when the key to toggle borders is pressed.
165 **************************************************************************/
166 static void xaw_key_map_borders_toggle(Widget w, XEvent *event,
167 String *argv, Cardinal *argc)
169 key_map_borders_toggle();
172 /*************************************************************************
173 Called when the key to toggle native tile display is pressed.
174 **************************************************************************/
175 static void xaw_key_map_native_toggle(Widget w, XEvent *event,
176 String *argv, Cardinal *argc)
178 key_map_native_toggle();
181 static void xaw_key_move_north(Widget w, XEvent *event, String *argv, Cardinal *argc)
183 key_unit_move(DIR8_NORTH);
186 static void xaw_key_move_north_east(Widget w, XEvent *event, String *argv, Cardinal *argc)
188 key_unit_move(DIR8_NORTHEAST);
191 static void xaw_key_move_east(Widget w, XEvent *event, String *argv, Cardinal *argc)
193 key_unit_move(DIR8_EAST);
196 static void xaw_key_move_south_east(Widget w, XEvent *event, String *argv, Cardinal *argc)
198 key_unit_move(DIR8_SOUTHEAST);
201 static void xaw_key_move_south(Widget w, XEvent *event, String *argv, Cardinal *argc)
203 key_unit_move(DIR8_SOUTH);
206 static void xaw_key_move_south_west(Widget w, XEvent *event, String *argv, Cardinal *argc)
208 key_unit_move(DIR8_SOUTHWEST);
211 static void xaw_key_move_west(Widget w, XEvent *event, String *argv, Cardinal *argc)
213 key_unit_move(DIR8_WEST);
216 static void xaw_key_move_north_west(Widget w, XEvent *event, String *argv, Cardinal *argc)
218 key_unit_move(DIR8_NORTHWEST);
221 /****************************************************************************
222 User pressed city report key
223 ****************************************************************************/
224 static void xaw_key_open_city_report(Widget w, XEvent *event, String *argv,
225 Cardinal *argc)
227 if (can_client_change_view()
228 && is_menu_item_active(MENU_REPORT, MENU_REPORT_CITIES)) {
229 city_report_dialog_popup(FALSE);
233 /****************************************************************************
234 User pressed demographics report key
235 ****************************************************************************/
236 static void xaw_key_open_demographics(Widget w, XEvent *event, String *argv,
237 Cardinal *argc)
239 if (can_client_change_view()
240 && is_menu_item_active(MENU_REPORT, MENU_REPORT_DEMOGRAPHIC)) {
241 send_report_request(REPORT_DEMOGRAPHIC);
245 /****************************************************************************
246 User pressed achievements report key
247 ****************************************************************************/
248 static void xaw_key_open_achievements(Widget w, XEvent *event, String *argv,
249 Cardinal *argc)
251 if (can_client_change_view()
252 && is_menu_item_active(MENU_REPORT, MENU_REPORT_ACHIEVEMENTS)) {
253 send_report_request(REPORT_ACHIEVEMENTS);
257 /****************************************************************************
258 User pressed economics report key
259 ****************************************************************************/
260 static void xaw_key_open_economy_report(Widget w, XEvent *event, String *argv,
261 Cardinal *argc)
263 if (can_client_change_view()
264 && is_menu_item_active(MENU_REPORT, MENU_REPORT_ECONOMY)) {
265 economy_report_dialog_popup(FALSE);
269 /****************************************************************************
270 Invoked when the key binding for government->find_city is pressed.
271 ****************************************************************************/
272 static void xaw_key_open_find_city(Widget w, XEvent *event,
273 String *argv, Cardinal *argc)
275 if (can_client_change_view()
276 && is_menu_item_active(MENU_GOVERNMENT, MENU_GOVERNMENT_FIND_CITY)) {
277 popup_find_dialog();
281 static void xaw_key_open_goto_airlift(Widget w, XEvent *event, String *argv, Cardinal *argc)
283 if (can_client_change_view() &&
284 is_menu_item_active(MENU_ORDER, MENU_ORDER_GOTO_CITY))
285 popup_goto_dialog();
288 static void xaw_key_open_messages(Widget w, XEvent *event, String *argv, Cardinal *argc)
290 if (can_client_change_view()
291 && is_menu_item_active(MENU_REPORT, MENU_REPORT_MESSAGES)) {
292 meswin_dialog_popup(FALSE);
296 static void xaw_key_open_players(Widget w, XEvent *event, String *argv, Cardinal *argc)
298 if (can_client_change_view() &&
299 is_menu_item_active(MENU_REPORT, MENU_REPORT_PLAYERS))
300 popup_players_dialog(FALSE);
303 /****************************************************************************
304 Invoked when the key binding for government->rates is pressed.
305 ****************************************************************************/
306 static void xaw_key_open_rates(Widget w, XEvent *event,
307 String *argv, Cardinal *argc)
309 if (can_client_change_view()
310 && is_menu_item_active(MENU_GOVERNMENT, MENU_GOVERNMENT_RATES)) {
311 popup_rates_dialog();
315 /****************************************************************************
316 Invoked when the key binding for government->revolution is pressed.
317 ****************************************************************************/
318 static void xaw_key_open_revolution(Widget w, XEvent *event,
319 String *argv, Cardinal *argc)
321 if (can_client_change_view()
322 && is_menu_item_active(MENU_GOVERNMENT, MENU_GOVERNMENT_REVOLUTION)) {
323 popup_revolution_dialog(NULL);
327 static void xaw_key_open_science_report(Widget w, XEvent *event, String *argv, Cardinal *argc)
329 if (can_client_change_view()
330 && is_menu_item_active(MENU_REPORT, MENU_REPORT_SCIENCE)) {
331 science_report_dialog_popup(FALSE);
335 static void xaw_key_open_spaceship(Widget w, XEvent *event, String *argv, Cardinal *argc)
337 if (can_client_change_view() &&
338 is_menu_item_active(MENU_REPORT, MENU_REPORT_SPACESHIP))
339 popup_spaceship_dialog(client.conn.playing);
342 /****************************************************************************
343 Invoked when the key binding for report->top_five_cities is pressed.
344 ****************************************************************************/
345 static void xaw_key_open_top_five(Widget w, XEvent *event,
346 String *argv, Cardinal *argc)
348 if (can_client_change_view()
349 && is_menu_item_active(MENU_REPORT, MENU_REPORT_TOP_CITIES)) {
350 send_report_request(REPORT_TOP_5_CITIES);
354 /****************************************************************************
355 Invoked when the key binding for report->units is pressed.
356 ****************************************************************************/
357 static void xaw_key_open_units_report(Widget w, XEvent *event,
358 String *argv, Cardinal *argc)
360 if (can_client_change_view()
361 && is_menu_item_active(MENU_REPORT, MENU_REPORT_UNITS)) {
362 units_report_dialog_popup(FALSE);
366 /****************************************************************************
367 Invoked when the key binding for report->wonders is pressed.
368 ****************************************************************************/
369 static void xaw_key_open_wonders(Widget w, XEvent *event, String *argv, Cardinal *argc)
371 if (can_client_change_view() &&
372 is_menu_item_active(MENU_REPORT, MENU_REPORT_WOW))
373 send_report_request(REPORT_WONDERS_OF_THE_WORLD);
376 /****************************************************************************
377 Invoked when the key binding for government->worklists is pressed.
378 ****************************************************************************/
379 static void xaw_key_open_worklists(Widget w, XEvent *event,
380 String *argv, Cardinal *argc)
382 if (can_client_change_view()
383 && is_menu_item_active(MENU_GOVERNMENT, MENU_GOVERNMENT_WORKLISTS)) {
384 popup_worklists_dialog(client.conn.playing);
388 /****************************************************************************
389 Invoked when the key binding for orders->airbase is pressed.
390 ****************************************************************************/
391 static void xaw_key_unit_airbase(Widget w, XEvent *event,
392 String *argv, Cardinal *argc)
394 if (can_client_issue_orders()
395 && is_menu_item_active(MENU_ORDER, MENU_ORDER_AIRBASE)) {
396 key_unit_airbase();
400 /****************************************************************************
401 Invoked when the key binding for orders->auto_explore is pressed.
402 ****************************************************************************/
403 static void xaw_key_unit_auto_explore(Widget w, XEvent *event, String *argv,
404 Cardinal *argc)
406 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_AUTO_EXPLORE))
407 key_unit_auto_explore();
410 /****************************************************************************
411 Invoked when the key binding for orders->auto_settle is pressed.
412 ****************************************************************************/
413 static void xaw_key_unit_auto_settle(Widget w, XEvent *event, String *argv,
414 Cardinal *argc)
416 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_AUTO_SETTLER))
417 key_unit_auto_settle();
420 /****************************************************************************
421 Invoked when the key binding for auto-settle or auto-attack is pressed.
422 Since there is no more auto-attack this function is just like another
423 way of calling key_unit_auto_settle.
424 ****************************************************************************/
425 static void xaw_key_unit_auto_attack_or_settle(Widget w, XEvent *event,
426 String *argv, Cardinal *argc)
428 unit_list_iterate(get_units_in_focus(), punit) {
429 request_unit_autosettlers(punit);
430 } unit_list_iterate_end;
433 static void xaw_key_unit_build_city(Widget w, XEvent *event, String *argv, Cardinal *argc)
435 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_BUILD_CITY))
436 key_unit_build_city();
439 static void xaw_key_unit_build_city_or_wonder(Widget w, XEvent *event, String *argv, Cardinal *argc)
441 unit_list_iterate(get_units_in_focus(), punit) {
442 if (unit_can_add_or_build_city(punit)) {
443 request_unit_build_city(punit);
444 } else {
445 request_unit_caravan_action(punit, ACTION_HELP_WONDER);
447 } unit_list_iterate_end;
450 static void xaw_key_unit_build_wonder(Widget w, XEvent *event, String *argv, Cardinal *argc)
452 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_BUILD_WONDER))
453 key_unit_build_wonder();
456 /****************************************************************
457 User requested connect with road
458 *****************************************************************/
459 static void xaw_key_unit_connect_road(Widget w, XEvent *event, String *argv, Cardinal *argc)
461 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_CONNECT_ROAD)) {
462 struct road_type *proad = road_by_compat_special(ROCO_ROAD);
464 if (proad != NULL) {
465 struct extra_type *tgt;
467 tgt = road_extra_get(proad);
469 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
474 /****************************************************************
475 User requested connect with rail
476 *****************************************************************/
477 static void xaw_key_unit_connect_rail(Widget w, XEvent *event, String *argv, Cardinal *argc)
479 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_CONNECT_RAIL)) {
480 struct road_type *prail = road_by_compat_special(ROCO_RAILROAD);
482 if (prail != NULL) {
483 struct extra_type *tgt;
485 tgt = road_extra_get(prail);
487 key_unit_connect(ACTIVITY_GEN_ROAD, tgt);
492 /****************************************************************************
493 Invoked when the key binding for connect with irrigation is pressed.
494 ****************************************************************************/
495 static void xaw_key_unit_connect_irrigate(Widget w, XEvent *event, String *argv, Cardinal *argc)
497 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_CONNECT_IRRIGATE)) {
498 struct extra_type_list *extras = extra_type_list_by_cause(EC_IRRIGATION);
500 if (extra_type_list_size(extras) > 0) {
501 struct extra_type *pextra;
503 pextra = extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION), 0);
505 key_unit_connect(ACTIVITY_IRRIGATE, pextra);
510 static void xaw_key_unit_diplomat_spy_action(Widget w, XEvent *event, String *argv, Cardinal *argc)
512 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_DIPLOMAT_DLG))
513 key_unit_action_select();
516 static void xaw_key_unit_convert(Widget w, XEvent *event, String *argv, Cardinal *argc)
518 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_CONVERT))
519 key_unit_convert();
522 static void xaw_key_unit_disband(Widget w, XEvent *event, String *argv, Cardinal *argc)
524 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_DISBAND))
525 popup_disband_dialog(get_units_in_focus());
528 static void xaw_key_unit_done(Widget w, XEvent *event, String *argv, Cardinal *argc)
530 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_DONE))
531 key_unit_done();
534 /****************************************************************************
535 Invoked when the key binding for fallout cleaning is pressed.
536 ****************************************************************************/
537 static void xaw_key_unit_fallout(Widget w, XEvent *event, String *argv, Cardinal *argc)
539 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_FALLOUT)) {
540 key_unit_fallout();
544 static void xaw_key_unit_fortify(Widget w, XEvent *event, String *argv, Cardinal *argc)
546 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_FORTIFY))
547 key_unit_fortify();
550 static void xaw_key_unit_fortify_or_fortress(Widget w, XEvent *event, String *argv, Cardinal *argc)
552 unit_list_iterate(get_units_in_focus(), punit) {
553 struct base_type *pbase = get_base_by_gui_type(BASE_GUI_FORTRESS,
554 punit, unit_tile(punit));
555 if (pbase != NULL) {
556 key_unit_fortress();
557 } else {
558 key_unit_fortify();
560 } unit_list_iterate_end;
563 static void xaw_key_unit_fortress(Widget w, XEvent *event, String *argv, Cardinal *argc)
565 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_FORTRESS))
566 key_unit_fortress();
569 static void xaw_key_unit_goto(Widget w, XEvent *event, String *argv, Cardinal *argc)
571 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_GOTO))
572 key_unit_goto();
575 static void xaw_key_unit_homecity(Widget w, XEvent *event, String *argv, Cardinal *argc)
577 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_HOMECITY))
578 key_unit_homecity();
581 /****************************************************************************
582 Invoked when the key binding for irrigate is pressed.
583 ****************************************************************************/
584 static void xaw_key_unit_irrigate(Widget w, XEvent *event, String *argv, Cardinal *argc)
586 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_IRRIGATE)) {
587 key_unit_irrigate();
591 /****************************************************************************
592 Invoked when the key binding for mine is pressed.
593 ****************************************************************************/
594 static void xaw_key_unit_mine(Widget w, XEvent *event, String *argv, Cardinal *argc)
596 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_MINE)) {
597 key_unit_mine();
601 static void xaw_key_unit_nuke(Widget w, XEvent *event, String *argv, Cardinal *argc)
603 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_NUKE))
604 key_unit_nuke();
607 static void xaw_key_unit_paradrop(Widget w, XEvent *event, String *argv, Cardinal *argc)
609 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_PARADROP))
610 key_unit_paradrop();
613 static void xaw_key_unit_paradrop_or_pollution(Widget w, XEvent *event, String *argv, Cardinal *argc)
615 unit_list_iterate(get_units_in_focus(), punit) {
616 if (can_unit_paradrop(punit)) {
617 key_unit_paradrop();
618 } else {
619 key_unit_pollution();
621 } unit_list_iterate_end;
624 static void xaw_key_unit_pillage(Widget w, XEvent *event, String *argv, Cardinal *argc)
626 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_PILLAGE))
627 key_unit_pillage();
630 /****************************************************************************
631 Invoked when the key binding for pollution cleaning is pressed.
632 ****************************************************************************/
633 static void xaw_key_unit_pollution(Widget w, XEvent *event, String *argv, Cardinal *argc)
635 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_POLLUTION)) {
636 key_unit_pollution();
640 static void xaw_key_unit_patrol(Widget w, XEvent *event, String *argv, Cardinal *argc)
642 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_PATROL))
643 key_unit_patrol();
646 static void xaw_key_unit_road(Widget w, XEvent *event, String *argv, Cardinal *argc)
648 if(is_menu_item_active(MENU_ORDER, MENU_ORDER_ROAD))
649 key_unit_road();
652 static void xaw_key_unit_road_or_trade_route(Widget w, XEvent *event, String *argv, Cardinal *argc)
654 unit_list_iterate(get_units_in_focus(), punit) {
655 if (unit_can_est_trade_route_here(punit)) {
656 key_unit_trade_route();
657 } else {
658 key_unit_road();
660 } unit_list_iterate_end;
663 /****************************************************************************
664 Invoked when the key binding for orders->sentry is pressed.
665 ****************************************************************************/
666 static void xaw_key_unit_sentry(Widget w, XEvent *event,
667 String *argv, Cardinal *argc)
669 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_SENTRY)) {
670 key_unit_sentry();
674 /****************************************************************************
675 Invoked when the key binding for orders->make_traderout is pressed.
676 ****************************************************************************/
677 static void xaw_key_unit_trade_route(Widget w, XEvent *event,
678 String *argv, Cardinal *argc)
680 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_TRADE_ROUTE)) {
681 key_unit_trade_route();
685 /****************************************************************************
686 Invoked when the key binding for orders->transform is pressed.
687 ****************************************************************************/
688 static void xaw_key_unit_transform(Widget w, XEvent *event,
689 String *argv, Cardinal *argc)
691 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_TRANSFORM)) {
692 key_unit_transform();
696 /****************************************************************************
697 Invoked when the key binding for orders->unload_transporter is pressed.
698 ****************************************************************************/
699 static void xaw_key_unit_unload_all(Widget w, XEvent *event,
700 String *argv, Cardinal *argc)
702 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_UNLOAD_TRANSPORTER)) {
703 key_unit_unload_all();
707 /****************************************************************************
708 Invoked when the key binding for orders->load is pressed.
709 ****************************************************************************/
710 static void xaw_key_unit_load(Widget w, XEvent *event,
711 String *argv, Cardinal *argc)
713 if (can_client_issue_orders()) {
714 unit_list_iterate(get_units_in_focus(), punit) {
715 request_unit_load(punit, NULL, unit_tile(punit));
716 } unit_list_iterate_end;
720 /****************************************************************************
721 Invoked when the key binding for orders->unload is pressed.
722 ****************************************************************************/
723 static void xaw_key_unit_unload(Widget w, XEvent *event,
724 String *argv, Cardinal *argc)
726 if (can_client_issue_orders()) {
727 unit_list_iterate(get_units_in_focus(), punit) {
728 request_unit_unload(punit);
729 } unit_list_iterate_end;
732 /****************************************************************************
733 Invoked when the key binding for orders->wait is pressed.
734 ****************************************************************************/
735 static void xaw_key_unit_wait(Widget w, XEvent *event,
736 String *argv, Cardinal *argc)
738 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_WAIT)) {
739 key_unit_wait();
743 /****************************************************************************
744 Invoked when the key binding for orders->wakeup_others is pressed.
745 ****************************************************************************/
746 static void xaw_key_unit_wakeup_others(Widget w, XEvent *event,
747 String *argv, Cardinal *argc)
749 if (is_menu_item_active(MENU_ORDER, MENU_ORDER_WAKEUP_OTHERS)) {
750 key_unit_wakeup_others();
754 /****************************************************************************
755 Invoked when the key binding for assign_battlegroup is pressed.
756 ****************************************************************************/
757 static void xaw_key_unit_assign_battlegroup1(Widget w, XEvent *event,
758 String *argv, Cardinal *argc)
760 assign_battlegroup(0);
763 /****************************************************************************
764 Invoked when the key binding for assign_battlegroup is pressed.
765 ****************************************************************************/
766 static void xaw_key_unit_assign_battlegroup2(Widget w, XEvent *event,
767 String *argv, Cardinal *argc)
769 assign_battlegroup(1);
772 /****************************************************************************
773 Invoked when the key binding for assign_battlegroup is pressed.
774 ****************************************************************************/
775 static void xaw_key_unit_assign_battlegroup3(Widget w, XEvent *event,
776 String *argv, Cardinal *argc)
778 assign_battlegroup(2);
781 /****************************************************************************
782 Invoked when the key binding for assign_battlegroup is pressed.
783 ****************************************************************************/
784 static void xaw_key_unit_assign_battlegroup4(Widget w, XEvent *event,
785 String *argv, Cardinal *argc)
787 assign_battlegroup(3);
790 /****************************************************************************
791 Invoked when the key binding for select_battlegroup is pressed.
792 ****************************************************************************/
793 static void xaw_key_unit_select_battlegroup1(Widget w, XEvent *event,
794 String *argv, Cardinal *argc)
796 select_battlegroup(0);
799 /****************************************************************************
800 Invoked when the key binding for select_battlegroup is pressed.
801 ****************************************************************************/
802 static void xaw_key_unit_select_battlegroup2(Widget w, XEvent *event,
803 String *argv, Cardinal *argc)
805 select_battlegroup(1);
808 /****************************************************************************
809 Invoked when the key binding for select_battlegroup is pressed.
810 ****************************************************************************/
811 static void xaw_key_unit_select_battlegroup3(Widget w, XEvent *event,
812 String *argv, Cardinal *argc)
814 select_battlegroup(2);
817 /****************************************************************************
818 Invoked when the key binding for select_battlegroup is pressed.
819 ****************************************************************************/
820 static void xaw_key_unit_select_battlegroup4(Widget w, XEvent *event,
821 String *argv, Cardinal *argc)
823 select_battlegroup(3);
826 /****************************************************************************
827 Invoked when the key binding for add_unit_to_battlegroup is pressed.
828 ****************************************************************************/
829 static void xaw_key_unit_add_to_battlegroup1(Widget w, XEvent *event,
830 String *argv, Cardinal *argc)
832 add_unit_to_battlegroup(0);
835 /****************************************************************************
836 Invoked when the key binding for add_unit_to_battlegroup is pressed.
837 ****************************************************************************/
838 static void xaw_key_unit_add_to_battlegroup2(Widget w, XEvent *event,
839 String *argv, Cardinal *argc)
841 add_unit_to_battlegroup(1);
844 /****************************************************************************
845 Invoked when the key binding for add_unit_to_battlegroup is pressed.
846 ****************************************************************************/
847 static void xaw_key_unit_add_to_battlegroup3(Widget w, XEvent *event,
848 String *argv, Cardinal *argc)
850 add_unit_to_battlegroup(2);
853 /****************************************************************************
854 Invoked when the key binding for add_unit_to_battlegroup is pressed.
855 ****************************************************************************/
856 static void xaw_key_unit_add_to_battlegroup4(Widget w, XEvent *event,
857 String *argv, Cardinal *argc)
859 add_unit_to_battlegroup(3);
862 static void xaw_msg_close_city(Widget w, XEvent *event, String *argv, Cardinal *argc)
864 citydlg_msg_close(w);
867 static void xaw_msg_close_city_report(Widget w, XEvent *event, String *argv, Cardinal *argc)
869 cityrep_msg_close(w);
872 static void xaw_msg_close_economy_report(Widget w, XEvent *event, String *argv, Cardinal *argc)
874 economyreport_msg_close(w);
877 static void xaw_msg_close_help(Widget w, XEvent *event, String *argv, Cardinal *argc)
879 helpdlg_msg_close(w);
882 static void xaw_msg_close_messages(Widget w, XEvent *event, String *argv, Cardinal *argc)
884 meswin_msg_close(w);
887 static void xaw_msg_close_players(Widget w, XEvent *event, String *argv, Cardinal *argc)
889 plrdlg_msg_close(w);
892 static void xaw_msg_close_intel(Widget w, XEvent *event, String *argv,
893 Cardinal *argc)
895 intel_dialog_msg_close(w);
898 static void xaw_msg_close_intel_diplo(Widget w, XEvent *event, String *argv,
899 Cardinal *argc)
901 intel_diplo_dialog_msg_close(w);
904 static void xaw_msg_close_science_report(Widget w, XEvent *event, String *argv, Cardinal *argc)
906 sciencereport_msg_close(w);
909 static void xaw_msg_close_spaceship(Widget w, XEvent *event, String *argv, Cardinal *argc)
911 spaceshipdlg_msg_close(w);
914 static void xaw_msg_close_units_report(Widget w, XEvent *event, String *argv, Cardinal *argc)
916 activeunits_msg_close(w);
919 static void xaw_msg_close_start_page(Widget w, XEvent *event, String *argv, Cardinal *argc)
921 start_page_msg_close(w);
924 static void xaw_msg_quit_freeciv(Widget w, XEvent *event, String *argv, Cardinal *argc)
926 xaw_ui_exit();
929 /*******************************************************************************
930 Table of Actions!!
931 *******************************************************************************/
932 static XtActionsRec Actions[] = {
933 { "mouse-moved", xaw_mouse_moved },
934 { "btn-adjust-workers", xaw_btn_adjust_workers },
935 { "btn-select-citymap", xaw_btn_select_citymap },
936 { "btn-select-mapcanvas", xaw_btn_select_mapcanvas },
937 { "btn-select-overviewcanvas", xaw_btn_select_overviewcanvas },
938 { "btn-show-info-popup", xaw_btn_show_info_popup },
939 { "key-cancel-action", xaw_key_cancel_action },
940 { "key-center-on-unit", xaw_key_center_on_unit },
941 { "key-chatline-send", xaw_key_chatline_send },
942 { "key-city-names-toggle", xaw_key_city_names_toggle },
943 { "key-city-productions-toggle", xaw_key_city_productions_toggle },
944 { "key-city-workers", xaw_key_city_workers },
945 { "key-dialog-city-close", xaw_key_dialog_city_close },
946 { "key-dialog-connect-connect", xaw_key_dialog_connect_connect },
947 { "key-dialog-diplo-gold", xaw_key_dialog_diplo_gold },
948 { "key-dialog-input-ok", xaw_key_dialog_input_ok },
949 { "key-dialog-races-ok", xaw_key_dialog_races_ok },
950 { "key-dialog-spaceship-close", xaw_key_dialog_spaceship_close },
951 { "key-end-turn", xaw_key_end_turn },
952 { "key-focus-to-next-unit", xaw_key_focus_to_next_unit },
953 { "key-map-grid-toggle", xaw_key_map_grid_toggle },
954 { "key-map-borders-toggle", xaw_key_map_borders_toggle },
955 { "key-map-native-toggle", xaw_key_map_native_toggle },
956 { "key-move-north", xaw_key_move_north },
957 { "key-move-north-east", xaw_key_move_north_east },
958 { "key-move-east", xaw_key_move_east },
959 { "key-move-south-east", xaw_key_move_south_east },
960 { "key-move-south", xaw_key_move_south },
961 { "key-move-south-west", xaw_key_move_south_west },
962 { "key-move-west", xaw_key_move_west },
963 { "key-move-north-west", xaw_key_move_north_west },
964 { "key-open-city-report", xaw_key_open_city_report },
965 { "key-open-demographics", xaw_key_open_demographics },
966 { "key-open-achievements", xaw_key_open_achievements },
967 { "key-open-economy-report", xaw_key_open_economy_report },
968 { "key-open-find-city", xaw_key_open_find_city },
969 { "key-open-goto-airlift", xaw_key_open_goto_airlift },
970 { "key-open-messages", xaw_key_open_messages },
971 { "key-open-players", xaw_key_open_players },
972 { "key-open-rates", xaw_key_open_rates },
973 { "key-open-revolution", xaw_key_open_revolution },
974 { "key-open-science-report", xaw_key_open_science_report },
975 { "key-open-spaceship", xaw_key_open_spaceship },
976 { "key-open-top-five", xaw_key_open_top_five },
977 { "key-open-units-report", xaw_key_open_units_report },
978 { "key-open-wonders", xaw_key_open_wonders },
979 { "key-open-worklists", xaw_key_open_worklists },
980 { "key-unit-airbase", xaw_key_unit_airbase },
981 { "key-unit-auto-attack-or-settle", xaw_key_unit_auto_attack_or_settle },
982 { "key-unit-auto-explore", xaw_key_unit_auto_explore },
983 { "key-unit-auto-settle", xaw_key_unit_auto_settle },
984 { "key-unit-build-city", xaw_key_unit_build_city },
985 { "key-unit-build-city-or-wonder", xaw_key_unit_build_city_or_wonder },
986 { "key-unit-build-wonder", xaw_key_unit_build_wonder },
987 { "key-unit-connect-road", xaw_key_unit_connect_road },
988 { "key-unit-connect-rail", xaw_key_unit_connect_rail },
989 { "key-unit-connect-irrigate", xaw_key_unit_connect_irrigate },
990 { "key-unit-convert", xaw_key_unit_convert },
991 { "key-unit-diplomat-spy-action", xaw_key_unit_diplomat_spy_action },
992 { "key-unit-disband", xaw_key_unit_disband },
993 { "key-unit-done", xaw_key_unit_done },
994 { "key-unit-fallout", xaw_key_unit_fallout },
995 { "key-unit-fortify", xaw_key_unit_fortify },
996 { "key-unit-fortify-or-fortress", xaw_key_unit_fortify_or_fortress },
997 { "key-unit-fortress", xaw_key_unit_fortress },
998 { "key-unit-goto", xaw_key_unit_goto },
999 { "key-unit-homecity", xaw_key_unit_homecity },
1000 { "key-unit-irrigate", xaw_key_unit_irrigate },
1001 { "key-unit-mine", xaw_key_unit_mine },
1002 { "key-unit-nuke", xaw_key_unit_nuke },
1003 { "key-unit-paradrop", xaw_key_unit_paradrop },
1004 { "key-unit-paradrop-or-pollution", xaw_key_unit_paradrop_or_pollution },
1005 { "key-unit-pillage", xaw_key_unit_pillage },
1006 { "key-unit-pollution", xaw_key_unit_pollution },
1007 { "key-unit-patrol", xaw_key_unit_patrol },
1008 { "key-unit-road", xaw_key_unit_road },
1009 { "key-unit-road-or-trade-route", xaw_key_unit_road_or_trade_route },
1010 { "key-unit-trade-route", xaw_key_unit_trade_route },
1011 { "key-unit-sentry", xaw_key_unit_sentry },
1012 { "key-unit-transform", xaw_key_unit_transform },
1013 { "key-unit-unload-all", xaw_key_unit_unload_all },
1014 { "key-unit-load", xaw_key_unit_load },
1015 { "key-unit-unload", xaw_key_unit_unload },
1016 { "key-unit-wait", xaw_key_unit_wait },
1017 { "key-unit-wakeup-others", xaw_key_unit_wakeup_others },
1018 { "key-unit-assign-battlegroup1", xaw_key_unit_assign_battlegroup1 },
1019 { "key-unit-assign-battlegroup2", xaw_key_unit_assign_battlegroup2 },
1020 { "key-unit-assign-battlegroup3", xaw_key_unit_assign_battlegroup3 },
1021 { "key-unit-assign-battlegroup4", xaw_key_unit_assign_battlegroup4 },
1022 { "key-unit-select-battlegroup1", xaw_key_unit_select_battlegroup1 },
1023 { "key-unit-select-battlegroup2", xaw_key_unit_select_battlegroup2 },
1024 { "key-unit-select-battlegroup3", xaw_key_unit_select_battlegroup3 },
1025 { "key-unit-select-battlegroup4", xaw_key_unit_select_battlegroup4 },
1026 { "key-unit-add-to-battlegroup1", xaw_key_unit_add_to_battlegroup1 },
1027 { "key-unit-add-to-battlegroup2", xaw_key_unit_add_to_battlegroup2 },
1028 { "key-unit-add-to-battlegroup3", xaw_key_unit_add_to_battlegroup3 },
1029 { "key-unit-add-to-battlegroup4", xaw_key_unit_add_to_battlegroup4 },
1030 { "msg-close-city", xaw_msg_close_city },
1031 { "msg-close-city-report", xaw_msg_close_city_report },
1032 { "msg-close-economy-report", xaw_msg_close_economy_report },
1033 { "msg-close-help", xaw_msg_close_help },
1034 { "msg-close-messages", xaw_msg_close_messages },
1035 { "msg-close-players", xaw_msg_close_players },
1036 { "msg-close-intel", xaw_msg_close_intel },
1037 { "msg-close-intel-diplo", xaw_msg_close_intel_diplo },
1038 { "msg-close-science-report", xaw_msg_close_science_report },
1039 { "msg-close-spaceship", xaw_msg_close_spaceship },
1040 { "msg-close-units-report", xaw_msg_close_units_report },
1041 { "msg-close-start-page", xaw_msg_close_start_page },
1042 { "msg-quit-freeciv", xaw_msg_quit_freeciv }
1045 /*******************************************************************************
1046 Initialize our Actions!!
1047 *******************************************************************************/
1048 void InitializeActions(XtAppContext context)
1050 XtAppAddActions(context, Actions, XtNumber(Actions));