Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-gtk-4.0/gui_main.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
gui_main.c
Go to the documentation of this file.
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.
7
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***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#ifdef AUDIO_SDL
19/* Though it would happily compile without this include,
20 * it is needed for sound to work.
21 * It defines "main" macro to rename our main() so that
22 * it can install SDL's own. */
23#ifdef SDL2_PLAIN_INCLUDE
24#include <SDL.h>
25#else /* PLAIN_INCLUDE */
26#include <SDL2/SDL.h>
27#endif /* PLAIN_INCLUDE */
28#endif /* AUDIO_SDL */
29
30#ifdef HAVE_LOCALE_H
31#include <locale.h>
32#endif
33#include <stdarg.h>
34#include <stdio.h>
35#include <stdlib.h>
36#include <string.h>
37#include <time.h>
38
39#ifdef HAVE_UNISTD_H
40#include <unistd.h>
41#endif
42
43#include <gtk/gtk.h>
44#include <gdk/gdkkeysyms.h>
45
46/* utility */
47#include "fc_cmdline.h"
48#include "fciconv.h"
49#include "fcintl.h"
50#include "log.h"
51#include "mem.h"
52#include "support.h"
53
54/* common */
55#include "dataio.h"
56#include "featured_text.h"
57#include "game.h"
58#include "government.h"
59#include "map.h"
60#include "unitlist.h"
61#include "version.h"
62
63/* client */
64#include "client_main.h"
65#include "climisc.h"
66#include "clinet.h"
67#include "colors.h"
68#include "connectdlg_common.h"
69#include "control.h"
70#include "editor.h"
71#include "options.h"
72#include "text.h"
73#include "tilespec.h"
74#include "zoom.h"
75
76/* client/gui-gtk-4.0 */
77#include "chatline.h"
78#include "citizensinfo.h"
79#include "connectdlg.h"
80#include "cma_fe.h"
81#include "dialogs.h"
82#include "diplodlg.h"
83#include "editgui.h"
84#include "gotodlg.h"
85#include "graphics.h"
86#include "gui_stuff.h"
87#include "happiness.h"
88#include "helpdlg.h"
89#include "inteldlg.h"
90#include "mapctrl.h"
91#include "mapview.h"
92#include "menu.h"
93#include "messagewin.h"
94#include "optiondlg.h"
95#include "pages.h"
96#include "plrdlg.h"
97#include "luaconsole.h"
98#include "spaceshipdlg.h"
99#include "repodlgs.h"
100#include "voteinfo_bar.h"
101
102#include "gui_main.h"
103
104 const char *client_string = GUI_NAME_FULL;
105
106GtkWidget *map_canvas; /* GtkDrawingArea */
107GtkWidget *map_horizontal_scrollbar;
108GtkWidget *map_vertical_scrollbar;
109
110GtkWidget *overview_canvas; /* GtkDrawingArea */
111GtkWidget *overview_scrolled_window; /* GtkScrolledWindow */
112/* The two values below define the width and height of the map overview. The
113 * first set of values (2*62, 2*46) define the size for a netbook display. For
114 * bigger displays the values are doubled (default). */
115#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK (2 * 64)
116#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK (2 * 46)
117#define OVERVIEW_CANVAS_STORE_WIDTH \
118 (2 * OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK)
119#define OVERVIEW_CANVAS_STORE_HEIGHT \
120 (2 * OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK)
121 int overview_canvas_store_width = OVERVIEW_CANVAS_STORE_WIDTH;
122 int overview_canvas_store_height = OVERVIEW_CANVAS_STORE_HEIGHT;
123
124GtkWidget *toplevel;
125GtkWidget *toplevel_tabs;
126GtkWidget *top_vbox;
127GtkWidget *top_notebook, *bottom_notebook, *right_notebook;
128GtkWidget *map_widget;
129 static GtkWidget *bottom_hpaned;
130
131PangoFontDescription *city_names_style = NULL;
132PangoFontDescription *city_productions_style = NULL;
133PangoFontDescription *reqtree_text_style = NULL;
134
135GtkWidget *main_frame_civ_name;
136GtkWidget *main_label_info;
137
138GtkWidget *avbox, *ahbox, *conn_box;
139GtkWidget* scroll_panel;
140
141GtkWidget *econ_label[10];
142GtkWidget *bulb_label;
143GtkWidget *sun_label;
144GtkWidget *flake_label;
145GtkWidget *government_label;
146GtkWidget *timeout_label;
147GtkWidget *turn_done_button;
148
149GtkWidget *unit_info_label;
150GtkWidget *unit_info_box;
151GtkWidget *unit_info_frame;
152
153GtkWidget *econ_widget;
154
155 const char *const gui_character_encoding = "UTF-8";
156 const bool gui_use_transliteration = FALSE;
157
158 static GdkPaintable *empty_unit_paintable = NULL;
159 static GtkWidget *unit_pic_table;
160 static GtkWidget *unit_pic;
161 static GtkWidget *unit_below_pic[MAX_NUM_UNITS_BELOW];
162 static GtkWidget *more_arrow;
163 static GtkWidget *more_arrow_container;
164
165 static int unit_id_top;
166 static int unit_ids[MAX_NUM_UNITS_BELOW]; /* ids of the units icons in
167 * information display: (or 0) */
168GtkTextView *main_message_area;
169GtkTextBuffer *message_buffer = NULL;
170 static GtkWidget *allied_chat_toggle_button;
171
172 static gint timer_id; /* Ditto */
173 static GIOChannel *srv_channel;
174 static guint srv_id;
175gint cur_x, cur_y;
176
177 static bool gui_up = FALSE;
178
179 static GtkApplication *fc_app;
180
181 static struct video_mode vmode = { -1, -1 };
182
183static void set_g_log_callbacks(void);
184
185static gboolean show_info_popup(GtkGestureClick *gesture, int n_press,
186 double x, double y, gpointer data);
187
188static void end_turn_callback(GtkWidget *w, gpointer data);
189static gboolean get_net_input(GIOChannel *source, GIOCondition condition,
190 gpointer data);
191static void set_wait_for_writable_socket(struct connection *pc,
192 bool socket_writable);
193
194static void print_usage(void);
195static void activate_gui(GtkApplication *app, gpointer data);
196static bool parse_options(int argc, char **argv);
197static gboolean toplevel_key_press_handler(GtkEventControllerKey *controller,
198 guint keyval,
199 guint keycode,
200 GdkModifierType state,
201 gpointer data);
202static gboolean mouse_scroll_mapcanvas(GtkEventControllerScroll *controller,
203 gdouble dx, gdouble dy,
204 gpointer data);
205
206static void tearoff_callback(GtkWidget *b, gpointer data);
207static GtkWidget *detached_widget_new(void);
208static GtkWidget *detached_widget_fill(GtkWidget *tearbox);
209
210static gboolean select_unit_pic_callback(GtkGestureClick *gesture, int n_press,
211 double x, double y, gpointer data);
212static gboolean select_more_arrow_callback(GtkGestureClick *gesture, int n_press,
213 double x, double y, gpointer data);
214static gboolean quit_dialog_callback(void);
215
216static void allied_chat_button_toggled(GtkToggleButton *button,
217 gpointer user_data);
218
219static void free_unit_table(void);
220
221static void adjust_default_options(void);
222
223 static float zoom_steps_custom[] = {
224 -1.0, 0.13, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 4.0, -1.0
225};
226
227/**********************************************************************/
230 static void log_callback_utf8(enum log_level level, const char *message,
231 bool file_too)
232{
233 if (!file_too || level <= LOG_FATAL) {
234 fc_fprintf(stderr, "%d: %s\n", level, message);
235 }
236}
237
238/**********************************************************************/
242 static gboolean timer_callback(gpointer data)
243{
244 double seconds = real_timer_callback();
245
246 timer_id = g_timeout_add(seconds * 1000, timer_callback, NULL);
247
248 return FALSE;
249}
250
251/**********************************************************************/
255 static void print_usage(void)
256{
257 /* add client-specific usage information here */
258 fc_fprintf(stderr,
259 _("gtk4-client gui-specific options are:\n"));
260
261 fc_fprintf(stderr,
262 _("-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
263 "screen\n"));
264
265 fc_fprintf(stderr, "\n");
266
267 /* TRANS: No full stop after the URL, could cause confusion. */
268 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
269}
270
271/**********************************************************************/
274 static bool parse_options(int argc, char **argv)
275{
276 int i = 1;
277
278 while (i < argc) {
279 char *option = NULL;
280
281 if (is_option("--help", argv[i])) {
282 print_usage();
283
284 return FALSE;
285 } else if ((option = get_option_malloc("--resolution", argv, &i, argc,
286 FALSE))) {
287 if (!string_to_video_mode(option, &vmode)) {
288 fc_fprintf(stderr, _("Illegal video mode '%s'\n"), option);
289 exit(EXIT_FAILURE);
290 }
291 free(option);
292 } else {
293 fc_fprintf(stderr, _("Unknown command-line option \"%s\".\n"),
294 argv[i]);
295 exit(EXIT_FAILURE);
296 }
297
298 i++;
299 }
300
301 return TRUE;
302}
303
304/**********************************************************************/
307 static void toplevel_focus(GtkWidget *w, GtkDirectionType arg,
308 gpointer data)
309{
310 switch (arg) {
311 case GTK_DIR_TAB_FORWARD:
312 case GTK_DIR_TAB_BACKWARD:
313
314 if (!gtk_widget_get_can_focus(w)) {
315 return;
316 }
317
318 if (!gtk_widget_is_focus(w)) {
319 gtk_widget_grab_focus(w);
320 return;
321 }
322 break;
323
324 default:
325 break;
326 }
327}
328
329/**********************************************************************/
334 void main_message_area_resize(void *data)
335{
336 if (get_current_client_page() == PAGE_GAME) {
337 static int old_width = 0, old_height = 0;
338 int width = gtk_widget_get_width(GTK_WIDGET(main_message_area));
339 int height = gtk_widget_get_height(GTK_WIDGET(main_message_area));
340
341 if (width != old_width
342 || height != old_height) {
343 chatline_scroll_to_bottom(TRUE);
344 old_width = width;
345 old_height = height;
346 }
347
348 add_idle_callback(main_message_area_resize, NULL);
349 }
350}
351
352/**********************************************************************/
355gboolean map_canvas_focus(void)
356{
357 gtk_window_present(GTK_WINDOW(toplevel));
358 gtk_notebook_set_current_page(GTK_NOTEBOOK(top_notebook), 0);
359 gtk_widget_grab_focus(map_canvas);
360
361 return TRUE;
362}
363
364/**********************************************************************/
367 static gboolean key_press_map_canvas(guint keyval, GdkModifierType state)
368{
369 if ((state & GDK_SHIFT_MASK)) {
370 switch (keyval) {
371
372 case GDK_KEY_Left:
373 scroll_mapview(DIR8_WEST);
374 return TRUE;
375
376 case GDK_KEY_Right:
377 scroll_mapview(DIR8_EAST);
378 return TRUE;
379
380 case GDK_KEY_Up:
381 scroll_mapview(DIR8_NORTH);
382 return TRUE;
383
384 case GDK_KEY_Down:
385 scroll_mapview(DIR8_SOUTH);
386 return TRUE;
387
388 case GDK_KEY_Home:
389 key_center_capital();
390 return TRUE;
391
392 case GDK_KEY_Page_Up:
393 g_signal_emit_by_name(main_message_area, "move_cursor",
394 GTK_MOVEMENT_PAGES, -1, FALSE);
395 return TRUE;
396
397 case GDK_KEY_Page_Down:
398 g_signal_emit_by_name(main_message_area, "move_cursor",
399 GTK_MOVEMENT_PAGES, 1, FALSE);
400 return TRUE;
401
402 default:
403 break;
404 }
405 } else if (!(state & GDK_CONTROL_MASK)) {
406 switch (keyval) {
407 default:
408 break;
409 }
410 }
411
412 if (state & GDK_SHIFT_MASK) {
413 bool volchange = FALSE;
414
415 switch (keyval) {
416 case GDK_KEY_plus:
417 case GDK_KEY_KP_Add:
418 gui_options.sound_effects_volume += 10;
419 volchange = TRUE;
420 break;
421
422 case GDK_KEY_minus:
423 case GDK_KEY_KP_Subtract:
424 gui_options.sound_effects_volume -= 10;
425 volchange = TRUE;
426 break;
427
428 default:
429 break;
430 }
431
432 if (volchange) {
433 struct option *poption = optset_option_by_name(client_optset,
434 "sound_effects_volume");
435
436 gui_options.sound_effects_volume = CLIP(0,
437 gui_options.sound_effects_volume,
438 100);
439 option_changed(poption);
440
441 return TRUE;
442 }
443 } else if (!(state & GDK_CONTROL_MASK)) {
444 switch (keyval) {
445 case GDK_KEY_plus:
446 case GDK_KEY_KP_Add:
447 zoom_step_up();
448 return TRUE;
449
450 case GDK_KEY_minus:
451 case GDK_KEY_KP_Subtract:
452 zoom_step_down();
453 return TRUE;
454
455 default:
456 break;
457 }
458 }
459
460 /* Return here if observer */
461 if (client_is_observer()) {
462 return FALSE;
463 }
464
465 switch (keyval) {
466
467 case GDK_KEY_KP_Up:
468 case GDK_KEY_KP_8:
469 case GDK_KEY_Up:
470 case GDK_KEY_8:
471 key_unit_move(DIR8_NORTH);
472 return TRUE;
473
474 case GDK_KEY_KP_Page_Up:
475 case GDK_KEY_KP_9:
476 case GDK_KEY_Page_Up:
477 case GDK_KEY_9:
478 key_unit_move(DIR8_NORTHEAST);
479 return TRUE;
480
481 case GDK_KEY_KP_Right:
482 case GDK_KEY_KP_6:
483 case GDK_KEY_Right:
484 case GDK_KEY_6:
485 key_unit_move(DIR8_EAST);
486 return TRUE;
487
488 case GDK_KEY_KP_Page_Down:
489 case GDK_KEY_KP_3:
490 case GDK_KEY_Page_Down:
491 case GDK_KEY_3:
492 key_unit_move(DIR8_SOUTHEAST);
493 return TRUE;
494
495 case GDK_KEY_KP_Down:
496 case GDK_KEY_KP_2:
497 case GDK_KEY_Down:
498 case GDK_KEY_2:
499 key_unit_move(DIR8_SOUTH);
500 return TRUE;
501
502 case GDK_KEY_KP_End:
503 case GDK_KEY_KP_1:
504 case GDK_KEY_End:
505 case GDK_KEY_1:
506 key_unit_move(DIR8_SOUTHWEST);
507 return TRUE;
508
509 case GDK_KEY_KP_Left:
510 case GDK_KEY_KP_4:
511 case GDK_KEY_Left:
512 case GDK_KEY_4:
513 key_unit_move(DIR8_WEST);
514 return TRUE;
515
516 case GDK_KEY_KP_Home:
517 case GDK_KEY_KP_7:
518 case GDK_KEY_Home:
519 case GDK_KEY_7:
520 key_unit_move(DIR8_NORTHWEST);
521 return TRUE;
522
523 case GDK_KEY_KP_Begin:
524 case GDK_KEY_KP_5:
525 case GDK_KEY_5:
526 key_recall_previous_focus_unit();
527 return TRUE;
528
529 case GDK_KEY_Escape:
530 key_cancel_action();
531 return TRUE;
532
533 case GDK_KEY_b:
534 if (tiles_hilited_cities) {
535 buy_production_in_selected_cities();
536 return TRUE;
537 }
538 break;
539
540 default:
541 break;
542 };
543
544 return FALSE;
545}
546
547/**********************************************************************/
550 static gboolean toplevel_key_press_handler(GtkEventControllerKey *controller,
551 guint keyval,
552 guint keycode,
553 GdkModifierType state,
554 gpointer data)
555{
556 if (inputline_has_focus()) {
557 return FALSE;
558 }
559
560 if (keyval == GDK_KEY_apostrophe) {
561 /* Allow this even if not in main map view; chatline is present on
562 * some other pages too */
563
564 /* Make the chatline visible if it's not currently.
565 * FIXME: should find the correct window, even when detached, from any
566 * other window; should scroll to the bottom automatically showing the
567 * latest text from other players; MUST NOT make spurious text windows
568 * at the bottom of other dialogs. */
569 if (gtk_widget_get_mapped(top_vbox)) {
570 /* The main game view is visible. May need to switch notebook. */
571 if (GUI_GTK_OPTION(message_chat_location) == GUI_GTK_MSGCHAT_MERGED) {
572 gtk_notebook_set_current_page(GTK_NOTEBOOK(top_notebook), 1);
573 } else {
574 gtk_notebook_set_current_page(GTK_NOTEBOOK(bottom_notebook), 0);
575 }
576 }
577
578 /* If the chatline is (now) visible, focus it. */
579 if (inputline_is_visible()) {
580 inputline_grab_focus();
581 return TRUE;
582 }
583 }
584
585 if (!gtk_widget_get_mapped(top_vbox)
586 || !can_client_change_view()) {
587 return FALSE;
588 }
589
590 if (editor_is_active()) {
591 if (handle_edit_key_press(keyval, state)) {
592 return TRUE;
593 }
594 }
595
596 if (state & GDK_SHIFT_MASK) {
597 switch (keyval) {
598
599 case GDK_KEY_Return:
600 case GDK_KEY_KP_Enter:
601 key_end_turn();
602 return TRUE;
603
604 default:
605 break;
606 }
607 }
608
609 if (0 == gtk_notebook_get_current_page(GTK_NOTEBOOK(top_notebook))) {
610 /* 0 means the map view is focused. */
611 return key_press_map_canvas(keyval, state);
612 }
613
614#if 0
615 /* We are focused some other dialog, tab, or widget. */
616 if ((state & GDK_CONTROL_MASK)) {
617 } else if ((state & GDK_SHIFT_MASK)) {
618 } else {
619 switch (keyval) {
620
621 case GDK_KEY_F4:
622 map_canvas_focus();
623 return TRUE;
624
625 default:
626 break;
627 };
628 }
629#endif /* 0 */
630
631 return FALSE;
632}
633
634/**********************************************************************/
637 static gboolean mouse_scroll_mapcanvas(GtkEventControllerScroll *controller,
638 gdouble dx, gdouble dy,
639 gpointer data)
640{
641 int scroll_x, scroll_y, xstep, ystep;
642 gdouble e_x, e_y;
643 GdkModifierType state;
644
645 if (!can_client_change_view()) {
646 return FALSE;
647 }
648
649 get_mapview_scroll_pos(&scroll_x, &scroll_y);
650 get_mapview_scroll_step(&xstep, &ystep);
651
652 scroll_y += ystep * dy;
653 scroll_x += xstep * dx;
654
655 set_mapview_scroll_pos(scroll_x, scroll_y, mouse_zoom);
656
657 /* Emulating mouse move now */
658 if (!gtk_widget_has_focus(map_canvas)) {
659 gtk_widget_grab_focus(map_canvas);
660 }
661
662 gdk_event_get_position(gtk_event_controller_get_current_event(
663 GTK_EVENT_CONTROLLER(controller)),
664 &e_x, &e_y);
665 update_line(e_x, e_y);
666 state = gtk_event_controller_get_current_event_state(
667 GTK_EVENT_CONTROLLER(controller));
668 if (rbutton_down && (state & GDK_BUTTON3_MASK)) {
669 update_selection_rectangle(e_x, e_y);
670 }
671
672 if (keyboardless_goto_button_down && hover_state == HOVER_NONE) {
673 maybe_activate_keyboardless_goto(cur_x, cur_y);
674 }
675
676 control_mouse_cursor(canvas_pos_to_tile(cur_x, cur_y, mouse_zoom));
677
678 return TRUE;
679}
680
681/**********************************************************************/
684 static void move_from_container_to_container(GtkWidget *wdg,
685 GtkWidget *old_wdg,
686 GtkWidget *new_wdg)
687{
688 g_object_ref(wdg); /* Make sure reference count stays above 0
689 * during the transition to new parent. */
690
691 if (GTK_IS_PANED(old_wdg)) {
692 gtk_paned_set_end_child(GTK_PANED(old_wdg), NULL);
693 } else if (GTK_IS_WINDOW(old_wdg)) {
694 gtk_window_set_child(GTK_WINDOW(old_wdg), NULL);
695 } else {
696 fc_assert(GTK_IS_BOX(old_wdg));
697
698 gtk_box_remove(GTK_BOX(old_wdg), wdg);
699 }
700
701 if (GTK_IS_PANED(new_wdg)) {
702 gtk_paned_set_end_child(GTK_PANED(new_wdg), wdg);
703 } else if (GTK_IS_WINDOW(new_wdg)) {
704 gtk_window_set_child(GTK_WINDOW(new_wdg), wdg);
705 } else {
706 fc_assert(GTK_IS_BOX(new_wdg));
707
708 gtk_box_append(GTK_BOX(new_wdg), wdg);
709 }
710
711 g_object_unref(wdg);
712}
713
714/**********************************************************************/
717 static void tearoff_reattach(GtkWidget *box)
718{
719 GtkWidget *aparent, *cparent;
720
721 aparent = g_object_get_data(G_OBJECT(box), "aparent");
722 cparent = gtk_widget_get_parent(box);
723
724 if (aparent != cparent) {
725 move_from_container_to_container(box, cparent, aparent);
726
727 gtk_window_destroy(GTK_WINDOW(cparent));
728 }
729}
730
731/**********************************************************************/
734 static void tearoff_close(GtkWidget *w, gpointer data)
735{
736 tearoff_reattach(GTK_WIDGET(data));
737}
738
739/**********************************************************************/
743 static void tearoff_callback(GtkWidget *b, gpointer data)
744{
745 GtkWidget *box = GTK_WIDGET(data);
746 GtkWidget *old_parent = gtk_widget_get_parent(box);
747
748 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b))) {
749 GtkWidget *w;
750 GtkWidget *temp_hide;
751
752 w = gtk_window_new();
753 setup_dialog(w, toplevel);
754 gtk_widget_set_name(w, "Freeciv");
755 gtk_window_set_title(GTK_WINDOW(w), _("Freeciv"));
756 g_signal_connect(w, "close-request", G_CALLBACK(tearoff_close), box);
757
758 g_object_set_data(G_OBJECT(box), "aparent", gtk_widget_get_parent(box));
759
760 temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent");
761 if (temp_hide != NULL) {
762 gtk_widget_hide(temp_hide);
763 }
764
765 move_from_container_to_container(box, old_parent, w);
766
767 gtk_widget_show(w);
768
769 if (temp_hide != NULL) {
770 gtk_widget_show(temp_hide);
771 }
772 } else {
773 tearoff_reattach(box);
774 }
775}
776
777/**********************************************************************/
780 static GtkWidget *detached_widget_new(void)
781{
782 GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
783
784 return hbox;
785}
786
787/**********************************************************************/
791 static GtkWidget *detached_widget_fill(GtkWidget *tearbox)
792{
793 GtkWidget *b, *fillbox;
794 static GtkCssProvider *detach_button_provider = NULL;
795
796 if (detach_button_provider == NULL) {
797 detach_button_provider = gtk_css_provider_new();
798
799 /* These toggle buttons run vertically down the side of many UI
800 * elements, so they need to be thin horizontally. */
801 gtk_css_provider_load_from_data(detach_button_provider,
802 ".detach_button {\n"
803 " padding: 0px 0px 0px 0px;\n"
804 " min-width: 6px;\n"
805 "}",
806 -1);
807 }
808
809 b = gtk_toggle_button_new();
810 gtk_style_context_add_provider_for_display(
811 gtk_widget_get_display(toplevel),
812 GTK_STYLE_PROVIDER(detach_button_provider),
813 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
814 gtk_widget_add_css_class(b, "detach_button");
815
816 gtk_box_append(GTK_BOX(tearbox), b);
817 g_signal_connect(b, "toggled", G_CALLBACK(tearoff_callback), tearbox);
818
819 fillbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
820
821 gtk_box_append(GTK_BOX(tearbox), fillbox);
822
823 return fillbox;
824}
825
826/**********************************************************************/
833 static void populate_unit_pic_table(void)
834{
835 int i, width;
836 GtkWidget *table = unit_pic_table;
837 GdkPixbuf *pix;
838 int ttw;
839 GtkEventController *controller;
840
841 /* Get width of the overview window */
842 width = (overview_canvas_store_width > GUI_GTK_OVERVIEW_MIN_XSIZE)
843 ? overview_canvas_store_width
844 : GUI_GTK_OVERVIEW_MIN_XSIZE;
845
846 ttw = tileset_tile_width(tileset);
847
848 if (GUI_GTK_OPTION(small_display_layout)) {
849 /* We want arrow to appear if there is other units in addition
850 to active one in tile. Active unit is not counted, so there
851 can be 0 other units to not to display arrow. */
852 num_units_below = 1 - 1;
853 } else {
854 num_units_below = width / ttw;
855 num_units_below = CLIP(1, num_units_below, MAX_NUM_UNITS_BELOW);
856 }
857
858 /* Top row: the active unit. */
859 /* Note, we ref this and other widgets here so that we can unref them
860 * in reset_unit_table. */
861 unit_pic = gtk_picture_new();
862 g_object_ref(unit_pic);
863 gtk_widget_set_size_request(unit_pic, ttw, -1);
864 gtk_grid_attach(GTK_GRID(table), unit_pic, 0, 0, 1, 1);
865
866 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
867 g_signal_connect(controller, "pressed",
868 G_CALLBACK(select_unit_pic_callback),
869 GINT_TO_POINTER(-1));
870 gtk_widget_add_controller(unit_pic, controller);
871
872 if (!GUI_GTK_OPTION(small_display_layout)) {
873 /* Bottom row: other units in the same tile. */
874 for (i = 0; i < num_units_below; i++) {
875 unit_below_pic[i] = gtk_picture_new();
876 g_object_ref(unit_below_pic[i]);
877 gtk_widget_set_size_request(unit_below_pic[i], ttw, -1);
878
879 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
880 g_signal_connect(controller, "pressed",
881 G_CALLBACK(select_unit_pic_callback),
882 GINT_TO_POINTER(i));
883 gtk_widget_add_controller(unit_below_pic[i], controller);
884
885 gtk_grid_attach(GTK_GRID(table), unit_below_pic[i],
886 i, 1, 1, 1);
887 }
888 }
889
890 /* Create arrow (popup for all units on the selected tile) */
891 pix = sprite_get_pixbuf(get_arrow_sprite(tileset, ARROW_RIGHT));
892 more_arrow = gtk_image_new_from_pixbuf(pix);
893 g_object_ref(more_arrow);
894
895 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
896 g_signal_connect(controller, "pressed",
897 G_CALLBACK(select_more_arrow_callback),
898 NULL);
899 gtk_widget_add_controller(more_arrow, controller);
900
901 /* An extra layer so that we can hide the clickable button but keep
902 * an explicit size request to avoid the layout jumping around */
903 more_arrow_container = gtk_frame_new(NULL);
904 gtk_widget_set_halign(more_arrow_container, GTK_ALIGN_CENTER);
905 gtk_widget_set_valign(more_arrow_container, GTK_ALIGN_CENTER);
906 g_object_ref(more_arrow_container);
907 gtk_frame_set_child(GTK_FRAME(more_arrow_container), more_arrow);
908 gtk_widget_set_size_request(more_arrow_container,
909 gdk_pixbuf_get_width(pix), -1);
910 g_object_unref(G_OBJECT(pix));
911
912 if (!GUI_GTK_OPTION(small_display_layout)) {
913 /* Display on bottom row. */
914 gtk_grid_attach(GTK_GRID(table), more_arrow_container,
915 num_units_below, 1, 1, 1);
916 } else {
917 /* Display on top row (there is no bottom row). */
918 gtk_grid_attach(GTK_GRID(table), more_arrow_container,
919 1, 0, 1, 1);
920 }
921
922 gtk_widget_show(table);
923}
924
925/**********************************************************************/
928 static void free_unit_table(void)
929{
930 if (unit_pic != NULL) {
931 gtk_grid_remove(GTK_GRID(unit_pic_table), unit_pic);
932 g_object_unref(unit_pic);
933 if (!GUI_GTK_OPTION(small_display_layout)) {
934 int i;
935
936 for (i = 0; i < num_units_below; i++) {
937 gtk_grid_remove(GTK_GRID(unit_pic_table),
938 unit_below_pic[i]);
939 g_object_unref(unit_below_pic[i]);
940 }
941 }
942 gtk_grid_remove(GTK_GRID(unit_pic_table),
943 more_arrow_container);
944 g_object_unref(more_arrow);
945 g_object_unref(more_arrow_container);
946 }
947}
948
949/**********************************************************************/
952 void reset_unit_table(void)
953{
954 /* Unreference all of the widgets that we're about to reallocate, thus
955 * avoiding a memory leak. Remove them from the container first, just
956 * to be safe. Note, the widgets are ref'd in
957 * populate_unit_pic_table(). */
958 free_unit_table();
959
960 populate_unit_pic_table();
961
962 /* We have to force a redraw of the units. And we explicitly have
963 * to force a redraw of the focus unit, which is normally only
964 * redrawn when the focus changes. We also have to force the 'more'
965 * arrow to go away, both by expicitly hiding it and telling it to
966 * do so (this will be reset immediately afterwards if necessary,
967 * but we have to make the *internal* state consistent). */
968 gtk_widget_hide(more_arrow);
969 set_unit_icons_more_arrow(FALSE);
970 if (get_num_units_in_focus() == 1) {
971 set_unit_icon(-1, head_of_units_in_focus());
972 } else {
973 set_unit_icon(-1, NULL);
974 }
975 update_unit_pix_label(get_units_in_focus());
976}
977
978/**********************************************************************/
981#if 0
982static void setup_canvas_color_for_state(GtkStateFlags state)
983{
984 gtk_widget_override_background_color(GTK_WIDGET(overview_canvas), state,
985 &get_color(tileset, COLOR_OVERVIEW_UNKNOWN)->color);
986 gtk_widget_override_background_color(GTK_WIDGET(map_canvas), state,
987 &get_color(tileset, COLOR_OVERVIEW_UNKNOWN)->color);
988}
989#endif
990
991/**********************************************************************/
994gboolean terminate_signal_processing(GtkEventControllerFocus *controller,
995 gpointer data)
996{
997 return TRUE;
998}
999
1000/**********************************************************************/
1003 void update_turn_done_tooltip(void)
1004{
1005 struct option *opt = optset_option_by_name(server_optset, "fixedlength");
1006
1007 if (opt != NULL && option_bool_get(opt)) {
1008 gtk_widget_set_tooltip_text(turn_done_button,
1009 _("Fixed length turns"));
1010 } else {
1011 char buf[256];
1012
1013 fc_snprintf(buf, sizeof(buf), "%s:\n%s",
1014 _("Turn Done"), _("Shift+Return"));
1015 gtk_widget_set_tooltip_text(turn_done_button, buf);
1016 }
1017}
1018
1019/**********************************************************************/
1022 static void setup_widgets(void)
1023{
1024 GtkWidget *page, *hgrid, *hgrid2, *label;
1025 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1026 GtkWidget *button, *view, *mainbox, *vbox, *right_vbox = NULL;
1027 int i;
1028 GtkWidget *notebook, *statusbar;
1029 GtkWidget *dtach_lowbox = NULL;
1030 struct sprite *spr;
1031 int right_row = 0;
1032 int top_row = 0;
1033 int grid_col = 0;
1034 int grid2_col = 0;
1035 GtkGesture *mc_gesture;
1036 GtkEventController *mc_controller;
1037 GtkWidget *ebar;
1038
1039 message_buffer = gtk_text_buffer_new(NULL);
1040
1041 notebook = gtk_notebook_new();
1042
1043 toplevel_tabs = notebook;
1044 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
1045 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
1046 mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
1047 gtk_window_set_child(GTK_WINDOW(toplevel), mainbox);
1048 gtk_box_append(GTK_BOX(mainbox), notebook);
1049 statusbar = create_statusbar();
1050 gtk_box_append(GTK_BOX(mainbox), statusbar);
1051
1052 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1053 create_main_page(), NULL);
1054 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1055 create_start_page(), NULL);
1056 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1057 create_scenario_page(), NULL);
1058 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1059 create_load_page(), NULL);
1060 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1061 create_network_page(), NULL);
1062
1063 editgui_create_widgets();
1064
1065 ingame_votebar = voteinfo_bar_new(FALSE);
1066 gtk_widget_set_margin_bottom(ingame_votebar, 2);
1067 gtk_widget_set_margin_end(ingame_votebar, 2);
1068 gtk_widget_set_margin_start(ingame_votebar, 2);
1069 gtk_widget_set_margin_top(ingame_votebar, 2);
1070
1071 /* *** Everything in the top *** */
1072
1073 page = gtk_scrolled_window_new();
1074 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(page),
1075 GTK_POLICY_AUTOMATIC,
1076 GTK_POLICY_AUTOMATIC);
1077 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(page),
1078 TRUE);
1079 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1080
1081 top_vbox = gtk_grid_new();
1082 gtk_orientable_set_orientation(GTK_ORIENTABLE(top_vbox),
1083 GTK_ORIENTATION_VERTICAL);
1084 gtk_grid_set_row_spacing(GTK_GRID(top_vbox), 5);
1085 hgrid = gtk_grid_new();
1086
1087 if (GUI_GTK_OPTION(small_display_layout)) {
1088 /* The window is divided into two horizontal panels: overview +
1089 * civinfo + unitinfo, main view + message window. */
1090 right_vbox = gtk_grid_new();
1091 right_row = 0;
1092 gtk_orientable_set_orientation(GTK_ORIENTABLE(right_vbox),
1093 GTK_ORIENTATION_VERTICAL);
1094 gtk_grid_attach(GTK_GRID(hgrid), right_vbox, grid_col++, 0, 1, 1);
1095
1096 paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
1097 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(page), top_vbox);
1098 gtk_grid_attach(GTK_GRID(top_vbox), hgrid, 0, top_row++, 1, 1);
1099 gtk_grid_attach(GTK_GRID(right_vbox), paned, 0, right_row++, 1, 1);
1100 gtk_grid_attach(GTK_GRID(right_vbox), ingame_votebar, 0, right_row++, 1, 1);
1101
1102 /* Overview size designed for small displays (netbooks). */
1103 overview_canvas_store_width = OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK;
1104 overview_canvas_store_height = OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK;
1105 } else {
1106 /* The window is divided into two vertical panes: overview +
1107 * + civinfo + unitinfo + main view, message window. */
1108 paned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
1109 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(page), paned);
1110 gtk_paned_set_start_child(GTK_PANED(paned), top_vbox);
1111 gtk_grid_attach(GTK_GRID(top_vbox), hgrid, 0, top_row++, 1, 1);
1112
1113 /* Overview size designed for big displays (desktops). */
1114 overview_canvas_store_width = OVERVIEW_CANVAS_STORE_WIDTH;
1115 overview_canvas_store_height = OVERVIEW_CANVAS_STORE_HEIGHT;
1116 }
1117
1118 /* This holds the overview canvas, production info, etc. */
1119 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
1120 /* Put vbox to the left of anything else in hgrid -- right_vbox is either
1121 * the chat/messages pane, or NULL which is OK */
1122 gtk_grid_attach_next_to(GTK_GRID(hgrid), vbox, right_vbox,
1123 GTK_POS_LEFT, 1, 1);
1124 grid_col++;
1125
1126 /* Overview canvas */
1127 ahbox = detached_widget_new();
1128 gtk_widget_set_hexpand(ahbox, FALSE);
1129 gtk_widget_set_vexpand(ahbox, FALSE);
1130 gtk_box_append(GTK_BOX(vbox), ahbox);
1131 avbox = detached_widget_fill(ahbox);
1132
1133 overview_scrolled_window = gtk_scrolled_window_new();
1134 gtk_widget_set_margin_start(overview_scrolled_window, 1);
1135 gtk_widget_set_margin_end(overview_scrolled_window, 1);
1136 gtk_widget_set_margin_top(overview_scrolled_window, 1);
1137 gtk_widget_set_margin_bottom(overview_scrolled_window, 1);
1138 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (overview_scrolled_window),
1139 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1140
1141 overview_canvas = gtk_drawing_area_new();
1142 gtk_widget_set_halign(overview_canvas, GTK_ALIGN_CENTER);
1143 gtk_widget_set_valign(overview_canvas, GTK_ALIGN_CENTER);
1144 gtk_widget_set_size_request(overview_canvas, overview_canvas_store_width,
1145 overview_canvas_store_height);
1146 gtk_widget_set_size_request(overview_scrolled_window, overview_canvas_store_width,
1147 overview_canvas_store_height);
1148 gtk_widget_set_hexpand(overview_canvas, TRUE);
1149 gtk_widget_set_vexpand(overview_canvas, TRUE);
1150
1151 gtk_box_append(GTK_BOX(avbox), overview_scrolled_window);
1152
1153 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(overview_scrolled_window),
1154 overview_canvas);
1155
1156 gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(overview_canvas),
1157 overview_canvas_draw, NULL, NULL);
1158
1159 mc_controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
1160 g_signal_connect(mc_controller, "pressed",
1161 G_CALLBACK(left_butt_down_overviewcanvas), NULL);
1162 gtk_widget_add_controller(overview_canvas, mc_controller);
1163 mc_gesture = gtk_gesture_click_new();
1164 gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(mc_gesture), 3);
1165 mc_controller = GTK_EVENT_CONTROLLER(mc_gesture);
1166 g_signal_connect(mc_controller, "pressed",
1167 G_CALLBACK(right_butt_down_overviewcanvas), NULL);
1168 gtk_widget_add_controller(overview_canvas, mc_controller);
1169 mc_controller = gtk_event_controller_motion_new();
1170 g_signal_connect(mc_controller, "motion",
1171 G_CALLBACK(move_overviewcanvas), NULL);
1172 gtk_widget_add_controller(overview_canvas, mc_controller);
1173
1174 /* The rest */
1175 ahbox = detached_widget_new();
1176 gtk_box_append(GTK_BOX(vbox), ahbox);
1177 gtk_widget_set_hexpand(ahbox, FALSE);
1178 avbox = detached_widget_fill(ahbox);
1179 gtk_widget_set_vexpand(avbox, TRUE);
1180 gtk_widget_set_valign(avbox, GTK_ALIGN_FILL);
1181
1182 /* Info on player's civilization, when game is running. */
1183 frame = gtk_frame_new("");
1184 gtk_box_append(GTK_BOX(avbox), frame);
1185
1186 main_frame_civ_name = frame;
1187
1188 mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
1189 gtk_frame_set_child(GTK_FRAME(frame), mainbox);
1190 gtk_widget_set_hexpand(mainbox, TRUE);
1191
1192 label = gtk_label_new(NULL);
1193 gtk_widget_set_halign(label, GTK_ALIGN_START);
1194 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1195 gtk_widget_set_margin_start(label, 2);
1196 gtk_widget_set_margin_end(label, 2);
1197 gtk_widget_set_margin_top(label, 2);
1198 gtk_widget_set_margin_bottom(label, 2);
1199
1200 mc_controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
1201 g_signal_connect(mc_controller, "pressed",
1202 G_CALLBACK(show_info_popup), frame);
1203 gtk_widget_add_controller(label, mc_controller);
1204 gtk_box_append(GTK_BOX(mainbox), label);
1205 main_label_info = label;
1206
1207 /* Production status */
1208 table = gtk_grid_new();
1209 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
1210 gtk_grid_set_column_homogeneous(GTK_GRID(table), TRUE);
1211 gtk_box_append(GTK_BOX(avbox), table);
1212
1213 /* Citizens for taxrates */
1214 table2 = gtk_grid_new();
1215 gtk_grid_attach(GTK_GRID(table), table2, 0, 0, 10, 1);
1216 econ_widget = table2;
1217
1218 for (i = 0; i < 10; i++) {
1219 GtkEventController *controller;
1220
1221 spr = i < 5 ? get_tax_sprite(tileset, O_SCIENCE) : get_tax_sprite(tileset, O_GOLD);
1222 econ_label[i] = picture_new_from_surface(spr->surface);
1223
1224 g_object_set_data(G_OBJECT(econ_label[i]), "rate_button", GUINT_TO_POINTER(i));
1225 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
1226 g_signal_connect(controller, "pressed",
1227 G_CALLBACK(taxrates_callback), NULL);
1228 gtk_widget_add_controller(econ_label[i], controller);
1229 mc_gesture = gtk_gesture_click_new();
1230 gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(mc_gesture), 3);
1231 controller = GTK_EVENT_CONTROLLER(mc_gesture);
1232 g_signal_connect(controller, "pressed",
1233 G_CALLBACK(reverse_taxrates_callback), NULL);
1234 gtk_widget_add_controller(econ_label[i], controller);
1235 gtk_grid_attach(GTK_GRID(table2), econ_label[i], i, 0, 1, 1);
1236 }
1237
1238 /* Science, environmental, govt, timeout */
1239 spr = client_research_sprite();
1240 if (spr != NULL) {
1241 bulb_label = picture_new_from_surface(spr->surface);
1242 } else {
1243 bulb_label = gtk_picture_new();
1244 }
1245
1246 spr = client_warming_sprite();
1247 if (spr != NULL) {
1248 sun_label = picture_new_from_surface(spr->surface);
1249 } else {
1250 sun_label = gtk_picture_new();
1251 }
1252
1253 spr = client_cooling_sprite();
1254 if (spr != NULL) {
1255 flake_label = picture_new_from_surface(spr->surface);
1256 } else {
1257 flake_label = gtk_picture_new();
1258 }
1259
1260 spr = client_government_sprite();
1261 if (spr != NULL) {
1262 government_label = picture_new_from_surface(spr->surface);
1263 } else {
1264 government_label = gtk_picture_new();
1265 }
1266
1267 for (i = 0; i < 4; i++) {
1268 GtkWidget *w;
1269
1270 switch (i) {
1271 case 0:
1272 w = bulb_label;
1273 break;
1274 case 1:
1275 w = sun_label;
1276 break;
1277 case 2:
1278 w = flake_label;
1279 break;
1280 default:
1281 case 3:
1282 w = government_label;
1283 break;
1284 }
1285
1286 gtk_widget_set_halign(w, GTK_ALIGN_START);
1287 gtk_widget_set_valign(w, GTK_ALIGN_START);
1288 gtk_widget_set_margin_start(w, 0);
1289 gtk_widget_set_margin_end(w, 0);
1290 gtk_widget_set_margin_top(w, 0);
1291 gtk_widget_set_margin_bottom(w, 0);
1292 gtk_grid_attach(GTK_GRID(table), w, i, 1, 1, 1);
1293 }
1294
1295 timeout_label = gtk_label_new("");
1296
1297 frame = gtk_frame_new(NULL);
1298 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1299 gtk_frame_set_child(GTK_FRAME(frame), timeout_label);
1300
1301
1302 /* Turn done */
1303 turn_done_button = gtk_button_new_with_label(_("Turn Done"));
1304
1305 gtk_grid_attach(GTK_GRID(table), turn_done_button, 0, 2, 10, 1);
1306
1307 g_signal_connect(turn_done_button, "clicked",
1308 G_CALLBACK(end_turn_callback), NULL);
1309 update_turn_done_tooltip();
1310
1311 /* Selected unit status */
1312
1313 /* If you turn this to something else than GtkBox, also adjust
1314 * editgui.c replace_widget() code that removes and adds widgets from it. */
1315 unit_info_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
1316 gtk_widget_set_hexpand(unit_info_box, FALSE);
1317 gtk_box_append(GTK_BOX(avbox), unit_info_box);
1318
1319 /* In edit mode the unit_info_box widget is replaced by the
1320 * editinfobox, so we need to add a ref here so that it is
1321 * not destroyed when removed from its container.
1322 * See editinfobox_refresh() call to replace_widget() */
1323 g_object_ref(unit_info_box);
1324
1325 unit_info_frame = gtk_frame_new("");
1326 gtk_box_append(GTK_BOX(unit_info_box), unit_info_frame);
1327
1328 sw = gtk_scrolled_window_new();
1329 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
1330 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1331 GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
1332 gtk_frame_set_child(GTK_FRAME(unit_info_frame), sw);
1333
1334 label = gtk_label_new(NULL);
1335 gtk_widget_set_hexpand(label, TRUE);
1336 gtk_widget_set_halign(label, GTK_ALIGN_START);
1337 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1338 gtk_widget_set_margin_start(label, 2);
1339 gtk_widget_set_margin_end(label, 2);
1340 gtk_widget_set_margin_top(label, 2);
1341 gtk_widget_set_margin_bottom(label, 2);
1342 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), label);
1343 unit_info_label = label;
1344
1345 hgrid2 = gtk_grid_new();
1346 gtk_box_append(GTK_BOX(unit_info_box), hgrid2);
1347
1348 table = gtk_grid_new();
1349 gtk_widget_set_margin_bottom(table, 5);
1350 gtk_widget_set_margin_end(table, 5);
1351 gtk_widget_set_margin_start(table, 5);
1352 gtk_widget_set_margin_top(table, 5);
1353 gtk_grid_attach(GTK_GRID(hgrid2), table, grid2_col++, 0, 1, 1);
1354
1355 gtk_grid_set_row_spacing(GTK_GRID(table), 2);
1356 gtk_grid_set_column_spacing(GTK_GRID(table), 2);
1357
1358 unit_pic_table = table;
1359
1360 /* Map canvas, editor toolbar, and scrollbars */
1361
1362 /* The top notebook containing the map view and dialogs. */
1363
1364 top_notebook = gtk_notebook_new();
1365 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(top_notebook), GTK_POS_BOTTOM);
1366 gtk_notebook_set_scrollable(GTK_NOTEBOOK(top_notebook), TRUE);
1367
1368
1369 if (GUI_GTK_OPTION(small_display_layout)) {
1370 gtk_paned_set_start_child(GTK_PANED(paned), top_notebook);
1371 } else if (GUI_GTK_OPTION(message_chat_location) == GUI_GTK_MSGCHAT_MERGED) {
1372 right_vbox = gtk_grid_new();
1373 right_row = 0;
1374 gtk_orientable_set_orientation(GTK_ORIENTABLE(right_vbox),
1375 GTK_ORIENTATION_VERTICAL);
1376
1377 gtk_grid_attach(GTK_GRID(right_vbox), top_notebook, 0, right_row++, 1, 1);
1378 gtk_grid_attach(GTK_GRID(right_vbox), ingame_votebar, 0, right_row++, 1, 1);
1379 gtk_grid_attach(GTK_GRID(hgrid), right_vbox, grid_col++, 0, 1, 1);
1380 } else {
1381 gtk_grid_attach(GTK_GRID(hgrid), top_notebook, grid_col++, 0, 1, 1);
1382 }
1383
1384 map_widget = gtk_grid_new();
1385
1386 mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
1387 gtk_box_append(GTK_BOX(mainbox), map_widget);
1388
1389 gtk_box_append(GTK_BOX(mainbox), editgui_get_editbar()->widget);
1390 ebar = editgui_get_editbar()->widget;
1391 gtk_widget_set_margin_bottom(ebar, 4);
1392 gtk_widget_set_margin_end(ebar, 4);
1393 gtk_widget_set_margin_start(ebar, 4);
1394 gtk_widget_set_margin_top(ebar, 4);
1395
1396 label = gtk_label_new(Q_("?noun:View"));
1397 gtk_notebook_append_page(GTK_NOTEBOOK(top_notebook), mainbox, label);
1398
1399 frame = gtk_frame_new(NULL);
1400 gtk_grid_attach(GTK_GRID(map_widget), frame, 0, 0, 1, 1);
1401
1402 map_canvas = gtk_drawing_area_new();
1403 gtk_widget_set_hexpand(map_canvas, TRUE);
1404 gtk_widget_set_vexpand(map_canvas, TRUE);
1405 gtk_widget_set_size_request(map_canvas, 300, 300);
1406 gtk_widget_set_can_focus(map_canvas, TRUE);
1407
1408 gtk_widget_set_focusable(map_canvas, TRUE);
1409
1410#if 0
1411 setup_canvas_color_for_state(GTK_STATE_FLAG_NORMAL);
1412 setup_canvas_color_for_state(GTK_STATE_FLAG_ACTIVE);
1413 setup_canvas_color_for_state(GTK_STATE_FLAG_PRELIGHT);
1414 setup_canvas_color_for_state(GTK_STATE_FLAG_SELECTED);
1415 setup_canvas_color_for_state(GTK_STATE_FLAG_INSENSITIVE);
1416 setup_canvas_color_for_state(GTK_STATE_FLAG_INCONSISTENT);
1417 setup_canvas_color_for_state(GTK_STATE_FLAG_FOCUSED);
1418 setup_canvas_color_for_state(GTK_STATE_FLAG_BACKDROP);
1419#endif /* 0 */
1420
1421 gtk_frame_set_child(GTK_FRAME(frame), map_canvas);
1422
1423 map_horizontal_scrollbar =
1424 gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
1425 gtk_grid_attach(GTK_GRID(map_widget), map_horizontal_scrollbar, 0, 1, 1, 1);
1426
1427 map_vertical_scrollbar =
1428 gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
1429 gtk_grid_attach(GTK_GRID(map_widget), map_vertical_scrollbar, 1, 0, 1, 1);
1430
1431 gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(map_canvas), map_canvas_draw,
1432 NULL, NULL);
1433
1434 mc_controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
1435 g_signal_connect(mc_controller, "pressed",
1436 G_CALLBACK(left_butt_down_mapcanvas), NULL);
1437 g_signal_connect(mc_controller, "released",
1438 G_CALLBACK(left_butt_up_mapcanvas), NULL);
1439 gtk_widget_add_controller(map_canvas, mc_controller);
1440 mc_gesture = gtk_gesture_click_new();
1441 gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(mc_gesture), 3);
1442 mc_controller = GTK_EVENT_CONTROLLER(mc_gesture);
1443 g_signal_connect(mc_controller, "pressed",
1444 G_CALLBACK(right_butt_down_mapcanvas), NULL);
1445 g_signal_connect(mc_controller, "released",
1446 G_CALLBACK(right_butt_up_mapcanvas), NULL);
1447 gtk_widget_add_controller(map_canvas, mc_controller);
1448 mc_gesture = gtk_gesture_click_new();
1449 gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(mc_gesture), 2);
1450 mc_controller = GTK_EVENT_CONTROLLER(mc_gesture);
1451 g_signal_connect(mc_controller, "pressed",
1452 G_CALLBACK(middle_butt_down_mapcanvas), NULL);
1453 gtk_widget_add_controller(map_canvas, mc_controller);
1454 mc_controller = gtk_event_controller_scroll_new(GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES);
1455 g_signal_connect(mc_controller, "scroll",
1456 G_CALLBACK(mouse_scroll_mapcanvas), NULL);
1457 gtk_widget_add_controller(map_canvas, mc_controller);
1458 mc_controller = gtk_event_controller_motion_new();
1459 g_signal_connect(mc_controller, "motion",
1460 G_CALLBACK(move_mapcanvas), NULL);
1461 g_signal_connect(mc_controller, "leave",
1462 G_CALLBACK(leave_mapcanvas), NULL);
1463 gtk_widget_add_controller(map_canvas, mc_controller);
1464
1465 g_signal_connect(map_canvas, "resize",
1466 G_CALLBACK(map_canvas_resize), NULL);
1467
1468 mc_controller = gtk_event_controller_key_new();
1469 g_signal_connect(mc_controller, "key-pressed",
1470 G_CALLBACK(toplevel_key_press_handler), NULL);
1471 gtk_widget_add_controller(toplevel, mc_controller);
1472
1473 /* *** The message window -- this is a detachable widget *** */
1474
1475 if (GUI_GTK_OPTION(message_chat_location) == GUI_GTK_MSGCHAT_MERGED) {
1476 bottom_hpaned = paned;
1477 right_notebook = bottom_notebook = top_notebook;
1478 } else {
1479 GtkWidget *hpaned;
1480
1481 dtach_lowbox = detached_widget_new();
1482 gtk_paned_set_end_child(GTK_PANED(paned), dtach_lowbox);
1483 avbox = detached_widget_fill(dtach_lowbox);
1484
1485 mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
1486 if (!GUI_GTK_OPTION(small_display_layout)) {
1487 gtk_box_append(GTK_BOX(mainbox), ingame_votebar);
1488 }
1489 gtk_box_append(GTK_BOX(avbox), mainbox);
1490
1491 if (GUI_GTK_OPTION(small_display_layout)) {
1492 hpaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
1493 } else {
1494 hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
1495 }
1496 gtk_box_append(GTK_BOX(mainbox), hpaned);
1497 gtk_widget_set_margin_bottom(hpaned, 4);
1498 gtk_widget_set_margin_end(hpaned, 4);
1499 gtk_widget_set_margin_start(hpaned, 4);
1500 gtk_widget_set_margin_top(hpaned, 4);
1501 bottom_hpaned = hpaned;
1502
1503 bottom_notebook = gtk_notebook_new();
1504 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(bottom_notebook), GTK_POS_TOP);
1505 gtk_notebook_set_scrollable(GTK_NOTEBOOK(bottom_notebook), TRUE);
1506 gtk_paned_set_start_child(GTK_PANED(hpaned), bottom_notebook);
1507
1508 right_notebook = gtk_notebook_new();
1509 g_object_ref(right_notebook);
1510 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(right_notebook), GTK_POS_TOP);
1511 gtk_notebook_set_scrollable(GTK_NOTEBOOK(right_notebook), TRUE);
1512 if (GUI_GTK_OPTION(message_chat_location) == GUI_GTK_MSGCHAT_SPLIT) {
1513 gtk_paned_set_end_child(GTK_PANED(hpaned), right_notebook);
1514 }
1515 }
1516
1517 mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
1518
1519 sw = gtk_scrolled_window_new();
1520 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw),
1521 TRUE);
1522 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1523 GTK_POLICY_AUTOMATIC,
1524 GTK_POLICY_ALWAYS);
1525 gtk_box_append(GTK_BOX(mainbox), sw);
1526
1527 label = gtk_label_new(_("Chat"));
1528 gtk_notebook_append_page(GTK_NOTEBOOK(bottom_notebook), mainbox, label);
1529
1530 text = gtk_text_view_new_with_buffer(message_buffer);
1531 gtk_widget_set_hexpand(text, TRUE);
1532 gtk_widget_set_vexpand(text, TRUE);
1533 set_message_buffer_view_link_handlers(text);
1534 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
1535 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), text);
1536
1537 gtk_widget_set_name(text, "chatline");
1538
1539 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
1540 gtk_widget_realize(text);
1541 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);
1542
1543 main_message_area = GTK_TEXT_VIEW(text);
1544 if (dtach_lowbox != NULL) {
1545 g_object_set_data(G_OBJECT(dtach_lowbox), "hide-over-reparent", main_message_area);
1546 }
1547
1548 chat_welcome_message(TRUE);
1549
1550 /* The chat line */
1551 view = inputline_toolkit_view_new();
1552 gtk_box_append(GTK_BOX(mainbox), view);
1553 gtk_widget_set_margin_bottom(view, 3);
1554 gtk_widget_set_margin_end(view, 3);
1555 gtk_widget_set_margin_start(view, 3);
1556 gtk_widget_set_margin_top(view, 3);
1557
1558 button = gtk_check_button_new_with_label(_("Allies Only"));
1559 gtk_widget_set_focus_on_click(button, FALSE);
1560 gtk_check_button_set_active(GTK_CHECK_BUTTON(button),
1561 GUI_GTK_OPTION(allied_chat_only));
1562 g_signal_connect(button, "toggled",
1563 G_CALLBACK(allied_chat_button_toggled), NULL);
1564 inputline_toolkit_view_append_button(view, button);
1565 allied_chat_toggle_button = button;
1566
1567 button = gtk_button_new_with_label(_("Clear links"));
1568 g_signal_connect(button, "clicked",
1569 G_CALLBACK(link_marks_clear_all), NULL);
1570 inputline_toolkit_view_append_button(view, button);
1571
1572 /* Other things to take care of */
1573
1574 gtk_widget_show(gtk_window_get_child(GTK_WINDOW(toplevel)));
1575
1576 if (GUI_GTK_OPTION(enable_tabs)) {
1577 meswin_dialog_popup(FALSE);
1578 }
1579
1580 gtk_notebook_set_current_page(GTK_NOTEBOOK(top_notebook), 0);
1581 gtk_notebook_set_current_page(GTK_NOTEBOOK(bottom_notebook), 0);
1582
1583 if (!GUI_GTK_OPTION(map_scrollbars)) {
1584 gtk_widget_hide(map_horizontal_scrollbar);
1585 gtk_widget_hide(map_vertical_scrollbar);
1586 }
1587}
1588
1589/**********************************************************************/
1592 static void g_log_to_freelog_cb(const gchar *log_domain,
1593 GLogLevelFlags log_level,
1594 const gchar *message,
1595 gpointer user_data)
1596{
1597 enum log_level fllvl = LOG_ERROR;
1598
1599 switch (log_level) {
1600 case G_LOG_LEVEL_DEBUG:
1601 fllvl = LOG_DEBUG;
1602 break;
1603 case G_LOG_LEVEL_WARNING:
1604 fllvl = LOG_WARN;
1605 break;
1606 default:
1607 break;
1608 }
1609
1610 if (log_domain != NULL) {
1611 log_base(fllvl, "%s: %s", log_domain, message);
1612 } else {
1613 log_base(fllvl, "%s", message);
1614 }
1615}
1616
1617/**********************************************************************/
1620 static GLogWriterOutput g_log_writer_to_freelog_cb(GLogLevelFlags log_level,
1621 const GLogField *fields,
1622 gsize n_fields,
1623 gpointer user_data)
1624{
1625 /* No need to have formatter of our own - let's use glib's default one. */
1626 gchar *out = g_log_writer_format_fields(log_level, fields, n_fields, FALSE);
1627
1628 g_log_to_freelog_cb(NULL, log_level, out, NULL);
1629
1630 return G_LOG_WRITER_HANDLED;
1631}
1632
1633/**********************************************************************/
1636 static void set_g_log_callback_domain(const char *domain)
1637{
1638 g_log_set_handler(domain,
1639 G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING
1640 | G_LOG_LEVEL_MASK
1641 | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
1642 g_log_to_freelog_cb, NULL);
1643}
1644
1645/**********************************************************************/
1648 static void set_g_log_callbacks(void)
1649{
1650 /* Old API, still used by many log producers */
1651 g_log_set_default_handler(g_log_to_freelog_cb, NULL);
1652
1653 set_g_log_callback_domain("Gtk");
1654 set_g_log_callback_domain("Gdk");
1655 set_g_log_callback_domain("Glib");
1656
1657 /* glib >= 2.50 API */
1658 g_log_set_writer_func(g_log_writer_to_freelog_cb, NULL, NULL);
1659}
1660
1661/**********************************************************************/
1664 void ui_init(void)
1665{
1666 log_set_callback(log_callback_utf8);
1667 set_g_log_callbacks();
1668 set_frame_by_frame_animation();
1669 zoom_phase_set(FALSE);
1670 zoom_set_steps(zoom_steps_custom);
1671}
1672
1673/**********************************************************************/
1676 int main(int argc, char **argv)
1677{
1678 return client_main(argc, argv, FALSE);
1679}
1680
1681/**********************************************************************/
1684 static void migrate_options_from_gtk2(void)
1685{
1686 log_normal(_("Migrating options from gtk2 to gtk3 client"));
1687
1688#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1689#define MIGRATE_STR_OPTION(opt) \
1690 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1691 sizeof(gui_options.gui_gtk3_##opt));
1692
1693 /* Default theme name is never migrated */
1694 /* 'fullscreen', 'small_display_layout', and 'message_chat_location'
1695 * not migrated, as (unlike Gtk2), Gtk3-client tries to pick better
1696 * defaults for these in fresh installations based on screen size (see
1697 * adjust_default_options()); so user is probably better served by
1698 * getting these adaptive defaults than whatever they had for Gtk2.
1699 * Since 'fullscreen' isn't migrated, we don't need to worry about
1700 * preserving gui_gtk2_migrated_from_2_5 either. */
1701 MIGRATE_OPTION(map_scrollbars);
1702 MIGRATE_OPTION(dialogs_on_top);
1703 MIGRATE_OPTION(show_task_icons);
1704 MIGRATE_OPTION(enable_tabs);
1705 MIGRATE_OPTION(show_chat_message_time);
1706 MIGRATE_OPTION(new_messages_go_to_top);
1707 MIGRATE_OPTION(show_message_window_buttons);
1708 MIGRATE_OPTION(metaserver_tab_first);
1709 MIGRATE_OPTION(allied_chat_only);
1710 MIGRATE_OPTION(mouse_over_map_focus);
1711 MIGRATE_OPTION(chatline_autocompletion);
1712 MIGRATE_OPTION(citydlg_xsize);
1713 MIGRATE_OPTION(citydlg_ysize);
1714 MIGRATE_OPTION(popup_tech_help);
1715
1716 MIGRATE_STR_OPTION(font_city_label);
1717 MIGRATE_STR_OPTION(font_notify_label);
1718 MIGRATE_STR_OPTION(font_spaceship_label);
1719 MIGRATE_STR_OPTION(font_help_label);
1720 MIGRATE_STR_OPTION(font_help_link);
1721 MIGRATE_STR_OPTION(font_help_text);
1722 MIGRATE_STR_OPTION(font_chatline);
1723 MIGRATE_STR_OPTION(font_beta_label);
1724 MIGRATE_STR_OPTION(font_small);
1725 MIGRATE_STR_OPTION(font_comment_label);
1726 MIGRATE_STR_OPTION(font_city_names);
1727 MIGRATE_STR_OPTION(font_city_productions);
1728 MIGRATE_STR_OPTION(font_reqtree_text);
1729
1730#undef MIGRATE_OPTION
1731#undef MIGRATE_STR_OPTION
1732
1733 gui_options.gui_gtk3_migrated_from_gtk2 = TRUE;
1734}
1735
1736/**********************************************************************/
1739 static void migrate_options_from_gtk3(void)
1740{
1741 log_normal(_("Migrating options from gtk3 to gtk3.22 client"));
1742
1743#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_22_##opt = gui_options.gui_gtk3_##opt;
1744#define MIGRATE_STR_OPTION(opt) \
1745 strncpy(gui_options.gui_gtk3_22_##opt, gui_options.gui_gtk3_##opt, \
1746 sizeof(gui_options.gui_gtk3_22_##opt));
1747
1748 /* Default theme name is never migrated */
1749
1750 /* Simulate gui-gtk3's migrate_options_from_2_5() */
1751 if (!gui_options.gui_gtk3_migrated_from_2_5) {
1752 log_normal(_("Migrating gtk3-client options from freeciv-2.5 options."));
1753 gui_options.gui_gtk3_fullscreen = gui_options.migrate_fullscreen;
1754 gui_options.gui_gtk3_migrated_from_2_5 = TRUE;
1755 }
1756
1757 MIGRATE_OPTION(fullscreen);
1758 MIGRATE_OPTION(map_scrollbars);
1759 MIGRATE_OPTION(dialogs_on_top);
1760 MIGRATE_OPTION(show_task_icons);
1761 MIGRATE_OPTION(enable_tabs);
1762 MIGRATE_OPTION(show_chat_message_time);
1763 MIGRATE_OPTION(new_messages_go_to_top);
1764 MIGRATE_OPTION(show_message_window_buttons);
1765 MIGRATE_OPTION(metaserver_tab_first);
1766 MIGRATE_OPTION(allied_chat_only);
1767 MIGRATE_OPTION(message_chat_location);
1768 MIGRATE_OPTION(small_display_layout);
1769 MIGRATE_OPTION(mouse_over_map_focus);
1770 MIGRATE_OPTION(chatline_autocompletion);
1771 MIGRATE_OPTION(citydlg_xsize);
1772 MIGRATE_OPTION(citydlg_ysize);
1773 MIGRATE_OPTION(popup_tech_help);
1774
1775 MIGRATE_STR_OPTION(font_city_label);
1776 MIGRATE_STR_OPTION(font_notify_label);
1777 MIGRATE_STR_OPTION(font_spaceship_label);
1778 MIGRATE_STR_OPTION(font_help_label);
1779 MIGRATE_STR_OPTION(font_help_link);
1780 MIGRATE_STR_OPTION(font_help_text);
1781 MIGRATE_STR_OPTION(font_chatline);
1782 MIGRATE_STR_OPTION(font_beta_label);
1783 MIGRATE_STR_OPTION(font_small);
1784 MIGRATE_STR_OPTION(font_comment_label);
1785 MIGRATE_STR_OPTION(font_city_names);
1786 MIGRATE_STR_OPTION(font_city_productions);
1787 MIGRATE_STR_OPTION(font_reqtree_text);
1788
1789#undef MIGRATE_OPTION
1790#undef MIGRATE_STR_OPTION
1791
1792 gui_options.gui_gtk3_22_migrated_from_gtk3 = TRUE;
1793}
1794
1795/**********************************************************************/
1798 static void migrate_options_from_gtk3_22(void)
1799{
1800 log_normal(_("Migrating options from gtk3.22 to gtk4 client"));
1801
1802#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk3_22_##opt;
1803#define MIGRATE_STR_OPTION(opt) \
1804 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_22_##opt, \
1805 sizeof(GUI_GTK_OPTION(opt)));
1806
1807 /* Default theme name is never migrated */
1808 MIGRATE_OPTION(fullscreen);
1809 MIGRATE_OPTION(map_scrollbars);
1810 MIGRATE_OPTION(dialogs_on_top);
1811 MIGRATE_OPTION(show_task_icons);
1812 MIGRATE_OPTION(enable_tabs);
1813 MIGRATE_OPTION(show_chat_message_time);
1814 MIGRATE_OPTION(new_messages_go_to_top);
1815 MIGRATE_OPTION(show_message_window_buttons);
1816 MIGRATE_OPTION(metaserver_tab_first);
1817 MIGRATE_OPTION(allied_chat_only);
1818 MIGRATE_OPTION(message_chat_location);
1819 MIGRATE_OPTION(small_display_layout);
1820 MIGRATE_OPTION(mouse_over_map_focus);
1821 MIGRATE_OPTION(chatline_autocompletion);
1822 MIGRATE_OPTION(citydlg_xsize);
1823 MIGRATE_OPTION(citydlg_ysize);
1824 MIGRATE_OPTION(popup_tech_help);
1825
1826 MIGRATE_STR_OPTION(font_city_label);
1827 MIGRATE_STR_OPTION(font_notify_label);
1828 MIGRATE_STR_OPTION(font_spaceship_label);
1829 MIGRATE_STR_OPTION(font_help_label);
1830 MIGRATE_STR_OPTION(font_help_link);
1831 MIGRATE_STR_OPTION(font_help_text);
1832 MIGRATE_STR_OPTION(font_chatline);
1833 MIGRATE_STR_OPTION(font_beta_label);
1834 MIGRATE_STR_OPTION(font_small);
1835 MIGRATE_STR_OPTION(font_comment_label);
1836 MIGRATE_STR_OPTION(font_city_names);
1837 MIGRATE_STR_OPTION(font_city_productions);
1838 MIGRATE_STR_OPTION(font_reqtree_text);
1839
1840#undef MIGRATE_OPTION
1841#undef MIGRATE_STR_OPTION
1842
1843 GUI_GTK_OPTION(migrated_from_gtk3_22) = TRUE;
1844}
1845
1846/**********************************************************************/
1849 int ui_main(int argc, char **argv)
1850{
1851 if (parse_options(argc, argv)) {
1852 /* The locale has already been set in init_nls() and the windows-specific
1853 * locale logic in gtk_init() causes problems with zh_CN (see PR#39475) */
1854 gtk_disable_setlocale();
1855
1856 if (!gtk_init_check()) {
1857 log_fatal(_("Failed to open graphical mode."));
1858 return EXIT_FAILURE;
1859 }
1860
1861 menus_set_initial_toggle_values();
1862
1863 gui_up = TRUE;
1864 fc_app = gtk_application_new(NULL, 0);
1865 g_signal_connect(fc_app, "activate", G_CALLBACK(activate_gui), NULL);
1866 g_application_run(G_APPLICATION(fc_app), 0, NULL);
1867 gui_up = FALSE;
1868
1869 destroy_server_scans();
1870 free_mapcanvas_and_overview();
1871 spaceship_dialog_done();
1872 intel_dialog_done();
1873 citizens_dialog_done();
1874 luaconsole_dialog_done();
1875 happiness_dialog_done();
1876 diplomacy_dialog_done();
1877 cma_fe_done();
1878 free_unit_table();
1879
1880 /* We have extra ref for unit_info_box that has protected
1881 * it from getting destroyed when editinfobox_refresh()
1882 * moves widgets around. Free that extra ref here. */
1883 g_object_unref(unit_info_box);
1884 if (empty_unit_paintable != NULL) {
1885 g_object_unref(empty_unit_paintable);
1886 }
1887
1888 editgui_free();
1889 gtk_window_destroy(GTK_WINDOW(toplevel));
1890 message_buffer = NULL; /* Result of destruction of everything */
1891 tileset_free_tiles(tileset);
1892 }
1893
1894 return EXIT_SUCCESS;
1895}
1896
1897/**********************************************************************/
1900 static void activate_gui(GtkApplication *app, gpointer data)
1901{
1902 PangoFontDescription *toplevel_font_name;
1903 guint sig;
1904 char window_name[1024];
1905
1906 toplevel = gtk_application_window_new(app);
1907 if (vmode.width > 0 && vmode.height > 0) {
1908 gtk_window_set_default_size(GTK_WINDOW(toplevel),
1909 vmode.width, vmode.height);
1910 }
1911
1912 gtk_widget_realize(toplevel);
1913 gtk_widget_set_name(toplevel, "Freeciv");
1914
1915 help_system_init();
1916
1917 dlg_tab_provider_prepare();
1918
1919 if (gui_options.first_boot) {
1920 adjust_default_options();
1921 /* We're using fresh defaults for this version of this client,
1922 * so prevent any future migrations from other clients / versions */
1923 GUI_GTK_OPTION(migrated_from_gtk3_22) = TRUE;
1924 /* Avoid also marking previous Gtk clients as migrated, so that
1925 * they can have their own run of their adjust_default_options() if
1926 * they are ever run (as a side effect of Gtk2->Gtk3 migration). */
1927 } else {
1928 if (!GUI_GTK_OPTION(migrated_from_gtk3_22)) {
1929 if (!gui_options.gui_gtk3_22_migrated_from_gtk3) {
1930 if (!gui_options.gui_gtk3_migrated_from_gtk2) {
1931 migrate_options_from_gtk2();
1932 /* We want a fresh look at screen-size-related options after Gtk2 */
1933 adjust_default_options();
1934 /* We don't ever want to consider pre-2.6 fullscreen option again
1935 * (even for gui-gtk3) */
1936 gui_options.gui_gtk3_migrated_from_2_5 = TRUE;
1937 }
1938 migrate_options_from_gtk3();
1939 }
1940 migrate_options_from_gtk3_22();
1941 }
1942 }
1943
1944 if (GUI_GTK_OPTION(fullscreen)) {
1945 gtk_window_fullscreen(GTK_WINDOW(toplevel));
1946 }
1947
1948 fc_snprintf(window_name, sizeof(window_name), _("Freeciv (%s)"), GUI_NAME_SHORT);
1949 gtk_window_set_title(GTK_WINDOW(toplevel), window_name);
1950
1951 g_signal_connect(toplevel, "close-request",
1952 G_CALLBACK(quit_dialog_callback), NULL);
1953
1954 /* Disable GTK cursor key focus movement */
1955 sig = g_signal_lookup("move-focus", GTK_TYPE_WIDGET);
1956 g_signal_handlers_disconnect_matched(toplevel, G_SIGNAL_MATCH_ID, sig,
1957 0, 0, 0, 0);
1958 g_signal_connect(toplevel, "move-focus", G_CALLBACK(toplevel_focus), NULL);
1959
1960 options_iterate(client_optset, poption) {
1961 if (OT_FONT == option_type(poption)) {
1962 /* Force to call the appropriate callback. */
1963 option_changed(poption);
1964 }
1965 } options_iterate_end;
1966
1967 toplevel_font_name = pango_context_get_font_description(
1968 gtk_widget_get_pango_context(toplevel));
1969
1970 if (NULL == city_names_style) {
1971 city_names_style = pango_font_description_copy(toplevel_font_name);
1972 log_error("city_names_style should have been set by options.");
1973 }
1974 if (NULL == city_productions_style) {
1975 city_productions_style = pango_font_description_copy(toplevel_font_name);
1976 log_error("city_productions_style should have been set by options.");
1977 }
1978 if (NULL == reqtree_text_style) {
1979 reqtree_text_style = pango_font_description_copy(toplevel_font_name);
1980 log_error("reqtree_text_style should have been set by options.");
1981 }
1982
1983 tileset_init(tileset);
1984 tileset_load_tiles(tileset);
1985
1986 /* keep the icon of the executable on Windows (see PR#36491) */
1987#ifndef FREECIV_MSWINDOWS
1988 {
1989 /* Only call this after tileset_load_tiles is called. */
1990 gtk_window_set_icon_name(GTK_WINDOW(toplevel), "freeciv");
1991 }
1992#endif /* FREECIV_MSWINDOWS */
1993
1994 setup_widgets();
1995 load_cursors();
1996 cma_fe_init();
1997 diplomacy_dialog_init();
1998 luaconsole_dialog_init();
1999 happiness_dialog_init();
2000 citizens_dialog_init();
2001 intel_dialog_init();
2002 spaceship_dialog_init();
2003 chatline_init();
2004 init_mapcanvas_and_overview();
2005
2006 tileset_use_preferred_theme(tileset);
2007
2008 gtk_widget_show(toplevel);
2009
2010 /* assumes toplevel showing */
2011 set_client_state(C_S_DISCONNECTED);
2012
2013 /* assumes client_state is set */
2014 timer_id = g_timeout_add(TIMER_INTERVAL, timer_callback, NULL);
2015}
2016
2017/**********************************************************************/
2020 bool is_gui_up(void)
2021{
2022 return gui_up;
2023}
2024
2025/**********************************************************************/
2028 void ui_exit(void)
2029{
2030 if (message_buffer != NULL) {
2031 g_object_unref(message_buffer);
2032 message_buffer = NULL;
2033 }
2034}
2035
2036/**********************************************************************/
2039 enum gui_type get_gui_type(void)
2040{
2041 return GUI_GTK4;
2042}
2043
2044/**********************************************************************/
2047 void sound_bell(void)
2048{
2049 gdk_display_beep(gdk_display_get_default());
2050}
2051
2052/**********************************************************************/
2058 void set_unit_icon(int idx, struct unit *punit)
2059{
2060 GtkWidget *w;
2061
2062 fc_assert_ret(idx >= -1 && idx < num_units_below);
2063
2064 if (idx == -1) {
2065 w = unit_pic;
2066 unit_id_top = punit ? punit->id : 0;
2067 } else {
2068 w = unit_below_pic[idx];
2069 unit_ids[idx] = punit ? punit->id : 0;
2070 }
2071
2072 if (!w) {
2073 return;
2074 }
2075
2076 if (punit) {
2077 put_unit_picture(punit, GTK_PICTURE(w), -1);
2078 } else {
2079 if (empty_unit_paintable == NULL) {
2080 /* FIXME: Use proper icon height instead of hardcoded 50 */
2081 empty_unit_paintable = gdk_paintable_new_empty(tileset_tile_width(tileset), 50);
2082
2083 /* Add ref to avoid it getting destroyed along any single parent widget. */
2084 g_object_ref(empty_unit_paintable);
2085 }
2086 gtk_picture_set_paintable(GTK_PICTURE(w), empty_unit_paintable);
2087 }
2088}
2089
2090/**********************************************************************/
2095 void set_unit_icons_more_arrow(bool onoff)
2096{
2097 static bool showing = FALSE;
2098
2099 if (!more_arrow) {
2100 return;
2101 }
2102
2103 if (onoff && !showing) {
2104 gtk_widget_show(more_arrow);
2105 showing = TRUE;
2106 } else if (!onoff && showing) {
2107 gtk_widget_hide(more_arrow);
2108 showing = FALSE;
2109 }
2110}
2111
2112/**********************************************************************/
2118 void real_focus_units_changed(void)
2119{
2120 goto_dialog_focus_units_changed();
2121}
2122
2123/**********************************************************************/
2127 static gboolean select_unit_pic_callback(GtkGestureClick *gesture, int n_press,
2128 double x, double y, gpointer data)
2129{
2130 int i = GPOINTER_TO_INT(data);
2131 struct unit *punit;
2132
2133 if (i == -1) {
2134 punit = game_unit_by_number(unit_id_top);
2135 if (punit && unit_is_in_focus(punit)) {
2136 /* Clicking on the currently selected unit will center it. */
2137 center_tile_mapcanvas(unit_tile(punit));
2138 }
2139 return TRUE;
2140 }
2141
2142 if (unit_ids[i] == 0) { /* No unit displayed at this place */
2143 return TRUE;
2144 }
2145
2146 punit = game_unit_by_number(unit_ids[i]);
2147 if (NULL != punit && unit_owner(punit) == client_player()) {
2148 /* Unit shouldn't be NULL but may be owned by an ally. */
2149 unit_focus_set(punit);
2150 }
2151
2152 return TRUE;
2153}
2154
2155/**********************************************************************/
2159 static gboolean select_more_arrow_callback(GtkGestureClick *gesture, int n_press,
2160 double x, double y, gpointer data)
2161{
2162 struct unit *punit = game_unit_by_number(unit_id_top);
2163
2164 if (punit) {
2165 unit_select_dialog_popup(unit_tile(punit));
2166 }
2167
2168 return TRUE;
2169}
2170
2171/**********************************************************************/
2174 static void info_popup_closed(GtkWidget *self, gpointer data)
2175{
2176 gtk_widget_unparent(self);
2177}
2178
2179/**********************************************************************/
2182 static gboolean show_info_popup(GtkGestureClick *gesture, int n_press,
2183 double x, double y, gpointer data)
2184{
2185 GtkWidget *p;
2186 GtkWidget *child;
2187 GtkWidget *frame = GTK_WIDGET(data);
2188
2189 p = gtk_popover_new();
2190
2191 gtk_widget_set_parent(p, frame);
2192 child = gtk_label_new(get_info_label_text_popup());
2193 gtk_popover_set_child(GTK_POPOVER(p), child);
2194 g_signal_connect(p, "closed",
2195 G_CALLBACK(info_popup_closed), NULL);
2196 gtk_popover_popup(GTK_POPOVER(p));
2197
2198 return TRUE;
2199}
2200
2201/**********************************************************************/
2204 static void end_turn_callback(GtkWidget *w, gpointer data)
2205{
2206 gtk_widget_set_sensitive(turn_done_button, FALSE);
2207 user_ended_turn();
2208}
2209
2210/**********************************************************************/
2213 static gboolean get_net_input(GIOChannel *source, GIOCondition condition,
2214 gpointer data)
2215{
2216 input_from_server(g_io_channel_unix_get_fd(source));
2217
2218 return TRUE;
2219}
2220
2221/**********************************************************************/
2224 static void set_wait_for_writable_socket(struct connection *pc,
2225 bool socket_writable)
2226{
2227 static bool previous_state = FALSE;
2228
2229 fc_assert_ret(pc == &client.conn);
2230
2231 if (previous_state == socket_writable)
2232 return;
2233
2234 log_debug("set_wait_for_writable_socket(%d)", socket_writable);
2235
2236 g_source_remove(srv_id);
2237 srv_id = g_io_add_watch(srv_channel,
2238 G_IO_IN | (socket_writable ? G_IO_OUT : 0) | G_IO_ERR,
2239 get_net_input,
2240 NULL);
2241
2242 previous_state = socket_writable;
2243}
2244
2245/**********************************************************************/
2249 void add_net_input(int sock)
2250{
2251#ifdef FREECIV_MSWINDOWS
2252 srv_channel = g_io_channel_win32_new_socket(sock);
2253#else
2254 srv_channel = g_io_channel_unix_new(sock);
2255#endif
2256 srv_id = g_io_add_watch(srv_channel,
2257 G_IO_IN | G_IO_ERR,
2258 get_net_input,
2259 NULL);
2260 client.conn.notify_of_writable_data = set_wait_for_writable_socket;
2261}
2262
2263/**********************************************************************/
2267 void remove_net_input(void)
2268{
2269 g_source_remove(srv_id);
2270 g_io_channel_unref(srv_channel);
2271 gtk_widget_set_cursor(toplevel, NULL);
2272}
2273
2274/**********************************************************************/
2278 static void quit_dialog_response(GtkWidget *dialog, gint response)
2279{
2280 gtk_window_destroy(GTK_WINDOW(dialog));
2281 if (response == GTK_RESPONSE_YES) {
2282 start_quitting();
2283 if (client.conn.used) {
2284 disconnect_from_server();
2285 }
2286 quit_gtk_main();
2287 }
2288}
2289
2290/**********************************************************************/
2293 void quit_gtk_main(void)
2294{
2295 /* Quit gtk main loop. After this it will return to finish
2296 * ui_main() */
2297
2298 g_application_quit(G_APPLICATION(fc_app));
2299}
2300
2301/**********************************************************************/
2305 void popup_quit_dialog(void)
2306{
2307 static GtkWidget *dialog;
2308
2309 if (!dialog) {
2310 dialog = gtk_message_dialog_new(NULL,
2311 0,
2312 GTK_MESSAGE_WARNING,
2313 GTK_BUTTONS_YES_NO,
2314 _("Are you sure you want to quit?"));
2315 setup_dialog(dialog, toplevel);
2316
2317 g_signal_connect(dialog, "response",
2318 G_CALLBACK(quit_dialog_response), NULL);
2319 g_signal_connect(dialog, "destroy",
2320 G_CALLBACK(widget_destroyed), &dialog);
2321 }
2322
2323 gtk_window_present(GTK_WINDOW(dialog));
2324}
2325
2326/**********************************************************************/
2329 static gboolean quit_dialog_callback(void)
2330{
2331 popup_quit_dialog();
2332 /* Stop emission of event. */
2333 return TRUE;
2334}
2335
2336struct callback {
2337 void (*callback)(void *data);
2338 void *data;
2339};
2340
2341/**********************************************************************/
2344 static gboolean idle_callback_wrapper(gpointer data)
2345{
2346 struct callback *cb = data;
2347
2348 (cb->callback)(cb->data);
2349 free(cb);
2350
2351 return FALSE;
2352}
2353
2354/**********************************************************************/
2359 void add_idle_callback(void (callback)(void *), void *data)
2360{
2361 struct callback *cb = fc_malloc(sizeof(*cb));
2362
2363 cb->callback = callback;
2364 cb->data = data;
2365 g_idle_add(idle_callback_wrapper, cb);
2366}
2367
2368/**********************************************************************/
2371 void animation_idle_cb(void *data)
2372{
2373 if (get_current_client_page() == PAGE_GAME) {
2374 update_animation();
2375 add_idle_callback(animation_idle_cb, NULL);
2376 }
2377}
2378
2379/**********************************************************************/
2383 static void allied_chat_only_callback(struct option *poption)
2384{
2385 GtkWidget *button;
2386
2387 button = allied_chat_toggle_button;
2388 fc_assert_ret(button != NULL);
2389 fc_assert_ret(GTK_IS_CHECK_BUTTON(button));
2390
2391 gtk_check_button_set_active(GTK_CHECK_BUTTON(button),
2392 option_bool_get(poption));
2393}
2394
2395/**********************************************************************/
2398 void fullscreen_opt_refresh(struct option *poption)
2399{
2400 if (GUI_GTK_OPTION(fullscreen)) {
2401 gtk_window_fullscreen(GTK_WINDOW(toplevel));
2402 } else {
2403 gtk_window_unfullscreen(GTK_WINDOW(toplevel));
2404 }
2405}
2406
2407/**********************************************************************/
2410 static void apply_city_names_font(struct option *poption)
2411{
2412 gui_update_font_full(option_font_target(poption),
2413 option_font_get(poption),
2414 &city_names_style);
2415 update_city_descriptions();
2416}
2417
2418/**********************************************************************/
2421 static void apply_city_productions_font(struct option *poption)
2422{
2423 gui_update_font_full(option_font_target(poption),
2424 option_font_get(poption),
2425 &city_productions_style);
2426 update_city_descriptions();
2427}
2428
2429/**********************************************************************/
2432 static void apply_reqtree_text_font(struct option *poption)
2433{
2434 gui_update_font_full(option_font_target(poption),
2435 option_font_get(poption),
2436 &reqtree_text_style);
2437 science_report_dialog_redraw();
2438}
2439
2440/**********************************************************************/
2444 void options_extra_init(void)
2445{
2446
2447 struct option *poption;
2448
2449#define option_var_set_callback(var, callback) \
2450 if ((poption = optset_option_by_name(client_optset, GUI_GTK_OPTION_STR(var)))) { \
2451 option_set_changed_callback(poption, callback); \
2452 } else { \
2453 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2454 }
2455
2456 option_var_set_callback(allied_chat_only,
2457 allied_chat_only_callback);
2458 option_var_set_callback(fullscreen,
2459 fullscreen_opt_refresh);
2460
2461 option_var_set_callback(font_city_names,
2462 apply_city_names_font);
2463 option_var_set_callback(font_city_productions,
2464 apply_city_productions_font);
2465 option_var_set_callback(font_reqtree_text,
2466 apply_reqtree_text_font);
2467#undef option_var_set_callback
2468}
2469
2470/**********************************************************************/
2474 void refresh_chat_buttons(void)
2475{
2476 GtkWidget *button;
2477
2478 button = allied_chat_toggle_button;
2479 fc_assert_ret(button != NULL);
2480 fc_assert_ret(GTK_IS_CHECK_BUTTON(button));
2481
2482 /* Hide the "Allies Only" button for local games. */
2483 if (is_server_running()) {
2484 gtk_widget_hide(button);
2485 } else {
2486 gtk_widget_show(button);
2487 gtk_check_button_set_active(GTK_CHECK_BUTTON(button),
2488 GUI_GTK_OPTION(allied_chat_only));
2489 }
2490}
2491
2492/**********************************************************************/
2495 static void allied_chat_button_toggled(GtkToggleButton *button,
2496 gpointer user_data)
2497{
2498 GUI_GTK_OPTION(allied_chat_only) = gtk_toggle_button_get_active(button);
2499}
2500
2501/**********************************************************************/
2504 void insert_client_build_info(char *outbuf, size_t outlen)
2505{
2506 cat_snprintf(outbuf, outlen, _("\nBuilt against gtk %d.%d.%d, using %d.%d.%d"
2507 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2508 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
2509 gtk_get_major_version(), gtk_get_minor_version(), gtk_get_micro_version(),
2510 GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
2511 glib_major_version, glib_minor_version, glib_micro_version);
2512}
2513
2514/**********************************************************************/
2518 static bool monitor_size(GdkRectangle *rect_p)
2519{
2520 GdkDisplay *display;
2521 GdkMonitor *monitor;
2522
2523 display = gdk_display_get_default();
2524 if (!display) {
2525 return FALSE;
2526 }
2527
2528 monitor = g_list_model_get_item(gdk_display_get_monitors(display), 0);
2529
2530 if (!monitor) {
2531 return FALSE;
2532 }
2533
2534 gdk_monitor_get_geometry(monitor, rect_p);
2535
2536 return TRUE;
2537}
2538
2539/**********************************************************************/
2542 int screen_width(void)
2543{
2544 GdkRectangle rect;
2545
2546 if (vmode.width > 0) {
2547 return vmode.width;
2548 }
2549
2550 if (monitor_size(&rect)) {
2551 return rect.width;
2552 } else {
2553 return 0;
2554 }
2555}
2556
2557/**********************************************************************/
2560 int screen_height(void)
2561{
2562 GdkRectangle rect;
2563
2564 if (vmode.height > 0) {
2565 return vmode.height;
2566 }
2567
2568 if (monitor_size(&rect)) {
2569 return rect.height;
2570 } else {
2571 return 0;
2572 }
2573}
2574
2575/**********************************************************************/
2578 struct video_mode *resolution_request_get(void)
2579{
2580 if (vmode.width > 0 && vmode.height > 0) {
2581 return &vmode;
2582 }
2583
2584 return NULL;
2585}
2586
2587/**********************************************************************/
2590 static void adjust_default_options(void)
2591{
2592 int scr_height = screen_height();
2593
2594 if (scr_height > 0) {
2595 /* Adjust these options only if we do know the screen height. */
2596
2597 if (scr_height <= 480) {
2598 /* Freeciv is practically unusable outside fullscreen mode in so
2599 * small display */
2600 log_verbose("Changing default to fullscreen due to very small screen");
2601 GUI_GTK_OPTION(fullscreen) = TRUE;
2602 }
2603 if (scr_height < 1024) {
2604 /* This is a small display */
2605 log_verbose("Defaulting to small widget layout due to small screen");
2606 GUI_GTK_OPTION(small_display_layout) = TRUE;
2607 log_verbose("Defaulting to merged messages/chat due to small screen");
2608 GUI_GTK_OPTION(message_chat_location) = GUI_GTK_MSGCHAT_MERGED;
2609 }
2610 }
2611}
2612
2613/**********************************************************************/
2616GtkApplication *gui_app(void)
2617{
2618 return fc_app;
2619}
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
chat_welcome_message
void chat_welcome_message(bool gui_has_copying_mitem)
Definition chatline_common.c:177
self
static struct ai_type * self
Definition classicai.c:46
client_is_observer
bool client_is_observer(void)
Definition client_main.c:1086
real_timer_callback
double real_timer_callback(void)
Definition client_main.c:1183
client_main
int client_main(int argc, char *argv[], bool postpone_tileset)
Definition client_main.c:344
user_ended_turn
void user_ended_turn(void)
Definition client_main.c:801
client
struct civclient client
Definition client_main.c:149
start_quitting
void start_quitting(void)
Definition client_main.c:1645
set_client_state
void set_client_state(enum client_states newstate)
Definition client_main.c:847
can_client_change_view
bool can_client_change_view(void)
Definition client_main.c:1313
client_main.h
client_player
#define client_player()
Definition client_main.h:106
TIMER_INTERVAL
#define TIMER_INTERVAL
Definition client_main.h:30
C_S_DISCONNECTED
@ C_S_DISCONNECTED
Definition client_main.h:45
buy_production_in_selected_cities
void buy_production_in_selected_cities(void)
Definition climisc.c:1299
client_warming_sprite
struct sprite * client_warming_sprite(void)
Definition climisc.c:371
client_cooling_sprite
struct sprite * client_cooling_sprite(void)
Definition climisc.c:388
client_research_sprite
struct sprite * client_research_sprite(void)
Definition climisc.c:348
client_government_sprite
struct sprite * client_government_sprite(void)
Definition climisc.c:406
climisc.h
input_from_server
void input_from_server(int fd)
Definition clinet.c:406
disconnect_from_server
void disconnect_from_server(void)
Definition clinet.c:305
clinet.h
get_color
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
Definition colors_common.c:100
is_server_running
bool is_server_running(void)
Definition connectdlg_common.c:124
connectdlg_common.h
key_recall_previous_focus_unit
void key_recall_previous_focus_unit(void)
Definition control.c:3132
unit_is_in_focus
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:384
key_cancel_action
void key_cancel_action(void)
Definition control.c:3071
num_units_below
int num_units_below
Definition control.c:76
unit_focus_set
void unit_focus_set(struct unit *punit)
Definition control.c:502
get_units_in_focus
struct unit_list * get_units_in_focus(void)
Definition control.c:177
key_end_turn
void key_end_turn(void)
Definition control.c:3124
update_unit_pix_label
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:966
key_unit_move
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3153
hover_state
enum cursor_hover_state hover_state
Definition control.c:89
head_of_units_in_focus
struct unit * head_of_units_in_focus(void)
Definition control.c:406
get_num_units_in_focus
int get_num_units_in_focus(void)
Definition control.c:185
control_mouse_cursor
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1188
key_center_capital
void key_center_capital(void)
Definition control.c:3107
control.h
MAX_NUM_UNITS_BELOW
#define MAX_NUM_UNITS_BELOW
Definition control.h:285
HOVER_NONE
@ HOVER_NONE
Definition control.h:26
dataio.h
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
editor_is_active
bool editor_is_active(void)
Definition editor.c:346
editor.h
is_option
bool is_option(const char *option_name, char *option)
Definition fc_cmdline.c:112
get_option_malloc
char * get_option_malloc(const char *option_name, char **argv, int *i, int argc, bool gc)
Definition fc_cmdline.c:50
fc_cmdline.h
O_SCIENCE
@ O_SCIENCE
Definition fc_types.h:91
O_GOLD
@ O_GOLD
Definition fc_types.h:91
fciconv.h
fc_fprintf
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
_
#define _(String)
Definition fcintl.h:67
featured_text.h
game_unit_by_number
struct unit * game_unit_by_number(int id)
Definition game.c:111
game.h
government.h
inputline_has_focus
bool inputline_has_focus(void)
Definition chatline.c:71
inputline_toolkit_view_append_button
void inputline_toolkit_view_append_button(GtkWidget *toolkit_view, GtkWidget *button)
Definition chatline.c:1288
inputline_toolkit_view_new
GtkWidget * inputline_toolkit_view_new(void)
Definition chatline.c:1266
set_message_buffer_view_link_handlers
void set_message_buffer_view_link_handlers(GtkWidget *view)
Definition chatline.c:744
inputline_is_visible
bool inputline_is_visible(void)
Definition chatline.c:87
chatline_init
void chatline_init(void)
Definition chatline.c:1298
inputline_grab_focus
void inputline_grab_focus(void)
Definition chatline.c:79
chatline_scroll_to_bottom
void chatline_scroll_to_bottom(bool delayed)
Definition chatline.c:1006
citizens_dialog_init
void citizens_dialog_init(void)
Definition citizensinfo.c:267
citizens_dialog_done
void citizens_dialog_done(void)
Definition citizensinfo.c:275
cma_fe_init
void cma_fe_init(void)
Definition cma_fe.c:88
cma_fe_done
void cma_fe_done(void)
Definition cma_fe.c:96
unit_select_dialog_popup
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:382
taxrates_callback
gboolean taxrates_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition dialogs.c:1434
diplomacy_dialog_init
void diplomacy_dialog_init(void)
Definition diplodlg.c:1173
diplomacy_dialog_done
void diplomacy_dialog_done(void)
Definition diplodlg.c:1182
handle_edit_key_press
gboolean handle_edit_key_press(GdkEventKey *ev)
Definition editgui.c:1661
editgui_create_widgets
void editgui_create_widgets(void)
Definition editgui.c:1821
editgui_get_editbar
struct editbar * editgui_get_editbar(void)
Definition editgui.c:1787
editgui_free
void editgui_free(void)
Definition editgui.c:1834
goto_dialog_focus_units_changed
void goto_dialog_focus_units_changed(void)
Definition gotodlg.c:540
source
static GtkWidget * source
Definition gotodlg.c:58
load_cursors
void load_cursors(void)
Definition graphics.c:78
map_vertical_scrollbar
GtkWidget * map_vertical_scrollbar
Definition gui_main.c:108
ui_main
int ui_main(int argc, char **argv)
Definition gui_main.c:1701
client_string
const char * client_string
Definition gui_main.c:104
message_buffer
GtkTextBuffer * message_buffer
Definition gui_main.c:177
quit_dialog_response
static void quit_dialog_response(GtkWidget *dialog, gint response)
Definition gui_main.c:2126
real_focus_units_changed
void real_focus_units_changed(void)
Definition gui_main.c:1954
set_unit_icons_more_arrow
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:1931
print_usage
static void print_usage(void)
Definition gui_main.c:249
OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK
#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK
Definition gui_main.c:115
option_var_set_callback
#define option_var_set_callback(var, callback)
quit_dialog_callback
static gboolean quit_dialog_callback(void)
Definition gui_main.c:2179
srv_channel
static GIOChannel * srv_channel
Definition gui_main.c:181
main_label_info
GtkWidget * main_label_info
Definition gui_main.c:137
bottom_notebook
GtkWidget * bottom_notebook
Definition gui_main.c:128
unit_info_label
GtkWidget * unit_info_label
Definition gui_main.c:150
timer_callback
static gboolean timer_callback(gpointer data)
Definition gui_main.c:236
resolution_request_get
struct video_mode * resolution_request_get(void)
Definition gui_main.c:2395
set_unit_icon
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:1901
unit_ids
static int unit_ids[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:174
timeout_label
GtkWidget * timeout_label
Definition gui_main.c:147
gui_up
static bool gui_up
Definition gui_main.c:185
srv_id
static guint srv_id
Definition gui_main.c:182
mouse_scroll_mapcanvas
static gboolean mouse_scroll_mapcanvas(GtkWidget *w, GdkEventScroll *ev)
Definition gui_main.c:690
city_productions_style
PangoFontDescription * city_productions_style
Definition gui_main.c:133
overview_scrolled_window
GtkWidget * overview_scrolled_window
Definition gui_main.c:111
detached_widget_fill
static GtkWidget * detached_widget_fill(GtkWidget *tearbox)
Definition gui_main.c:817
top_notebook
GtkWidget * top_notebook
Definition gui_main.c:128
MIGRATE_STR_OPTION
#define MIGRATE_STR_OPTION(opt)
unit_info_box
GtkWidget * unit_info_box
Definition gui_main.c:151
ui_exit
void ui_exit(void)
Definition gui_main.c:1871
get_gui_type
enum gui_type get_gui_type(void)
Definition gui_main.c:1882
detached_widget_new
static GtkWidget * detached_widget_new(void)
Definition gui_main.c:805
cur_y
gint cur_y
Definition gui_main.c:183
main
int main(int argc, char **argv)
Definition gui_main.c:1626
fullscreen_opt_refresh
void fullscreen_opt_refresh(struct option *poption)
Definition gui_main.c:2237
ui_init
void ui_init(void)
Definition gui_main.c:1617
free_unit_table
static void free_unit_table(void)
Definition gui_main.c:943
idle_callback_wrapper
static gboolean idle_callback_wrapper(gpointer data)
Definition gui_main.c:2194
apply_city_names_font
static void apply_city_names_font(struct option *poption)
Definition gui_main.c:2249
apply_city_productions_font
static void apply_city_productions_font(struct option *poption)
Definition gui_main.c:2260
government_label
GtkWidget * government_label
Definition gui_main.c:146
sun_label
GtkWidget * sun_label
Definition gui_main.c:144
city_names_style
PangoFontDescription * city_names_style
Definition gui_main.c:132
refresh_chat_buttons
void refresh_chat_buttons(void)
Definition gui_main.c:2312
map_canvas_focus
gboolean map_canvas_focus(void)
Definition gui_main.c:366
turn_done_button
GtkWidget * turn_done_button
Definition gui_main.c:148
bottom_hpaned
static GtkWidget * bottom_hpaned
Definition gui_main.c:130
timer_id
static gint timer_id
Definition gui_main.c:180
screen_width
int screen_width(void)
Definition gui_main.c:2355
scroll_panel
GtkWidget * scroll_panel
Definition gui_main.c:140
end_turn_callback
static void end_turn_callback(GtkWidget *w, gpointer data)
Definition gui_main.c:2051
OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK
#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK
Definition gui_main.c:116
log_callback_utf8
static void log_callback_utf8(enum log_level level, const char *message, bool file_too)
Definition gui_main.c:224
add_idle_callback
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2209
show_info_popup
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2020
reset_unit_table
void reset_unit_table(void)
Definition gui_main.c:971
key_press_map_canvas
static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:407
unit_info_frame
GtkWidget * unit_info_frame
Definition gui_main.c:152
options_extra_init
void options_extra_init(void)
Definition gui_main.c:2283
top_vbox
GtkWidget * top_vbox
Definition gui_main.c:127
allied_chat_only_callback
static void allied_chat_only_callback(struct option *poption)
Definition gui_main.c:2222
adjust_default_options
static void adjust_default_options(void)
Definition gui_main.c:2407
set_wait_for_writable_socket
static void set_wait_for_writable_socket(struct connection *pc, bool socket_writable)
Definition gui_main.c:2071
ahbox
GtkWidget * ahbox
Definition gui_main.c:139
apply_reqtree_text_font
static void apply_reqtree_text_font(struct option *poption)
Definition gui_main.c:2271
is_gui_up
bool is_gui_up(void)
Definition gui_main.c:1863
toplevel_focus
static gboolean toplevel_focus(GtkWidget *w, GtkDirectionType arg)
Definition gui_main.c:322
reqtree_text_style
PangoFontDescription * reqtree_text_style
Definition gui_main.c:134
flake_label
GtkWidget * flake_label
Definition gui_main.c:145
avbox
GtkWidget * avbox
Definition gui_main.c:139
cur_x
gint cur_x
Definition gui_main.c:183
insert_client_build_info
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2342
bulb_label
GtkWidget * bulb_label
Definition gui_main.c:143
overview_canvas
GtkWidget * overview_canvas
Definition gui_main.c:110
toplevel
GtkWidget * toplevel
Definition gui_main.c:124
setup_widgets
static void setup_widgets(void)
Definition gui_main.c:1073
OVERVIEW_CANVAS_STORE_WIDTH
#define OVERVIEW_CANVAS_STORE_WIDTH
Definition gui_main.c:117
remove_net_input
void remove_net_input(void)
Definition gui_main.c:2115
map_horizontal_scrollbar
GtkWidget * map_horizontal_scrollbar
Definition gui_main.c:107
setup_canvas_color_for_state
static void setup_canvas_color_for_state(GtkStateFlags state)
Definition gui_main.c:1043
map_canvas
GtkWidget * map_canvas
Definition gui_main.c:106
toplevel_key_press_handler
static gboolean toplevel_key_press_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:606
sound_bell
void sound_bell(void)
Definition gui_main.c:1890
migrate_options_from_gtk2
static void migrate_options_from_gtk2(void)
Definition gui_main.c:1634
econ_label
GtkWidget * econ_label[10]
Definition gui_main.c:142
popup_quit_dialog
void popup_quit_dialog(void)
Definition gui_main.c:2153
gui_character_encoding
const char *const gui_character_encoding
Definition gui_main.c:160
unit_id_top
static int unit_id_top
Definition gui_main.c:173
get_net_input
static gboolean get_net_input(GIOChannel *source, GIOCondition condition, gpointer data)
Definition gui_main.c:2060
map_widget
GtkWidget * map_widget
Definition gui_main.c:129
right_notebook
GtkWidget * right_notebook
Definition gui_main.c:128
quit_gtk_main
void quit_gtk_main(void)
Definition gui_main.c:2141
allied_chat_button_toggled
static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data)
Definition gui_main.c:2333
vmode
static struct video_mode vmode
Definition gui_main.c:187
add_net_input
void add_net_input(int sock)
Definition gui_main.c:2097
toplevel_tabs
GtkWidget * toplevel_tabs
Definition gui_main.c:126
allied_chat_toggle_button
static GtkWidget * allied_chat_toggle_button
Definition gui_main.c:178
overview_canvas_store_width
int overview_canvas_store_width
Definition gui_main.c:121
update_turn_done_tooltip
void update_turn_done_tooltip(void)
Definition gui_main.c:1054
tearoff_callback
static void tearoff_callback(GtkWidget *b, gpointer data)
Definition gui_main.c:769
main_message_area
GtkTextView * main_message_area
Definition gui_main.c:176
overview_canvas_store_height
int overview_canvas_store_height
Definition gui_main.c:122
screen_height
int screen_height(void)
Definition gui_main.c:2375
parse_options
static bool parse_options(int argc, char **argv)
Definition gui_main.c:286
conn_box
GtkWidget * conn_box
Definition gui_main.c:139
OVERVIEW_CANVAS_STORE_HEIGHT
#define OVERVIEW_CANVAS_STORE_HEIGHT
Definition gui_main.c:119
main_frame_civ_name
GtkWidget * main_frame_civ_name
Definition gui_main.c:136
MIGRATE_OPTION
#define MIGRATE_OPTION(opt)
gui_use_transliteration
const bool gui_use_transliteration
Definition gui_main.c:161
GUI_NAME_FULL
#define GUI_NAME_FULL
Definition gui_main.h:22
GUI_NAME_SHORT
#define GUI_NAME_SHORT
Definition gui_main.h:23
GUI_GTK_OPTION
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
setup_dialog
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:281
gui_update_font_full
void gui_update_font_full(const char *font_name, const char *font_value, PangoFontDescription **font_desc)
Definition gui_stuff.c:1070
happiness_dialog_init
void happiness_dialog_init(void)
Definition happiness.c:86
happiness_dialog_done
void happiness_dialog_done(void)
Definition happiness.c:94
help_system_init
void help_system_init(void)
Definition helpdlg.c:156
intel_dialog_done
void intel_dialog_done(void)
Definition inteldlg.c:127
intel_dialog_init
void intel_dialog_init(void)
Definition inteldlg.c:118
luaconsole_dialog_init
void luaconsole_dialog_init(void)
Definition luaconsole.c:83
luaconsole_dialog_done
void luaconsole_dialog_done(void)
Definition luaconsole.c:101
move_overviewcanvas
gboolean move_overviewcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
Definition mapctrl.c:458
move_mapcanvas
gboolean move_mapcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
Definition mapctrl.c:400
leave_mapcanvas
gboolean leave_mapcanvas(GtkWidget *widget, GdkEventCrossing *event)
Definition mapctrl.c:429
update_city_descriptions
void update_city_descriptions(void)
Definition mapview.c:470
map_canvas_draw
gboolean map_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data)
Definition mapview.c:407
overview_canvas_draw
gboolean overview_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data)
Definition mapview.c:339
meswin_dialog_popup
void meswin_dialog_popup(bool raise)
Definition messagewin.c:416
create_start_page
GtkWidget * create_start_page(void)
Definition pages.c:2605
create_network_page
GtkWidget * create_network_page(void)
Definition pages.c:1183
create_scenario_page
GtkWidget * create_scenario_page(void)
Definition pages.c:3168
statusbar
static GtkWidget * statusbar
Definition pages.c:89
get_current_client_page
enum client_pages get_current_client_page(void)
Definition pages.c:3329
destroy_server_scans
void destroy_server_scans(void)
Definition pages.c:751
create_load_page
GtkWidget * create_load_page(void)
Definition pages.c:2886
create_statusbar
GtkWidget * create_statusbar(void)
Definition pages.c:892
create_main_page
GtkWidget * create_main_page(void)
Definition pages.c:229
science_report_dialog_redraw
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
spaceship_dialog_init
void spaceship_dialog_init(void)
Definition spaceshipdlg.c:87
spaceship_dialog_done
void spaceship_dialog_done(void)
Definition spaceshipdlg.c:95
sprite_get_pixbuf
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
ingame_votebar
GtkWidget * ingame_votebar
Definition voteinfo_bar.c:50
voteinfo_bar_new
GtkWidget * voteinfo_bar_new(bool split_bar)
Definition voteinfo_bar.c:92
monitor_size
static bool monitor_size(GdkRectangle *rect_p)
Definition gui_main.c:2515
set_g_log_callbacks
static void set_g_log_callbacks(void)
Definition gui_main.c:1706
g_log_to_freelog_cb
static void g_log_to_freelog_cb(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
Definition gui_main.c:1650
set_g_log_callback_domain
static void set_g_log_callback_domain(const char *domain)
Definition gui_main.c:1694
migrate_options_from_gtk3
static void migrate_options_from_gtk3(void)
Definition gui_main.c:1795
g_log_writer_to_freelog_cb
static GLogWriterOutput g_log_writer_to_freelog_cb(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data)
Definition gui_main.c:1678
dlg_tab_provider_prepare
void dlg_tab_provider_prepare(void)
Definition gui_stuff.c:1151
citizensinfo.h
reverse_taxrates_callback
gboolean reverse_taxrates_callback(GtkGestureClick *gesture, int n_press, double x, double y)
Definition dialogs.c:1454
editgui.h
empty_unit_paintable
static GdkPaintable * empty_unit_paintable
Definition gui_main.c:158
tearoff_close
static void tearoff_close(GtkWidget *w, gpointer data)
Definition gui_main.c:734
tearoff_reattach
static void tearoff_reattach(GtkWidget *box)
Definition gui_main.c:717
terminate_signal_processing
gboolean terminate_signal_processing(GtkEventControllerFocus *controller, gpointer data)
Definition gui_main.c:994
more_arrow_container
static GtkWidget * more_arrow_container
Definition gui_main.c:163
unit_pic
static GtkWidget * unit_pic
Definition gui_main.c:160
select_more_arrow_callback
static gboolean select_more_arrow_callback(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition gui_main.c:2159
econ_widget
GtkWidget * econ_widget
Definition gui_main.c:153
fc_app
static GtkApplication * fc_app
Definition gui_main.c:179
gui_app
GtkApplication * gui_app(void)
Definition gui_main.c:2616
more_arrow
static GtkWidget * more_arrow
Definition gui_main.c:162
zoom_steps_custom
static float zoom_steps_custom[]
Definition gui_main.c:223
migrate_options_from_gtk3_22
static void migrate_options_from_gtk3_22(void)
Definition gui_main.c:1798
animation_idle_cb
void animation_idle_cb(void *data)
Definition gui_main.c:2371
activate_gui
static void activate_gui(GtkApplication *app, gpointer data)
Definition gui_main.c:1900
populate_unit_pic_table
static void populate_unit_pic_table(void)
Definition gui_main.c:833
info_popup_closed
static void info_popup_closed(GtkWidget *self, gpointer data)
Definition gui_main.c:2174
move_from_container_to_container
static void move_from_container_to_container(GtkWidget *wdg, GtkWidget *old_wdg, GtkWidget *new_wdg)
Definition gui_main.c:684
select_unit_pic_callback
static gboolean select_unit_pic_callback(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition gui_main.c:2127
unit_pic_table
static GtkWidget * unit_pic_table
Definition gui_main.c:159
unit_below_pic
static GtkWidget * unit_below_pic[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:161
main_message_area_resize
void main_message_area_resize(void *data)
Definition gui_main.c:334
widget_destroyed
void widget_destroyed(GtkWidget *wdg, void *data)
Definition gui_stuff.c:1145
gui_stuff.h
happiness.h
right_butt_down_overviewcanvas
gboolean right_butt_down_overviewcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:499
left_butt_up_mapcanvas
gboolean left_butt_up_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:164
right_butt_up_mapcanvas
gboolean right_butt_up_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:181
left_butt_down_overviewcanvas
gboolean left_butt_down_overviewcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:474
left_butt_down_mapcanvas
gboolean left_butt_down_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:206
right_butt_down_mapcanvas
gboolean right_butt_down_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:261
middle_butt_down_mapcanvas
gboolean middle_butt_down_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:330
map_canvas_resize
void map_canvas_resize(GtkWidget *w, int width, int height, gpointer data)
Definition mapview.c:406
put_unit_picture
void put_unit_picture(struct unit *punit, GtkPicture *p, int height)
Definition mapview.c:492
menus_set_initial_toggle_values
void menus_set_initial_toggle_values(void)
Definition menu.c:2907
picture_new_from_surface
GtkWidget * picture_new_from_surface(cairo_surface_t *surf)
Definition sprite.c:526
cma_fe.h
chatline.h
colors.h
connectdlg.h
dialogs.h
diplodlg.h
gotodlg.h
graphics.h
gui_main.h
helpdlg.h
inteldlg.h
luaconsole.h
mapctrl.h
mapview.h
menu.h
messagewin.h
optiondlg.h
pages.h
plrdlg.h
repodlgs.h
spaceshipdlg.h
voteinfo_bar.h
log_set_callback
log_callback_fn log_set_callback(log_callback_fn callback)
Definition log.c:290
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
log_verbose
#define log_verbose(message,...)
Definition log.h:109
fc_assert
#define fc_assert(condition)
Definition log.h:176
log_fatal
#define log_fatal(message,...)
Definition log.h:100
log_debug
#define log_debug(message,...)
Definition log.h:115
log_normal
#define log_normal(message,...)
Definition log.h:107
log_base
#define log_base(level, message,...)
Definition log.h:94
log_level
log_level
Definition log.h:28
LOG_ERROR
@ LOG_ERROR
Definition log.h:30
LOG_DEBUG
@ LOG_DEBUG
Definition log.h:34
LOG_FATAL
@ LOG_FATAL
Definition log.h:29
LOG_WARN
@ LOG_WARN
Definition log.h:31
log_error
#define log_error(message,...)
Definition log.h:103
map.h
update_line
void update_line(int canvas_x, int canvas_y)
Definition mapctrl_common.c:662
maybe_activate_keyboardless_goto
void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
Definition mapctrl_common.c:504
rbutton_down
bool rbutton_down
Definition mapctrl_common.c:55
tiles_hilited_cities
bool tiles_hilited_cities
Definition mapctrl_common.c:60
scroll_mapview
void scroll_mapview(enum direction8 gui_dir)
Definition mapctrl_common.c:549
keyboardless_goto_button_down
bool keyboardless_goto_button_down
Definition mapctrl_common.c:69
update_selection_rectangle
void update_selection_rectangle(float canvas_x, float canvas_y)
Definition mapctrl_common.c:201
init_mapcanvas_and_overview
void init_mapcanvas_and_overview(void)
Definition mapview_common.c:3683
canvas_pos_to_tile
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
Definition mapview_common.c:751
free_mapcanvas_and_overview
void free_mapcanvas_and_overview(void)
Definition mapview_common.c:3692
get_mapview_scroll_pos
void get_mapview_scroll_pos(int *scroll_x, int *scroll_y)
Definition mapview_common.c:1191
get_mapview_scroll_step
void get_mapview_scroll_step(int *xstep, int *ystep)
Definition mapview_common.c:1177
set_mapview_scroll_pos
void set_mapview_scroll_pos(int scroll_x, int scroll_y, float zoom)
Definition mapview_common.c:1200
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1222
update_animation
void update_animation(void)
Definition mapview_common.c:428
set_frame_by_frame_animation
void set_frame_by_frame_animation(void)
Definition mapview_common.c:4081
link_marks_clear_all
void link_marks_clear_all(void)
Definition mapview_common.c:3952
mem.h
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
option_changed
void option_changed(struct option *poption)
Definition options.c:723
server_optset
const struct option_set * server_optset
Definition options.c:4009
client_optset
const struct option_set * client_optset
Definition options.c:1255
option_bool_get
bool option_bool_get(const struct option *poption)
Definition options.c:772
option_type
enum option_type option_type(const struct option *poption)
Definition options.c:633
option_font_target
const char * option_font_target(const struct option *poption)
Definition options.c:1138
string_to_video_mode
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6453
gui_options
struct client_options gui_options
Definition options.c:71
option_font_get
const char * option_font_get(const struct option *poption)
Definition options.c:1116
optset_option_by_name
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:406
options.h
GUI_GTK_OVERVIEW_MIN_XSIZE
#define GUI_GTK_OVERVIEW_MIN_XSIZE
Definition options.h:574
options_iterate
#define options_iterate(poptset, poption)
Definition options.h:527
GUI_GTK_MSGCHAT_MERGED
@ GUI_GTK_MSGCHAT_MERGED
Definition options.h:68
GUI_GTK_MSGCHAT_SPLIT
@ GUI_GTK_MSGCHAT_SPLIT
Definition options.h:66
options_iterate_end
#define options_iterate_end
Definition options.h:532
get_info_label_text_popup
const char * get_info_label_text_popup(void)
Definition text.c:1002
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:183
CLIP
#define CLIP(lower, current, upper)
Definition shared.h:57
callback
Definition gui_main.c:2186
callback::data
void * data
Definition gui_main.c:2188
callback::callback
void(* callback)(void *data)
Definition gui_main.c:2187
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::gui_gtk3_22_migrated_from_gtk3
bool gui_gtk3_22_migrated_from_gtk3
Definition options.h:130
client_options::gui_gtk3_migrated_from_2_5
bool gui_gtk3_migrated_from_2_5
Definition options.h:134
client_options::sound_effects_volume
int sound_effects_volume
Definition options.h:183
client_options::first_boot
bool first_boot
Definition options.h:124
client_options::gui_gtk3_fullscreen
bool gui_gtk3_fullscreen
Definition options.h:261
client_options::migrate_fullscreen
bool migrate_fullscreen
Definition options.h:138
client_options::gui_gtk3_migrated_from_gtk2
bool gui_gtk3_migrated_from_gtk2
Definition options.h:129
color
Definition colors.h:20
connection
Definition connection.h:141
connection::notify_of_writable_data
void(* notify_of_writable_data)(struct connection *pc, bool data_available_and_socket_full)
Definition connection.h:186
connection::used
bool used
Definition connection.h:144
editbar::widget
GtkWidget * widget
Definition editgui.h:26
message
Definition messagewin_common.h:29
option
Definition options.c:454
sprite
Definition sprite.h:22
sprite::surface
cairo_surface_t * surface
Definition sprite.h:23
tileset
Definition tilespec.c:459
unit
Definition unit.h:138
unit::id
int id
Definition unit.h:145
video_mode
Definition options.h:45
video_mode::height
int height
Definition options.h:47
video_mode::width
int width
Definition options.h:46
view
Definition mapview_common.h:36
widget
Definition widget.h:112
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
cat_snprintf
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:995
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
text.h
tileset_load_tiles
void tileset_load_tiles(struct tileset *t)
Definition tilespec.c:3452
tileset_free_tiles
void tileset_free_tiles(struct tileset *t)
Definition tilespec.c:6346
tileset_use_preferred_theme
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:6768
tileset_init
void tileset_init(struct tileset *t)
Definition tilespec.c:6827
get_arrow_sprite
struct sprite * get_arrow_sprite(const struct tileset *t, enum arrow_type arrow)
Definition tilespec.c:6568
get_tax_sprite
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:6579
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
tilespec.h
ARROW_RIGHT
@ ARROW_RIGHT
Definition tilespec.h:199
unit_tile
#define unit_tile(_pu)
Definition unit.h:388
unit_owner
#define unit_owner(_pu)
Definition unit.h:387
unitlist.h
version.h
mouse_zoom
float mouse_zoom
Definition zoom.c:28
zoom_phase_set
void zoom_phase_set(bool individual_tiles)
Definition zoom.c:93
zoom_set_steps
void zoom_set_steps(float *steps)
Definition zoom.c:80
zoom_step_down
void zoom_step_down(void)
Definition zoom.c:130
zoom_step_up
void zoom_step_up(void)
Definition zoom.c:106
zoom.h