Freeciv-3.4
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_KP_Add:
472 zoom_step_up();
473 return TRUE;
474
477 return TRUE;
478
479 default:
480 break;
481 }
482 }
483
484 /* Return here if observer */
485 if (client_is_observer()) {
486 return FALSE;
487 }
488
489 switch (keyval) {
490
491 case GDK_KEY_KP_Up:
492 case GDK_KEY_KP_8:
493 case GDK_KEY_Up:
494 case GDK_KEY_8:
496 return TRUE;
497
499 case GDK_KEY_KP_9:
500 case GDK_KEY_Page_Up:
501 case GDK_KEY_9:
503 return TRUE;
504
505 case GDK_KEY_KP_Right:
506 case GDK_KEY_KP_6:
507 case GDK_KEY_Right:
508 case GDK_KEY_6:
510 return TRUE;
511
513 case GDK_KEY_KP_3:
515 case GDK_KEY_3:
517 return TRUE;
518
519 case GDK_KEY_KP_Down:
520 case GDK_KEY_KP_2:
521 case GDK_KEY_Down:
522 case GDK_KEY_2:
524 return TRUE;
525
526 case GDK_KEY_KP_End:
527 case GDK_KEY_KP_1:
528 case GDK_KEY_End:
529 case GDK_KEY_1:
531 return TRUE;
532
533 case GDK_KEY_KP_Left:
534 case GDK_KEY_KP_4:
535 case GDK_KEY_Left:
536 case GDK_KEY_4:
538 return TRUE;
539
540 case GDK_KEY_KP_Home:
541 case GDK_KEY_KP_7:
542 case GDK_KEY_Home:
543 case GDK_KEY_7:
545 return TRUE;
546
547 case GDK_KEY_KP_Begin:
548 case GDK_KEY_KP_5:
549 case GDK_KEY_5:
551 return TRUE;
552
553 case GDK_KEY_Escape:
555 return TRUE;
556
557 case GDK_KEY_b:
560 return TRUE;
561 }
562 break;
563
564 default:
565 break;
566 };
567
568 return FALSE;
569}
570
571/**********************************************************************/
577 GdkModifierType state,
578 gpointer data)
579{
580 if (inputline_has_focus()) {
581 return FALSE;
582 }
583
584 if (keyval == GDK_KEY_apostrophe) {
585 /* Allow this even if not in main map view; chatline is present on
586 * some other pages too */
587
588 /* Make the chatline visible if it's not currently.
589 * FIXME: should find the correct window, even when detached, from any
590 * other window; should scroll to the bottom automatically showing the
591 * latest text from other players; MUST NOT make spurious text windows
592 * at the bottom of other dialogs. */
594 /* The main game view is visible. May need to switch notebook. */
597 } else {
599 }
600 }
601
602 /* If the chatline is (now) visible, focus it. */
603 if (inputline_is_visible()) {
605 return TRUE;
606 }
607 }
608
611 return FALSE;
612 }
613
614 if (editor_is_active()) {
615 if (handle_edit_key_press(keyval, state)) {
616 return TRUE;
617 }
618 }
619
620 if (state & GDK_SHIFT_MASK) {
621 switch (keyval) {
622
623 case GDK_KEY_Return:
624 case GDK_KEY_KP_Enter:
625 key_end_turn();
626 return TRUE;
627
628 default:
629 break;
630 }
631 }
632
634 /* 0 means the map view is focused. */
635 return key_press_map_canvas(keyval, state);
636 }
637
638#if 0
639 /* We are focused some other dialog, tab, or widget. */
640 if ((state & GDK_CONTROL_MASK)) {
641 } else if ((state & GDK_SHIFT_MASK)) {
642 } else {
643 switch (keyval) {
644
645 case GDK_KEY_F4:
647 return TRUE;
648
649 default:
650 break;
651 };
652 }
653#endif /* 0 */
654
655 return FALSE;
656}
657
658/**********************************************************************/
704
705/**********************************************************************/
711{
712 g_object_ref(wdg); /* Make sure reference count stays above 0
713 * during the transition to new parent. */
714
715 if (GTK_IS_PANED(old_wdg)) {
717 } else if (GTK_IS_WINDOW(old_wdg)) {
719 } else {
721
723 }
724
725 if (GTK_IS_PANED(new_wdg)) {
727 } else if (GTK_IS_WINDOW(new_wdg)) {
729 } else {
731
733 }
734
736}
737
738/**********************************************************************/
748
749/**********************************************************************/
759
760/**********************************************************************/
764{
766
767 aparent = g_object_get_data(G_OBJECT(box), "aparent");
769
770 if (aparent != cparent) {
772
774 }
775}
776
777/**********************************************************************/
780static void tearoff_close(GtkWidget *w, gpointer data)
781{
783}
784
785/**********************************************************************/
790{
791 GtkWidget *box = GTK_WIDGET(data);
793
795 GtkWidget *w;
797
798 w = gtk_window_new();
800 gtk_widget_set_name(w, "Freeciv");
801 gtk_window_set_title(GTK_WINDOW(w), _("Freeciv"));
802 g_signal_connect(w, "close-request", G_CALLBACK(tearoff_close), box);
803
804 g_object_set_data(G_OBJECT(box), "aparent", gtk_widget_get_parent(box));
805
806 temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent");
807 if (temp_hide != nullptr) {
809 }
810
812
814
815 if (temp_hide != nullptr) {
817 }
818 } else {
819 tearoff_reattach(box);
820 }
821}
822
823/**********************************************************************/
827{
829
830 return hbox;
831}
832
833/**********************************************************************/
838{
839 GtkWidget *b, *fillbox;
841
844
845 /* These toggle buttons run vertically down the side of many UI
846 * elements, so they need to be thin horizontally. */
848 ".detach_button {\n"
849 " padding: 0px 0px 0px 0px;\n"
850 " min-width: 6px;\n"
851 "}",
852 -1);
853 }
854
860 gtk_widget_add_css_class(b, "detach_button");
861 gtk_widget_set_tooltip_text(b, _("Detach/Attach the pane."));
862
865
867
869
870 return fillbox;
871}
872
873/**********************************************************************/
880static void populate_unit_pic_table(void)
881{
882 int i, width;
884 GdkPixbuf *pix;
885 int ttw;
887
888 /* Get width of the overview window */
892
894
896 /* We want arrow to appear if there is other units in addition
897 to active one in tile. Active unit is not counted, so there
898 can be 0 other units to not to display arrow. */
899 num_units_below = 1 - 1;
900 } else {
903 }
904
905 /* Top row: the active unit. */
906 /* Note, we ref this and other widgets here so that we can unref them
907 * in reset_unit_table. */
911 gtk_grid_attach(GTK_GRID(table), unit_pic, 0, 0, 1, 1);
912
914 g_signal_connect(controller, "pressed",
916 GINT_TO_POINTER(-1));
918
920 /* Bottom row: other units in the same tile. */
921 for (i = 0; i < num_units_below; i++) {
925
927 g_signal_connect(controller, "pressed",
931
933 i, 1, 1, 1);
934 }
935 }
936
937 /* Create arrow (popup for all units on the selected tile) */
941
943 g_signal_connect(controller, "pressed",
945 NULL);
947
948 /* An extra layer so that we can hide the clickable button but keep
949 * an explicit size request to avoid the layout jumping around */
956 gdk_pixbuf_get_width(pix), -1);
958
960 /* Display on bottom row. */
962 num_units_below, 1, 1, 1);
963 } else {
964 /* Display on top row (there is no bottom row). */
966 1, 0, 1, 1);
967 }
968
970}
971
972/**********************************************************************/
995
996/**********************************************************************/
1000{
1001 /* Unreference all of the widgets that we're about to reallocate, thus
1002 * avoiding a memory leak. Remove them from the container first, just
1003 * to be safe. Note, the widgets are ref'd in
1004 * populate_unit_pic_table(). */
1006
1008
1009 /* We have to force a redraw of the units. And we explicitly have
1010 * to force a redraw of the focus unit, which is normally only
1011 * redrawn when the focus changes. We also have to force the 'more'
1012 * arrow to go away, both by expicitly hiding it and telling it to
1013 * do so (this will be reset immediately afterwards if necessary,
1014 * but we have to make the *internal* state consistent). */
1017 if (get_num_units_in_focus() == 1) {
1019 } else {
1020 set_unit_icon(-1, NULL);
1021 }
1023}
1024
1025/**********************************************************************/
1028#if 0
1030{
1035}
1036#endif
1037
1038/**********************************************************************/
1046
1047/**********************************************************************/
1051{
1052 struct option *opt = optset_option_by_name(server_optset, "fixedlength");
1053
1054 if (opt != NULL && option_bool_get(opt)) {
1056 _("Fixed length turns"));
1057 } else {
1058 char buf[256];
1059
1060 fc_snprintf(buf, sizeof(buf), "%s:\n%s",
1061 _("Turn Done"), _("Shift+Return"));
1063 }
1064}
1065
1066/**********************************************************************/
1069static void setup_widgets(void)
1070{
1071 GtkWidget *page, *hgrid, *hgrid2, *label;
1072 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1073 GtkWidget *button, *view, *mainbox, *vbox, *right_vbox = NULL;
1074 int i;
1075 GtkWidget *notebook, *statusbar;
1077 struct sprite *spr;
1078 int right_row = 0;
1079 int top_row = 0;
1080 int grid_col = 0;
1081 int grid2_col = 0;
1084 GtkWidget *ebar;
1085
1087
1088 notebook = gtk_notebook_new();
1089
1090 toplevel_tabs = notebook;
1095 gtk_box_append(GTK_BOX(mainbox), notebook);
1098
1109
1111
1117
1118 /* *** Everything in the top *** */
1119
1120 page = gtk_scrolled_window_new();
1125 TRUE);
1126 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1127
1132 hgrid = gtk_grid_new();
1133
1135 /* The window is divided into two horizontal panels: overview +
1136 * civinfo + unitinfo, main view + message window. */
1138 right_row = 0;
1142
1148
1149 /* Overview size designed for small displays (netbooks). */
1152 } else {
1153 /* The window is divided into two vertical panes: overview +
1154 * + civinfo + unitinfo + main view, message window. */
1159
1160 /* Overview size designed for big displays (desktops). */
1163 }
1164
1165 /* This holds the overview canvas, production info, etc. */
1167 /* Put vbox to the left of anything else in hgrid -- right_vbox is either
1168 * the chat/messages pane, or NULL which is OK */
1170 GTK_POS_LEFT, 1, 1);
1171 grid_col++;
1172
1173 /* Overview canvas */
1179
1187
1197
1199
1202
1205
1220
1221 /* The rest */
1228
1229 /* Info on player's civilization, when game is running. */
1230 frame = gtk_frame_new("");
1231 gtk_box_append(GTK_BOX(avbox), frame);
1232
1233 main_frame_civ_name = frame;
1234
1238
1239 label = gtk_label_new(NULL);
1243 gtk_widget_set_margin_end(label, 2);
1244 gtk_widget_set_margin_top(label, 2);
1246
1249 G_CALLBACK(show_info_popup), frame);
1252 main_label_info = label;
1253
1254 /* Production status */
1255 table = gtk_grid_new();
1259
1260 /* Citizens for taxrates */
1261 table2 = gtk_grid_new();
1262 gtk_grid_attach(GTK_GRID(table), table2, 0, 0, 10, 1);
1264
1265 for (i = 0; i < 10; i++) {
1267
1270
1273 g_signal_connect(controller, "pressed",
1279 g_signal_connect(controller, "pressed",
1283 }
1284
1285 /* Science, environmental, govt, timeout */
1287 if (spr != NULL) {
1289 } else {
1291 }
1292
1294 if (spr != NULL) {
1296 } else {
1298 }
1299
1301 if (spr != NULL) {
1303 } else {
1305 }
1306
1308 if (spr != NULL) {
1310 } else {
1312 }
1313
1314 for (i = 0; i < 4; i++) {
1315 GtkWidget *w;
1316
1317 switch (i) {
1318 case 0:
1319 w = bulb_label;
1320 break;
1321 case 1:
1322 w = sun_label;
1323 break;
1324 case 2:
1325 w = flake_label;
1326 break;
1327 default:
1328 case 3:
1329 w = government_label;
1330 break;
1331 }
1332
1339 gtk_grid_attach(GTK_GRID(table), w, i, 1, 1, 1);
1340 }
1341
1343
1344 frame = gtk_frame_new(NULL);
1345 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1347
1348
1349 /* Turn done */
1351
1353
1357
1358 /* Selected unit status */
1359
1360 /* If you turn this to something else than GtkBox, also adjust
1361 * editgui.c replace_widget() code that removes and adds widgets from it. */
1365
1366 /* In edit mode the unit_info_box widget is replaced by the
1367 * editinfobox, so we need to add a ref here so that it is
1368 * not destroyed when removed from its container.
1369 * See editinfobox_refresh() call to replace_widget() */
1371
1374
1380
1381 label = gtk_label_new(NULL);
1386 gtk_widget_set_margin_end(label, 2);
1387 gtk_widget_set_margin_top(label, 2);
1390 unit_info_label = label;
1391
1392 hgrid2 = gtk_grid_new();
1394
1395 table = gtk_grid_new();
1401
1404
1406
1407 /* Map canvas, editor toolbar, and scrollbars */
1408
1409 /* The top notebook containing the map view and dialogs. */
1410
1414
1415
1420 right_row = 0;
1423
1427 } else {
1429 }
1430
1432
1435
1442
1443 label = gtk_label_new(Q_("?noun:View"));
1445
1446 frame = gtk_frame_new(NULL);
1447 gtk_grid_attach(GTK_GRID(map_widget), frame, 0, 0, 1, 1);
1448
1454
1456
1457#if 0
1466#endif /* 0 */
1467
1469
1473
1477
1479 NULL, NULL);
1480
1484 g_signal_connect(mc_controller, "released",
1492 g_signal_connect(mc_controller, "released",
1511
1512 g_signal_connect(map_canvas, "resize",
1514
1516 g_signal_connect(mc_controller, "key-pressed",
1519
1520 /* *** The message window -- this is a detachable widget *** */
1521
1525 } else {
1527
1531
1535 }
1537
1540 } else {
1542 }
1549
1554
1561 }
1562 }
1563
1565
1568 TRUE);
1573
1574 label = gtk_label_new(_("Chat"));
1576
1583
1584 gtk_widget_set_name(text, "chatline");
1585
1587 gtk_widget_realize(text);
1589
1591 if (dtach_lowbox != NULL) {
1593 }
1594
1596
1597 /* The chat line */
1604
1605 button = gtk_check_button_new_with_label(_("Allies Only"));
1609 g_signal_connect(button, "toggled",
1613
1614 button = gtk_button_new_with_label(_("Clear links"));
1615 g_signal_connect(button, "clicked",
1618
1619 /* Other things to take care of */
1620
1622 TRUE);
1623
1626 }
1627
1630
1634 }
1635}
1636
1637/**********************************************************************/
1642 const gchar *message,
1643 gpointer user_data)
1644{
1645 enum log_level fllvl = LOG_ERROR;
1646
1647 switch (log_level) {
1648 case G_LOG_LEVEL_DEBUG:
1649 fllvl = LOG_DEBUG;
1650 break;
1652 fllvl = LOG_WARN;
1653 break;
1654 default:
1655 break;
1656 }
1657
1658 if (log_domain != NULL) {
1659 log_base(fllvl, "%s: %s", log_domain, message);
1660 } else {
1661 log_base(fllvl, "%s", message);
1662 }
1663}
1664
1665/**********************************************************************/
1669 const GLogField *fields,
1671 gpointer user_data)
1672{
1673 /* No need to have formatter of our own - let's use glib's default one. */
1675
1677
1678 return G_LOG_WRITER_HANDLED;
1679}
1680
1681/**********************************************************************/
1692
1693/**********************************************************************/
1696static void set_g_log_callbacks(void)
1697{
1698 /* Old API, still used by many log producers */
1700
1704
1705 /* glib >= 2.50 API */
1707}
1708
1709/**********************************************************************/
1720
1721/**********************************************************************/
1724int main(int argc, char **argv)
1725{
1726 return client_main(argc, argv, FALSE);
1727}
1728
1729/**********************************************************************/
1733{
1734 log_normal(_("Migrating options from gtk2 to gtk3 client"));
1735
1736#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1737#define MIGRATE_STR_OPTION(opt) \
1738 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1739 sizeof(gui_options.gui_gtk3_##opt));
1740
1741 /* Default theme name is never migrated */
1742 /* 'fullscreen', 'small_display_layout', and 'message_chat_location'
1743 * not migrated, as (unlike Gtk2), Gtk3-client tries to pick better
1744 * defaults for these in fresh installations based on screen size (see
1745 * adjust_default_options()); so user is probably better served by
1746 * getting these adaptive defaults than whatever they had for Gtk2.
1747 * Since 'fullscreen' isn't migrated, we don't need to worry about
1748 * preserving gui_gtk2_migrated_from_2_5 either. */
1762 MIGRATE_OPTION(popup_tech_help);
1763
1777
1778#undef MIGRATE_OPTION
1779#undef MIGRATE_STR_OPTION
1780
1782}
1783
1784/**********************************************************************/
1788{
1789 log_normal(_("Migrating options from gtk3 to gtk3.22 client"));
1790
1791#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_22_##opt = gui_options.gui_gtk3_##opt;
1792#define MIGRATE_STR_OPTION(opt) \
1793 strncpy(gui_options.gui_gtk3_22_##opt, gui_options.gui_gtk3_##opt, \
1794 sizeof(gui_options.gui_gtk3_22_##opt));
1795
1796 /* Default theme name is never migrated */
1797
1798 /* Simulate gui-gtk3's migrate_options_from_2_5() */
1800 log_normal(_("Migrating gtk3-client options from freeciv-2.5 options."));
1803 }
1804
1821 MIGRATE_OPTION(popup_tech_help);
1822
1836
1837#undef MIGRATE_OPTION
1838#undef MIGRATE_STR_OPTION
1839
1841}
1842
1843/**********************************************************************/
1847{
1848 log_normal(_("Migrating options from gtk3.22 to gtk4 client"));
1849
1850#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk3_22_##opt;
1851#define MIGRATE_STR_OPTION(opt) \
1852 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_22_##opt, \
1853 sizeof(GUI_GTK_OPTION(opt)));
1854
1855 /* Default theme name is never migrated */
1876 MIGRATE_OPTION(popup_tech_help);
1877
1891
1892#undef MIGRATE_OPTION
1893#undef MIGRATE_STR_OPTION
1894
1896}
1897
1898/**********************************************************************/
1901int ui_main(int argc, char **argv)
1902{
1903 if (parse_options(argc, argv)) {
1904 /* The locale has already been set in init_nls() and the windows-specific
1905 * locale logic in gtk_init() causes problems with zh_CN (see PR#39475) */
1907
1908 if (!gtk_init_check()) {
1909 log_fatal(_("Failed to open graphical mode."));
1910 return EXIT_FAILURE;
1911 }
1912
1914
1915 gui_up = TRUE;
1919 gui_up = FALSE;
1920
1929 cma_fe_done();
1931
1932 /* We have extra ref for unit_info_box that has protected
1933 * it from getting destroyed when editinfobox_refresh()
1934 * moves widgets around. Free that extra ref here. */
1936 if (empty_unit_paintable != NULL) {
1938 }
1939
1940 editgui_free();
1942 message_buffer = NULL; /* Result of destruction of everything */
1944 }
1945
1946 return EXIT_SUCCESS;
1947}
1948
1949/**********************************************************************/
1953{
1955 guint sig;
1957 char window_name[1024];
1958
1960 if (vmode.width > 0 && vmode.height > 0) {
1963 }
1964
1971
1973 gtk_widget_set_name(toplevel, "Freeciv");
1974
1976
1978
1979 if (gui_options.first_boot) {
1981 /* We're using fresh defaults for this version of this client,
1982 * so prevent any future migrations from other clients / versions */
1984 /* Avoid also marking previous Gtk clients as migrated, so that
1985 * they can have their own run of their adjust_default_options() if
1986 * they are ever run (as a side effect of Gtk2->Gtk3 migration). */
1987 } else {
1992 /* We want a fresh look at screen-size-related options after Gtk2 */
1994 /* We don't ever want to consider pre-2.6 fullscreen option again
1995 * (even for gui-gtk3) */
1997 }
1999 }
2001 }
2002 }
2003
2006 }
2007
2008 fc_snprintf(window_name, sizeof(window_name), _("Freeciv (%s)"), GUI_NAME_SHORT);
2010
2011 g_signal_connect(toplevel, "close-request",
2013
2014 /* Disable GTK cursor key focus movement */
2015 sig = g_signal_lookup("move-focus", GTK_TYPE_WIDGET);
2017 0, 0, 0, 0);
2019
2021 if (OT_FONT == option_type(poption)) {
2022 /* Force to call the appropriate callback. */
2024 }
2026
2029
2030 if (NULL == city_names_style) {
2032 log_error("city_names_style should have been set by options.");
2033 }
2036 log_error("city_productions_style should have been set by options.");
2037 }
2038 if (NULL == reqtree_text_style) {
2040 log_error("reqtree_text_style should have been set by options.");
2041 }
2042
2045
2046 /* Keep the icon of the executable on Windows (see PR#36491) */
2047#ifndef FREECIV_MSWINDOWS
2048 {
2049 /* Only call this after tileset_load_tiles is called. */
2051 }
2052#endif /* FREECIV_MSWINDOWS */
2053
2054 setup_widgets();
2055 load_cursors();
2056 cma_fe_init();
2063 chatline_init();
2065
2067
2069
2070 /* Assumes toplevel showing */
2072
2073 /* Assumes client_state is set */
2075}
2076
2077/**********************************************************************/
2080bool is_gui_up(void)
2081{
2082 return gui_up;
2083}
2084
2085/**********************************************************************/
2088void ui_exit(void)
2089{
2090 if (message_buffer != NULL) {
2093 }
2094}
2095
2096/**********************************************************************/
2099enum gui_type get_gui_type(void)
2100{
2101 return GUI_GTK4;
2102}
2103
2104/**********************************************************************/
2111
2112/**********************************************************************/
2118void set_unit_icon(int idx, struct unit *punit)
2119{
2120 GtkWidget *w;
2121
2122 fc_assert_ret(idx >= -1 && idx < num_units_below);
2123
2124 if (idx == -1) {
2125 w = unit_pic;
2126 unit_id_top = punit ? punit->id : 0;
2127 } else {
2128 w = unit_below_pic[idx];
2129 unit_ids[idx] = punit ? punit->id : 0;
2130 }
2131
2132 if (!w) {
2133 return;
2134 }
2135
2136 if (punit) {
2138 } else {
2139 if (empty_unit_paintable == NULL) {
2140 /* FIXME: Use proper icon height instead of hardcoded 50 */
2142
2143 /* Add ref to avoid it getting destroyed along any single parent widget. */
2145 }
2147 }
2148}
2149
2150/**********************************************************************/
2156{
2157 static bool showing = FALSE;
2158
2159 if (more_arrow == nullptr) {
2160 return;
2161 }
2162
2163 if (onoff && !showing) {
2165 showing = TRUE;
2166 } else if (!onoff && showing) {
2168 showing = FALSE;
2169 }
2170}
2171
2172/**********************************************************************/
2182
2183/**********************************************************************/
2188 double x, double y, gpointer data)
2189{
2190 int i = GPOINTER_TO_INT(data);
2191 struct unit *punit;
2192
2193 if (i == -1) {
2195 if (punit && unit_is_in_focus(punit)) {
2196 /* Clicking on the currently selected unit will center it. */
2198 }
2199 return TRUE;
2200 }
2201
2202 if (unit_ids[i] == 0) { /* No unit displayed at this place */
2203 return TRUE;
2204 }
2205
2207 if (NULL != punit && unit_owner(punit) == client_player()) {
2208 /* Unit shouldn't be NULL but may be owned by an ally. */
2210 }
2211
2212 return TRUE;
2213}
2214
2215/**********************************************************************/
2220 double x, double y, gpointer data)
2221{
2223
2224 if (punit) {
2226 }
2227
2228 return TRUE;
2229}
2230
2231/**********************************************************************/
2235{
2237}
2238
2239/**********************************************************************/
2243 double x, double y, gpointer data)
2244{
2245 GtkWidget *p;
2246 GtkWidget *child;
2247 GtkWidget *frame = GTK_WIDGET(data);
2248
2249 p = gtk_popover_new();
2250
2251 gtk_widget_set_parent(p, frame);
2254 g_signal_connect(p, "closed",
2257
2258 return TRUE;
2259}
2260
2261/**********************************************************************/
2269
2270/**********************************************************************/
2274 gpointer data)
2275{
2277
2278 return TRUE;
2279}
2280
2281/**********************************************************************/
2285 bool socket_writable)
2286{
2287 static bool previous_state = FALSE;
2288
2290
2292 return;
2293
2294 log_debug("set_wait_for_writable_socket(%d)", socket_writable);
2295
2300 NULL);
2301
2303}
2304
2305/**********************************************************************/
2309void add_net_input(int sock)
2310{
2311#ifdef FREECIV_MSWINDOWS
2313#else
2315#endif
2317 G_IO_IN | G_IO_ERR,
2319 NULL);
2321}
2322
2323/**********************************************************************/
2333
2334/**********************************************************************/
2338static void quit_dialog_response(GtkWidget *dialog, gint response)
2339{
2341 if (response == GTK_RESPONSE_YES) {
2343 if (client.conn.used) {
2345 }
2346 quit_gtk_main();
2347 }
2348}
2349
2350/**********************************************************************/
2354{
2355 /* Quit gtk main loop. After this it will return to finish
2356 * ui_main() */
2357
2359}
2360
2361/**********************************************************************/
2366{
2367 static GtkWidget *dialog;
2368
2369 if (!dialog) {
2371 0,
2374 _("Are you sure you want to quit?"));
2375 setup_dialog(dialog, toplevel);
2376
2377 g_signal_connect(dialog, "response",
2379 g_signal_connect(dialog, "destroy",
2380 G_CALLBACK(widget_destroyed), &dialog);
2381 }
2382
2384}
2385
2386/**********************************************************************/
2390{
2392 /* Stop emission of event. */
2393 return TRUE;
2394}
2395
2396struct callback {
2397 void (*callback)(void *data);
2398 void *data;
2399};
2400
2401/**********************************************************************/
2405{
2406 struct callback *cb = data;
2407
2408 (cb->callback)(cb->data);
2409 free(cb);
2410
2411 return FALSE;
2412}
2413
2414/**********************************************************************/
2419void add_idle_callback(void (callback)(void *), void *data)
2420{
2421 struct callback *cb = fc_malloc(sizeof(*cb));
2422
2423 cb->callback = callback;
2424 cb->data = data;
2426}
2427
2428/**********************************************************************/
2438
2439/**********************************************************************/
2444{
2445 GtkWidget *button;
2446
2448 fc_assert_ret(button != NULL);
2450
2453}
2454
2455/**********************************************************************/
2466
2467/**********************************************************************/
2477
2478/**********************************************************************/
2488
2489/**********************************************************************/
2499
2500/**********************************************************************/
2505{
2506 struct option *poption;
2507
2508#define option_var_set_callback(var, callback) \
2509 if ((poption = optset_option_by_name(client_optset, \
2510 GUI_GTK_OPTION_STR(var)))) { \
2511 option_set_changed_callback(poption, callback); \
2512 } else { \
2513 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2514 }
2515
2520
2527#undef option_var_set_callback
2528}
2529
2530/**********************************************************************/
2535{
2536 GtkWidget *button;
2537
2539 fc_assert_ret(button != nullptr);
2541
2542 /* Hide the "Allies Only" button for local games. */
2543 if (is_server_running()) {
2545 } else {
2549 }
2550}
2551
2552/**********************************************************************/
2560
2561/**********************************************************************/
2565{
2566 cat_snprintf(outbuf, outlen, _("\nBuilt against gtk %d.%d.%d, using %d.%d.%d"
2567 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2572}
2573
2574/**********************************************************************/
2579{
2582
2584 if (!display) {
2585 return FALSE;
2586 }
2587
2589
2590 if (!monitor) {
2591 return FALSE;
2592 }
2593
2595
2596 return TRUE;
2597}
2598
2599/**********************************************************************/
2603{
2604 GdkRectangle rect;
2605
2606 if (vmode.width > 0) {
2607 return vmode.width;
2608 }
2609
2610 if (monitor_size(&rect)) {
2611 return rect.width;
2612 } else {
2613 return 0;
2614 }
2615}
2616
2617/**********************************************************************/
2621{
2622 GdkRectangle rect;
2623
2624 if (vmode.height > 0) {
2625 return vmode.height;
2626 }
2627
2628 if (monitor_size(&rect)) {
2629 return rect.height;
2630 } else {
2631 return 0;
2632 }
2633}
2634
2635/**********************************************************************/
2639{
2640 if (vmode.width > 0 && vmode.height > 0) {
2641 return &vmode;
2642 }
2643
2644 return NULL;
2645}
2646
2647/**********************************************************************/
2650static void adjust_default_options(void)
2651{
2652 int scr_height = screen_height();
2653
2654 if (scr_height > 0) {
2655 /* Adjust these options only if we do know the screen height. */
2656
2657 if (scr_height <= 480) {
2658 /* Freeciv is practically unusable outside fullscreen mode in so
2659 * small display */
2660 log_verbose("Changing default to fullscreen due to very small screen");
2662 }
2663 if (scr_height < 1024) {
2664 /* This is a small display */
2665 log_verbose("Defaulting to small widget layout due to small screen");
2667 log_verbose("Defaulting to merged messages/chat due to small screen");
2669 }
2670 }
2671}
2672
2673/**********************************************************************/
2677{
2678 return fc_app;
2679}
2680
2681/**********************************************************************/
2685{
2689#ifdef GTK3_3D_ENABLED
2691#else /* GTK3_3D_ENABLED */
2693#endif /* GTK3_3D_ENABLED */
2694}
void audio_pause(void)
Definition audio.c:609
void audio_resume(void)
Definition audio.c:617
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:1322
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:77
bool is_server_running(void)
void key_recall_previous_focus_unit(void)
Definition control.c:3332
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:388
void key_cancel_action(void)
Definition control.c:3270
int num_units_below
Definition control.c:76
void unit_focus_set(struct unit *punit)
Definition control.c:518
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void key_end_turn(void)
Definition control.c:3324
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:997
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3353
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:1227
void key_center_capital(void)
Definition control.c:3307
#define MAX_NUM_UNITS_BELOW
Definition control.h:296
@ 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:103
@ O_GOLD
Definition fc_types.h:103
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:1663
void editgui_create_widgets(void)
Definition editgui.c:1824
struct editbar * editgui_get_editbar(void)
Definition editgui.c:1790
void editgui_free(void)
Definition editgui.c:1837
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:64
GtkWidget * map_vertical_scrollbar
Definition gui_main.c:110
int ui_main(int argc, char **argv)
Definition gui_main.c:1885
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:2320
void real_focus_units_changed(void)
Definition gui_main.c:2147
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2124
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:2373
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:2551
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:2609
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2094
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:681
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:843
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:733
void ui_exit(void)
Definition gui_main.c:2064
enum gui_type get_gui_type(void)
Definition gui_main.c:2075
static GtkWidget * detached_widget_new(void)
Definition gui_main.c:832
gint cur_y
Definition gui_main.c:185
int main(int argc, char **argv)
Definition gui_main.c:1763
void fullscreen_opt_refresh(struct option *poption)
Definition gui_main.c:2431
void ui_init(void)
Definition gui_main.c:1753
static void free_unit_table(void)
Definition gui_main.c:993
static gboolean idle_callback_wrapper(gpointer data)
Definition gui_main.c:2388
static void apply_city_names_font(struct option *poption)
Definition gui_main.c:2443
static void apply_city_productions_font(struct option *poption)
Definition gui_main.c:2454
gboolean fc_gained_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:743
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:2507
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:2573
GtkWidget * scroll_panel
Definition gui_main.c:142
static void end_turn_callback(GtkWidget *w, gpointer data)
Definition gui_main.c:2246
#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:2403
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2215
static void set_g_log_callbacks(void)
Definition gui_main.c:1737
void reset_unit_table(void)
Definition gui_main.c:1021
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:2477
GtkWidget * top_vbox
Definition gui_main.c:129
static void allied_chat_only_callback(struct option *poption)
Definition gui_main.c:2416
static void adjust_default_options(void)
Definition gui_main.c:2621
static void set_wait_for_writable_socket(struct connection *pc, bool socket_writable)
Definition gui_main.c:2266
GtkWidget * ahbox
Definition gui_main.c:141
static void apply_reqtree_text_font(struct option *poption)
Definition gui_main.c:2465
bool is_gui_up(void)
Definition gui_main.c:2056
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:1681
GtkWidget * avbox
Definition gui_main.c:141
gint cur_x
Definition gui_main.c:185
void setup_gui_properties(void)
Definition gui_main.c:2647
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2537
static void set_g_log_callback_domain(const char *domain)
Definition gui_main.c:1725
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:1125
#define OVERVIEW_CANVAS_STORE_WIDTH
Definition gui_main.c:119
void remove_net_input(void)
Definition gui_main.c:2309
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:597
void sound_bell(void)
Definition gui_main.c:2083
static void migrate_options_from_gtk2(void)
Definition gui_main.c:1771
GtkWidget * econ_label[10]
Definition gui_main.c:144
void popup_quit_dialog(void)
Definition gui_main.c:2347
static void migrate_options_from_gtk3(void)
Definition gui_main.c:1826
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:2255
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:2335
static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data)
Definition gui_main.c:2528
static struct video_mode vmode
Definition gui_main.c:192
void add_net_input(int sock)
Definition gui_main.c:2291
static GLogWriterOutput g_log_writer_to_freelog_cb(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data)
Definition gui_main.c:1709
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:1106
static void tearoff_callback(GtkWidget *b, gpointer data)
Definition gui_main.c:787
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:2591
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:29
#define GUI_NAME_SHORT
Definition gui_main.h:30
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:32
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:1461
static GdkPaintable * empty_unit_paintable
Definition gui_main.c:160
static void tearoff_close(GtkWidget *w, gpointer data)
Definition gui_main.c:780
static void tearoff_reattach(GtkWidget *box)
Definition gui_main.c:763
gboolean terminate_signal_processing(GtkEventControllerFocus *controller, gpointer data)
Definition gui_main.c:1041
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:2219
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:2676
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:1846
void animation_idle_cb(void *data)
Definition gui_main.c:2431
static void activate_gui(GtkApplication *app, gpointer data)
Definition gui_main.c:1952
static void populate_unit_pic_table(void)
Definition gui_main.c:880
static void info_popup_closed(GtkWidget *self, gpointer data)
Definition gui_main.c:2234
static void move_from_container_to_container(GtkWidget *wdg, GtkWidget *old_wdg, GtkWidget *new_wdg)
Definition gui_main.c:708
static gboolean select_unit_pic_callback(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition gui_main.c:2187
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:3033
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:298
#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:799
const struct option_set * server_optset
Definition options.c:4369
const struct option_set * client_optset
Definition options.c:1331
bool option_bool_get(const struct option *poption)
Definition options.c:848
enum option_type option_type(const struct option *poption)
Definition options.c:709
const char * option_font_target(const struct option *poption)
Definition options.c:1214
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6894
struct client_options gui_options
Definition options.c:71
const char * option_font_get(const struct option *poption)
Definition options.c:1192
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:482
#define GUI_GTK_OVERVIEW_MIN_XSIZE
Definition options.h:649
#define options_iterate(poptset, poption)
Definition options.h:602
@ GUI_GTK_MSGCHAT_MERGED
Definition options.h:69
@ GUI_GTK_MSGCHAT_SPLIT
Definition options.h:67
#define options_iterate_end
Definition options.h:607
const char * get_info_label_text_popup(void)
Definition text.c:1022
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:2382
void(* callback)(void *data)
Definition gui_main.c:2381
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
struct client_properties::@227 views
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:3825
void tileset_free_tiles(struct tileset *t)
Definition tilespec.c:6845
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7327
void tileset_init(struct tileset *t)
Definition tilespec.c:7388
struct sprite * get_arrow_sprite(const struct tileset *t, enum arrow_type arrow)
Definition tilespec.c:7126
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:7137
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:779
@ ARROW_RIGHT
Definition tilespec.h:203
#define unit_tile(_pu)
Definition unit.h:408
#define unit_owner(_pu)
Definition unit.h:407
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