Freeciv-3.2
Loading...
Searching...
No Matches
gui_main.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#ifdef AUDIO_SDL
19/* Though it would happily compile without this include,
20 * it is needed for sound to work.
21 * It defines "main" macro to rename our main() so that
22 * it can install SDL's own. */
23#ifdef SDL2_PLAIN_INCLUDE
24#include <SDL.h>
25#else /* PLAIN_INCLUDE */
26#include <SDL2/SDL.h>
27#endif /* PLAIN_INCLUDE */
28#endif /* AUDIO_SDL */
29
30#ifdef HAVE_LOCALE_H
31#include <locale.h>
32#endif
33#include <stdarg.h>
34#include <stdio.h>
35#include <stdlib.h>
36#include <string.h>
37#include <time.h>
38
39#ifdef HAVE_UNISTD_H
40#include <unistd.h>
41#endif
42
43#include <gtk/gtk.h>
44#include <gdk/gdkkeysyms.h>
45
46/* utility */
47#include "fc_cmdline.h"
48#include "fciconv.h"
49#include "fcintl.h"
50#include "log.h"
51#include "mem.h"
52#include "support.h"
53
54/* common */
55#include "dataio.h"
56#include "featured_text.h"
57#include "game.h"
58#include "government.h"
59#include "map.h"
60#include "unitlist.h"
61#include "version.h"
62
63/* client */
64#include "audio.h"
65#include "client_main.h"
66#include "climisc.h"
67#include "clinet.h"
68#include "colors.h"
69#include "connectdlg_common.h"
70#include "control.h"
71#include "editor.h"
72#include "options.h"
73#include "text.h"
74#include "tilespec.h"
75#include "zoom.h"
76
77/* client/gui-gtk-4.0 */
78#include "chatline.h"
79#include "citizensinfo.h"
80#include "connectdlg.h"
81#include "cma_fe.h"
82#include "dialogs.h"
83#include "diplodlg.h"
84#include "editgui.h"
85#include "gotodlg.h"
86#include "graphics.h"
87#include "gui_stuff.h"
88#include "happiness.h"
89#include "helpdlg.h"
90#include "inteldlg.h"
91#include "mapctrl.h"
92#include "mapview.h"
93#include "menu.h"
94#include "messagewin.h"
95#include "optiondlg.h"
96#include "pages.h"
97#include "plrdlg.h"
98#include "luaconsole.h"
99#include "spaceshipdlg.h"
100#include "repodlgs.h"
101#include "voteinfo_bar.h"
102
103#include "gui_main.h"
104
106
107GtkWidget *map_canvas; /* GtkDrawingArea */
110
111GtkWidget *overview_canvas; /* GtkDrawingArea */
112GtkWidget *overview_scrolled_window; /* GtkScrolledWindow */
113/* The two values below define the width and height of the map overview. The
114 * first set of values (2*62, 2*46) define the size for a netbook display. For
115 * bigger displays the values are doubled (default). */
116#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK (2 * 64)
117#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK (2 * 46)
118#define OVERVIEW_CANVAS_STORE_WIDTH \
119 (2 * OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK)
120#define OVERVIEW_CANVAS_STORE_HEIGHT \
121 (2 * OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK)
124
131
135
138
141
149
153
155
156const char *const gui_character_encoding = "UTF-8";
158
165
166static int unit_id_top;
167static int unit_ids[MAX_NUM_UNITS_BELOW]; /* ids of the units icons in
168 * information display: (or 0) */
172
173static gint timer_id; /* Ditto */
177
178static bool gui_up = FALSE;
179
180static bool audio_paused = FALSE;
181static bool client_focus = TRUE;
182
184
185static struct video_mode vmode = { -1, -1 };
186
187static void set_g_log_callbacks(void);
188
190 double x, double y, gpointer data);
191
192static void end_turn_callback(GtkWidget *w, gpointer data);
194 gpointer data);
195static void set_wait_for_writable_socket(struct connection *pc,
196 bool socket_writable);
197
198static void print_usage(void);
199static void activate_gui(GtkApplication *app, gpointer data);
200static bool parse_options(int argc, char **argv);
204 GdkModifierType state,
205 gpointer data);
207 gdouble dx, gdouble dy,
208 gpointer data);
209
210static void tearoff_callback(GtkWidget *b, gpointer data);
211static GtkWidget *detached_widget_new(void);
213
215 double x, double y, gpointer data);
217 double x, double y, gpointer data);
218static gboolean quit_dialog_callback(void);
219
221 gpointer user_data);
222
223static void free_unit_table(void);
224
225static void adjust_default_options(void);
226
227static float zoom_steps_custom[] = {
228 -1.0, 0.13, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 4.0, -1.0
229};
230
231/**********************************************************************/
234static void log_callback_utf8(enum log_level level, const char *message,
235 bool file_too)
236{
237 if (!file_too || level <= LOG_FATAL) {
238 fc_fprintf(stderr, "%d: %s\n", level, message);
239 }
240}
241
242/**********************************************************************/
247{
248 double seconds = real_timer_callback();
249
251 if (!audio_paused && !client_focus) {
252 audio_pause();
254 } else if (audio_paused && client_focus) {
255 audio_resume();
257 }
258 }
259
261
262 return FALSE;
263}
264
265/**********************************************************************/
269static void print_usage(void)
270{
271 /* add client-specific usage information here */
273 _("gtk4-client gui-specific options are:\n"));
274
276 _("-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
277 "screen\n"));
279 /* TRANS: Keep word 'default' untranslated */
280 _("-z, --zoom LEVEL\tSet zoom level; use value 'default' "
281 "to reset\n\n"));
282
283 /* TRANS: No full stop after the URL, could cause confusion. */
284 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
285}
286
287/**********************************************************************/
290static bool parse_options(int argc, char **argv)
291{
292 int i = 1;
293
294 while (i < argc) {
295 char *option = NULL;
296
297 if (is_option("--help", argv[i])) {
298 print_usage();
299
300 return FALSE;
301 } else if ((option = get_option_malloc("--zoom", argv, &i, argc, FALSE))) {
302 char *endptr;
303
304 if (strcmp("default", option)) {
307 } else {
309 }
310 free(option);
311 } else if ((option = get_option_malloc("--resolution", argv, &i, argc, FALSE))) {
313 fc_fprintf(stderr, _("Illegal video mode '%s'\n"), option);
315 }
316 free(option);
317 } else {
318 fc_fprintf(stderr, _("Unknown command-line option \"%s\".\n"),
319 argv[i]);
321 }
322
323 i++;
324 }
325
326 return TRUE;
327}
328
329/**********************************************************************/
333 gpointer data)
334{
335 switch (arg) {
338
339 if (!gtk_widget_get_can_focus(w)) {
340 return;
341 }
342
343 if (!gtk_widget_is_focus(w)) {
345 return;
346 }
347 break;
348
349 default:
350 break;
351 }
352}
353
354/**********************************************************************/
376
377/**********************************************************************/
388
389/**********************************************************************/
393{
394 if ((state & GDK_SHIFT_MASK)) {
395 switch (keyval) {
396
397 case GDK_KEY_Left:
399 return TRUE;
400
401 case GDK_KEY_Right:
403 return TRUE;
404
405 case GDK_KEY_Up:
407 return TRUE;
408
409 case GDK_KEY_Down:
411 return TRUE;
412
413 case GDK_KEY_Home:
415 return TRUE;
416
417 case GDK_KEY_Page_Up:
420 return TRUE;
421
425 return TRUE;
426
427 default:
428 break;
429 }
430 } else if (!(state & GDK_CONTROL_MASK)) {
431 switch (keyval) {
432 default:
433 break;
434 }
435 }
436
437 if (state & GDK_SHIFT_MASK) {
438 bool volchange = FALSE;
439
440 switch (keyval) {
441 case GDK_KEY_plus:
442 case GDK_KEY_KP_Add:
444 volchange = TRUE;
445 break;
446
447 case GDK_KEY_minus:
450 volchange = TRUE;
451 break;
452
453 default:
454 break;
455 }
456
457 if (volchange) {
459 "sound_effects_volume");
460
463 100);
465
466 return TRUE;
467 }
468 } else if (!(state & GDK_CONTROL_MASK)) {
469 switch (keyval) {
470 case GDK_KEY_plus:
471 case GDK_KEY_KP_Add:
472 zoom_step_up();
473 return TRUE;
474
475 case GDK_KEY_minus:
478 return TRUE;
479
480 default:
481 break;
482 }
483 }
484
485 /* Return here if observer */
486 if (client_is_observer()) {
487 return FALSE;
488 }
489
490 switch (keyval) {
491
492 case GDK_KEY_KP_Up:
493 case GDK_KEY_KP_8:
494 case GDK_KEY_Up:
495 case GDK_KEY_8:
497 return TRUE;
498
500 case GDK_KEY_KP_9:
501 case GDK_KEY_Page_Up:
502 case GDK_KEY_9:
504 return TRUE;
505
506 case GDK_KEY_KP_Right:
507 case GDK_KEY_KP_6:
508 case GDK_KEY_Right:
509 case GDK_KEY_6:
511 return TRUE;
512
514 case GDK_KEY_KP_3:
516 case GDK_KEY_3:
518 return TRUE;
519
520 case GDK_KEY_KP_Down:
521 case GDK_KEY_KP_2:
522 case GDK_KEY_Down:
523 case GDK_KEY_2:
525 return TRUE;
526
527 case GDK_KEY_KP_End:
528 case GDK_KEY_KP_1:
529 case GDK_KEY_End:
530 case GDK_KEY_1:
532 return TRUE;
533
534 case GDK_KEY_KP_Left:
535 case GDK_KEY_KP_4:
536 case GDK_KEY_Left:
537 case GDK_KEY_4:
539 return TRUE;
540
541 case GDK_KEY_KP_Home:
542 case GDK_KEY_KP_7:
543 case GDK_KEY_Home:
544 case GDK_KEY_7:
546 return TRUE;
547
548 case GDK_KEY_KP_Begin:
549 case GDK_KEY_KP_5:
550 case GDK_KEY_5:
552 return TRUE;
553
554 case GDK_KEY_Escape:
556 return TRUE;
557
558 case GDK_KEY_b:
561 return TRUE;
562 }
563 break;
564
565 default:
566 break;
567 };
568
569 return FALSE;
570}
571
572/**********************************************************************/
578 GdkModifierType state,
579 gpointer data)
580{
581 if (inputline_has_focus()) {
582 return FALSE;
583 }
584
585 if (keyval == GDK_KEY_apostrophe) {
586 /* Allow this even if not in main map view; chatline is present on
587 * some other pages too */
588
589 /* Make the chatline visible if it's not currently.
590 * FIXME: should find the correct window, even when detached, from any
591 * other window; should scroll to the bottom automatically showing the
592 * latest text from other players; MUST NOT make spurious text windows
593 * at the bottom of other dialogs. */
595 /* The main game view is visible. May need to switch notebook. */
598 } else {
600 }
601 }
602
603 /* If the chatline is (now) visible, focus it. */
604 if (inputline_is_visible()) {
606 return TRUE;
607 }
608 }
609
612 return FALSE;
613 }
614
615 if (editor_is_active()) {
616 if (handle_edit_key_press(keyval, state)) {
617 return TRUE;
618 }
619 }
620
621 if (state & GDK_SHIFT_MASK) {
622 switch (keyval) {
623
624 case GDK_KEY_Return:
625 case GDK_KEY_KP_Enter:
626 key_end_turn();
627 return TRUE;
628
629 default:
630 break;
631 }
632 }
633
635 /* 0 means the map view is focused. */
636 return key_press_map_canvas(keyval, state);
637 }
638
639#if 0
640 /* We are focused some other dialog, tab, or widget. */
641 if ((state & GDK_CONTROL_MASK)) {
642 } else if ((state & GDK_SHIFT_MASK)) {
643 } else {
644 switch (keyval) {
645
646 case GDK_KEY_F4:
648 return TRUE;
649
650 default:
651 break;
652 };
653 }
654#endif /* 0 */
655
656 return FALSE;
657}
658
659/**********************************************************************/
705
706/**********************************************************************/
712{
713 g_object_ref(wdg); /* Make sure reference count stays above 0
714 * during the transition to new parent. */
715
716 if (GTK_IS_PANED(old_wdg)) {
718 } else if (GTK_IS_WINDOW(old_wdg)) {
720 } else {
722
724 }
725
726 if (GTK_IS_PANED(new_wdg)) {
728 } else if (GTK_IS_WINDOW(new_wdg)) {
730 } else {
732
734 }
735
737}
738
739/**********************************************************************/
749
750/**********************************************************************/
760
761/**********************************************************************/
765{
767
768 aparent = g_object_get_data(G_OBJECT(box), "aparent");
770
771 if (aparent != cparent) {
773
775 }
776}
777
778/**********************************************************************/
781static void tearoff_close(GtkWidget *w, gpointer data)
782{
784}
785
786/**********************************************************************/
791{
792 GtkWidget *box = GTK_WIDGET(data);
794
796 GtkWidget *w;
798
799 w = gtk_window_new();
801 gtk_widget_set_name(w, "Freeciv");
802 gtk_window_set_title(GTK_WINDOW(w), _("Freeciv"));
803 g_signal_connect(w, "close-request", G_CALLBACK(tearoff_close), box);
804
805 g_object_set_data(G_OBJECT(box), "aparent", gtk_widget_get_parent(box));
806
807 temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent");
808 if (temp_hide != NULL) {
810 }
811
813
815
816 if (temp_hide != NULL) {
818 }
819 } else {
820 tearoff_reattach(box);
821 }
822}
823
824/**********************************************************************/
828{
830
831 return hbox;
832}
833
834/**********************************************************************/
839{
840 GtkWidget *b, *fillbox;
842
845
846 /* These toggle buttons run vertically down the side of many UI
847 * elements, so they need to be thin horizontally. */
849 ".detach_button {\n"
850 " padding: 0px 0px 0px 0px;\n"
851 " min-width: 6px;\n"
852 "}",
853 -1);
854 }
855
861 gtk_widget_add_css_class(b, "detach_button");
862 gtk_widget_set_tooltip_text(b, _("Detach/Attach the pane."));
863
866
868
870
871 return fillbox;
872}
873
874/**********************************************************************/
881static void populate_unit_pic_table(void)
882{
883 int i, width;
885 GdkPixbuf *pix;
886 int ttw;
888
889 /* Get width of the overview window */
893
895
897 /* We want arrow to appear if there is other units in addition
898 to active one in tile. Active unit is not counted, so there
899 can be 0 other units to not to display arrow. */
900 num_units_below = 1 - 1;
901 } else {
904 }
905
906 /* Top row: the active unit. */
907 /* Note, we ref this and other widgets here so that we can unref them
908 * in reset_unit_table. */
912 gtk_grid_attach(GTK_GRID(table), unit_pic, 0, 0, 1, 1);
913
915 g_signal_connect(controller, "pressed",
917 GINT_TO_POINTER(-1));
919
921 /* Bottom row: other units in the same tile. */
922 for (i = 0; i < num_units_below; i++) {
926
928 g_signal_connect(controller, "pressed",
932
934 i, 1, 1, 1);
935 }
936 }
937
938 /* Create arrow (popup for all units on the selected tile) */
942
944 g_signal_connect(controller, "pressed",
946 NULL);
948
949 /* An extra layer so that we can hide the clickable button but keep
950 * an explicit size request to avoid the layout jumping around */
957 gdk_pixbuf_get_width(pix), -1);
959
961 /* Display on bottom row. */
963 num_units_below, 1, 1, 1);
964 } else {
965 /* Display on top row (there is no bottom row). */
967 1, 0, 1, 1);
968 }
969
971}
972
973/**********************************************************************/
996
997/**********************************************************************/
1001{
1002 /* Unreference all of the widgets that we're about to reallocate, thus
1003 * avoiding a memory leak. Remove them from the container first, just
1004 * to be safe. Note, the widgets are ref'd in
1005 * populate_unit_pic_table(). */
1007
1009
1010 /* We have to force a redraw of the units. And we explicitly have
1011 * to force a redraw of the focus unit, which is normally only
1012 * redrawn when the focus changes. We also have to force the 'more'
1013 * arrow to go away, both by expicitly hiding it and telling it to
1014 * do so (this will be reset immediately afterwards if necessary,
1015 * but we have to make the *internal* state consistent). */
1018 if (get_num_units_in_focus() == 1) {
1020 } else {
1021 set_unit_icon(-1, NULL);
1022 }
1024}
1025
1026/**********************************************************************/
1029#if 0
1031{
1036}
1037#endif
1038
1039/**********************************************************************/
1047
1048/**********************************************************************/
1052{
1053 struct option *opt = optset_option_by_name(server_optset, "fixedlength");
1054
1055 if (opt != NULL && option_bool_get(opt)) {
1057 _("Fixed length turns"));
1058 } else {
1059 char buf[256];
1060
1061 fc_snprintf(buf, sizeof(buf), "%s:\n%s",
1062 _("Turn Done"), _("Shift+Return"));
1064 }
1065}
1066
1067/**********************************************************************/
1070static void setup_widgets(void)
1071{
1072 GtkWidget *page, *hgrid, *hgrid2, *label;
1073 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1074 GtkWidget *button, *view, *mainbox, *vbox, *right_vbox = NULL;
1075 int i;
1076 GtkWidget *notebook, *statusbar;
1078 struct sprite *spr;
1079 int right_row = 0;
1080 int top_row = 0;
1081 int grid_col = 0;
1082 int grid2_col = 0;
1085 GtkWidget *ebar;
1086
1088
1089 notebook = gtk_notebook_new();
1090
1091 toplevel_tabs = notebook;
1096 gtk_box_append(GTK_BOX(mainbox), notebook);
1099
1110
1112
1118
1119 /* *** Everything in the top *** */
1120
1121 page = gtk_scrolled_window_new();
1126 TRUE);
1127 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1128
1133 hgrid = gtk_grid_new();
1134
1136 /* The window is divided into two horizontal panels: overview +
1137 * civinfo + unitinfo, main view + message window. */
1139 right_row = 0;
1143
1149
1150 /* Overview size designed for small displays (netbooks). */
1153 } else {
1154 /* The window is divided into two vertical panes: overview +
1155 * + civinfo + unitinfo + main view, message window. */
1160
1161 /* Overview size designed for big displays (desktops). */
1164 }
1165
1166 /* This holds the overview canvas, production info, etc. */
1168 /* Put vbox to the left of anything else in hgrid -- right_vbox is either
1169 * the chat/messages pane, or NULL which is OK */
1171 GTK_POS_LEFT, 1, 1);
1172 grid_col++;
1173
1174 /* Overview canvas */
1180
1188
1198
1200
1203
1206
1221
1222 /* The rest */
1229
1230 /* Info on player's civilization, when game is running. */
1231 frame = gtk_frame_new("");
1232 gtk_box_append(GTK_BOX(avbox), frame);
1233
1234 main_frame_civ_name = frame;
1235
1239
1240 label = gtk_label_new(NULL);
1244 gtk_widget_set_margin_end(label, 2);
1245 gtk_widget_set_margin_top(label, 2);
1247
1250 G_CALLBACK(show_info_popup), frame);
1253 main_label_info = label;
1254
1255 /* Production status */
1256 table = gtk_grid_new();
1260
1261 /* Citizens for taxrates */
1262 table2 = gtk_grid_new();
1263 gtk_grid_attach(GTK_GRID(table), table2, 0, 0, 10, 1);
1265
1266 for (i = 0; i < 10; i++) {
1268
1271
1274 g_signal_connect(controller, "pressed",
1280 g_signal_connect(controller, "pressed",
1284 }
1285
1286 /* Science, environmental, govt, timeout */
1288 if (spr != NULL) {
1290 } else {
1292 }
1293
1295 if (spr != NULL) {
1297 } else {
1299 }
1300
1302 if (spr != NULL) {
1304 } else {
1306 }
1307
1309 if (spr != NULL) {
1311 } else {
1313 }
1314
1315 for (i = 0; i < 4; i++) {
1316 GtkWidget *w;
1317
1318 switch (i) {
1319 case 0:
1320 w = bulb_label;
1321 break;
1322 case 1:
1323 w = sun_label;
1324 break;
1325 case 2:
1326 w = flake_label;
1327 break;
1328 default:
1329 case 3:
1330 w = government_label;
1331 break;
1332 }
1333
1340 gtk_grid_attach(GTK_GRID(table), w, i, 1, 1, 1);
1341 }
1342
1344
1345 frame = gtk_frame_new(NULL);
1346 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1348
1349
1350 /* Turn done */
1352
1354
1358
1359 /* Selected unit status */
1360
1361 /* If you turn this to something else than GtkBox, also adjust
1362 * editgui.c replace_widget() code that removes and adds widgets from it. */
1366
1367 /* In edit mode the unit_info_box widget is replaced by the
1368 * editinfobox, so we need to add a ref here so that it is
1369 * not destroyed when removed from its container.
1370 * See editinfobox_refresh() call to replace_widget() */
1372
1375
1381
1382 label = gtk_label_new(NULL);
1387 gtk_widget_set_margin_end(label, 2);
1388 gtk_widget_set_margin_top(label, 2);
1391 unit_info_label = label;
1392
1393 hgrid2 = gtk_grid_new();
1395
1396 table = gtk_grid_new();
1402
1405
1407
1408 /* Map canvas, editor toolbar, and scrollbars */
1409
1410 /* The top notebook containing the map view and dialogs. */
1411
1415
1416
1421 right_row = 0;
1424
1428 } else {
1430 }
1431
1433
1436
1443
1444 label = gtk_label_new(Q_("?noun:View"));
1446
1447 frame = gtk_frame_new(NULL);
1448 gtk_grid_attach(GTK_GRID(map_widget), frame, 0, 0, 1, 1);
1449
1455
1457
1458#if 0
1467#endif /* 0 */
1468
1470
1474
1478
1480 NULL, NULL);
1481
1485 g_signal_connect(mc_controller, "released",
1493 g_signal_connect(mc_controller, "released",
1512
1513 g_signal_connect(map_canvas, "resize",
1515
1517 g_signal_connect(mc_controller, "key-pressed",
1520
1521 /* *** The message window -- this is a detachable widget *** */
1522
1526 } else {
1528
1532
1536 }
1538
1541 } else {
1543 }
1550
1555
1562 }
1563 }
1564
1566
1569 TRUE);
1574
1575 label = gtk_label_new(_("Chat"));
1577
1584
1585 gtk_widget_set_name(text, "chatline");
1586
1588 gtk_widget_realize(text);
1590
1592 if (dtach_lowbox != NULL) {
1594 }
1595
1597
1598 /* The chat line */
1605
1606 button = gtk_check_button_new_with_label(_("Allies Only"));
1610 g_signal_connect(button, "toggled",
1614
1615 button = gtk_button_new_with_label(_("Clear links"));
1616 g_signal_connect(button, "clicked",
1619
1620 /* Other things to take care of */
1621
1623 TRUE);
1624
1627 }
1628
1631
1635 }
1636}
1637
1638/**********************************************************************/
1643 const gchar *message,
1644 gpointer user_data)
1645{
1646 enum log_level fllvl = LOG_ERROR;
1647
1648 switch (log_level) {
1649 case G_LOG_LEVEL_DEBUG:
1650 fllvl = LOG_DEBUG;
1651 break;
1653 fllvl = LOG_WARN;
1654 break;
1655 default:
1656 break;
1657 }
1658
1659 if (log_domain != NULL) {
1660 log_base(fllvl, "%s: %s", log_domain, message);
1661 } else {
1662 log_base(fllvl, "%s", message);
1663 }
1664}
1665
1666/**********************************************************************/
1670 const GLogField *fields,
1672 gpointer user_data)
1673{
1674 /* No need to have formatter of our own - let's use glib's default one. */
1676
1678
1679 return G_LOG_WRITER_HANDLED;
1680}
1681
1682/**********************************************************************/
1693
1694/**********************************************************************/
1697static void set_g_log_callbacks(void)
1698{
1699 /* Old API, still used by many log producers */
1701
1705
1706 /* glib >= 2.50 API */
1708}
1709
1710/**********************************************************************/
1721
1722/**********************************************************************/
1725int main(int argc, char **argv)
1726{
1727 return client_main(argc, argv, FALSE);
1728}
1729
1730/**********************************************************************/
1734{
1735 log_normal(_("Migrating options from gtk2 to gtk3 client"));
1736
1737#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1738#define MIGRATE_STR_OPTION(opt) \
1739 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1740 sizeof(gui_options.gui_gtk3_##opt));
1741
1742 /* Default theme name is never migrated */
1743 /* 'fullscreen', 'small_display_layout', and 'message_chat_location'
1744 * not migrated, as (unlike Gtk2), Gtk3-client tries to pick better
1745 * defaults for these in fresh installations based on screen size (see
1746 * adjust_default_options()); so user is probably better served by
1747 * getting these adaptive defaults than whatever they had for Gtk2.
1748 * Since 'fullscreen' isn't migrated, we don't need to worry about
1749 * preserving gui_gtk2_migrated_from_2_5 either. */
1763 MIGRATE_OPTION(popup_tech_help);
1764
1778
1779#undef MIGRATE_OPTION
1780#undef MIGRATE_STR_OPTION
1781
1783}
1784
1785/**********************************************************************/
1789{
1790 log_normal(_("Migrating options from gtk3 to gtk3.22 client"));
1791
1792#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_22_##opt = gui_options.gui_gtk3_##opt;
1793#define MIGRATE_STR_OPTION(opt) \
1794 strncpy(gui_options.gui_gtk3_22_##opt, gui_options.gui_gtk3_##opt, \
1795 sizeof(gui_options.gui_gtk3_22_##opt));
1796
1797 /* Default theme name is never migrated */
1798
1799 /* Simulate gui-gtk3's migrate_options_from_2_5() */
1801 log_normal(_("Migrating gtk3-client options from freeciv-2.5 options."));
1804 }
1805
1822 MIGRATE_OPTION(popup_tech_help);
1823
1837
1838#undef MIGRATE_OPTION
1839#undef MIGRATE_STR_OPTION
1840
1842}
1843
1844/**********************************************************************/
1848{
1849 log_normal(_("Migrating options from gtk3.22 to gtk4 client"));
1850
1851#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk3_22_##opt;
1852#define MIGRATE_STR_OPTION(opt) \
1853 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_22_##opt, \
1854 sizeof(GUI_GTK_OPTION(opt)));
1855
1856 /* Default theme name is never migrated */
1873 MIGRATE_OPTION(popup_tech_help);
1874
1888
1889#undef MIGRATE_OPTION
1890#undef MIGRATE_STR_OPTION
1891
1893}
1894
1895/**********************************************************************/
1898int ui_main(int argc, char **argv)
1899{
1900 if (parse_options(argc, argv)) {
1901 /* The locale has already been set in init_nls() and the windows-specific
1902 * locale logic in gtk_init() causes problems with zh_CN (see PR#39475) */
1904
1905 if (!gtk_init_check()) {
1906 log_fatal(_("Failed to open graphical mode."));
1907 return EXIT_FAILURE;
1908 }
1909
1911
1912 gui_up = TRUE;
1916 gui_up = FALSE;
1917
1926 cma_fe_done();
1928
1929 /* We have extra ref for unit_info_box that has protected
1930 * it from getting destroyed when editinfobox_refresh()
1931 * moves widgets around. Free that extra ref here. */
1933 if (empty_unit_paintable != NULL) {
1935 }
1936
1937 editgui_free();
1939 message_buffer = NULL; /* Result of destruction of everything */
1941 }
1942
1943 return EXIT_SUCCESS;
1944}
1945
1946/**********************************************************************/
1950{
1952 guint sig;
1954 char window_name[1024];
1955
1957 if (vmode.width > 0 && vmode.height > 0) {
1960 }
1961
1968
1970 gtk_widget_set_name(toplevel, "Freeciv");
1971
1973
1975
1976 if (gui_options.first_boot) {
1978 /* We're using fresh defaults for this version of this client,
1979 * so prevent any future migrations from other clients / versions */
1981 /* Avoid also marking previous Gtk clients as migrated, so that
1982 * they can have their own run of their adjust_default_options() if
1983 * they are ever run (as a side effect of Gtk2->Gtk3 migration). */
1984 } else {
1989 /* We want a fresh look at screen-size-related options after Gtk2 */
1991 /* We don't ever want to consider pre-2.6 fullscreen option again
1992 * (even for gui-gtk3) */
1994 }
1996 }
1998 }
1999 }
2000
2003 }
2004
2005 fc_snprintf(window_name, sizeof(window_name), _("Freeciv (%s)"), GUI_NAME_SHORT);
2007
2008 g_signal_connect(toplevel, "close-request",
2010
2011 /* Disable GTK cursor key focus movement */
2012 sig = g_signal_lookup("move-focus", GTK_TYPE_WIDGET);
2014 0, 0, 0, 0);
2016
2018 if (OT_FONT == option_type(poption)) {
2019 /* Force to call the appropriate callback. */
2021 }
2023
2026
2027 if (NULL == city_names_style) {
2029 log_error("city_names_style should have been set by options.");
2030 }
2033 log_error("city_productions_style should have been set by options.");
2034 }
2035 if (NULL == reqtree_text_style) {
2037 log_error("reqtree_text_style should have been set by options.");
2038 }
2039
2042
2043 /* keep the icon of the executable on Windows (see PR#36491) */
2044#ifndef FREECIV_MSWINDOWS
2045 {
2046 /* Only call this after tileset_load_tiles is called. */
2048 }
2049#endif /* FREECIV_MSWINDOWS */
2050
2051 setup_widgets();
2052 load_cursors();
2053 cma_fe_init();
2060 chatline_init();
2062
2064
2066
2067 /* Assumes toplevel showing */
2069
2070 /* Assumes client_state is set */
2072}
2073
2074/**********************************************************************/
2077bool is_gui_up(void)
2078{
2079 return gui_up;
2080}
2081
2082/**********************************************************************/
2085void ui_exit(void)
2086{
2087 if (message_buffer != NULL) {
2090 }
2091}
2092
2093/**********************************************************************/
2096enum gui_type get_gui_type(void)
2097{
2098 return GUI_GTK4;
2099}
2100
2101/**********************************************************************/
2108
2109/**********************************************************************/
2115void set_unit_icon(int idx, struct unit *punit)
2116{
2117 GtkWidget *w;
2118
2119 fc_assert_ret(idx >= -1 && idx < num_units_below);
2120
2121 if (idx == -1) {
2122 w = unit_pic;
2123 unit_id_top = punit ? punit->id : 0;
2124 } else {
2125 w = unit_below_pic[idx];
2126 unit_ids[idx] = punit ? punit->id : 0;
2127 }
2128
2129 if (!w) {
2130 return;
2131 }
2132
2133 if (punit) {
2135 } else {
2136 if (empty_unit_paintable == NULL) {
2137 /* FIXME: Use proper icon height instead of hardcoded 50 */
2139
2140 /* Add ref to avoid it getting destroyed along any single parent widget. */
2142 }
2144 }
2145}
2146
2147/**********************************************************************/
2153{
2154 static bool showing = FALSE;
2155
2156 if (more_arrow == NULL) {
2157 return;
2158 }
2159
2160 if (onoff && !showing) {
2162 showing = TRUE;
2163 } else if (!onoff && showing) {
2165 showing = FALSE;
2166 }
2167}
2168
2169/**********************************************************************/
2179
2180/**********************************************************************/
2185 double x, double y, gpointer data)
2186{
2187 int i = GPOINTER_TO_INT(data);
2188 struct unit *punit;
2189
2190 if (i == -1) {
2192 if (punit && unit_is_in_focus(punit)) {
2193 /* Clicking on the currently selected unit will center it. */
2195 }
2196 return TRUE;
2197 }
2198
2199 if (unit_ids[i] == 0) { /* No unit displayed at this place */
2200 return TRUE;
2201 }
2202
2204 if (NULL != punit && unit_owner(punit) == client_player()) {
2205 /* Unit shouldn't be NULL but may be owned by an ally. */
2207 }
2208
2209 return TRUE;
2210}
2211
2212/**********************************************************************/
2217 double x, double y, gpointer data)
2218{
2220
2221 if (punit) {
2223 }
2224
2225 return TRUE;
2226}
2227
2228/**********************************************************************/
2232{
2234}
2235
2236/**********************************************************************/
2240 double x, double y, gpointer data)
2241{
2242 GtkWidget *p;
2243 GtkWidget *child;
2244 GtkWidget *frame = GTK_WIDGET(data);
2245
2246 p = gtk_popover_new();
2247
2248 gtk_widget_set_parent(p, frame);
2251 g_signal_connect(p, "closed",
2254
2255 return TRUE;
2256}
2257
2258/**********************************************************************/
2266
2267/**********************************************************************/
2271 gpointer data)
2272{
2274
2275 return TRUE;
2276}
2277
2278/**********************************************************************/
2282 bool socket_writable)
2283{
2284 static bool previous_state = FALSE;
2285
2287
2289 return;
2290
2291 log_debug("set_wait_for_writable_socket(%d)", socket_writable);
2292
2297 NULL);
2298
2300}
2301
2302/**********************************************************************/
2306void add_net_input(int sock)
2307{
2308#ifdef FREECIV_MSWINDOWS
2310#else
2312#endif
2314 G_IO_IN | G_IO_ERR,
2316 NULL);
2318}
2319
2320/**********************************************************************/
2330
2331/**********************************************************************/
2335static void quit_dialog_response(GtkWidget *dialog, gint response)
2336{
2338 if (response == GTK_RESPONSE_YES) {
2340 if (client.conn.used) {
2342 }
2343 quit_gtk_main();
2344 }
2345}
2346
2347/**********************************************************************/
2351{
2352 /* Quit gtk main loop. After this it will return to finish
2353 * ui_main() */
2354
2356}
2357
2358/**********************************************************************/
2363{
2364 static GtkWidget *dialog;
2365
2366 if (!dialog) {
2368 0,
2371 _("Are you sure you want to quit?"));
2372 setup_dialog(dialog, toplevel);
2373
2374 g_signal_connect(dialog, "response",
2376 g_signal_connect(dialog, "destroy",
2377 G_CALLBACK(widget_destroyed), &dialog);
2378 }
2379
2381}
2382
2383/**********************************************************************/
2387{
2389 /* Stop emission of event. */
2390 return TRUE;
2391}
2392
2393struct callback {
2394 void (*callback)(void *data);
2395 void *data;
2396};
2397
2398/**********************************************************************/
2402{
2403 struct callback *cb = data;
2404
2405 (cb->callback)(cb->data);
2406 free(cb);
2407
2408 return FALSE;
2409}
2410
2411/**********************************************************************/
2416void add_idle_callback(void (callback)(void *), void *data)
2417{
2418 struct callback *cb = fc_malloc(sizeof(*cb));
2419
2420 cb->callback = callback;
2421 cb->data = data;
2423}
2424
2425/**********************************************************************/
2435
2436/**********************************************************************/
2441{
2442 GtkWidget *button;
2443
2445 fc_assert_ret(button != NULL);
2447
2450}
2451
2452/**********************************************************************/
2463
2464/**********************************************************************/
2474
2475/**********************************************************************/
2485
2486/**********************************************************************/
2496
2497/**********************************************************************/
2502{
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 != NULL);
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}
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:45
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:1316
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:75
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:116
bool inputline_has_focus(void)
Definition chatline.c:71
void inputline_toolkit_view_append_button(GtkWidget *toolkit_view, GtkWidget *button)
Definition chatline.c:1292
GtkWidget * inputline_toolkit_view_new(void)
Definition chatline.c:1270
void set_message_buffer_view_link_handlers(GtkWidget *view)
Definition chatline.c:744
bool inputline_is_visible(void)
Definition chatline.c:87
void chatline_init(void)
Definition chatline.c:1302
void inputline_grab_focus(void)
Definition chatline.c:79
void chatline_scroll_to_bottom(bool delayed)
Definition chatline.c:1006
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:78
GtkWidget * map_vertical_scrollbar
Definition gui_main.c:109
int ui_main(int argc, char **argv)
Definition gui_main.c:1887
const char * client_string
Definition gui_main.c:105
GtkTextBuffer * message_buffer
Definition gui_main.c:178
static void quit_dialog_response(GtkWidget *dialog, gint response)
Definition gui_main.c:2322
void real_focus_units_changed(void)
Definition gui_main.c:2149
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2126
static void print_usage(void)
Definition gui_main.c:265
#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK
Definition gui_main.c:116
#define option_var_set_callback(var, callback)
static gboolean quit_dialog_callback(void)
Definition gui_main.c:2375
static GIOChannel * srv_channel
Definition gui_main.c:182
GtkWidget * main_label_info
Definition gui_main.c:138
static bool monitor_size(GdkRectangle *rect_p)
Definition gui_main.c:2553
GtkWidget * bottom_notebook
Definition gui_main.c:129
GtkWidget * unit_info_label
Definition gui_main.c:151
static gboolean timer_callback(gpointer data)
Definition gui_main.c:242
struct video_mode * resolution_request_get(void)
Definition gui_main.c:2611
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2096
static int unit_ids[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:175
GtkWidget * timeout_label
Definition gui_main.c:148
static bool gui_up
Definition gui_main.c:186
static guint srv_id
Definition gui_main.c:183
static gboolean mouse_scroll_mapcanvas(GtkWidget *w, GdkEventScroll *ev)
Definition gui_main.c:683
PangoFontDescription * city_productions_style
Definition gui_main.c:134
GtkWidget * overview_scrolled_window
Definition gui_main.c:112
static GtkWidget * detached_widget_fill(GtkWidget *tearbox)
Definition gui_main.c:845
GtkWidget * top_notebook
Definition gui_main.c:129
#define MIGRATE_STR_OPTION(opt)
GtkWidget * unit_info_box
Definition gui_main.c:152
gboolean fc_lost_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:735
void ui_exit(void)
Definition gui_main.c:2066
enum gui_type get_gui_type(void)
Definition gui_main.c:2077
static GtkWidget * detached_widget_new(void)
Definition gui_main.c:834
gint cur_y
Definition gui_main.c:184
int main(int argc, char **argv)
Definition gui_main.c:1765
void fullscreen_opt_refresh(struct option *poption)
Definition gui_main.c:2433
void ui_init(void)
Definition gui_main.c:1755
static void free_unit_table(void)
Definition gui_main.c:995
static gboolean idle_callback_wrapper(gpointer data)
Definition gui_main.c:2390
static void apply_city_names_font(struct option *poption)
Definition gui_main.c:2445
static void apply_city_productions_font(struct option *poption)
Definition gui_main.c:2456
gboolean fc_gained_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:745
GtkWidget * government_label
Definition gui_main.c:147
GtkWidget * sun_label
Definition gui_main.c:145
PangoFontDescription * city_names_style
Definition gui_main.c:133
void refresh_chat_buttons(void)
Definition gui_main.c:2509
gboolean map_canvas_focus(void)
Definition gui_main.c:359
GtkWidget * turn_done_button
Definition gui_main.c:149
static GtkWidget * bottom_hpaned
Definition gui_main.c:131
static gint timer_id
Definition gui_main.c:181
int screen_width(void)
Definition gui_main.c:2575
GtkWidget * scroll_panel
Definition gui_main.c:141
static void end_turn_callback(GtkWidget *w, gpointer data)
Definition gui_main.c:2248
#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK
Definition gui_main.c:117
static void log_callback_utf8(enum log_level level, const char *message, bool file_too)
Definition gui_main.c:230
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2405
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2217
static void set_g_log_callbacks(void)
Definition gui_main.c:1739
void reset_unit_table(void)
Definition gui_main.c:1023
static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:400
GtkWidget * unit_info_frame
Definition gui_main.c:153
void options_extra_init(void)
Definition gui_main.c:2479
GtkWidget * top_vbox
Definition gui_main.c:128
static void allied_chat_only_callback(struct option *poption)
Definition gui_main.c:2418
static void adjust_default_options(void)
Definition gui_main.c:2623
static void set_wait_for_writable_socket(struct connection *pc, bool socket_writable)
Definition gui_main.c:2268
GtkWidget * ahbox
Definition gui_main.c:140
static void apply_reqtree_text_font(struct option *poption)
Definition gui_main.c:2467
bool is_gui_up(void)
Definition gui_main.c:2058
static gboolean toplevel_focus(GtkWidget *w, GtkDirectionType arg)
Definition gui_main.c:315
PangoFontDescription * reqtree_text_style
Definition gui_main.c:135
GtkWidget * flake_label
Definition gui_main.c:146
static void g_log_to_freelog_cb(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
Definition gui_main.c:1683
GtkWidget * avbox
Definition gui_main.c:140
gint cur_x
Definition gui_main.c:184
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2539
static void set_g_log_callback_domain(const char *domain)
Definition gui_main.c:1727
GtkWidget * bulb_label
Definition gui_main.c:144
GtkWidget * overview_canvas
Definition gui_main.c:111
GtkWidget * toplevel
Definition gui_main.c:125
static void setup_widgets(void)
Definition gui_main.c:1127
#define OVERVIEW_CANVAS_STORE_WIDTH
Definition gui_main.c:118
void remove_net_input(void)
Definition gui_main.c:2311
GtkWidget * map_horizontal_scrollbar
Definition gui_main.c:108
GtkWidget * map_canvas
Definition gui_main.c:107
static gboolean toplevel_key_press_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:599
void sound_bell(void)
Definition gui_main.c:2085
static void migrate_options_from_gtk2(void)
Definition gui_main.c:1773
GtkWidget * econ_label[10]
Definition gui_main.c:143
void popup_quit_dialog(void)
Definition gui_main.c:2349
static void migrate_options_from_gtk3(void)
Definition gui_main.c:1828
const char *const gui_character_encoding
Definition gui_main.c:161
static int unit_id_top
Definition gui_main.c:174
static gboolean get_net_input(GIOChannel *source, GIOCondition condition, gpointer data)
Definition gui_main.c:2257
static bool audio_paused
Definition gui_main.c:188
GtkWidget * map_widget
Definition gui_main.c:130
static bool client_focus
Definition gui_main.c:189
GtkWidget * right_notebook
Definition gui_main.c:129
void quit_gtk_main(void)
Definition gui_main.c:2337
static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data)
Definition gui_main.c:2530
static struct video_mode vmode
Definition gui_main.c:191
void add_net_input(int sock)
Definition gui_main.c:2293
static GLogWriterOutput g_log_writer_to_freelog_cb(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data)
Definition gui_main.c:1711
GtkWidget * toplevel_tabs
Definition gui_main.c:127
static GtkWidget * allied_chat_toggle_button
Definition gui_main.c:179
int overview_canvas_store_width
Definition gui_main.c:122
void update_turn_done_tooltip(void)
Definition gui_main.c:1108
static void tearoff_callback(GtkWidget *b, gpointer data)
Definition gui_main.c:789
GtkTextView * main_message_area
Definition gui_main.c:177
int overview_canvas_store_height
Definition gui_main.c:123
int screen_height(void)
Definition gui_main.c:2593
static bool parse_options(int argc, char **argv)
Definition gui_main.c:286
GtkWidget * conn_box
Definition gui_main.c:140
#define OVERVIEW_CANVAS_STORE_HEIGHT
Definition gui_main.c:120
GtkWidget * main_frame_civ_name
Definition gui_main.c:137
#define MIGRATE_OPTION(opt)
const bool gui_use_transliteration
Definition gui_main.c:162
#define GUI_NAME_FULL
Definition gui_main.h:22
#define GUI_NAME_SHORT
Definition gui_main.h:23
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
void dlg_tab_provider_prepare(void)
Definition gui_stuff.c:1155
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void gui_update_font_full(const char *font_name, const char *font_value, PangoFontDescription **font_desc)
Definition gui_stuff.c:1073
void happiness_dialog_init(void)
Definition happiness.c:86
void happiness_dialog_done(void)
Definition happiness.c:94
void help_system_init(void)
Definition helpdlg.c:157
void intel_dialog_done(void)
Definition inteldlg.c:128
void intel_dialog_init(void)
Definition inteldlg.c:119
void luaconsole_dialog_init(void)
Definition luaconsole.c:83
void luaconsole_dialog_done(void)
Definition luaconsole.c:101
gboolean move_overviewcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
Definition mapctrl.c:463
gboolean move_mapcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
Definition mapctrl.c:406
gboolean leave_mapcanvas(GtkWidget *widget, GdkEventCrossing *event)
Definition mapctrl.c:435
void update_city_descriptions(void)
Definition mapview.c:488
gboolean map_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data)
Definition mapview.c:424
gboolean overview_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data)
Definition mapview.c:356
void meswin_dialog_popup(bool raise)
Definition messagewin.c:417
GtkWidget * create_start_page(void)
Definition pages.c: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:1458
static GdkPaintable * empty_unit_paintable
Definition gui_main.c:159
static void tearoff_close(GtkWidget *w, gpointer data)
Definition gui_main.c:781
static void tearoff_reattach(GtkWidget *box)
Definition gui_main.c:764
gboolean terminate_signal_processing(GtkEventControllerFocus *controller, gpointer data)
Definition gui_main.c:1042
static GtkWidget * more_arrow_container
Definition gui_main.c:164
static GtkWidget * unit_pic
Definition gui_main.c:161
static gboolean select_more_arrow_callback(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition gui_main.c:2216
GtkWidget * econ_widget
Definition gui_main.c:154
static GtkApplication * fc_app
Definition gui_main.c:183
GtkApplication * gui_app(void)
Definition gui_main.c:2674
static GtkWidget * more_arrow
Definition gui_main.c:163
static float zoom_steps_custom[]
Definition gui_main.c:227
static void migrate_options_from_gtk3_22(void)
Definition gui_main.c:1847
void animation_idle_cb(void *data)
Definition gui_main.c:2428
static void activate_gui(GtkApplication *app, gpointer data)
Definition gui_main.c:1949
static void populate_unit_pic_table(void)
Definition gui_main.c:881
static void info_popup_closed(GtkWidget *self, gpointer data)
Definition gui_main.c:2231
static void move_from_container_to_container(GtkWidget *wdg, GtkWidget *old_wdg, GtkWidget *new_wdg)
Definition gui_main.c:709
static gboolean select_unit_pic_callback(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition gui_main.c:2184
static GtkWidget * unit_pic_table
Definition gui_main.c:160
static GtkWidget * unit_below_pic[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:162
void main_message_area_resize(void *data)
Definition gui_main.c:359
void widget_destroyed(GtkWidget *wdg, void *data)
Definition gui_stuff.c:1154
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:407
void put_unit_picture(struct unit *punit, GtkPicture *p, int height)
Definition mapview.c:493
void menus_set_initial_toggle_values(void)
Definition menu.c:2941
GtkWidget * picture_new_from_surface(cairo_surface_t *surf)
Definition sprite.c:526
log_callback_fn log_set_callback(log_callback_fn callback)
Definition log.c:290
#define fc_assert_ret(condition)
Definition log.h:191
#define log_verbose(message,...)
Definition log.h:109
#define fc_assert(condition)
Definition log.h:176
#define log_fatal(message,...)
Definition log.h:100
#define log_debug(message,...)
Definition log.h:115
#define log_normal(message,...)
Definition log.h:107
#define log_base(level, message,...)
Definition log.h:94
log_level
Definition log.h:28
@ LOG_ERROR
Definition log.h:30
@ LOG_DEBUG
Definition log.h:34
@ LOG_FATAL
Definition log.h:29
@ LOG_WARN
Definition log.h:31
#define log_error(message,...)
Definition log.h:103
void update_line(int canvas_x, int canvas_y)
void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
bool rbutton_down
bool tiles_hilited_cities
void scroll_mapview(enum direction8 gui_dir)
bool keyboardless_goto_button_down
void update_selection_rectangle(float canvas_x, float canvas_y)
void init_mapcanvas_and_overview(void)
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
void free_mapcanvas_and_overview(void)
void get_mapview_scroll_pos(int *scroll_x, int *scroll_y)
void get_mapview_scroll_step(int *xstep, int *ystep)
void set_mapview_scroll_pos(int scroll_x, int scroll_y, float zoom)
void center_tile_mapcanvas(const struct tile *ptile)
void update_animation(void)
void set_frame_by_frame_animation(void)
void link_marks_clear_all(void)
#define fc_malloc(sz)
Definition mem.h:34
void option_changed(struct option *poption)
Definition options.c:748
const struct option_set * server_optset
Definition options.c:4016
const struct option_set * client_optset
Definition options.c:1280
bool option_bool_get(const struct option *poption)
Definition options.c:797
enum option_type option_type(const struct option *poption)
Definition options.c:658
const char * option_font_target(const struct option *poption)
Definition options.c:1163
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6507
struct client_options gui_options
Definition options.c:71
const char * option_font_get(const struct option *poption)
Definition options.c:1141
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:431
#define GUI_GTK_OVERVIEW_MIN_XSIZE
Definition options.h:597
#define options_iterate(poptset, poption)
Definition options.h:550
@ GUI_GTK_MSGCHAT_MERGED
Definition options.h:69
@ GUI_GTK_MSGCHAT_SPLIT
Definition options.h:67
#define options_iterate_end
Definition options.h:555
const char * get_info_label_text_popup(void)
Definition text.c:969
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:2384
void(* callback)(void *data)
Definition gui_main.c:2383
struct connection conn
Definition client_main.h:96
bool silent_when_not_in_focus
Definition options.h:191
bool gui_gtk3_22_migrated_from_gtk3
Definition options.h:134
bool gui_gtk3_migrated_from_2_5
Definition options.h:139
int sound_effects_volume
Definition options.h:190
bool first_boot
Definition options.h:128
float zoom_default_level
Definition options.h:231
bool gui_gtk3_fullscreen
Definition options.h:266
bool migrate_fullscreen
Definition options.h:145
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:138
int id
Definition unit.h:145
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:974
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:1000
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
void tileset_load_tiles(struct tileset *t)
Definition tilespec.c:3628
void tileset_free_tiles(struct tileset *t)
Definition tilespec.c:6604
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7069
void tileset_init(struct tileset *t)
Definition tilespec.c:7126
struct sprite * get_arrow_sprite(const struct tileset *t, enum arrow_type arrow)
Definition tilespec.c:6868
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:6879
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:753
@ ARROW_RIGHT
Definition tilespec.h:200
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
float mouse_zoom
Definition zoom.c:28
void zoom_phase_set(bool individual_tiles)
Definition zoom.c: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