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 "options.h"
73#include "text.h"
74#include "tilespec.h"
75#include "zoom.h"
76
77/* client/gui-gtk-4.0 */
78#include "chatline.h"
79#include "citizensinfo.h"
80#include "connectdlg.h"
81#include "cma_fe.h"
82#include "dialogs.h"
83#include "diplodlg.h"
84#include "editgui.h"
85#include "gotodlg.h"
86#include "graphics.h"
87#include "gui_stuff.h"
88#include "happiness.h"
89#include "helpdlg.h"
90#include "inteldlg.h"
91#include "mapctrl.h"
92#include "mapview.h"
93#include "menu.h"
94#include "messagewin.h"
95#include "optiondlg.h"
96#include "pages.h"
97#include "plrdlg.h"
98#include "luaconsole.h"
99#include "spaceshipdlg.h"
100#include "repodlgs.h"
101#include "voteinfo_bar.h"
102
103#include "gui_main.h"
104
106
107GtkWidget *map_canvas; /* GtkDrawingArea */
110
111GtkWidget *overview_canvas; /* GtkDrawingArea */
112GtkWidget *overview_scrolled_window; /* GtkScrolledWindow */
113/* The two values below define the width and height of the map overview. The
114 * first set of values (2*62, 2*46) define the size for a netbook display. For
115 * bigger displays the values are doubled (default). */
116#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK (2 * 64)
117#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK (2 * 46)
118#define OVERVIEW_CANVAS_STORE_WIDTH \
119 (2 * OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK)
120#define OVERVIEW_CANVAS_STORE_HEIGHT \
121 (2 * OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK)
124
131
135
138
141
149
153
155
156const char *const gui_character_encoding = "UTF-8";
158
165
166static int unit_id_top;
167static int unit_ids[MAX_NUM_UNITS_BELOW]; /* ids of the units icons in
168 * information display: (or 0) */
172
173static gint timer_id; /* Ditto */
177
178static bool gui_up = FALSE;
179
180static bool audio_paused = FALSE;
181static bool client_focus = TRUE;
182
184
185static struct video_mode vmode = { -1, -1 };
186
187static void set_g_log_callbacks(void);
188
190 double x, double y, gpointer data);
191
192static void end_turn_callback(GtkWidget *w, gpointer data);
194 gpointer data);
195static void set_wait_for_writable_socket(struct connection *pc,
196 bool socket_writable);
197
198static void print_usage(void);
199static void activate_gui(GtkApplication *app, gpointer data);
200static bool parse_options(int argc, char **argv);
204 GdkModifierType state,
205 gpointer data);
207 gdouble dx, gdouble dy,
208 gpointer data);
209
210static void tearoff_callback(GtkWidget *b, gpointer data);
211static GtkWidget *detached_widget_new(void);
213
215 double x, double y, gpointer data);
217 double x, double y, gpointer data);
218static gboolean quit_dialog_callback(void);
219
221 gpointer user_data);
222
223static void free_unit_table(void);
224
225static void adjust_default_options(void);
226
227static float zoom_steps_custom[] = {
228 -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
229};
230
231/**********************************************************************/
234static void log_callback_utf8(enum log_level level, const char *message,
235 bool file_too)
236{
237 if (!file_too || level <= LOG_FATAL) {
238 fc_fprintf(stderr, "%d: %s\n", level, message);
239 }
240}
241
242/**********************************************************************/
247{
248 double seconds = real_timer_callback();
249
251 if (!audio_paused && !client_focus) {
252 audio_pause();
254 } else if (audio_paused && client_focus) {
255 audio_resume();
257 }
258 }
259
261
262 return FALSE;
263}
264
265/**********************************************************************/
269static void print_usage(void)
270{
271 /* Add client-specific usage information here */
273 _("gtk4-client gui-specific options are:\n"));
274
276 _("-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
277 "screen\n"));
278
279#ifdef EXP_ZOOM_LEVELS
281 /* TRANS: Keep word 'default' untranslated */
282 _("-z, --zoom LEVEL\tSet zoom level; use value 'default' "
283 "to reset\n\n"));
284#else
285 fc_fprintf(stderr, "\n");
286#endif /* EXP_ZOOM_LEVELS */
287
288 /* TRANS: No full stop after the URL, could cause confusion. */
289 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
290}
291
292/**********************************************************************/
295static bool parse_options(int argc, char **argv)
296{
297 int i = 1;
298
299 while (i < argc) {
300 char *option = NULL;
301
302 if (is_option("--help", argv[i])) {
303 print_usage();
304
305 return FALSE;
306
307#ifdef EXP_ZOOM_LEVELS
308 } else if ((option = get_option_malloc("--zoom", argv, &i, argc, FALSE))) {
309 char *endptr;
310
311 if (strcmp("default", option)) {
314 } else {
316 }
317 free(option);
318#endif /* EXP_ZOOM_LEVELS */
319
320 } else if ((option = get_option_malloc("--resolution", argv, &i, argc, FALSE))) {
322 fc_fprintf(stderr, _("Illegal video mode '%s'\n"), option);
324 }
325 free(option);
326 } else {
327 fc_fprintf(stderr, _("Unknown command-line option \"%s\".\n"),
328 argv[i]);
330 }
331
332 i++;
333 }
334
335 return TRUE;
336}
337
338/**********************************************************************/
342 gpointer data)
343{
344 switch (arg) {
347
348 if (!gtk_widget_get_can_focus(w)) {
349 return;
350 }
351
352 if (!gtk_widget_is_focus(w)) {
354 return;
355 }
356 break;
357
358 default:
359 break;
360 }
361}
362
363/**********************************************************************/
385
386/**********************************************************************/
397
398/**********************************************************************/
402{
403 if ((state & GDK_SHIFT_MASK)) {
404 switch (keyval) {
405
406 case GDK_KEY_Left:
408 return TRUE;
409
410 case GDK_KEY_Right:
412 return TRUE;
413
414 case GDK_KEY_Up:
416 return TRUE;
417
418 case GDK_KEY_Down:
420 return TRUE;
421
422 case GDK_KEY_Home:
424 return TRUE;
425
426 case GDK_KEY_Page_Up:
429 return TRUE;
430
434 return TRUE;
435
436 default:
437 break;
438 }
439 } else if (!(state & GDK_CONTROL_MASK)) {
440 switch (keyval) {
441 default:
442 break;
443 }
444 }
445
446 if (state & GDK_SHIFT_MASK) {
447 bool volchange = FALSE;
448
449 switch (keyval) {
450 case GDK_KEY_plus:
451 case GDK_KEY_KP_Add:
453 volchange = TRUE;
454 break;
455
456 case GDK_KEY_minus:
459 volchange = TRUE;
460 break;
461
462 default:
463 break;
464 }
465
466 if (volchange) {
468 "sound_effects_volume");
469
472 100);
474
475 return TRUE;
476 }
477 } else if (!(state & GDK_CONTROL_MASK)) {
478 switch (keyval) {
479 case GDK_KEY_plus:
480 case GDK_KEY_KP_Add:
481 zoom_step_up();
482 return TRUE;
483
484 case GDK_KEY_minus:
487 return TRUE;
488
489 default:
490 break;
491 }
492 }
493
494 /* Return here if observer */
495 if (client_is_observer()) {
496 return FALSE;
497 }
498
499 switch (keyval) {
500
501 case GDK_KEY_KP_Up:
502 case GDK_KEY_KP_8:
503 case GDK_KEY_Up:
504 case GDK_KEY_8:
506 return TRUE;
507
509 case GDK_KEY_KP_9:
510 case GDK_KEY_Page_Up:
511 case GDK_KEY_9:
513 return TRUE;
514
515 case GDK_KEY_KP_Right:
516 case GDK_KEY_KP_6:
517 case GDK_KEY_Right:
518 case GDK_KEY_6:
520 return TRUE;
521
523 case GDK_KEY_KP_3:
525 case GDK_KEY_3:
527 return TRUE;
528
529 case GDK_KEY_KP_Down:
530 case GDK_KEY_KP_2:
531 case GDK_KEY_Down:
532 case GDK_KEY_2:
534 return TRUE;
535
536 case GDK_KEY_KP_End:
537 case GDK_KEY_KP_1:
538 case GDK_KEY_End:
539 case GDK_KEY_1:
541 return TRUE;
542
543 case GDK_KEY_KP_Left:
544 case GDK_KEY_KP_4:
545 case GDK_KEY_Left:
546 case GDK_KEY_4:
548 return TRUE;
549
550 case GDK_KEY_KP_Home:
551 case GDK_KEY_KP_7:
552 case GDK_KEY_Home:
553 case GDK_KEY_7:
555 return TRUE;
556
557 case GDK_KEY_KP_Begin:
558 case GDK_KEY_KP_5:
559 case GDK_KEY_5:
561 return TRUE;
562
563 case GDK_KEY_Escape:
565 return TRUE;
566
567 case GDK_KEY_b:
570 return TRUE;
571 }
572 break;
573
574 default:
575 break;
576 };
577
578 return FALSE;
579}
580
581/**********************************************************************/
587 GdkModifierType state,
588 gpointer data)
589{
590 if (inputline_has_focus()) {
591 return FALSE;
592 }
593
594 if (keyval == GDK_KEY_apostrophe) {
595 /* Allow this even if not in main map view; chatline is present on
596 * some other pages too */
597
598 /* Make the chatline visible if it's not currently.
599 * FIXME: should find the correct window, even when detached, from any
600 * other window; should scroll to the bottom automatically showing the
601 * latest text from other players; MUST NOT make spurious text windows
602 * at the bottom of other dialogs. */
604 /* The main game view is visible. May need to switch notebook. */
607 } else {
609 }
610 }
611
612 /* If the chatline is (now) visible, focus it. */
613 if (inputline_is_visible()) {
615 return TRUE;
616 }
617 }
618
621 return FALSE;
622 }
623
624 if (editor_is_active()) {
625 if (handle_edit_key_press(keyval, state)) {
626 return TRUE;
627 }
628 }
629
630 if (state & GDK_SHIFT_MASK) {
631 switch (keyval) {
632
633 case GDK_KEY_Return:
634 case GDK_KEY_KP_Enter:
635 key_end_turn();
636 return TRUE;
637
638 default:
639 break;
640 }
641 }
642
644 /* 0 means the map view is focused. */
645 return key_press_map_canvas(keyval, state);
646 }
647
648#if 0
649 /* We are focused some other dialog, tab, or widget. */
650 if ((state & GDK_CONTROL_MASK)) {
651 } else if ((state & GDK_SHIFT_MASK)) {
652 } else {
653 switch (keyval) {
654
655 case GDK_KEY_F4:
657 return TRUE;
658
659 default:
660 break;
661 };
662 }
663#endif /* 0 */
664
665 return FALSE;
666}
667
668/**********************************************************************/
714
715/**********************************************************************/
721{
722 g_object_ref(wdg); /* Make sure reference count stays above 0
723 * during the transition to new parent. */
724
725 if (GTK_IS_PANED(old_wdg)) {
727 } else if (GTK_IS_WINDOW(old_wdg)) {
729 } else {
731
733 }
734
735 if (GTK_IS_PANED(new_wdg)) {
737 } else if (GTK_IS_WINDOW(new_wdg)) {
739 } else {
741
743 }
744
746}
747
748/**********************************************************************/
758
759/**********************************************************************/
769
770/**********************************************************************/
774{
776
777 aparent = g_object_get_data(G_OBJECT(box), "aparent");
779
780 if (aparent != cparent) {
782
784 }
785}
786
787/**********************************************************************/
790static void tearoff_close(GtkWidget *w, gpointer data)
791{
793}
794
795/**********************************************************************/
800{
801 GtkWidget *box = GTK_WIDGET(data);
803
805 GtkWidget *w;
807
808 w = gtk_window_new();
810 gtk_widget_set_name(w, "Freeciv");
811 gtk_window_set_title(GTK_WINDOW(w), _("Freeciv"));
812 g_signal_connect(w, "close-request", G_CALLBACK(tearoff_close), box);
813
814 g_object_set_data(G_OBJECT(box), "aparent", gtk_widget_get_parent(box));
815
816 temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent");
817 if (temp_hide != nullptr) {
819 }
820
822
824
825 if (temp_hide != nullptr) {
827 }
828 } else {
829 tearoff_reattach(box);
830 }
831}
832
833/**********************************************************************/
837{
839
840 return hbox;
841}
842
843/**********************************************************************/
848{
849 GtkWidget *b, *fillbox;
851
854
855 /* These toggle buttons run vertically down the side of many UI
856 * elements, so they need to be thin horizontally. */
858 ".detach_button {\n"
859 " padding: 0px 0px 0px 0px;\n"
860 " min-width: 6px;\n"
861 "}",
862 -1);
863 }
864
870 gtk_widget_add_css_class(b, "detach_button");
871 gtk_widget_set_tooltip_text(b, _("Detach/Attach the pane."));
872
875
877
879
880 return fillbox;
881}
882
883/**********************************************************************/
890static void populate_unit_pic_table(void)
891{
892 int i, width;
894 GdkPixbuf *pix;
895 int ttw;
897
898 /* Get width of the overview window */
902
904
906 /* We want arrow to appear if there is other units in addition
907 to active one in tile. Active unit is not counted, so there
908 can be 0 other units to not to display arrow. */
909 num_units_below = 1 - 1;
910 } else {
913 }
914
915 /* Top row: the active unit. */
916 /* Note, we ref this and other widgets here so that we can unref them
917 * in reset_unit_table. */
921 gtk_grid_attach(GTK_GRID(table), unit_pic, 0, 0, 1, 1);
922
924 g_signal_connect(controller, "pressed",
926 GINT_TO_POINTER(-1));
928
930 /* Bottom row: other units in the same tile. */
931 for (i = 0; i < num_units_below; i++) {
935
937 g_signal_connect(controller, "pressed",
941
943 i, 1, 1, 1);
944 }
945 }
946
947 /* Create arrow (popup for all units on the selected tile) */
951
953 g_signal_connect(controller, "pressed",
955 NULL);
957
958 /* An extra layer so that we can hide the clickable button but keep
959 * an explicit size request to avoid the layout jumping around */
966 gdk_pixbuf_get_width(pix), -1);
968
970 /* Display on bottom row. */
972 num_units_below, 1, 1, 1);
973 } else {
974 /* Display on top row (there is no bottom row). */
976 1, 0, 1, 1);
977 }
978
980}
981
982/**********************************************************************/
1005
1006/**********************************************************************/
1010{
1011 /* Unreference all of the widgets that we're about to reallocate, thus
1012 * avoiding a memory leak. Remove them from the container first, just
1013 * to be safe. Note, the widgets are ref'd in
1014 * populate_unit_pic_table(). */
1016
1018
1019 /* We have to force a redraw of the units. And we explicitly have
1020 * to force a redraw of the focus unit, which is normally only
1021 * redrawn when the focus changes. We also have to force the 'more'
1022 * arrow to go away, both by expicitly hiding it and telling it to
1023 * do so (this will be reset immediately afterwards if necessary,
1024 * but we have to make the *internal* state consistent). */
1027 if (get_num_units_in_focus() == 1) {
1029 } else {
1030 set_unit_icon(-1, NULL);
1031 }
1033}
1034
1035/**********************************************************************/
1038#if 0
1040{
1045}
1046#endif
1047
1048/**********************************************************************/
1056
1057/**********************************************************************/
1061{
1062 struct option *opt = optset_option_by_name(server_optset, "fixedlength");
1063
1064 if (opt != NULL && option_bool_get(opt)) {
1066 _("Fixed length turns"));
1067 } else {
1068 char buf[256];
1069
1070 fc_snprintf(buf, sizeof(buf), "%s:\n%s",
1071 _("Turn Done"), _("Shift+Return"));
1073 }
1074}
1075
1076/**********************************************************************/
1079static void setup_widgets(void)
1080{
1081 GtkWidget *page, *hgrid, *hgrid2, *label;
1082 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1083 GtkWidget *button, *view, *mainbox, *vbox, *right_vbox = NULL;
1084 int i;
1085 GtkWidget *notebook, *statusbar;
1087 struct sprite *spr;
1088 int right_row = 0;
1089 int top_row = 0;
1090 int grid_col = 0;
1091 int grid2_col = 0;
1094 GtkWidget *ebar;
1095
1097
1098 notebook = gtk_notebook_new();
1099
1100 toplevel_tabs = notebook;
1105 gtk_box_append(GTK_BOX(mainbox), notebook);
1108
1119
1121
1127
1128 /* *** Everything in the top *** */
1129
1130 page = gtk_scrolled_window_new();
1135 TRUE);
1136 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1137
1142 hgrid = gtk_grid_new();
1143
1145 /* The window is divided into two horizontal panels: overview +
1146 * civinfo + unitinfo, main view + message window. */
1148 right_row = 0;
1152
1158
1159 /* Overview size designed for small displays (netbooks). */
1162 } else {
1163 /* The window is divided into two vertical panes: overview +
1164 * + civinfo + unitinfo + main view, message window. */
1169
1170 /* Overview size designed for big displays (desktops). */
1173 }
1174
1175 /* This holds the overview canvas, production info, etc. */
1177 /* Put vbox to the left of anything else in hgrid -- right_vbox is either
1178 * the chat/messages pane, or NULL which is OK */
1180 GTK_POS_LEFT, 1, 1);
1181 grid_col++;
1182
1183 /* Overview canvas */
1189
1197
1207
1209
1212
1215
1230
1231 /* The rest */
1238
1239 /* Info on player's civilization, when game is running. */
1240 frame = gtk_frame_new("");
1241 gtk_box_append(GTK_BOX(avbox), frame);
1242
1243 main_frame_civ_name = frame;
1244
1248
1249 label = gtk_label_new(NULL);
1253 gtk_widget_set_margin_end(label, 2);
1254 gtk_widget_set_margin_top(label, 2);
1256
1259 G_CALLBACK(show_info_popup), frame);
1262 main_label_info = label;
1263
1264 /* Production status */
1265 table = gtk_grid_new();
1269
1270 /* Citizens for taxrates */
1271 table2 = gtk_grid_new();
1272 gtk_grid_attach(GTK_GRID(table), table2, 0, 0, 10, 1);
1274
1275 for (i = 0; i < 10; i++) {
1277
1280
1283 g_signal_connect(controller, "pressed",
1289 g_signal_connect(controller, "pressed",
1293 }
1294
1295 /* Science, environmental, govt, timeout */
1297 if (spr != NULL) {
1299 } else {
1301 }
1302
1304 if (spr != NULL) {
1306 } else {
1308 }
1309
1311 if (spr != NULL) {
1313 } else {
1315 }
1316
1318 if (spr != NULL) {
1320 } else {
1322 }
1323
1324 for (i = 0; i < 4; i++) {
1325 GtkWidget *w;
1326
1327 switch (i) {
1328 case 0:
1329 w = bulb_label;
1330 break;
1331 case 1:
1332 w = sun_label;
1333 break;
1334 case 2:
1335 w = flake_label;
1336 break;
1337 default:
1338 case 3:
1339 w = government_label;
1340 break;
1341 }
1342
1349 gtk_grid_attach(GTK_GRID(table), w, i, 1, 1, 1);
1350 }
1351
1353
1354 frame = gtk_frame_new(NULL);
1355 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1357
1358
1359 /* Turn done */
1361
1363
1367
1368 /* Selected unit status */
1369
1370 /* If you turn this to something else than GtkBox, also adjust
1371 * editgui.c replace_widget() code that removes and adds widgets from it. */
1375
1376 /* In edit mode the unit_info_box widget is replaced by the
1377 * editinfobox, so we need to add a ref here so that it is
1378 * not destroyed when removed from its container.
1379 * See editinfobox_refresh() call to replace_widget() */
1381
1384
1390
1391 label = gtk_label_new(NULL);
1396 gtk_widget_set_margin_end(label, 2);
1397 gtk_widget_set_margin_top(label, 2);
1400 unit_info_label = label;
1401
1402 hgrid2 = gtk_grid_new();
1404
1405 table = gtk_grid_new();
1411
1414
1416
1417 /* Map canvas, editor toolbar, and scrollbars */
1418
1419 /* The top notebook containing the map view and dialogs. */
1420
1424
1425
1430 right_row = 0;
1433
1437 } else {
1439 }
1440
1442
1445
1452
1453 label = gtk_label_new(Q_("?noun:View"));
1455
1456 frame = gtk_frame_new(NULL);
1457 gtk_grid_attach(GTK_GRID(map_widget), frame, 0, 0, 1, 1);
1458
1464
1466
1467#if 0
1476#endif /* 0 */
1477
1479
1483
1487
1489 NULL, NULL);
1490
1494 g_signal_connect(mc_controller, "released",
1502 g_signal_connect(mc_controller, "released",
1521
1522 g_signal_connect(map_canvas, "resize",
1524
1526 g_signal_connect(mc_controller, "key-pressed",
1529
1530 /* *** The message window -- this is a detachable widget *** */
1531
1535 } else {
1537
1541
1545 }
1547
1550 } else {
1552 }
1559
1564
1571 }
1572 }
1573
1575
1578 TRUE);
1583
1584 label = gtk_label_new(_("Chat"));
1586
1593
1594 gtk_widget_set_name(text, "chatline");
1595
1597 gtk_widget_realize(text);
1599
1601 if (dtach_lowbox != NULL) {
1603 }
1604
1606
1607 /* The chat line */
1614
1615 button = gtk_check_button_new_with_label(_("Allies Only"));
1619 g_signal_connect(button, "toggled",
1623
1624 button = gtk_button_new_with_label(_("Clear links"));
1625 g_signal_connect(button, "clicked",
1628
1629 /* Other things to take care of */
1630
1632 TRUE);
1633
1636 }
1637
1640
1644 }
1645}
1646
1647/**********************************************************************/
1652 const gchar *message,
1653 gpointer user_data)
1654{
1655 enum log_level fllvl = LOG_ERROR;
1656
1657 switch (log_level) {
1658 case G_LOG_LEVEL_DEBUG:
1659 fllvl = LOG_DEBUG;
1660 break;
1662 fllvl = LOG_WARN;
1663 break;
1664 default:
1665 break;
1666 }
1667
1668 if (log_domain != NULL) {
1669 log_base(fllvl, "%s: %s", log_domain, message);
1670 } else {
1671 log_base(fllvl, "%s", message);
1672 }
1673}
1674
1675/**********************************************************************/
1679 const GLogField *fields,
1681 gpointer user_data)
1682{
1683 /* No need to have formatter of our own - let's use glib's default one. */
1685
1687
1688 return G_LOG_WRITER_HANDLED;
1689}
1690
1691/**********************************************************************/
1702
1703/**********************************************************************/
1706static void set_g_log_callbacks(void)
1707{
1708 /* Old API, still used by many log producers */
1710
1714
1715 /* glib >= 2.50 API */
1717}
1718
1719/**********************************************************************/
1730
1731/**********************************************************************/
1734int main(int argc, char **argv)
1735{
1736 return client_main(argc, argv, FALSE);
1737}
1738
1739/**********************************************************************/
1743{
1744 log_normal(_("Migrating options from gtk2 to gtk3 client"));
1745
1746#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1747#define MIGRATE_STR_OPTION(opt) \
1748 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1749 sizeof(gui_options.gui_gtk3_##opt));
1750
1751 /* Default theme name is never migrated */
1752 /* 'fullscreen', 'small_display_layout', and 'message_chat_location'
1753 * not migrated, as (unlike Gtk2), Gtk3-client tries to pick better
1754 * defaults for these in fresh installations based on screen size (see
1755 * adjust_default_options()); so user is probably better served by
1756 * getting these adaptive defaults than whatever they had for Gtk2.
1757 * Since 'fullscreen' isn't migrated, we don't need to worry about
1758 * preserving gui_gtk2_migrated_from_2_5 either. */
1772 MIGRATE_OPTION(popup_tech_help);
1773
1787
1788#undef MIGRATE_OPTION
1789#undef MIGRATE_STR_OPTION
1790
1792}
1793
1794/**********************************************************************/
1798{
1799 log_normal(_("Migrating options from gtk3 to gtk3.22 client"));
1800
1801#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_22_##opt = gui_options.gui_gtk3_##opt;
1802#define MIGRATE_STR_OPTION(opt) \
1803 strncpy(gui_options.gui_gtk3_22_##opt, gui_options.gui_gtk3_##opt, \
1804 sizeof(gui_options.gui_gtk3_22_##opt));
1805
1806 /* Default theme name is never migrated */
1807
1808 /* Simulate gui-gtk3's migrate_options_from_2_5() */
1810 log_normal(_("Migrating gtk3-client options from freeciv-2.5 options."));
1813 }
1814
1831 MIGRATE_OPTION(popup_tech_help);
1832
1846
1847#undef MIGRATE_OPTION
1848#undef MIGRATE_STR_OPTION
1849
1851}
1852
1853/**********************************************************************/
1857{
1858 log_normal(_("Migrating options from gtk3.22 to gtk4 client"));
1859
1860#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk3_22_##opt;
1861#define MIGRATE_STR_OPTION(opt) \
1862 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_22_##opt, \
1863 sizeof(GUI_GTK_OPTION(opt)));
1864
1865 /* Default theme name is never migrated */
1882 MIGRATE_OPTION(popup_tech_help);
1883
1897
1898#undef MIGRATE_OPTION
1899#undef MIGRATE_STR_OPTION
1900
1902}
1903
1904/**********************************************************************/
1907int ui_main(int argc, char **argv)
1908{
1909 if (parse_options(argc, argv)) {
1910 /* The locale has already been set in init_nls() and the windows-specific
1911 * locale logic in gtk_init() causes problems with zh_CN (see PR#39475) */
1913
1914 if (!gtk_init_check()) {
1915 log_fatal(_("Failed to open graphical mode."));
1916 return EXIT_FAILURE;
1917 }
1918
1920
1921 gui_up = TRUE;
1925 gui_up = FALSE;
1926
1935 cma_fe_done();
1937
1938 /* We have extra ref for unit_info_box that has protected
1939 * it from getting destroyed when editinfobox_refresh()
1940 * moves widgets around. Free that extra ref here. */
1942 if (empty_unit_paintable != NULL) {
1944 }
1945
1946 editgui_free();
1948 message_buffer = NULL; /* Result of destruction of everything */
1950 }
1951
1952 return EXIT_SUCCESS;
1953}
1954
1955/**********************************************************************/
1959{
1961 guint sig;
1963 char window_name[1024];
1964
1966 if (vmode.width > 0 && vmode.height > 0) {
1969 }
1970
1977
1979 gtk_widget_set_name(toplevel, "Freeciv");
1980
1982
1984
1985 if (gui_options.first_boot) {
1987 /* We're using fresh defaults for this version of this client,
1988 * so prevent any future migrations from other clients / versions */
1990 /* Avoid also marking previous Gtk clients as migrated, so that
1991 * they can have their own run of their adjust_default_options() if
1992 * they are ever run (as a side effect of Gtk2->Gtk3 migration). */
1993 } else {
1998 /* We want a fresh look at screen-size-related options after Gtk2 */
2000 /* We don't ever want to consider pre-2.6 fullscreen option again
2001 * (even for gui-gtk3) */
2003 }
2005 }
2007 }
2008 }
2009
2012 }
2013
2014 fc_snprintf(window_name, sizeof(window_name), _("Freeciv (%s)"), GUI_NAME_SHORT);
2016
2017 g_signal_connect(toplevel, "close-request",
2019
2020 /* Disable GTK cursor key focus movement */
2021 sig = g_signal_lookup("move-focus", GTK_TYPE_WIDGET);
2023 0, 0, 0, 0);
2025
2027 if (OT_FONT == option_type(poption)) {
2028 /* Force to call the appropriate callback. */
2030 }
2032
2035
2036 if (NULL == city_names_style) {
2038 log_error("city_names_style should have been set by options.");
2039 }
2042 log_error("city_productions_style should have been set by options.");
2043 }
2044 if (NULL == reqtree_text_style) {
2046 log_error("reqtree_text_style should have been set by options.");
2047 }
2048
2051
2052 /* Keep the icon of the executable on Windows (see PR#36491) */
2053#ifndef FREECIV_MSWINDOWS
2054 {
2055 /* Only call this after tileset_load_tiles is called. */
2057 }
2058#endif /* FREECIV_MSWINDOWS */
2059
2060 setup_widgets();
2061 load_cursors();
2062 cma_fe_init();
2069 chatline_init();
2071
2073
2075
2076 /* Assumes toplevel showing */
2078
2079 /* Assumes client_state is set */
2081}
2082
2083/**********************************************************************/
2086bool is_gui_up(void)
2087{
2088 return gui_up;
2089}
2090
2091/**********************************************************************/
2094void ui_exit(void)
2095{
2096 if (message_buffer != NULL) {
2099 }
2100}
2101
2102/**********************************************************************/
2105enum gui_type get_gui_type(void)
2106{
2107 return GUI_GTK4;
2108}
2109
2110/**********************************************************************/
2117
2118/**********************************************************************/
2124void set_unit_icon(int idx, struct unit *punit)
2125{
2126 GtkWidget *w;
2127
2128 fc_assert_ret(idx >= -1 && idx < num_units_below);
2129
2130 if (idx == -1) {
2131 w = unit_pic;
2132 unit_id_top = punit ? punit->id : 0;
2133 } else {
2134 w = unit_below_pic[idx];
2135 unit_ids[idx] = punit ? punit->id : 0;
2136 }
2137
2138 if (!w) {
2139 return;
2140 }
2141
2142 if (punit) {
2144 } else {
2145 if (empty_unit_paintable == NULL) {
2146 /* FIXME: Use proper icon height instead of hardcoded 50 */
2148
2149 /* Add ref to avoid it getting destroyed along any single parent widget. */
2151 }
2153 }
2154}
2155
2156/**********************************************************************/
2162{
2163 static bool showing = FALSE;
2164
2165 if (more_arrow == nullptr) {
2166 return;
2167 }
2168
2169 if (onoff && !showing) {
2171 showing = TRUE;
2172 } else if (!onoff && showing) {
2174 showing = FALSE;
2175 }
2176}
2177
2178/**********************************************************************/
2188
2189/**********************************************************************/
2194 double x, double y, gpointer data)
2195{
2196 int i = GPOINTER_TO_INT(data);
2197 struct unit *punit;
2198
2199 if (i == -1) {
2201 if (punit && unit_is_in_focus(punit)) {
2202 /* Clicking on the currently selected unit will center it. */
2204 }
2205 return TRUE;
2206 }
2207
2208 if (unit_ids[i] == 0) { /* No unit displayed at this place */
2209 return TRUE;
2210 }
2211
2213 if (NULL != punit && unit_owner(punit) == client_player()) {
2214 /* Unit shouldn't be NULL but may be owned by an ally. */
2216 }
2217
2218 return TRUE;
2219}
2220
2221/**********************************************************************/
2226 double x, double y, gpointer data)
2227{
2229
2230 if (punit) {
2232 }
2233
2234 return TRUE;
2235}
2236
2237/**********************************************************************/
2241{
2243}
2244
2245/**********************************************************************/
2249 double x, double y, gpointer data)
2250{
2251 GtkWidget *p;
2252 GtkWidget *child;
2253 GtkWidget *frame = GTK_WIDGET(data);
2254
2255 p = gtk_popover_new();
2256
2257 gtk_widget_set_parent(p, frame);
2260 g_signal_connect(p, "closed",
2263
2264 return TRUE;
2265}
2266
2267/**********************************************************************/
2275
2276/**********************************************************************/
2280 gpointer data)
2281{
2283
2284 return TRUE;
2285}
2286
2287/**********************************************************************/
2291 bool socket_writable)
2292{
2293 static bool previous_state = FALSE;
2294
2296
2298 return;
2299
2300 log_debug("set_wait_for_writable_socket(%d)", socket_writable);
2301
2306 NULL);
2307
2309}
2310
2311/**********************************************************************/
2315void add_net_input(int sock)
2316{
2317#ifdef FREECIV_MSWINDOWS
2319#else
2321#endif
2323 G_IO_IN | G_IO_ERR,
2325 NULL);
2327}
2328
2329/**********************************************************************/
2339
2340/**********************************************************************/
2344static void quit_dialog_response(GtkWidget *dialog, gint response)
2345{
2347 if (response == GTK_RESPONSE_YES) {
2349 if (client.conn.used) {
2351 }
2352 quit_gtk_main();
2353 }
2354}
2355
2356/**********************************************************************/
2360{
2361 /* Quit gtk main loop. After this it will return to finish
2362 * ui_main() */
2363
2365}
2366
2367/**********************************************************************/
2372{
2373 static GtkWidget *dialog;
2374
2375 if (!dialog) {
2377 0,
2380 _("Are you sure you want to quit?"));
2381 setup_dialog(dialog, toplevel);
2382
2383 g_signal_connect(dialog, "response",
2385 g_signal_connect(dialog, "destroy",
2386 G_CALLBACK(widget_destroyed), &dialog);
2387 }
2388
2390}
2391
2392/**********************************************************************/
2396{
2398 /* Stop emission of event. */
2399 return TRUE;
2400}
2401
2402struct callback {
2403 void (*callback)(void *data);
2404 void *data;
2405};
2406
2407/**********************************************************************/
2411{
2412 struct callback *cb = data;
2413
2414 (cb->callback)(cb->data);
2415 free(cb);
2416
2417 return FALSE;
2418}
2419
2420/**********************************************************************/
2425void add_idle_callback(void (callback)(void *), void *data)
2426{
2427 struct callback *cb = fc_malloc(sizeof(*cb));
2428
2429 cb->callback = callback;
2430 cb->data = data;
2432}
2433
2434/**********************************************************************/
2444
2445/**********************************************************************/
2450{
2451 GtkWidget *button;
2452
2454 fc_assert_ret(button != NULL);
2456
2459}
2460
2461/**********************************************************************/
2472
2473/**********************************************************************/
2483
2484/**********************************************************************/
2494
2495/**********************************************************************/
2505
2506/**********************************************************************/
2511{
2512 struct option *poption;
2513
2514#define option_var_set_callback(var, callback) \
2515 if ((poption = optset_option_by_name(client_optset, \
2516 GUI_GTK_OPTION_STR(var)))) { \
2517 option_set_changed_callback(poption, callback); \
2518 } else { \
2519 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2520 }
2521
2526
2533#undef option_var_set_callback
2534}
2535
2536/**********************************************************************/
2541{
2542 GtkWidget *button;
2543
2545 fc_assert_ret(button != nullptr);
2547
2548 /* Hide the "Allies Only" button for local games. */
2549 if (is_server_running()) {
2551 } else {
2555 }
2556}
2557
2558/**********************************************************************/
2566
2567/**********************************************************************/
2571{
2572 cat_snprintf(outbuf, outlen, _("\nBuilt against gtk %d.%d.%d, using %d.%d.%d"
2573 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2578}
2579
2580/**********************************************************************/
2585{
2588
2590 if (!display) {
2591 return FALSE;
2592 }
2593
2595
2596 if (!monitor) {
2597 return FALSE;
2598 }
2599
2601
2602 return TRUE;
2603}
2604
2605/**********************************************************************/
2609{
2610 GdkRectangle rect;
2611
2612 if (vmode.width > 0) {
2613 return vmode.width;
2614 }
2615
2616 if (monitor_size(&rect)) {
2617 return rect.width;
2618 } else {
2619 return 0;
2620 }
2621}
2622
2623/**********************************************************************/
2627{
2628 GdkRectangle rect;
2629
2630 if (vmode.height > 0) {
2631 return vmode.height;
2632 }
2633
2634 if (monitor_size(&rect)) {
2635 return rect.height;
2636 } else {
2637 return 0;
2638 }
2639}
2640
2641/**********************************************************************/
2645{
2646 if (vmode.width > 0 && vmode.height > 0) {
2647 return &vmode;
2648 }
2649
2650 return NULL;
2651}
2652
2653/**********************************************************************/
2656static void adjust_default_options(void)
2657{
2658 int scr_height = screen_height();
2659
2660 if (scr_height > 0) {
2661 /* Adjust these options only if we do know the screen height. */
2662
2663 if (scr_height <= 480) {
2664 /* Freeciv is practically unusable outside fullscreen mode in so
2665 * small display */
2666 log_verbose("Changing default to fullscreen due to very small screen");
2668 }
2669 if (scr_height < 1024) {
2670 /* This is a small display */
2671 log_verbose("Defaulting to small widget layout due to small screen");
2673 log_verbose("Defaulting to merged messages/chat due to small screen");
2675 }
2676 }
2677}
2678
2679/**********************************************************************/
2683{
2684 return fc_app;
2685}
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:1306
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:74
bool is_server_running(void)
void key_recall_previous_focus_unit(void)
Definition control.c:3293
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:383
void key_cancel_action(void)
Definition control.c:3231
int num_units_below
Definition control.c:76
void unit_focus_set(struct unit *punit)
Definition control.c:501
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void key_end_turn(void)
Definition control.c:3285
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:967
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3314
enum cursor_hover_state hover_state
Definition control.c:89
struct unit * head_of_units_in_focus(void)
Definition control.c:405
int get_num_units_in_focus(void)
Definition control.c:185
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1189
void key_center_capital(void)
Definition control.c:3268
#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:1204
void diplomacy_dialog_done(void)
Definition diplodlg.c:1213
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:109
int ui_main(int argc, char **argv)
Definition gui_main.c:1910
const char * client_string
Definition gui_main.c:105
GtkTextBuffer * message_buffer
Definition gui_main.c:178
static void quit_dialog_response(GtkWidget *dialog, gint response)
Definition gui_main.c:2345
void real_focus_units_changed(void)
Definition gui_main.c:2172
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2149
static void print_usage(void)
Definition gui_main.c:265
#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK
Definition gui_main.c:116
#define option_var_set_callback(var, callback)
static gboolean quit_dialog_callback(void)
Definition gui_main.c:2398
static GIOChannel * srv_channel
Definition gui_main.c:182
GtkWidget * main_label_info
Definition gui_main.c:138
static bool monitor_size(GdkRectangle *rect_p)
Definition gui_main.c:2576
GtkWidget * bottom_notebook
Definition gui_main.c:129
GtkWidget * unit_info_label
Definition gui_main.c:151
static gboolean timer_callback(gpointer data)
Definition gui_main.c:242
struct video_mode * resolution_request_get(void)
Definition gui_main.c:2634
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2119
static int unit_ids[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:175
GtkWidget * timeout_label
Definition gui_main.c:148
static bool gui_up
Definition gui_main.c:186
static guint srv_id
Definition gui_main.c:183
static gboolean mouse_scroll_mapcanvas(GtkWidget *w, GdkEventScroll *ev)
Definition gui_main.c:706
PangoFontDescription * city_productions_style
Definition gui_main.c:134
GtkWidget * overview_scrolled_window
Definition gui_main.c:112
static GtkWidget * detached_widget_fill(GtkWidget *tearbox)
Definition gui_main.c:868
GtkWidget * top_notebook
Definition gui_main.c:129
#define MIGRATE_STR_OPTION(opt)
GtkWidget * unit_info_box
Definition gui_main.c:152
gboolean fc_lost_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:758
void ui_exit(void)
Definition gui_main.c:2089
enum gui_type get_gui_type(void)
Definition gui_main.c:2100
static GtkWidget * detached_widget_new(void)
Definition gui_main.c:857
gint cur_y
Definition gui_main.c:184
int main(int argc, char **argv)
Definition gui_main.c:1788
void fullscreen_opt_refresh(struct option *poption)
Definition gui_main.c:2456
void ui_init(void)
Definition gui_main.c:1778
static void free_unit_table(void)
Definition gui_main.c:1018
static gboolean idle_callback_wrapper(gpointer data)
Definition gui_main.c:2413
static void apply_city_names_font(struct option *poption)
Definition gui_main.c:2468
static void apply_city_productions_font(struct option *poption)
Definition gui_main.c:2479
gboolean fc_gained_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:768
GtkWidget * government_label
Definition gui_main.c:147
GtkWidget * sun_label
Definition gui_main.c:145
PangoFontDescription * city_names_style
Definition gui_main.c:133
void refresh_chat_buttons(void)
Definition gui_main.c:2532
gboolean map_canvas_focus(void)
Definition gui_main.c:382
GtkWidget * turn_done_button
Definition gui_main.c:149
static GtkWidget * bottom_hpaned
Definition gui_main.c:131
static gint timer_id
Definition gui_main.c:181
int screen_width(void)
Definition gui_main.c:2598
GtkWidget * scroll_panel
Definition gui_main.c:141
static void end_turn_callback(GtkWidget *w, gpointer data)
Definition gui_main.c:2271
#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK
Definition gui_main.c:117
static void log_callback_utf8(enum log_level level, const char *message, bool file_too)
Definition gui_main.c:230
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2428
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2240
static void set_g_log_callbacks(void)
Definition gui_main.c:1762
void reset_unit_table(void)
Definition gui_main.c:1046
static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:423
GtkWidget * unit_info_frame
Definition gui_main.c:153
void options_extra_init(void)
Definition gui_main.c:2502
GtkWidget * top_vbox
Definition gui_main.c:128
static void allied_chat_only_callback(struct option *poption)
Definition gui_main.c:2441
static void adjust_default_options(void)
Definition gui_main.c:2646
static void set_wait_for_writable_socket(struct connection *pc, bool socket_writable)
Definition gui_main.c:2291
GtkWidget * ahbox
Definition gui_main.c:140
static void apply_reqtree_text_font(struct option *poption)
Definition gui_main.c:2490
bool is_gui_up(void)
Definition gui_main.c:2081
static gboolean toplevel_focus(GtkWidget *w, GtkDirectionType arg)
Definition gui_main.c:338
PangoFontDescription * reqtree_text_style
Definition gui_main.c:135
GtkWidget * flake_label
Definition gui_main.c:146
static void g_log_to_freelog_cb(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
Definition gui_main.c:1706
GtkWidget * avbox
Definition gui_main.c:140
gint cur_x
Definition gui_main.c:184
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2562
static void set_g_log_callback_domain(const char *domain)
Definition gui_main.c:1750
GtkWidget * bulb_label
Definition gui_main.c:144
GtkWidget * overview_canvas
Definition gui_main.c:111
GtkWidget * toplevel
Definition gui_main.c:125
static void setup_widgets(void)
Definition gui_main.c:1150
#define OVERVIEW_CANVAS_STORE_WIDTH
Definition gui_main.c:118
void remove_net_input(void)
Definition gui_main.c:2334
GtkWidget * map_horizontal_scrollbar
Definition gui_main.c:108
GtkWidget * map_canvas
Definition gui_main.c:107
static gboolean toplevel_key_press_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:622
void sound_bell(void)
Definition gui_main.c:2108
static void migrate_options_from_gtk2(void)
Definition gui_main.c:1796
GtkWidget * econ_label[10]
Definition gui_main.c:143
void popup_quit_dialog(void)
Definition gui_main.c:2372
static void migrate_options_from_gtk3(void)
Definition gui_main.c:1851
const char *const gui_character_encoding
Definition gui_main.c:161
static int unit_id_top
Definition gui_main.c:174
static gboolean get_net_input(GIOChannel *source, GIOCondition condition, gpointer data)
Definition gui_main.c:2280
static bool audio_paused
Definition gui_main.c:188
GtkWidget * map_widget
Definition gui_main.c:130
static bool client_focus
Definition gui_main.c:189
GtkWidget * right_notebook
Definition gui_main.c:129
void quit_gtk_main(void)
Definition gui_main.c:2360
static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data)
Definition gui_main.c:2553
static struct video_mode vmode
Definition gui_main.c:191
void add_net_input(int sock)
Definition gui_main.c:2316
static GLogWriterOutput g_log_writer_to_freelog_cb(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data)
Definition gui_main.c:1734
GtkWidget * toplevel_tabs
Definition gui_main.c:127
static GtkWidget * allied_chat_toggle_button
Definition gui_main.c:179
int overview_canvas_store_width
Definition gui_main.c:122
void update_turn_done_tooltip(void)
Definition gui_main.c:1131
static void tearoff_callback(GtkWidget *b, gpointer data)
Definition gui_main.c:812
GtkTextView * main_message_area
Definition gui_main.c:177
int overview_canvas_store_height
Definition gui_main.c:123
int screen_height(void)
Definition gui_main.c:2616
static bool parse_options(int argc, char **argv)
Definition gui_main.c:295
GtkWidget * conn_box
Definition gui_main.c:140
#define OVERVIEW_CANVAS_STORE_HEIGHT
Definition gui_main.c:120
GtkWidget * main_frame_civ_name
Definition gui_main.c:137
#define MIGRATE_OPTION(opt)
const bool gui_use_transliteration
Definition gui_main.c:162
#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:2621
GtkWidget * create_network_page(void)
Definition pages.c:1199
GtkWidget * create_scenario_page(void)
Definition pages.c:3183
static GtkWidget * statusbar
Definition pages.c:89
enum client_pages get_current_client_page(void)
Definition pages.c:3343
void destroy_server_scans(void)
Definition pages.c:766
GtkWidget * create_load_page(void)
Definition pages.c:2902
GtkWidget * create_statusbar(void)
Definition pages.c:907
GtkWidget * create_main_page(void)
Definition pages.c:229
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:159
static void tearoff_close(GtkWidget *w, gpointer data)
Definition gui_main.c:790
static void tearoff_reattach(GtkWidget *box)
Definition gui_main.c:773
gboolean terminate_signal_processing(GtkEventControllerFocus *controller, gpointer data)
Definition gui_main.c:1051
static GtkWidget * more_arrow_container
Definition gui_main.c:164
static GtkWidget * unit_pic
Definition gui_main.c:161
static gboolean select_more_arrow_callback(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition gui_main.c:2225
GtkWidget * econ_widget
Definition gui_main.c:154
static GtkApplication * fc_app
Definition gui_main.c:183
GtkApplication * gui_app(void)
Definition gui_main.c:2682
static GtkWidget * more_arrow
Definition gui_main.c:163
static float zoom_steps_custom[]
Definition gui_main.c:227
static void migrate_options_from_gtk3_22(void)
Definition gui_main.c:1856
void animation_idle_cb(void *data)
Definition gui_main.c:2437
static void activate_gui(GtkApplication *app, gpointer data)
Definition gui_main.c:1958
static void populate_unit_pic_table(void)
Definition gui_main.c:890
static void info_popup_closed(GtkWidget *self, gpointer data)
Definition gui_main.c:2240
static void move_from_container_to_container(GtkWidget *wdg, GtkWidget *old_wdg, GtkWidget *new_wdg)
Definition gui_main.c:718
static gboolean select_unit_pic_callback(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition gui_main.c:2193
static GtkWidget * unit_pic_table
Definition gui_main.c:160
static GtkWidget * unit_below_pic[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:162
void main_message_area_resize(void *data)
Definition gui_main.c:368
void widget_destroyed(GtkWidget *wdg, void *data)
Definition gui_stuff.c:1155
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
log_callback_fn log_set_callback(log_callback_fn callback)
Definition log.c:290
#define fc_assert_ret(condition)
Definition log.h:191
#define log_verbose(message,...)
Definition log.h:109
#define fc_assert(condition)
Definition log.h:176
#define log_fatal(message,...)
Definition log.h:100
#define log_debug(message,...)
Definition log.h:115
#define log_normal(message,...)
Definition log.h:107
#define log_base(level, message,...)
Definition log.h:94
log_level
Definition log.h:28
@ LOG_ERROR
Definition log.h:30
@ LOG_DEBUG
Definition log.h:34
@ LOG_FATAL
Definition log.h:29
@ LOG_WARN
Definition log.h:31
#define log_error(message,...)
Definition log.h:103
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:783
const struct option_set * server_optset
Definition options.c:4281
const struct option_set * client_optset
Definition options.c:1315
bool option_bool_get(const struct option *poption)
Definition options.c:832
enum option_type option_type(const struct option *poption)
Definition options.c:693
const char * option_font_target(const struct option *poption)
Definition options.c:1198
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6761
struct client_options gui_options
Definition options.c:71
const char * option_font_get(const struct option *poption)
Definition options.c:1176
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:466
@ 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:635
#define options_iterate(poptset, poption)
Definition options.h:588
#define options_iterate_end
Definition options.h:593
const char * get_info_label_text_popup(void)
Definition text.c:982
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:2407
void(* callback)(void *data)
Definition gui_main.c:2406
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_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
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:3662
void tileset_free_tiles(struct tileset *t)
Definition tilespec.c:6643
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7108
void tileset_init(struct tileset *t)
Definition tilespec.c:7169
struct sprite * get_arrow_sprite(const struct tileset *t, enum arrow_type arrow)
Definition tilespec.c:6907
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:6918
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:754
@ ARROW_RIGHT
Definition tilespec.h:202
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
float mouse_zoom
Definition zoom.c:28
void zoom_phase_set(bool individual_tiles)
Definition zoom.c:97
void zoom_set_steps(float *steps)
Definition zoom.c:84
void zoom_step_down(void)
Definition zoom.c:134
void zoom_step_up(void)
Definition zoom.c:110