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-4.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
185
186static struct video_mode vmode = { -1, -1 };
187
188static void set_g_log_callbacks(void);
189
191 double x, double y, gpointer data);
192
193static void end_turn_callback(GtkWidget *w, gpointer data);
195 gpointer data);
196static void set_wait_for_writable_socket(struct connection *pc,
197 bool socket_writable);
198
199static void print_usage(void);
200static void activate_gui(GtkApplication *app, gpointer data);
201static bool parse_options(int argc, char **argv);
205 GdkModifierType state,
206 gpointer data);
208 gdouble dx, gdouble dy,
209 gpointer data);
210
211static void tearoff_callback(GtkWidget *b, gpointer data);
212static GtkWidget *detached_widget_new(void);
214
216 double x, double y, gpointer data);
218 double x, double y, gpointer data);
219static gboolean quit_dialog_callback(void);
220
222 gpointer user_data);
223
224static void free_unit_table(void);
225
226static void adjust_default_options(void);
227
228static float zoom_steps_custom[] = {
229 -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
230};
231
232/**********************************************************************/
235static void log_callback_utf8(enum log_level level, const char *message,
236 bool file_too)
237{
238 if (!file_too || level <= LOG_FATAL) {
239 fc_fprintf(stderr, "%d: %s\n", level, message);
240 }
241}
242
243/**********************************************************************/
248{
249 double seconds = real_timer_callback();
250
252 if (!audio_paused && !client_focus) {
253 audio_pause();
255 } else if (audio_paused && client_focus) {
256 audio_resume();
258 }
259 }
260
262
263 return FALSE;
264}
265
266/**********************************************************************/
270static void print_usage(void)
271{
272 /* Add client-specific usage information here */
274 _("gtk4-client gui-specific options are:\n"));
275
277 _("-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
278 "screen\n"));
280 /* TRANS: Keep word 'default' untranslated */
281 _("-z, --zoom LEVEL\tSet zoom level; use value 'default' "
282 "to reset\n\n"));
283
284 /* TRANS: No full stop after the URL, could cause confusion. */
285 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
286}
287
288/**********************************************************************/
291static bool parse_options(int argc, char **argv)
292{
293 int i = 1;
294
295 while (i < argc) {
296 char *option = NULL;
297
298 if (is_option("--help", argv[i])) {
299 print_usage();
300
301 return FALSE;
302 } else if ((option = get_option_malloc("--zoom", argv, &i, argc, FALSE))) {
303 char *endptr;
304
305 if (strcmp("default", option)) {
308 } else {
310 }
311 free(option);
312 } else if ((option = get_option_malloc("--resolution", argv, &i, argc, FALSE))) {
314 fc_fprintf(stderr, _("Illegal video mode '%s'\n"), option);
316 }
317 free(option);
318 } else {
319 fc_fprintf(stderr, _("Unknown command-line option \"%s\".\n"),
320 argv[i]);
322 }
323
324 i++;
325 }
326
327 return TRUE;
328}
329
330/**********************************************************************/
334 gpointer data)
335{
336 switch (arg) {
339
340 if (!gtk_widget_get_can_focus(w)) {
341 return;
342 }
343
344 if (!gtk_widget_is_focus(w)) {
346 return;
347 }
348 break;
349
350 default:
351 break;
352 }
353}
354
355/**********************************************************************/
377
378/**********************************************************************/
389
390/**********************************************************************/
394{
395 if ((state & GDK_SHIFT_MASK)) {
396 switch (keyval) {
397
398 case GDK_KEY_Left:
400 return TRUE;
401
402 case GDK_KEY_Right:
404 return TRUE;
405
406 case GDK_KEY_Up:
408 return TRUE;
409
410 case GDK_KEY_Down:
412 return TRUE;
413
414 case GDK_KEY_Home:
416 return TRUE;
417
418 case GDK_KEY_Page_Up:
421 return TRUE;
422
426 return TRUE;
427
428 default:
429 break;
430 }
431 } else if (!(state & GDK_CONTROL_MASK)) {
432 switch (keyval) {
433 default:
434 break;
435 }
436 }
437
438 if (state & GDK_SHIFT_MASK) {
439 bool volchange = FALSE;
440
441 switch (keyval) {
442 case GDK_KEY_plus:
443 case GDK_KEY_KP_Add:
445 volchange = TRUE;
446 break;
447
448 case GDK_KEY_minus:
451 volchange = TRUE;
452 break;
453
454 default:
455 break;
456 }
457
458 if (volchange) {
460 "sound_effects_volume");
461
464 100);
466
467 return TRUE;
468 }
469 } else if (!(state & GDK_CONTROL_MASK)) {
470 switch (keyval) {
471 case GDK_KEY_plus:
472 case GDK_KEY_KP_Add:
473 zoom_step_up();
474 return TRUE;
475
476 case GDK_KEY_minus:
479 return TRUE;
480
481 default:
482 break;
483 }
484 }
485
486 /* Return here if observer */
487 if (client_is_observer()) {
488 return FALSE;
489 }
490
491 switch (keyval) {
492
493 case GDK_KEY_KP_Up:
494 case GDK_KEY_KP_8:
495 case GDK_KEY_Up:
496 case GDK_KEY_8:
498 return TRUE;
499
501 case GDK_KEY_KP_9:
502 case GDK_KEY_Page_Up:
503 case GDK_KEY_9:
505 return TRUE;
506
507 case GDK_KEY_KP_Right:
508 case GDK_KEY_KP_6:
509 case GDK_KEY_Right:
510 case GDK_KEY_6:
512 return TRUE;
513
515 case GDK_KEY_KP_3:
517 case GDK_KEY_3:
519 return TRUE;
520
521 case GDK_KEY_KP_Down:
522 case GDK_KEY_KP_2:
523 case GDK_KEY_Down:
524 case GDK_KEY_2:
526 return TRUE;
527
528 case GDK_KEY_KP_End:
529 case GDK_KEY_KP_1:
530 case GDK_KEY_End:
531 case GDK_KEY_1:
533 return TRUE;
534
535 case GDK_KEY_KP_Left:
536 case GDK_KEY_KP_4:
537 case GDK_KEY_Left:
538 case GDK_KEY_4:
540 return TRUE;
541
542 case GDK_KEY_KP_Home:
543 case GDK_KEY_KP_7:
544 case GDK_KEY_Home:
545 case GDK_KEY_7:
547 return TRUE;
548
549 case GDK_KEY_KP_Begin:
550 case GDK_KEY_KP_5:
551 case GDK_KEY_5:
553 return TRUE;
554
555 case GDK_KEY_Escape:
557 return TRUE;
558
559 case GDK_KEY_b:
562 return TRUE;
563 }
564 break;
565
566 default:
567 break;
568 };
569
570 return FALSE;
571}
572
573/**********************************************************************/
579 GdkModifierType state,
580 gpointer data)
581{
582 if (inputline_has_focus()) {
583 return FALSE;
584 }
585
586 if (keyval == GDK_KEY_apostrophe) {
587 /* Allow this even if not in main map view; chatline is present on
588 * some other pages too */
589
590 /* Make the chatline visible if it's not currently.
591 * FIXME: should find the correct window, even when detached, from any
592 * other window; should scroll to the bottom automatically showing the
593 * latest text from other players; MUST NOT make spurious text windows
594 * at the bottom of other dialogs. */
596 /* The main game view is visible. May need to switch notebook. */
599 } else {
601 }
602 }
603
604 /* If the chatline is (now) visible, focus it. */
605 if (inputline_is_visible()) {
607 return TRUE;
608 }
609 }
610
613 return FALSE;
614 }
615
616 if (editor_is_active()) {
617 if (handle_edit_key_press(keyval, state)) {
618 return TRUE;
619 }
620 }
621
622 if (state & GDK_SHIFT_MASK) {
623 switch (keyval) {
624
625 case GDK_KEY_Return:
626 case GDK_KEY_KP_Enter:
627 key_end_turn();
628 return TRUE;
629
630 default:
631 break;
632 }
633 }
634
636 /* 0 means the map view is focused. */
637 return key_press_map_canvas(keyval, state);
638 }
639
640#if 0
641 /* We are focused some other dialog, tab, or widget. */
642 if ((state & GDK_CONTROL_MASK)) {
643 } else if ((state & GDK_SHIFT_MASK)) {
644 } else {
645 switch (keyval) {
646
647 case GDK_KEY_F4:
649 return TRUE;
650
651 default:
652 break;
653 };
654 }
655#endif /* 0 */
656
657 return FALSE;
658}
659
660/**********************************************************************/
706
707/**********************************************************************/
713{
714 g_object_ref(wdg); /* Make sure reference count stays above 0
715 * during the transition to new parent. */
716
717 if (GTK_IS_PANED(old_wdg)) {
719 } else if (GTK_IS_WINDOW(old_wdg)) {
721 } else {
723
725 }
726
727 if (GTK_IS_PANED(new_wdg)) {
729 } else if (GTK_IS_WINDOW(new_wdg)) {
731 } else {
733
735 }
736
738}
739
740/**********************************************************************/
750
751/**********************************************************************/
761
762/**********************************************************************/
766{
768
769 aparent = g_object_get_data(G_OBJECT(box), "aparent");
771
772 if (aparent != cparent) {
774
776 }
777}
778
779/**********************************************************************/
782static void tearoff_close(GtkWidget *w, gpointer data)
783{
785}
786
787/**********************************************************************/
792{
793 GtkWidget *box = GTK_WIDGET(data);
795
797 GtkWidget *w;
799
800 w = gtk_window_new();
802 gtk_widget_set_name(w, "Freeciv");
803 gtk_window_set_title(GTK_WINDOW(w), _("Freeciv"));
804 g_signal_connect(w, "close-request", G_CALLBACK(tearoff_close), box);
805
806 g_object_set_data(G_OBJECT(box), "aparent", gtk_widget_get_parent(box));
807
808 temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent");
809 if (temp_hide != nullptr) {
811 }
812
814
816
817 if (temp_hide != nullptr) {
819 }
820 } else {
821 tearoff_reattach(box);
822 }
823}
824
825/**********************************************************************/
829{
831
832 return hbox;
833}
834
835/**********************************************************************/
840{
841 GtkWidget *b, *fillbox;
843
846
847 /* These toggle buttons run vertically down the side of many UI
848 * elements, so they need to be thin horizontally. */
850 ".detach_button {\n"
851 " padding: 0px 0px 0px 0px;\n"
852 " min-width: 6px;\n"
853 "}",
854 -1);
855 }
856
862 gtk_widget_add_css_class(b, "detach_button");
863 gtk_widget_set_tooltip_text(b, _("Detach/Attach the pane."));
864
867
869
871
872 return fillbox;
873}
874
875/**********************************************************************/
882static void populate_unit_pic_table(void)
883{
884 int i, width;
886 GdkPixbuf *pix;
887 int ttw;
889
890 /* Get width of the overview window */
894
896
898 /* We want arrow to appear if there is other units in addition
899 to active one in tile. Active unit is not counted, so there
900 can be 0 other units to not to display arrow. */
901 num_units_below = 1 - 1;
902 } else {
905 }
906
907 /* Top row: the active unit. */
908 /* Note, we ref this and other widgets here so that we can unref them
909 * in reset_unit_table. */
913 gtk_grid_attach(GTK_GRID(table), unit_pic, 0, 0, 1, 1);
914
916 g_signal_connect(controller, "pressed",
918 GINT_TO_POINTER(-1));
920
922 /* Bottom row: other units in the same tile. */
923 for (i = 0; i < num_units_below; i++) {
927
929 g_signal_connect(controller, "pressed",
933
935 i, 1, 1, 1);
936 }
937 }
938
939 /* Create arrow (popup for all units on the selected tile) */
943
945 g_signal_connect(controller, "pressed",
947 NULL);
949
950 /* An extra layer so that we can hide the clickable button but keep
951 * an explicit size request to avoid the layout jumping around */
958 gdk_pixbuf_get_width(pix), -1);
960
962 /* Display on bottom row. */
964 num_units_below, 1, 1, 1);
965 } else {
966 /* Display on top row (there is no bottom row). */
968 1, 0, 1, 1);
969 }
970
972}
973
974/**********************************************************************/
997
998/**********************************************************************/
1002{
1003 /* Unreference all of the widgets that we're about to reallocate, thus
1004 * avoiding a memory leak. Remove them from the container first, just
1005 * to be safe. Note, the widgets are ref'd in
1006 * populate_unit_pic_table(). */
1008
1010
1011 /* We have to force a redraw of the units. And we explicitly have
1012 * to force a redraw of the focus unit, which is normally only
1013 * redrawn when the focus changes. We also have to force the 'more'
1014 * arrow to go away, both by expicitly hiding it and telling it to
1015 * do so (this will be reset immediately afterwards if necessary,
1016 * but we have to make the *internal* state consistent). */
1019 if (get_num_units_in_focus() == 1) {
1021 } else {
1022 set_unit_icon(-1, NULL);
1023 }
1025}
1026
1027/**********************************************************************/
1030#if 0
1032{
1037}
1038#endif
1039
1040/**********************************************************************/
1048
1049/**********************************************************************/
1053{
1054 struct option *opt = optset_option_by_name(server_optset, "fixedlength");
1055
1056 if (opt != NULL && option_bool_get(opt)) {
1058 _("Fixed length turns"));
1059 } else {
1060 char buf[256];
1061
1062 fc_snprintf(buf, sizeof(buf), "%s:\n%s",
1063 _("Turn Done"), _("Shift+Return"));
1065 }
1066}
1067
1068/**********************************************************************/
1071static void setup_widgets(void)
1072{
1073 GtkWidget *page, *hgrid, *hgrid2, *label;
1074 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1075 GtkWidget *button, *view, *mainbox, *vbox, *right_vbox = NULL;
1076 int i;
1077 GtkWidget *notebook, *statusbar;
1079 struct sprite *spr;
1080 int right_row = 0;
1081 int top_row = 0;
1082 int grid_col = 0;
1083 int grid2_col = 0;
1086 GtkWidget *ebar;
1087
1089
1090 notebook = gtk_notebook_new();
1091
1092 toplevel_tabs = notebook;
1097 gtk_box_append(GTK_BOX(mainbox), notebook);
1100
1111
1113
1119
1120 /* *** Everything in the top *** */
1121
1122 page = gtk_scrolled_window_new();
1127 TRUE);
1128 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1129
1134 hgrid = gtk_grid_new();
1135
1137 /* The window is divided into two horizontal panels: overview +
1138 * civinfo + unitinfo, main view + message window. */
1140 right_row = 0;
1144
1150
1151 /* Overview size designed for small displays (netbooks). */
1154 } else {
1155 /* The window is divided into two vertical panes: overview +
1156 * + civinfo + unitinfo + main view, message window. */
1161
1162 /* Overview size designed for big displays (desktops). */
1165 }
1166
1167 /* This holds the overview canvas, production info, etc. */
1169 /* Put vbox to the left of anything else in hgrid -- right_vbox is either
1170 * the chat/messages pane, or NULL which is OK */
1172 GTK_POS_LEFT, 1, 1);
1173 grid_col++;
1174
1175 /* Overview canvas */
1181
1189
1199
1201
1204
1207
1222
1223 /* The rest */
1230
1231 /* Info on player's civilization, when game is running. */
1232 frame = gtk_frame_new("");
1233 gtk_box_append(GTK_BOX(avbox), frame);
1234
1235 main_frame_civ_name = frame;
1236
1240
1241 label = gtk_label_new(NULL);
1245 gtk_widget_set_margin_end(label, 2);
1246 gtk_widget_set_margin_top(label, 2);
1248
1251 G_CALLBACK(show_info_popup), frame);
1254 main_label_info = label;
1255
1256 /* Production status */
1257 table = gtk_grid_new();
1261
1262 /* Citizens for taxrates */
1263 table2 = gtk_grid_new();
1264 gtk_grid_attach(GTK_GRID(table), table2, 0, 0, 10, 1);
1266
1267 for (i = 0; i < 10; i++) {
1269
1272
1275 g_signal_connect(controller, "pressed",
1281 g_signal_connect(controller, "pressed",
1285 }
1286
1287 /* Science, environmental, govt, timeout */
1289 if (spr != NULL) {
1291 } else {
1293 }
1294
1296 if (spr != NULL) {
1298 } else {
1300 }
1301
1303 if (spr != NULL) {
1305 } else {
1307 }
1308
1310 if (spr != NULL) {
1312 } else {
1314 }
1315
1316 for (i = 0; i < 4; i++) {
1317 GtkWidget *w;
1318
1319 switch (i) {
1320 case 0:
1321 w = bulb_label;
1322 break;
1323 case 1:
1324 w = sun_label;
1325 break;
1326 case 2:
1327 w = flake_label;
1328 break;
1329 default:
1330 case 3:
1331 w = government_label;
1332 break;
1333 }
1334
1341 gtk_grid_attach(GTK_GRID(table), w, i, 1, 1, 1);
1342 }
1343
1345
1346 frame = gtk_frame_new(NULL);
1347 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1349
1350
1351 /* Turn done */
1353
1355
1359
1360 /* Selected unit status */
1361
1362 /* If you turn this to something else than GtkBox, also adjust
1363 * editgui.c replace_widget() code that removes and adds widgets from it. */
1367
1368 /* In edit mode the unit_info_box widget is replaced by the
1369 * editinfobox, so we need to add a ref here so that it is
1370 * not destroyed when removed from its container.
1371 * See editinfobox_refresh() call to replace_widget() */
1373
1376
1382
1383 label = gtk_label_new(NULL);
1388 gtk_widget_set_margin_end(label, 2);
1389 gtk_widget_set_margin_top(label, 2);
1392 unit_info_label = label;
1393
1394 hgrid2 = gtk_grid_new();
1396
1397 table = gtk_grid_new();
1403
1406
1408
1409 /* Map canvas, editor toolbar, and scrollbars */
1410
1411 /* The top notebook containing the map view and dialogs. */
1412
1416
1417
1422 right_row = 0;
1425
1429 } else {
1431 }
1432
1434
1437
1444
1445 label = gtk_label_new(Q_("?noun:View"));
1447
1448 frame = gtk_frame_new(NULL);
1449 gtk_grid_attach(GTK_GRID(map_widget), frame, 0, 0, 1, 1);
1450
1456
1458
1459#if 0
1468#endif /* 0 */
1469
1471
1475
1479
1481 NULL, NULL);
1482
1486 g_signal_connect(mc_controller, "released",
1494 g_signal_connect(mc_controller, "released",
1513
1514 g_signal_connect(map_canvas, "resize",
1516
1518 g_signal_connect(mc_controller, "key-pressed",
1521
1522 /* *** The message window -- this is a detachable widget *** */
1523
1527 } else {
1529
1533
1537 }
1539
1542 } else {
1544 }
1551
1556
1563 }
1564 }
1565
1567
1570 TRUE);
1575
1576 label = gtk_label_new(_("Chat"));
1578
1585
1586 gtk_widget_set_name(text, "chatline");
1587
1589 gtk_widget_realize(text);
1591
1593 if (dtach_lowbox != NULL) {
1595 }
1596
1598
1599 /* The chat line */
1606
1607 button = gtk_check_button_new_with_label(_("Allies Only"));
1611 g_signal_connect(button, "toggled",
1615
1616 button = gtk_button_new_with_label(_("Clear links"));
1617 g_signal_connect(button, "clicked",
1620
1621 /* Other things to take care of */
1622
1624 TRUE);
1625
1628 }
1629
1632
1636 }
1637}
1638
1639/**********************************************************************/
1644 const gchar *message,
1645 gpointer user_data)
1646{
1647 enum log_level fllvl = LOG_ERROR;
1648
1649 switch (log_level) {
1650 case G_LOG_LEVEL_DEBUG:
1651 fllvl = LOG_DEBUG;
1652 break;
1654 fllvl = LOG_WARN;
1655 break;
1656 default:
1657 break;
1658 }
1659
1660 if (log_domain != NULL) {
1661 log_base(fllvl, "%s: %s", log_domain, message);
1662 } else {
1663 log_base(fllvl, "%s", message);
1664 }
1665}
1666
1667/**********************************************************************/
1671 const GLogField *fields,
1673 gpointer user_data)
1674{
1675 /* No need to have formatter of our own - let's use glib's default one. */
1677
1679
1680 return G_LOG_WRITER_HANDLED;
1681}
1682
1683/**********************************************************************/
1694
1695/**********************************************************************/
1698static void set_g_log_callbacks(void)
1699{
1700 /* Old API, still used by many log producers */
1702
1706
1707 /* glib >= 2.50 API */
1709}
1710
1711/**********************************************************************/
1722
1723/**********************************************************************/
1726int main(int argc, char **argv)
1727{
1728 return client_main(argc, argv, FALSE);
1729}
1730
1731/**********************************************************************/
1735{
1736 log_normal(_("Migrating options from gtk2 to gtk3 client"));
1737
1738#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1739#define MIGRATE_STR_OPTION(opt) \
1740 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1741 sizeof(gui_options.gui_gtk3_##opt));
1742
1743 /* Default theme name is never migrated */
1744 /* 'fullscreen', 'small_display_layout', and 'message_chat_location'
1745 * not migrated, as (unlike Gtk2), Gtk3-client tries to pick better
1746 * defaults for these in fresh installations based on screen size (see
1747 * adjust_default_options()); so user is probably better served by
1748 * getting these adaptive defaults than whatever they had for Gtk2.
1749 * Since 'fullscreen' isn't migrated, we don't need to worry about
1750 * preserving gui_gtk2_migrated_from_2_5 either. */
1764 MIGRATE_OPTION(popup_tech_help);
1765
1779
1780#undef MIGRATE_OPTION
1781#undef MIGRATE_STR_OPTION
1782
1784}
1785
1786/**********************************************************************/
1790{
1791 log_normal(_("Migrating options from gtk3 to gtk3.22 client"));
1792
1793#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_22_##opt = gui_options.gui_gtk3_##opt;
1794#define MIGRATE_STR_OPTION(opt) \
1795 strncpy(gui_options.gui_gtk3_22_##opt, gui_options.gui_gtk3_##opt, \
1796 sizeof(gui_options.gui_gtk3_22_##opt));
1797
1798 /* Default theme name is never migrated */
1799
1800 /* Simulate gui-gtk3's migrate_options_from_2_5() */
1802 log_normal(_("Migrating gtk3-client options from freeciv-2.5 options."));
1805 }
1806
1823 MIGRATE_OPTION(popup_tech_help);
1824
1838
1839#undef MIGRATE_OPTION
1840#undef MIGRATE_STR_OPTION
1841
1843}
1844
1845/**********************************************************************/
1849{
1850 log_normal(_("Migrating options from gtk3.22 to gtk4 client"));
1851
1852#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk3_22_##opt;
1853#define MIGRATE_STR_OPTION(opt) \
1854 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_22_##opt, \
1855 sizeof(GUI_GTK_OPTION(opt)));
1856
1857 /* Default theme name is never migrated */
1874 MIGRATE_OPTION(popup_tech_help);
1875
1889
1890#undef MIGRATE_OPTION
1891#undef MIGRATE_STR_OPTION
1892
1894}
1895
1896/**********************************************************************/
1899int ui_main(int argc, char **argv)
1900{
1901 if (parse_options(argc, argv)) {
1902 /* The locale has already been set in init_nls() and the windows-specific
1903 * locale logic in gtk_init() causes problems with zh_CN (see PR#39475) */
1905
1906 if (!gtk_init_check()) {
1907 log_fatal(_("Failed to open graphical mode."));
1908 return EXIT_FAILURE;
1909 }
1910
1912
1913 gui_up = TRUE;
1917 gui_up = FALSE;
1918
1927 cma_fe_done();
1929
1930 /* We have extra ref for unit_info_box that has protected
1931 * it from getting destroyed when editinfobox_refresh()
1932 * moves widgets around. Free that extra ref here. */
1934 if (empty_unit_paintable != NULL) {
1936 }
1937
1938 editgui_free();
1940 message_buffer = NULL; /* Result of destruction of everything */
1942 }
1943
1944 return EXIT_SUCCESS;
1945}
1946
1947/**********************************************************************/
1951{
1953 guint sig;
1955 char window_name[1024];
1956
1958 if (vmode.width > 0 && vmode.height > 0) {
1961 }
1962
1969
1971 gtk_widget_set_name(toplevel, "Freeciv");
1972
1974
1976
1977 if (gui_options.first_boot) {
1979 /* We're using fresh defaults for this version of this client,
1980 * so prevent any future migrations from other clients / versions */
1982 /* Avoid also marking previous Gtk clients as migrated, so that
1983 * they can have their own run of their adjust_default_options() if
1984 * they are ever run (as a side effect of Gtk2->Gtk3 migration). */
1985 } else {
1990 /* We want a fresh look at screen-size-related options after Gtk2 */
1992 /* We don't ever want to consider pre-2.6 fullscreen option again
1993 * (even for gui-gtk3) */
1995 }
1997 }
1999 }
2000 }
2001
2004 }
2005
2006 fc_snprintf(window_name, sizeof(window_name), _("Freeciv (%s)"), GUI_NAME_SHORT);
2008
2009 g_signal_connect(toplevel, "close-request",
2011
2012 /* Disable GTK cursor key focus movement */
2013 sig = g_signal_lookup("move-focus", GTK_TYPE_WIDGET);
2015 0, 0, 0, 0);
2017
2019 if (OT_FONT == option_type(poption)) {
2020 /* Force to call the appropriate callback. */
2022 }
2024
2027
2028 if (NULL == city_names_style) {
2030 log_error("city_names_style should have been set by options.");
2031 }
2034 log_error("city_productions_style should have been set by options.");
2035 }
2036 if (NULL == reqtree_text_style) {
2038 log_error("reqtree_text_style should have been set by options.");
2039 }
2040
2043
2044 /* Keep the icon of the executable on Windows (see PR#36491) */
2045#ifndef FREECIV_MSWINDOWS
2046 {
2047 /* Only call this after tileset_load_tiles is called. */
2049 }
2050#endif /* FREECIV_MSWINDOWS */
2051
2052 setup_widgets();
2053 load_cursors();
2054 cma_fe_init();
2061 chatline_init();
2063
2065
2067
2068 /* Assumes toplevel showing */
2070
2071 /* Assumes client_state is set */
2073}
2074
2075/**********************************************************************/
2078bool is_gui_up(void)
2079{
2080 return gui_up;
2081}
2082
2083/**********************************************************************/
2086void ui_exit(void)
2087{
2088 if (message_buffer != NULL) {
2091 }
2092}
2093
2094/**********************************************************************/
2097enum gui_type get_gui_type(void)
2098{
2099 return GUI_GTK4;
2100}
2101
2102/**********************************************************************/
2109
2110/**********************************************************************/
2116void set_unit_icon(int idx, struct unit *punit)
2117{
2118 GtkWidget *w;
2119
2120 fc_assert_ret(idx >= -1 && idx < num_units_below);
2121
2122 if (idx == -1) {
2123 w = unit_pic;
2124 unit_id_top = punit ? punit->id : 0;
2125 } else {
2126 w = unit_below_pic[idx];
2127 unit_ids[idx] = punit ? punit->id : 0;
2128 }
2129
2130 if (!w) {
2131 return;
2132 }
2133
2134 if (punit) {
2136 } else {
2137 if (empty_unit_paintable == NULL) {
2138 /* FIXME: Use proper icon height instead of hardcoded 50 */
2140
2141 /* Add ref to avoid it getting destroyed along any single parent widget. */
2143 }
2145 }
2146}
2147
2148/**********************************************************************/
2154{
2155 static bool showing = FALSE;
2156
2157 if (more_arrow == nullptr) {
2158 return;
2159 }
2160
2161 if (onoff && !showing) {
2163 showing = TRUE;
2164 } else if (!onoff && showing) {
2166 showing = FALSE;
2167 }
2168}
2169
2170/**********************************************************************/
2180
2181/**********************************************************************/
2186 double x, double y, gpointer data)
2187{
2188 int i = GPOINTER_TO_INT(data);
2189 struct unit *punit;
2190
2191 if (i == -1) {
2193 if (punit && unit_is_in_focus(punit)) {
2194 /* Clicking on the currently selected unit will center it. */
2196 }
2197 return TRUE;
2198 }
2199
2200 if (unit_ids[i] == 0) { /* No unit displayed at this place */
2201 return TRUE;
2202 }
2203
2205 if (NULL != punit && unit_owner(punit) == client_player()) {
2206 /* Unit shouldn't be NULL but may be owned by an ally. */
2208 }
2209
2210 return TRUE;
2211}
2212
2213/**********************************************************************/
2218 double x, double y, gpointer data)
2219{
2221
2222 if (punit) {
2224 }
2225
2226 return TRUE;
2227}
2228
2229/**********************************************************************/
2233{
2235}
2236
2237/**********************************************************************/
2241 double x, double y, gpointer data)
2242{
2243 GtkWidget *p;
2244 GtkWidget *child;
2245 GtkWidget *frame = GTK_WIDGET(data);
2246
2247 p = gtk_popover_new();
2248
2249 gtk_widget_set_parent(p, frame);
2252 g_signal_connect(p, "closed",
2255
2256 return TRUE;
2257}
2258
2259/**********************************************************************/
2267
2268/**********************************************************************/
2272 gpointer data)
2273{
2275
2276 return TRUE;
2277}
2278
2279/**********************************************************************/
2283 bool socket_writable)
2284{
2285 static bool previous_state = FALSE;
2286
2288
2290 return;
2291
2292 log_debug("set_wait_for_writable_socket(%d)", socket_writable);
2293
2298 NULL);
2299
2301}
2302
2303/**********************************************************************/
2307void add_net_input(int sock)
2308{
2309#ifdef FREECIV_MSWINDOWS
2311#else
2313#endif
2315 G_IO_IN | G_IO_ERR,
2317 NULL);
2319}
2320
2321/**********************************************************************/
2331
2332/**********************************************************************/
2336static void quit_dialog_response(GtkWidget *dialog, gint response)
2337{
2339 if (response == GTK_RESPONSE_YES) {
2341 if (client.conn.used) {
2343 }
2344 quit_gtk_main();
2345 }
2346}
2347
2348/**********************************************************************/
2352{
2353 /* Quit gtk main loop. After this it will return to finish
2354 * ui_main() */
2355
2357}
2358
2359/**********************************************************************/
2364{
2365 static GtkWidget *dialog;
2366
2367 if (!dialog) {
2369 0,
2372 _("Are you sure you want to quit?"));
2373 setup_dialog(dialog, toplevel);
2374
2375 g_signal_connect(dialog, "response",
2377 g_signal_connect(dialog, "destroy",
2378 G_CALLBACK(widget_destroyed), &dialog);
2379 }
2380
2382}
2383
2384/**********************************************************************/
2388{
2390 /* Stop emission of event. */
2391 return TRUE;
2392}
2393
2394struct callback {
2395 void (*callback)(void *data);
2396 void *data;
2397};
2398
2399/**********************************************************************/
2403{
2404 struct callback *cb = data;
2405
2406 (cb->callback)(cb->data);
2407 free(cb);
2408
2409 return FALSE;
2410}
2411
2412/**********************************************************************/
2417void add_idle_callback(void (callback)(void *), void *data)
2418{
2419 struct callback *cb = fc_malloc(sizeof(*cb));
2420
2421 cb->callback = callback;
2422 cb->data = data;
2424}
2425
2426/**********************************************************************/
2436
2437/**********************************************************************/
2442{
2443 GtkWidget *button;
2444
2446 fc_assert_ret(button != NULL);
2448
2451}
2452
2453/**********************************************************************/
2464
2465/**********************************************************************/
2475
2476/**********************************************************************/
2486
2487/**********************************************************************/
2497
2498/**********************************************************************/
2503{
2504 struct option *poption;
2505
2506#define option_var_set_callback(var, callback) \
2507 if ((poption = optset_option_by_name(client_optset, \
2508 GUI_GTK_OPTION_STR(var)))) { \
2509 option_set_changed_callback(poption, callback); \
2510 } else { \
2511 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2512 }
2513
2518
2525#undef option_var_set_callback
2526}
2527
2528/**********************************************************************/
2533{
2534 GtkWidget *button;
2535
2537 fc_assert_ret(button != nullptr);
2539
2540 /* Hide the "Allies Only" button for local games. */
2541 if (is_server_running()) {
2543 } else {
2547 }
2548}
2549
2550/**********************************************************************/
2558
2559/**********************************************************************/
2563{
2564 cat_snprintf(outbuf, outlen, _("\nBuilt against gtk %d.%d.%d, using %d.%d.%d"
2565 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2570}
2571
2572/**********************************************************************/
2577{
2580
2582 if (!display) {
2583 return FALSE;
2584 }
2585
2587
2588 if (!monitor) {
2589 return FALSE;
2590 }
2591
2593
2594 return TRUE;
2595}
2596
2597/**********************************************************************/
2601{
2602 GdkRectangle rect;
2603
2604 if (vmode.width > 0) {
2605 return vmode.width;
2606 }
2607
2608 if (monitor_size(&rect)) {
2609 return rect.width;
2610 } else {
2611 return 0;
2612 }
2613}
2614
2615/**********************************************************************/
2619{
2620 GdkRectangle rect;
2621
2622 if (vmode.height > 0) {
2623 return vmode.height;
2624 }
2625
2626 if (monitor_size(&rect)) {
2627 return rect.height;
2628 } else {
2629 return 0;
2630 }
2631}
2632
2633/**********************************************************************/
2637{
2638 if (vmode.width > 0 && vmode.height > 0) {
2639 return &vmode;
2640 }
2641
2642 return NULL;
2643}
2644
2645/**********************************************************************/
2648static void adjust_default_options(void)
2649{
2650 int scr_height = screen_height();
2651
2652 if (scr_height > 0) {
2653 /* Adjust these options only if we do know the screen height. */
2654
2655 if (scr_height <= 480) {
2656 /* Freeciv is practically unusable outside fullscreen mode in so
2657 * small display */
2658 log_verbose("Changing default to fullscreen due to very small screen");
2660 }
2661 if (scr_height < 1024) {
2662 /* This is a small display */
2663 log_verbose("Defaulting to small widget layout due to small screen");
2665 log_verbose("Defaulting to merged messages/chat due to small screen");
2667 }
2668 }
2669}
2670
2671/**********************************************************************/
2675{
2676 return fc_app;
2677}
2678
2679/**********************************************************************/
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
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
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_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: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