Freeciv-3.3
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 "audio.h"
65#include "client_main.h"
66#include "climisc.h"
67#include "clinet.h"
68#include "colors.h"
69#include "connectdlg_common.h"
70#include "control.h"
71#include "editor.h"
72#include "gui_properties.h"
73#include "options.h"
74#include "text.h"
75#include "tilespec.h"
76#include "zoom.h"
77
78/* client/gui-gtk-5.0 */
79#include "chatline.h"
80#include "citizensinfo.h"
81#include "connectdlg.h"
82#include "cma_fe.h"
83#include "dialogs.h"
84#include "diplodlg.h"
85#include "editgui.h"
86#include "gotodlg.h"
87#include "graphics.h"
88#include "gui_stuff.h"
89#include "happiness.h"
90#include "helpdlg.h"
91#include "inteldlg.h"
92#include "mapctrl.h"
93#include "mapview.h"
94#include "menu.h"
95#include "messagewin.h"
96#include "optiondlg.h"
97#include "pages.h"
98#include "plrdlg.h"
99#include "luaconsole.h"
100#include "spaceshipdlg.h"
101#include "repodlgs.h"
102#include "voteinfo_bar.h"
103
104#include "gui_main.h"
105
107
108GtkWidget *map_canvas; /* GtkDrawingArea */
111
112GtkWidget *overview_canvas; /* GtkDrawingArea */
113GtkWidget *overview_scrolled_window; /* GtkScrolledWindow */
114/* The two values below define the width and height of the map overview. The
115 * first set of values (2*62, 2*46) define the size for a netbook display. For
116 * bigger displays the values are doubled (default). */
117#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK (2 * 64)
118#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK (2 * 46)
119#define OVERVIEW_CANVAS_STORE_WIDTH \
120 (2 * OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK)
121#define OVERVIEW_CANVAS_STORE_HEIGHT \
122 (2 * OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK)
125
132
136
139
142
150
154
156
157const char *const gui_character_encoding = "UTF-8";
159
166
167static int unit_id_top;
168static int unit_ids[MAX_NUM_UNITS_BELOW]; /* ids of the units icons in
169 * information display: (or 0) */
173
174static gint timer_id; /* Ditto */
178
179static bool gui_up = FALSE;
180
181static bool audio_paused = FALSE;
182static bool client_focus = TRUE;
183
186
187static struct video_mode vmode = { -1, -1 };
188
189static void set_g_log_callbacks(void);
190
192 double x, double y, gpointer data);
193
194static void end_turn_callback(GtkWidget *w, gpointer data);
196 gpointer data);
197static void set_wait_for_writable_socket(struct connection *pc,
198 bool socket_writable);
199
200static void print_usage(void);
201static void activate_gui(GtkApplication *app, gpointer data);
202static bool parse_options(int argc, char **argv);
206 GdkModifierType state,
207 gpointer data);
209 gdouble dx, gdouble dy,
210 gpointer data);
211
212static void tearoff_callback(GtkWidget *b, gpointer data);
213static GtkWidget *detached_widget_new(void);
215
217 double x, double y, gpointer data);
219 double x, double y, gpointer data);
220static gboolean quit_dialog_callback(void);
221
223 gpointer user_data);
224
225static void free_unit_table(void);
226
227static void adjust_default_options(void);
228
229static float zoom_steps_custom[] = {
230 -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
231};
232
233/**********************************************************************/
236static void log_callback_utf8(enum log_level level, const char *message,
237 bool file_too)
238{
239 if (!file_too || level <= LOG_FATAL) {
240 fc_fprintf(stderr, "%d: %s\n", level, message);
241 }
242}
243
244/**********************************************************************/
249{
250 double seconds = real_timer_callback();
251
253 if (!audio_paused && !client_focus) {
254 audio_pause();
256 } else if (audio_paused && client_focus) {
257 audio_resume();
259 }
260 }
261
263
264 return FALSE;
265}
266
267/**********************************************************************/
271static void print_usage(void)
272{
273 /* Add client-specific usage information here */
275 _("gtk4x-client gui-specific options are:\n"));
276
278 _("-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
279 "screen\n"));
281 /* TRANS: Keep word 'default' untranslated */
282 _("-z, --zoom LEVEL\tSet zoom level; use value 'default' "
283 "to reset\n\n"));
284
285 /* TRANS: No full stop after the URL, could cause confusion. */
286 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
287}
288
289/**********************************************************************/
292static bool parse_options(int argc, char **argv)
293{
294 int i = 1;
295
296 while (i < argc) {
297 char *option = NULL;
298
299 if (is_option("--help", argv[i])) {
300 print_usage();
301
302 return FALSE;
303 } else if ((option = get_option_malloc("--zoom", argv, &i, argc, FALSE))) {
304 char *endptr;
305
306 if (strcmp("default", option)) {
309 } else {
311 }
312 free(option);
313 } else if ((option = get_option_malloc("--resolution", argv, &i, argc, FALSE))) {
315 fc_fprintf(stderr, _("Illegal video mode '%s'\n"), option);
317 }
318 free(option);
319 } else {
320 fc_fprintf(stderr, _("Unknown command-line option \"%s\".\n"),
321 argv[i]);
323 }
324
325 i++;
326 }
327
328 return TRUE;
329}
330
331/**********************************************************************/
335 gpointer data)
336{
337 switch (arg) {
340
341 if (!gtk_widget_get_can_focus(w)) {
342 return;
343 }
344
345 if (!gtk_widget_is_focus(w)) {
347 return;
348 }
349 break;
350
351 default:
352 break;
353 }
354}
355
356/**********************************************************************/
378
379/**********************************************************************/
390
391/**********************************************************************/
395{
396 if ((state & GDK_SHIFT_MASK)) {
397 switch (keyval) {
398
399 case GDK_KEY_Left:
401 return TRUE;
402
403 case GDK_KEY_Right:
405 return TRUE;
406
407 case GDK_KEY_Up:
409 return TRUE;
410
411 case GDK_KEY_Down:
413 return TRUE;
414
415 case GDK_KEY_Home:
417 return TRUE;
418
419 case GDK_KEY_Page_Up:
422 return TRUE;
423
427 return TRUE;
428
429 default:
430 break;
431 }
432 } else if (!(state & GDK_CONTROL_MASK)) {
433 switch (keyval) {
434 default:
435 break;
436 }
437 }
438
439 if (state & GDK_SHIFT_MASK) {
440 bool volchange = FALSE;
441
442 switch (keyval) {
443 case GDK_KEY_plus:
444 case GDK_KEY_KP_Add:
446 volchange = TRUE;
447 break;
448
449 case GDK_KEY_minus:
452 volchange = TRUE;
453 break;
454
455 default:
456 break;
457 }
458
459 if (volchange) {
461 "sound_effects_volume");
462
465 100);
467
468 return TRUE;
469 }
470 } else if (!(state & GDK_CONTROL_MASK)) {
471 switch (keyval) {
472 case GDK_KEY_plus:
473 case GDK_KEY_KP_Add:
474 zoom_step_up();
475 return TRUE;
476
477 case GDK_KEY_minus:
480 return TRUE;
481
482 default:
483 break;
484 }
485 }
486
487 /* Return here if observer */
488 if (client_is_observer()) {
489 return FALSE;
490 }
491
492 switch (keyval) {
493
494 case GDK_KEY_KP_Up:
495 case GDK_KEY_KP_8:
496 case GDK_KEY_Up:
497 case GDK_KEY_8:
499 return TRUE;
500
502 case GDK_KEY_KP_9:
503 case GDK_KEY_Page_Up:
504 case GDK_KEY_9:
506 return TRUE;
507
508 case GDK_KEY_KP_Right:
509 case GDK_KEY_KP_6:
510 case GDK_KEY_Right:
511 case GDK_KEY_6:
513 return TRUE;
514
516 case GDK_KEY_KP_3:
518 case GDK_KEY_3:
520 return TRUE;
521
522 case GDK_KEY_KP_Down:
523 case GDK_KEY_KP_2:
524 case GDK_KEY_Down:
525 case GDK_KEY_2:
527 return TRUE;
528
529 case GDK_KEY_KP_End:
530 case GDK_KEY_KP_1:
531 case GDK_KEY_End:
532 case GDK_KEY_1:
534 return TRUE;
535
536 case GDK_KEY_KP_Left:
537 case GDK_KEY_KP_4:
538 case GDK_KEY_Left:
539 case GDK_KEY_4:
541 return TRUE;
542
543 case GDK_KEY_KP_Home:
544 case GDK_KEY_KP_7:
545 case GDK_KEY_Home:
546 case GDK_KEY_7:
548 return TRUE;
549
550 case GDK_KEY_KP_Begin:
551 case GDK_KEY_KP_5:
552 case GDK_KEY_5:
554 return TRUE;
555
556 case GDK_KEY_Escape:
558 return TRUE;
559
560 case GDK_KEY_b:
563 return TRUE;
564 }
565 break;
566
567 default:
568 break;
569 };
570
571 return FALSE;
572}
573
574/**********************************************************************/
580 GdkModifierType state,
581 gpointer data)
582{
583 if (inputline_has_focus()) {
584 return FALSE;
585 }
586
587 if (keyval == GDK_KEY_apostrophe) {
588 /* Allow this even if not in main map view; chatline is present on
589 * some other pages too */
590
591 /* Make the chatline visible if it's not currently.
592 * FIXME: should find the correct window, even when detached, from any
593 * other window; should scroll to the bottom automatically showing the
594 * latest text from other players; MUST NOT make spurious text windows
595 * at the bottom of other dialogs. */
597 /* The main game view is visible. May need to switch notebook. */
600 } else {
602 }
603 }
604
605 /* If the chatline is (now) visible, focus it. */
606 if (inputline_is_visible()) {
608 return TRUE;
609 }
610 }
611
614 return FALSE;
615 }
616
617 if (editor_is_active()) {
618 if (handle_edit_key_press(keyval, state)) {
619 return TRUE;
620 }
621 }
622
623 if (state & GDK_SHIFT_MASK) {
624 switch (keyval) {
625
626 case GDK_KEY_Return:
627 case GDK_KEY_KP_Enter:
628 key_end_turn();
629 return TRUE;
630
631 default:
632 break;
633 }
634 }
635
637 /* 0 means the map view is focused. */
638 return key_press_map_canvas(keyval, state);
639 }
640
641#if 0
642 /* We are focused some other dialog, tab, or widget. */
643 if ((state & GDK_CONTROL_MASK)) {
644 } else if ((state & GDK_SHIFT_MASK)) {
645 } else {
646 switch (keyval) {
647
648 case GDK_KEY_F4:
650 return TRUE;
651
652 default:
653 break;
654 };
655 }
656#endif /* 0 */
657
658 return FALSE;
659}
660
661/**********************************************************************/
707
708/**********************************************************************/
714{
715 g_object_ref(wdg); /* Make sure reference count stays above 0
716 * during the transition to new parent. */
717
718 if (GTK_IS_PANED(old_wdg)) {
720 } else if (GTK_IS_WINDOW(old_wdg)) {
722 } else {
724
726 }
727
728 if (GTK_IS_PANED(new_wdg)) {
730 } else if (GTK_IS_WINDOW(new_wdg)) {
732 } else {
734
736 }
737
739}
740
741/**********************************************************************/
751
752/**********************************************************************/
762
763/**********************************************************************/
767{
769
770 aparent = g_object_get_data(G_OBJECT(box), "aparent");
772
773 if (aparent != cparent) {
775
777 }
778}
779
780/**********************************************************************/
783static void tearoff_close(GtkWidget *w, gpointer data)
784{
786}
787
788/**********************************************************************/
793{
794 GtkWidget *box = GTK_WIDGET(data);
796
798 GtkWidget *w;
800
801 w = gtk_window_new();
803 gtk_widget_set_name(w, "Freeciv");
804 gtk_window_set_title(GTK_WINDOW(w), _("Freeciv"));
805 g_signal_connect(w, "close-request", G_CALLBACK(tearoff_close), box);
806
807 g_object_set_data(G_OBJECT(box), "aparent", gtk_widget_get_parent(box));
808
809 temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent");
810 if (temp_hide != nullptr) {
812 }
813
815
817
818 if (temp_hide != nullptr) {
820 }
821 } else {
822 tearoff_reattach(box);
823 }
824}
825
826/**********************************************************************/
830{
832
833 return hbox;
834}
835
836/**********************************************************************/
841{
842 GtkWidget *b, *fillbox;
844
847
848 /* These toggle buttons run vertically down the side of many UI
849 * elements, so they need to be thin horizontally. */
851 ".detach_button {\n"
852 " padding: 0px 0px 0px 0px;\n"
853 " min-width: 6px;\n"
854 "}",
855 -1);
856 }
857
863 gtk_widget_add_css_class(b, "detach_button");
864 gtk_widget_set_tooltip_text(b, _("Detach/Attach the pane."));
865
868
870
872
873 return fillbox;
874}
875
876/**********************************************************************/
883static void populate_unit_pic_table(void)
884{
885 int i, width;
887 GdkPixbuf *pix;
888 int ttw;
890
891 /* Get width of the overview window */
895
897
899 /* We want arrow to appear if there is other units in addition
900 to active one in tile. Active unit is not counted, so there
901 can be 0 other units to not to display arrow. */
902 num_units_below = 1 - 1;
903 } else {
906 }
907
908 /* Top row: the active unit. */
909 /* Note, we ref this and other widgets here so that we can unref them
910 * in reset_unit_table. */
914 gtk_grid_attach(GTK_GRID(table), unit_pic, 0, 0, 1, 1);
915
917 g_signal_connect(controller, "pressed",
919 GINT_TO_POINTER(-1));
921
923 /* Bottom row: other units in the same tile. */
924 for (i = 0; i < num_units_below; i++) {
928
930 g_signal_connect(controller, "pressed",
934
936 i, 1, 1, 1);
937 }
938 }
939
940 /* Create arrow (popup for all units on the selected tile) */
944
946 g_signal_connect(controller, "pressed",
948 NULL);
950
951 /* An extra layer so that we can hide the clickable button but keep
952 * an explicit size request to avoid the layout jumping around */
959 gdk_pixbuf_get_width(pix), -1);
961
963 /* Display on bottom row. */
965 num_units_below, 1, 1, 1);
966 } else {
967 /* Display on top row (there is no bottom row). */
969 1, 0, 1, 1);
970 }
971
973}
974
975/**********************************************************************/
998
999/**********************************************************************/
1003{
1004 /* Unreference all of the widgets that we're about to reallocate, thus
1005 * avoiding a memory leak. Remove them from the container first, just
1006 * to be safe. Note, the widgets are ref'd in
1007 * populate_unit_pic_table(). */
1009
1011
1012 /* We have to force a redraw of the units. And we explicitly have
1013 * to force a redraw of the focus unit, which is normally only
1014 * redrawn when the focus changes. We also have to force the 'more'
1015 * arrow to go away, both by expicitly hiding it and telling it to
1016 * do so (this will be reset immediately afterwards if necessary,
1017 * but we have to make the *internal* state consistent). */
1020 if (get_num_units_in_focus() == 1) {
1022 } else {
1023 set_unit_icon(-1, NULL);
1024 }
1026}
1027
1028/**********************************************************************/
1031#if 0
1033{
1038}
1039#endif
1040
1041/**********************************************************************/
1049
1050/**********************************************************************/
1054{
1055 struct option *opt = optset_option_by_name(server_optset, "fixedlength");
1056
1057 if (opt != NULL && option_bool_get(opt)) {
1059 _("Fixed length turns"));
1060 } else {
1061 char buf[256];
1062
1063 fc_snprintf(buf, sizeof(buf), "%s:\n%s",
1064 _("Turn Done"), _("Shift+Return"));
1066 }
1067}
1068
1069/**********************************************************************/
1072static void setup_widgets(void)
1073{
1074 GtkWidget *page, *hgrid, *hgrid2, *label;
1075 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1076 GtkWidget *button, *view, *mainbox, *vbox, *right_vbox = NULL;
1077 int i;
1078 GtkWidget *notebook, *statusbar;
1080 struct sprite *spr;
1081 int right_row = 0;
1082 int top_row = 0;
1083 int grid_col = 0;
1084 int grid2_col = 0;
1087 GtkWidget *ebar;
1088
1090
1091 notebook = gtk_notebook_new();
1092
1093 toplevel_tabs = notebook;
1098 gtk_box_append(GTK_BOX(mainbox), notebook);
1101
1112
1114
1120
1121 /* *** Everything in the top *** */
1122
1123 page = gtk_scrolled_window_new();
1128 TRUE);
1129 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1130
1135 hgrid = gtk_grid_new();
1136
1138 /* The window is divided into two horizontal panels: overview +
1139 * civinfo + unitinfo, main view + message window. */
1141 right_row = 0;
1145
1151
1152 /* Overview size designed for small displays (netbooks). */
1155 } else {
1156 /* The window is divided into two vertical panes: overview +
1157 * + civinfo + unitinfo + main view, message window. */
1162
1163 /* Overview size designed for big displays (desktops). */
1166 }
1167
1168 /* This holds the overview canvas, production info, etc. */
1170 /* Put vbox to the left of anything else in hgrid -- right_vbox is either
1171 * the chat/messages pane, or NULL which is OK */
1173 GTK_POS_LEFT, 1, 1);
1174 grid_col++;
1175
1176 /* Overview canvas */
1182
1190
1200
1202
1205
1208
1223
1224 /* The rest */
1231
1232 /* Info on player's civilization, when game is running. */
1233 frame = gtk_frame_new("");
1234 gtk_box_append(GTK_BOX(avbox), frame);
1235
1236 main_frame_civ_name = frame;
1237
1241
1242 label = gtk_label_new(NULL);
1246 gtk_widget_set_margin_end(label, 2);
1247 gtk_widget_set_margin_top(label, 2);
1249
1252 G_CALLBACK(show_info_popup), frame);
1255 main_label_info = label;
1256
1257 /* Production status */
1258 table = gtk_grid_new();
1262
1263 /* Citizens for taxrates */
1264 table2 = gtk_grid_new();
1265 gtk_grid_attach(GTK_GRID(table), table2, 0, 0, 10, 1);
1267
1268 for (i = 0; i < 10; i++) {
1270
1273
1276 g_signal_connect(controller, "pressed",
1282 g_signal_connect(controller, "pressed",
1286 }
1287
1288 /* Science, environmental, govt, timeout */
1290 if (spr != NULL) {
1292 } else {
1294 }
1295
1297 if (spr != NULL) {
1299 } else {
1301 }
1302
1304 if (spr != NULL) {
1306 } else {
1308 }
1309
1311 if (spr != NULL) {
1313 } else {
1315 }
1316
1317 for (i = 0; i < 4; i++) {
1318 GtkWidget *w;
1319
1320 switch (i) {
1321 case 0:
1322 w = bulb_label;
1323 break;
1324 case 1:
1325 w = sun_label;
1326 break;
1327 case 2:
1328 w = flake_label;
1329 break;
1330 default:
1331 case 3:
1332 w = government_label;
1333 break;
1334 }
1335
1342 gtk_grid_attach(GTK_GRID(table), w, i, 1, 1, 1);
1343 }
1344
1346
1347 frame = gtk_frame_new(NULL);
1348 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1350
1351
1352 /* Turn done */
1354
1356
1360
1361 /* Selected unit status */
1362
1363 /* If you turn this to something else than GtkBox, also adjust
1364 * editgui.c replace_widget() code that removes and adds widgets from it. */
1368
1369 /* In edit mode the unit_info_box widget is replaced by the
1370 * editinfobox, so we need to add a ref here so that it is
1371 * not destroyed when removed from its container.
1372 * See editinfobox_refresh() call to replace_widget() */
1374
1377
1383
1384 label = gtk_label_new(NULL);
1389 gtk_widget_set_margin_end(label, 2);
1390 gtk_widget_set_margin_top(label, 2);
1393 unit_info_label = label;
1394
1395 hgrid2 = gtk_grid_new();
1397
1398 table = gtk_grid_new();
1404
1407
1409
1410 /* Map canvas, editor toolbar, and scrollbars */
1411
1412 /* The top notebook containing the map view and dialogs. */
1413
1417
1418
1423 right_row = 0;
1426
1430 } else {
1432 }
1433
1435
1438
1445
1446 label = gtk_label_new(Q_("?noun:View"));
1448
1449 frame = gtk_frame_new(NULL);
1450 gtk_grid_attach(GTK_GRID(map_widget), frame, 0, 0, 1, 1);
1451
1457
1459
1460#if 0
1469#endif /* 0 */
1470
1472
1476
1480
1482 NULL, NULL);
1483
1487 g_signal_connect(mc_controller, "released",
1495 g_signal_connect(mc_controller, "released",
1514
1515 g_signal_connect(map_canvas, "resize",
1517
1519 g_signal_connect(mc_controller, "key-pressed",
1522
1523 /* *** The message window -- this is a detachable widget *** */
1524
1528 } else {
1530
1534
1538 }
1540
1543 } else {
1545 }
1552
1557
1564 }
1565 }
1566
1568
1571 TRUE);
1576
1577 label = gtk_label_new(_("Chat"));
1579
1586
1587 gtk_widget_set_name(text, "chatline");
1588
1590 gtk_widget_realize(text);
1592
1594 if (dtach_lowbox != NULL) {
1596 }
1597
1599
1600 /* The chat line */
1607
1608 button = gtk_check_button_new_with_label(_("Allies Only"));
1612 g_signal_connect(button, "toggled",
1616
1617 button = gtk_button_new_with_label(_("Clear links"));
1618 g_signal_connect(button, "clicked",
1621
1622 /* Other things to take care of */
1623
1625 TRUE);
1626
1629 }
1630
1633
1637 }
1638}
1639
1640/**********************************************************************/
1645 const gchar *message,
1646 gpointer user_data)
1647{
1648 enum log_level fllvl = LOG_ERROR;
1649
1650 switch (log_level) {
1651 case G_LOG_LEVEL_DEBUG:
1652 fllvl = LOG_DEBUG;
1653 break;
1655 fllvl = LOG_WARN;
1656 break;
1657 default:
1658 break;
1659 }
1660
1661 if (log_domain != NULL) {
1662 log_base(fllvl, "%s: %s", log_domain, message);
1663 } else {
1664 log_base(fllvl, "%s", message);
1665 }
1666}
1667
1668/**********************************************************************/
1672 const GLogField *fields,
1674 gpointer user_data)
1675{
1676 /* No need to have formatter of our own - let's use glib's default one. */
1678
1680
1681 return G_LOG_WRITER_HANDLED;
1682}
1683
1684/**********************************************************************/
1695
1696/**********************************************************************/
1699static void set_g_log_callbacks(void)
1700{
1701 /* Old API, still used by many log producers */
1703
1707
1708 /* glib >= 2.50 API */
1710}
1711
1712/**********************************************************************/
1723
1724/**********************************************************************/
1727int main(int argc, char **argv)
1728{
1729 return client_main(argc, argv, FALSE);
1730}
1731
1732/**********************************************************************/
1736{
1737 log_normal(_("Migrating options from gtk2 to gtk3 client"));
1738
1739#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1740#define MIGRATE_STR_OPTION(opt) \
1741 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1742 sizeof(gui_options.gui_gtk3_##opt));
1743
1744 /* Default theme name is never migrated */
1745 /* 'fullscreen', 'small_display_layout', and 'message_chat_location'
1746 * not migrated, as (unlike Gtk2), Gtk3-client tries to pick better
1747 * defaults for these in fresh installations based on screen size (see
1748 * adjust_default_options()); so user is probably better served by
1749 * getting these adaptive defaults than whatever they had for Gtk2.
1750 * Since 'fullscreen' isn't migrated, we don't need to worry about
1751 * preserving gui_gtk2_migrated_from_2_5 either. */
1765 MIGRATE_OPTION(popup_tech_help);
1766
1780
1781#undef MIGRATE_OPTION
1782#undef MIGRATE_STR_OPTION
1783
1785}
1786
1787/**********************************************************************/
1791{
1792 log_normal(_("Migrating options from gtk3 to gtk3.22 client"));
1793
1794#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_22_##opt = gui_options.gui_gtk3_##opt;
1795#define MIGRATE_STR_OPTION(opt) \
1796 strncpy(gui_options.gui_gtk3_22_##opt, gui_options.gui_gtk3_##opt, \
1797 sizeof(gui_options.gui_gtk3_22_##opt));
1798
1799 /* Default theme name is never migrated */
1800
1801 /* Simulate gui-gtk3's migrate_options_from_2_5() */
1803 log_normal(_("Migrating gtk3-client options from freeciv-2.5 options."));
1806 }
1807
1824 MIGRATE_OPTION(popup_tech_help);
1825
1839
1840#undef MIGRATE_OPTION
1841#undef MIGRATE_STR_OPTION
1842
1844}
1845
1846/**********************************************************************/
1850{
1851 log_normal(_("Migrating options from gtk3.22 to gtk4 client"));
1852
1853#define MIGRATE_OPTION(opt) gui_options.gui_gtk4_##opt = gui_options.gui_gtk3_22_##opt;
1854#define MIGRATE_STR_OPTION(opt) \
1855 strncpy(gui_options.gui_gtk4_##opt, gui_options.gui_gtk3_22_##opt, \
1856 sizeof(gui_options.gui_gtk4_##opt));
1857
1858 /* Default theme name is never migrated */
1875 MIGRATE_OPTION(popup_tech_help);
1876
1890
1891#undef MIGRATE_OPTION
1892#undef MIGRATE_STR_OPTION
1893
1895}
1896
1897/**********************************************************************/
1901{
1902 log_normal(_("Migrating options from gtk4 to gtk4x client"));
1903
1904#define MIGRATE_OPTION(opt) gui_options.gui_gtk5_##opt = gui_options.gui_gtk4_##opt;
1905#define MIGRATE_STR_OPTION(opt) \
1906 strncpy(gui_options.gui_gtk5_##opt, gui_options.gui_gtk4_##opt, \
1907 sizeof(gui_options.gui_gtk5_##opt));
1908
1909 /* Default theme name is never migrated */
1926 MIGRATE_OPTION(popup_tech_help);
1927
1941
1942#undef MIGRATE_OPTION
1943#undef MIGRATE_STR_OPTION
1944
1946}
1947
1948/**********************************************************************/
1951int ui_main(int argc, char **argv)
1952{
1953 if (parse_options(argc, argv)) {
1954 /* The locale has already been set in init_nls() and the windows-specific
1955 * locale logic in gtk_init() causes problems with zh_CN (see PR#39475) */
1957
1958 if (!gtk_init_check()) {
1959 log_fatal(_("Failed to open graphical mode."));
1960 return EXIT_FAILURE;
1961 }
1962
1964
1965 gui_up = TRUE;
1969 gui_up = FALSE;
1970
1979 cma_fe_done();
1981
1982 /* We have extra ref for unit_info_box that has protected
1983 * it from getting destroyed when editinfobox_refresh()
1984 * moves widgets around. Free that extra ref here. */
1986 if (empty_unit_paintable != NULL) {
1988 }
1989
1990 editgui_free();
1992 message_buffer = NULL; /* Result of destruction of everything */
1994 }
1995
1996 return EXIT_SUCCESS;
1997}
1998
1999/**********************************************************************/
2003{
2005 guint sig;
2007 char window_name[1024];
2008
2010 if (vmode.width > 0 && vmode.height > 0) {
2013 }
2014
2021
2023 gtk_widget_set_name(toplevel, "Freeciv");
2024
2026
2028
2029 if (gui_options.first_boot) {
2031 /* We're using fresh defaults for this version of this client,
2032 * so prevent any future migrations from other clients / versions */
2034 /* Avoid also marking previous Gtk clients as migrated, so that
2035 * they can have their own run of their adjust_default_options() if
2036 * they are ever run (as a side effect of Gtk3.22->Gtk4 migration). */
2037 } else {
2043 /* We want a fresh look at screen-size-related options after Gtk2 */
2045 /* We don't ever want to consider pre-2.6 fullscreen option again
2046 * (even for gui-gtk3) */
2048 }
2050 }
2052 }
2054 }
2055 }
2056
2059 }
2060
2061 fc_snprintf(window_name, sizeof(window_name), _("Freeciv (%s)"), GUI_NAME_SHORT);
2063
2064 g_signal_connect(toplevel, "close-request",
2066
2067 /* Disable GTK cursor key focus movement */
2068 sig = g_signal_lookup("move-focus", GTK_TYPE_WIDGET);
2070 0, 0, 0, 0);
2072
2074 if (OT_FONT == option_type(poption)) {
2075 /* Force to call the appropriate callback. */
2077 }
2079
2082
2083 if (NULL == city_names_style) {
2085 log_error("city_names_style should have been set by options.");
2086 }
2089 log_error("city_productions_style should have been set by options.");
2090 }
2091 if (NULL == reqtree_text_style) {
2093 log_error("reqtree_text_style should have been set by options.");
2094 }
2095
2098
2099 /* Keep the icon of the executable on Windows (see PR#36491) */
2100#ifndef FREECIV_MSWINDOWS
2101 {
2102 /* Only call this after tileset_load_tiles is called. */
2104 }
2105#endif /* FREECIV_MSWINDOWS */
2106
2107 setup_widgets();
2108 load_cursors();
2109 cma_fe_init();
2116 chatline_init();
2118
2120
2122
2123 /* Assumes toplevel showing */
2125
2126 /* Assumes client_state is set */
2128}
2129
2130/**********************************************************************/
2133bool is_gui_up(void)
2134{
2135 return gui_up;
2136}
2137
2138/**********************************************************************/
2141void ui_exit(void)
2142{
2143 if (message_buffer != NULL) {
2146 }
2147}
2148
2149/**********************************************************************/
2152enum gui_type get_gui_type(void)
2153{
2154 return GUI_GTK5;
2155}
2156
2157/**********************************************************************/
2164
2165/**********************************************************************/
2171void set_unit_icon(int idx, struct unit *punit)
2172{
2173 GtkWidget *w;
2174
2175 fc_assert_ret(idx >= -1 && idx < num_units_below);
2176
2177 if (idx == -1) {
2178 w = unit_pic;
2179 unit_id_top = punit ? punit->id : 0;
2180 } else {
2181 w = unit_below_pic[idx];
2182 unit_ids[idx] = punit ? punit->id : 0;
2183 }
2184
2185 if (!w) {
2186 return;
2187 }
2188
2189 if (punit) {
2191 } else {
2192 if (empty_unit_paintable == NULL) {
2193 /* FIXME: Use proper icon height instead of hardcoded 50 */
2195
2196 /* Add ref to avoid it getting destroyed along any single parent widget. */
2198 }
2200 }
2201}
2202
2203/**********************************************************************/
2209{
2210 static bool showing = FALSE;
2211
2212 if (more_arrow == nullptr) {
2213 return;
2214 }
2215
2216 if (onoff && !showing) {
2218 showing = TRUE;
2219 } else if (!onoff && showing) {
2221 showing = FALSE;
2222 }
2223}
2224
2225/**********************************************************************/
2235
2236/**********************************************************************/
2241 double x, double y, gpointer data)
2242{
2243 int i = GPOINTER_TO_INT(data);
2244 struct unit *punit;
2245
2246 if (i == -1) {
2248 if (punit && unit_is_in_focus(punit)) {
2249 /* Clicking on the currently selected unit will center it. */
2251 }
2252 return TRUE;
2253 }
2254
2255 if (unit_ids[i] == 0) { /* No unit displayed at this place */
2256 return TRUE;
2257 }
2258
2260 if (NULL != punit && unit_owner(punit) == client_player()) {
2261 /* Unit shouldn't be NULL but may be owned by an ally. */
2263 }
2264
2265 return TRUE;
2266}
2267
2268/**********************************************************************/
2273 double x, double y, gpointer data)
2274{
2276
2277 if (punit) {
2279 }
2280
2281 return TRUE;
2282}
2283
2284/**********************************************************************/
2288{
2290}
2291
2292/**********************************************************************/
2296 double x, double y, gpointer data)
2297{
2298 GtkWidget *p;
2299 GtkWidget *child;
2300 GtkWidget *frame = GTK_WIDGET(data);
2301
2302 p = gtk_popover_new();
2303
2304 gtk_widget_set_parent(p, frame);
2307 g_signal_connect(p, "closed",
2310
2311 return TRUE;
2312}
2313
2314/**********************************************************************/
2322
2323/**********************************************************************/
2327 gpointer data)
2328{
2330
2331 return TRUE;
2332}
2333
2334/**********************************************************************/
2338 bool socket_writable)
2339{
2340 static bool previous_state = FALSE;
2341
2343
2345 return;
2346
2347 log_debug("set_wait_for_writable_socket(%d)", socket_writable);
2348
2353 NULL);
2354
2356}
2357
2358/**********************************************************************/
2362void add_net_input(int sock)
2363{
2364#ifdef FREECIV_MSWINDOWS
2366#else
2368#endif
2370 G_IO_IN | G_IO_ERR,
2372 NULL);
2374}
2375
2376/**********************************************************************/
2386
2387/**********************************************************************/
2391static void quit_dialog_response(GObject *dialog, GAsyncResult *result,
2392 gpointer data)
2393{
2395 result, NULL);
2396
2397 if (button == 0) {
2399 if (client.conn.used) {
2401 }
2402 quit_gtk_main();
2403 }
2404
2405 quit_dialog = NULL;
2406}
2407
2408/**********************************************************************/
2412{
2413 /* Quit gtk main loop. After this it will return to finish
2414 * ui_main() */
2415
2417}
2418
2419/**********************************************************************/
2424{
2425 if (quit_dialog == NULL) {
2426 const char *buttons[] = { _("Yes"), _("No"), NULL };
2427
2428 quit_dialog = gtk_alert_dialog_new(_("Are you sure you want to quit?"));
2430
2434 }
2435}
2436
2437/**********************************************************************/
2441{
2443 /* Stop emission of event. */
2444 return TRUE;
2445}
2446
2447struct callback {
2448 void (*callback)(void *data);
2449 void *data;
2450};
2451
2452/**********************************************************************/
2456{
2457 struct callback *cb = data;
2458
2459 (cb->callback)(cb->data);
2460 free(cb);
2461
2462 return FALSE;
2463}
2464
2465/**********************************************************************/
2470void add_idle_callback(void (callback)(void *), void *data)
2471{
2472 struct callback *cb = fc_malloc(sizeof(*cb));
2473
2474 cb->callback = callback;
2475 cb->data = data;
2477}
2478
2479/**********************************************************************/
2489
2490/**********************************************************************/
2495{
2496 GtkWidget *button;
2497
2499 fc_assert_ret(button != NULL);
2501
2504}
2505
2506/**********************************************************************/
2517
2518/**********************************************************************/
2528
2529/**********************************************************************/
2539
2540/**********************************************************************/
2550
2551/**********************************************************************/
2556{
2557 struct option *poption;
2558
2559#define option_var_set_callback(var, callback) \
2560 if ((poption = optset_option_by_name(client_optset, \
2561 GUI_GTK_OPTION_STR(var)))) { \
2562 option_set_changed_callback(poption, callback); \
2563 } else { \
2564 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2565 }
2566
2571
2578#undef option_var_set_callback
2579}
2580
2581/**********************************************************************/
2586{
2587 GtkWidget *button;
2588
2590 fc_assert_ret(button != nullptr);
2592
2593 /* Hide the "Allies Only" button for local games. */
2594 if (is_server_running()) {
2596 } else {
2600 }
2601}
2602
2603/**********************************************************************/
2611
2612/**********************************************************************/
2616{
2617 cat_snprintf(outbuf, outlen, _("\nBuilt against gtk %d.%d.%d, using %d.%d.%d"
2618 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2623}
2624
2625/**********************************************************************/
2630{
2633
2635 if (!display) {
2636 return FALSE;
2637 }
2638
2640
2641 if (!monitor) {
2642 return FALSE;
2643 }
2644
2646
2647 return TRUE;
2648}
2649
2650/**********************************************************************/
2654{
2655 GdkRectangle rect;
2656
2657 if (vmode.width > 0) {
2658 return vmode.width;
2659 }
2660
2661 if (monitor_size(&rect)) {
2662 return rect.width;
2663 } else {
2664 return 0;
2665 }
2666}
2667
2668/**********************************************************************/
2672{
2673 GdkRectangle rect;
2674
2675 if (vmode.height > 0) {
2676 return vmode.height;
2677 }
2678
2679 if (monitor_size(&rect)) {
2680 return rect.height;
2681 } else {
2682 return 0;
2683 }
2684}
2685
2686/**********************************************************************/
2690{
2691 if (vmode.width > 0 && vmode.height > 0) {
2692 return &vmode;
2693 }
2694
2695 return NULL;
2696}
2697
2698/**********************************************************************/
2701static void adjust_default_options(void)
2702{
2703 int scr_height = screen_height();
2704
2705 if (scr_height > 0) {
2706 /* Adjust these options only if we do know the screen height. */
2707
2708 if (scr_height <= 480) {
2709 /* Freeciv is practically unusable outside fullscreen mode in so
2710 * small display */
2711 log_verbose("Changing default to fullscreen due to very small screen");
2713 }
2714 if (scr_height < 1024) {
2715 /* This is a small display */
2716 log_verbose("Defaulting to small widget layout due to small screen");
2718 log_verbose("Defaulting to merged messages/chat due to small screen");
2720 }
2721 }
2722}
2723
2724/**********************************************************************/
2728{
2729 return fc_app;
2730}
2731
2732/**********************************************************************/
void audio_pause(void)
Definition audio.c:606
void audio_resume(void)
Definition audio.c:614
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void chat_welcome_message(bool gui_has_copying_mitem)
static struct ai_type * self
Definition classicai.c:46
bool client_is_observer(void)
double real_timer_callback(void)
int client_main(int argc, char *argv[], bool postpone_tileset)
void user_ended_turn(void)
struct civclient client
void start_quitting(void)
void set_client_state(enum client_states newstate)
bool can_client_change_view(void)
#define client_player()
#define TIMER_INTERVAL
Definition client_main.h:30
@ C_S_DISCONNECTED
Definition client_main.h:45
void buy_production_in_selected_cities(void)
Definition climisc.c:1317
struct sprite * client_warming_sprite(void)
Definition climisc.c:377
struct sprite * client_cooling_sprite(void)
Definition climisc.c:394
struct sprite * client_research_sprite(void)
Definition climisc.c:354
struct sprite * client_government_sprite(void)
Definition climisc.c:412
void disconnect_from_server(bool leaving_sound)
Definition clinet.c:306
void input_from_server(int fd)
Definition clinet.c:411
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
char * incite_cost
Definition comments.c:76
bool is_server_running(void)
void key_recall_previous_focus_unit(void)
Definition control.c:3320
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:388
void key_cancel_action(void)
Definition control.c:3258
int num_units_below
Definition control.c:76
void unit_focus_set(struct unit *punit)
Definition control.c:506
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void key_end_turn(void)
Definition control.c:3312
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:985
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3341
enum cursor_hover_state hover_state
Definition control.c:89
struct unit * head_of_units_in_focus(void)
Definition control.c:410
int get_num_units_in_focus(void)
Definition control.c:185
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1215
void key_center_capital(void)
Definition control.c:3295
#define MAX_NUM_UNITS_BELOW
Definition control.h:295
@ HOVER_NONE
Definition control.h:26
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:74
bool editor_is_active(void)
Definition editor.c:346
bool is_option(const char *option_name, char *option)
Definition fc_cmdline.c:112
char * get_option_malloc(const char *option_name, char **argv, int *i, int argc, bool gc)
Definition fc_cmdline.c:50
@ O_SCIENCE
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
struct unit * game_unit_by_number(int id)
Definition game.c:115
bool inputline_has_focus(void)
Definition chatline.c:72
void inputline_toolkit_view_append_button(GtkWidget *toolkit_view, GtkWidget *button)
Definition chatline.c:1293
GtkWidget * inputline_toolkit_view_new(void)
Definition chatline.c:1271
void set_message_buffer_view_link_handlers(GtkWidget *view)
Definition chatline.c:745
bool inputline_is_visible(void)
Definition chatline.c:88
void chatline_init(void)
Definition chatline.c:1303
void inputline_grab_focus(void)
Definition chatline.c:80
void chatline_scroll_to_bottom(bool delayed)
Definition chatline.c:1007
void citizens_dialog_init(void)
void citizens_dialog_done(void)
void cma_fe_init(void)
Definition cma_fe.c:88
void cma_fe_done(void)
Definition cma_fe.c:96
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
gboolean taxrates_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition dialogs.c:1425
void diplomacy_dialog_init(void)
Definition diplodlg.c:1206
void diplomacy_dialog_done(void)
Definition diplodlg.c:1215
gboolean handle_edit_key_press(GdkEventKey *ev)
Definition editgui.c:1662
void editgui_create_widgets(void)
Definition editgui.c:1822
struct editbar * editgui_get_editbar(void)
Definition editgui.c:1788
void editgui_free(void)
Definition editgui.c:1835
void goto_dialog_focus_units_changed(void)
Definition gotodlg.c:541
static GtkWidget * source
Definition gotodlg.c:58
void load_cursors(void)
Definition graphics.c:84
GtkWidget * map_vertical_scrollbar
Definition gui_main.c:110
int ui_main(int argc, char **argv)
Definition gui_main.c:1888
const char * client_string
Definition gui_main.c:106
GtkTextBuffer * message_buffer
Definition gui_main.c:179
static void quit_dialog_response(GtkWidget *dialog, gint response)
Definition gui_main.c:2323
void real_focus_units_changed(void)
Definition gui_main.c:2150
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2127
static void print_usage(void)
Definition gui_main.c:266
#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK
Definition gui_main.c:117
#define option_var_set_callback(var, callback)
static gboolean quit_dialog_callback(void)
Definition gui_main.c:2376
static GIOChannel * srv_channel
Definition gui_main.c:183
GtkWidget * main_label_info
Definition gui_main.c:139
static bool monitor_size(GdkRectangle *rect_p)
Definition gui_main.c:2554
GtkWidget * bottom_notebook
Definition gui_main.c:130
GtkWidget * unit_info_label
Definition gui_main.c:152
static gboolean timer_callback(gpointer data)
Definition gui_main.c:243
struct video_mode * resolution_request_get(void)
Definition gui_main.c:2612
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2097
static int unit_ids[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:176
GtkWidget * timeout_label
Definition gui_main.c:149
static bool gui_up
Definition gui_main.c:187
static guint srv_id
Definition gui_main.c:184
static gboolean mouse_scroll_mapcanvas(GtkWidget *w, GdkEventScroll *ev)
Definition gui_main.c:684
PangoFontDescription * city_productions_style
Definition gui_main.c:135
GtkWidget * overview_scrolled_window
Definition gui_main.c:113
static GtkWidget * detached_widget_fill(GtkWidget *tearbox)
Definition gui_main.c:846
GtkWidget * top_notebook
Definition gui_main.c:130
#define MIGRATE_STR_OPTION(opt)
GtkWidget * unit_info_box
Definition gui_main.c:153
gboolean fc_lost_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:736
void ui_exit(void)
Definition gui_main.c:2067
enum gui_type get_gui_type(void)
Definition gui_main.c:2078
static GtkWidget * detached_widget_new(void)
Definition gui_main.c:835
gint cur_y
Definition gui_main.c:185
int main(int argc, char **argv)
Definition gui_main.c:1766
void fullscreen_opt_refresh(struct option *poption)
Definition gui_main.c:2434
void ui_init(void)
Definition gui_main.c:1756
static void free_unit_table(void)
Definition gui_main.c:996
static gboolean idle_callback_wrapper(gpointer data)
Definition gui_main.c:2391
static void apply_city_names_font(struct option *poption)
Definition gui_main.c:2446
static void apply_city_productions_font(struct option *poption)
Definition gui_main.c:2457
gboolean fc_gained_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:746
GtkWidget * government_label
Definition gui_main.c:148
GtkWidget * sun_label
Definition gui_main.c:146
PangoFontDescription * city_names_style
Definition gui_main.c:134
void refresh_chat_buttons(void)
Definition gui_main.c:2510
gboolean map_canvas_focus(void)
Definition gui_main.c:360
GtkWidget * turn_done_button
Definition gui_main.c:150
static GtkWidget * bottom_hpaned
Definition gui_main.c:132
static gint timer_id
Definition gui_main.c:182
int screen_width(void)
Definition gui_main.c:2576
GtkWidget * scroll_panel
Definition gui_main.c:142
static void end_turn_callback(GtkWidget *w, gpointer data)
Definition gui_main.c:2249
#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK
Definition gui_main.c:118
static void log_callback_utf8(enum log_level level, const char *message, bool file_too)
Definition gui_main.c:231
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2406
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2218
static void set_g_log_callbacks(void)
Definition gui_main.c:1740
void reset_unit_table(void)
Definition gui_main.c:1024
static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:401
GtkWidget * unit_info_frame
Definition gui_main.c:154
void options_extra_init(void)
Definition gui_main.c:2480
GtkWidget * top_vbox
Definition gui_main.c:129
static void allied_chat_only_callback(struct option *poption)
Definition gui_main.c:2419
static void adjust_default_options(void)
Definition gui_main.c:2624
static void set_wait_for_writable_socket(struct connection *pc, bool socket_writable)
Definition gui_main.c:2269
GtkWidget * ahbox
Definition gui_main.c:141
static void apply_reqtree_text_font(struct option *poption)
Definition gui_main.c:2468
bool is_gui_up(void)
Definition gui_main.c:2059
static gboolean toplevel_focus(GtkWidget *w, GtkDirectionType arg)
Definition gui_main.c:316
PangoFontDescription * reqtree_text_style
Definition gui_main.c:136
GtkWidget * flake_label
Definition gui_main.c:147
static void g_log_to_freelog_cb(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
Definition gui_main.c:1684
GtkWidget * avbox
Definition gui_main.c:141
gint cur_x
Definition gui_main.c:185
void setup_gui_properties(void)
Definition gui_main.c:2650
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2540
static void set_g_log_callback_domain(const char *domain)
Definition gui_main.c:1728
GtkWidget * bulb_label
Definition gui_main.c:145
GtkWidget * overview_canvas
Definition gui_main.c:112
GtkWidget * toplevel
Definition gui_main.c:126
static void setup_widgets(void)
Definition gui_main.c:1128
#define OVERVIEW_CANVAS_STORE_WIDTH
Definition gui_main.c:119
void remove_net_input(void)
Definition gui_main.c:2312
GtkWidget * map_horizontal_scrollbar
Definition gui_main.c:109
GtkWidget * map_canvas
Definition gui_main.c:108
static gboolean toplevel_key_press_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:600
void sound_bell(void)
Definition gui_main.c:2086
static void migrate_options_from_gtk2(void)
Definition gui_main.c:1774
GtkWidget * econ_label[10]
Definition gui_main.c:144
void popup_quit_dialog(void)
Definition gui_main.c:2350
static void migrate_options_from_gtk3(void)
Definition gui_main.c:1829
const char *const gui_character_encoding
Definition gui_main.c:162
static int unit_id_top
Definition gui_main.c:175
static gboolean get_net_input(GIOChannel *source, GIOCondition condition, gpointer data)
Definition gui_main.c:2258
static bool audio_paused
Definition gui_main.c:189
GtkWidget * map_widget
Definition gui_main.c:131
static bool client_focus
Definition gui_main.c:190
GtkWidget * right_notebook
Definition gui_main.c:130
void quit_gtk_main(void)
Definition gui_main.c:2338
static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data)
Definition gui_main.c:2531
static struct video_mode vmode
Definition gui_main.c:192
void add_net_input(int sock)
Definition gui_main.c:2294
static GLogWriterOutput g_log_writer_to_freelog_cb(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data)
Definition gui_main.c:1712
GtkWidget * toplevel_tabs
Definition gui_main.c:128
static GtkWidget * allied_chat_toggle_button
Definition gui_main.c:180
int overview_canvas_store_width
Definition gui_main.c:123
void update_turn_done_tooltip(void)
Definition gui_main.c:1109
static void tearoff_callback(GtkWidget *b, gpointer data)
Definition gui_main.c:790
GtkTextView * main_message_area
Definition gui_main.c:178
int overview_canvas_store_height
Definition gui_main.c:124
int screen_height(void)
Definition gui_main.c:2594
static bool parse_options(int argc, char **argv)
Definition gui_main.c:287
GtkWidget * conn_box
Definition gui_main.c:141
#define OVERVIEW_CANVAS_STORE_HEIGHT
Definition gui_main.c:121
GtkWidget * main_frame_civ_name
Definition gui_main.c:138
#define MIGRATE_OPTION(opt)
const bool gui_use_transliteration
Definition gui_main.c:163
#define GUI_NAME_FULL
Definition gui_main.h:22
#define GUI_NAME_SHORT
Definition gui_main.h:23
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
void dlg_tab_provider_prepare(void)
Definition gui_stuff.c:1155
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void gui_update_font_full(const char *font_name, const char *font_value, PangoFontDescription **font_desc)
Definition gui_stuff.c:1073
void happiness_dialog_init(void)
Definition happiness.c:86
void happiness_dialog_done(void)
Definition happiness.c:94
void help_system_init(void)
Definition helpdlg.c:157
void intel_dialog_done(void)
Definition inteldlg.c:128
void intel_dialog_init(void)
Definition inteldlg.c:119
void luaconsole_dialog_init(void)
Definition luaconsole.c:83
void luaconsole_dialog_done(void)
Definition luaconsole.c:101
gboolean move_overviewcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
Definition mapctrl.c:463
gboolean move_mapcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
Definition mapctrl.c:406
gboolean leave_mapcanvas(GtkWidget *widget, GdkEventCrossing *event)
Definition mapctrl.c:435
void update_city_descriptions(void)
Definition mapview.c:488
gboolean map_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data)
Definition mapview.c:424
gboolean overview_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data)
Definition mapview.c:356
void meswin_dialog_popup(bool raise)
Definition messagewin.c:417
GtkWidget * create_start_page(void)
Definition pages.c:2623
GtkWidget * create_network_page(void)
Definition pages.c:1201
GtkWidget * create_scenario_page(void)
Definition pages.c:3185
static GtkWidget * statusbar
Definition pages.c:89
enum client_pages get_current_client_page(void)
Definition pages.c:3345
void destroy_server_scans(void)
Definition pages.c:768
GtkWidget * create_load_page(void)
Definition pages.c:2904
GtkWidget * create_statusbar(void)
Definition pages.c:909
GtkWidget * create_main_page(void)
Definition pages.c:231
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
void spaceship_dialog_init(void)
void spaceship_dialog_done(void)
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
GtkWidget * ingame_votebar
GtkWidget * voteinfo_bar_new(bool split_bar)
gboolean reverse_taxrates_callback(GtkGestureClick *gesture, int n_press, double x, double y)
Definition dialogs.c:1459
static GdkPaintable * empty_unit_paintable
Definition gui_main.c:160
static void tearoff_close(GtkWidget *w, gpointer data)
Definition gui_main.c:782
static void tearoff_reattach(GtkWidget *box)
Definition gui_main.c:765
gboolean terminate_signal_processing(GtkEventControllerFocus *controller, gpointer data)
Definition gui_main.c:1043
static GtkWidget * more_arrow_container
Definition gui_main.c:165
static GtkWidget * unit_pic
Definition gui_main.c:162
static gboolean select_more_arrow_callback(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition gui_main.c:2217
GtkWidget * econ_widget
Definition gui_main.c:155
static GtkApplication * fc_app
Definition gui_main.c:184
GtkApplication * gui_app(void)
Definition gui_main.c:2674
static GtkWidget * more_arrow
Definition gui_main.c:164
static float zoom_steps_custom[]
Definition gui_main.c:228
static void migrate_options_from_gtk3_22(void)
Definition gui_main.c:1848
void animation_idle_cb(void *data)
Definition gui_main.c:2429
static void activate_gui(GtkApplication *app, gpointer data)
Definition gui_main.c:1950
static void populate_unit_pic_table(void)
Definition gui_main.c:882
static void info_popup_closed(GtkWidget *self, gpointer data)
Definition gui_main.c:2232
static void move_from_container_to_container(GtkWidget *wdg, GtkWidget *old_wdg, GtkWidget *new_wdg)
Definition gui_main.c:710
static gboolean select_unit_pic_callback(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition gui_main.c:2185
static GtkWidget * unit_pic_table
Definition gui_main.c:161
static GtkWidget * unit_below_pic[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:163
void main_message_area_resize(void *data)
Definition gui_main.c:360
gboolean right_butt_down_overviewcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:499
gboolean left_butt_up_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:164
gboolean right_butt_up_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:181
gboolean left_butt_down_overviewcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:474
gboolean left_butt_down_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:206
gboolean right_butt_down_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:261
gboolean middle_butt_down_mapcanvas(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition mapctrl.c:330
void map_canvas_resize(GtkWidget *w, int width, int height, gpointer data)
Definition mapview.c:408
void put_unit_picture(struct unit *punit, GtkPicture *p, int height)
Definition mapview.c:494
void menus_set_initial_toggle_values(void)
Definition menu.c:2941
GtkWidget * picture_new_from_surface(cairo_surface_t *surf)
Definition sprite.c:526
static void migrate_options_from_gtk4(void)
Definition gui_main.c:1900
static GtkAlertDialog * quit_dialog
Definition gui_main.c:185
struct client_properties gui_properties
log_callback_fn log_set_callback(log_callback_fn callback)
Definition log.c:290
#define fc_assert_ret(condition)
Definition log.h:192
#define log_verbose(message,...)
Definition log.h:110
#define fc_assert(condition)
Definition log.h:177
#define log_fatal(message,...)
Definition log.h:101
#define log_debug(message,...)
Definition log.h:116
#define log_normal(message,...)
Definition log.h:108
#define log_base(level, message,...)
Definition log.h:95
log_level
Definition log.h:29
@ LOG_ERROR
Definition log.h:31
@ LOG_DEBUG
Definition log.h:35
@ LOG_FATAL
Definition log.h:30
@ LOG_WARN
Definition log.h:32
#define log_error(message,...)
Definition log.h:104
void update_line(int canvas_x, int canvas_y)
void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
bool rbutton_down
bool tiles_hilited_cities
void scroll_mapview(enum direction8 gui_dir)
bool keyboardless_goto_button_down
void update_selection_rectangle(float canvas_x, float canvas_y)
void init_mapcanvas_and_overview(void)
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
void free_mapcanvas_and_overview(void)
void get_mapview_scroll_pos(int *scroll_x, int *scroll_y)
void get_mapview_scroll_step(int *xstep, int *ystep)
void set_mapview_scroll_pos(int scroll_x, int scroll_y, float zoom)
void center_tile_mapcanvas(const struct tile *ptile)
void update_animation(void)
void set_frame_by_frame_animation(void)
void link_marks_clear_all(void)
#define fc_malloc(sz)
Definition mem.h:34
void option_changed(struct option *poption)
Definition options.c:784
const struct option_set * server_optset
Definition options.c:4278
const struct option_set * client_optset
Definition options.c:1316
bool option_bool_get(const struct option *poption)
Definition options.c:833
enum option_type option_type(const struct option *poption)
Definition options.c:694
const char * option_font_target(const struct option *poption)
Definition options.c:1199
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6760
struct client_options gui_options
Definition options.c:71
const char * option_font_get(const struct option *poption)
Definition options.c:1177
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:467
@ GUI_GTK_MSGCHAT_MERGED
Definition options.h:69
@ GUI_GTK_MSGCHAT_SPLIT
Definition options.h:67
#define GUI_GTK_OVERVIEW_MIN_XSIZE
Definition options.h:634
#define options_iterate(poptset, poption)
Definition options.h:587
#define options_iterate_end
Definition options.h:592
const char * get_info_label_text_popup(void)
Definition text.c:1016
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
#define CLIP(lower, current, upper)
Definition shared.h:57
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
void * data
Definition gui_main.c:2385
void(* callback)(void *data)
Definition gui_main.c:2384
struct connection conn
Definition client_main.h:96
bool silent_when_not_in_focus
Definition options.h:192
bool gui_gtk3_22_migrated_from_gtk3
Definition options.h:134
bool gui_gtk5_migrated_from_gtk4
Definition options.h:135
bool gui_gtk3_migrated_from_2_5
Definition options.h:140
int sound_effects_volume
Definition options.h:191
bool first_boot
Definition options.h:128
float zoom_default_level
Definition options.h:232
bool gui_gtk3_fullscreen
Definition options.h:267
bool migrate_fullscreen
Definition options.h:146
bool gui_gtk3_migrated_from_gtk2
Definition options.h:133
bool gui_gtk4_migrated_from_gtk3_22
Definition options.h:136
Definition colors.h:21
void(* notify_of_writable_data)(struct connection *pc, bool data_available_and_socket_full)
Definition connection.h:181
GtkWidget * widget
Definition editgui.h:26
Definition unit.h:140
int id
Definition unit.h:147
int height
Definition options.h:48
int width
Definition options.h:47
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:986
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
void tileset_load_tiles(struct tileset *t)
Definition tilespec.c:3804
void tileset_free_tiles(struct tileset *t)
Definition tilespec.c:6819
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7293
void tileset_init(struct tileset *t)
Definition tilespec.c:7354
struct sprite * get_arrow_sprite(const struct tileset *t, enum arrow_type arrow)
Definition tilespec.c:7092
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:7103
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:779
@ ARROW_RIGHT
Definition tilespec.h:202
#define unit_tile(_pu)
Definition unit.h:404
#define unit_owner(_pu)
Definition unit.h:403
float mouse_zoom
Definition zoom.c:28
void zoom_phase_set(bool individual_tiles)
Definition zoom.c:93
void zoom_set_steps(float *steps)
Definition zoom.c:80
void zoom_step_down(void)
Definition zoom.c:130
void zoom_step_up(void)
Definition zoom.c:106