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_SDL2
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_SDL2 */
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-3.22 */
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
159
160const char *const gui_character_encoding = "UTF-8";
162
172
173static int unit_id_top;
174static int unit_ids[MAX_NUM_UNITS_BELOW]; /* ids of the units icons in
175 * information display: (or 0) */
179
183
184static bool gui_up = FALSE;
185
186static bool audio_paused = FALSE;
187static bool client_focus = TRUE;
188
189static struct video_mode vmode = { -1, -1 };
190
191static void set_g_log_callbacks(void);
192
195
196static void end_turn_callback(GtkWidget *w, gpointer data);
198 gpointer data);
199static void set_wait_for_writable_socket(struct connection *pc,
200 bool socket_writable);
201
202static void print_usage(void);
203static bool parse_options(int argc, char **argv);
207
208static void tearoff_callback(GtkWidget *b, gpointer data);
209static GtkWidget *detached_widget_new(void);
211
213 gpointer data);
215 gpointer data);
216static gboolean quit_dialog_callback(void);
217
219 gpointer user_data);
220
221static void free_unit_table(void);
222
223static void adjust_default_options(void);
224
225/**********************************************************************/
228static void log_callback_utf8(enum log_level level, const char *message,
229 bool file_too)
230{
231 if (!file_too || level <= LOG_FATAL) {
232 fc_fprintf(stderr, "%d: %s\n", level, message);
233 }
234}
235
236/**********************************************************************/
241{
242 double seconds = real_timer_callback();
243
245 if (!audio_paused && !client_focus) {
246 audio_pause();
248 } else if (audio_paused && client_focus) {
249 audio_resume();
251 }
252 }
253
255
256 return FALSE;
257}
258
259/**********************************************************************/
263static void print_usage(void)
264{
265 /* add client-specific usage information here */
267 _("This client accepts the standard Gtk command-line options\n"
268 "after '--'. See the Gtk documentation.\n\n"));
269
271 _("Other gui-specific options are:\n"));
272
274 _("-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
275 "screen\n\n"));
276
277 /* TRANS: No full stop after the URL, could cause confusion. */
278 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
279}
280
281/**********************************************************************/
284static bool parse_options(int argc, char **argv)
285{
286 int i = 1;
287
288 while (i < argc) {
289 char *option = NULL;
290
291 if (is_option("--help", argv[i])) {
292 print_usage();
293
294 return FALSE;
295 } else if ((option = get_option_malloc("--resolution", argv, &i, argc, FALSE))) {
297 fc_fprintf(stderr, _("Illegal video mode '%s'\n"), option);
299 }
300 free(option);
301 }
302 /* Can't check against unknown options, as those might be gtk options */
303
304 i++;
305 }
306
307 return TRUE;
308}
309
310/**********************************************************************/
314{
315 switch (arg) {
318
319 if (!gtk_widget_get_can_focus(w)) {
320 return FALSE;
321 }
322
323 if (!gtk_widget_is_focus(w)) {
325 return TRUE;
326 }
327 break;
328
329 default:
330 break;
331 }
332 return FALSE;
333}
334
335/**********************************************************************/
342 gpointer data)
343{
344 static int old_width = 0, old_height = 0;
345
346 if (allocation->width != old_width
347 || allocation->height != old_height) {
349 old_width = allocation->width;
350 old_height = allocation->height;
351 }
352}
353
354/**********************************************************************/
364
365/**********************************************************************/
375{
376 GtkWidget *focus;
377
379 if (focus) {
380 if (GTK_IS_ENTRY(focus)
381 || (GTK_IS_TEXT_VIEW(focus)
383 /* Propagate event to currently focused entry widget. */
384 if (gtk_widget_event(focus, ev)) {
385 /* Do not propagate event to our children. */
386 return TRUE;
387 }
388 }
389 }
390
391 /* Continue propagating event to our children. */
392 return FALSE;
393}
394
395/**********************************************************************/
399 gpointer data)
400{
401 if ((ev->state & GDK_SHIFT_MASK)) {
402 switch (ev->keyval) {
403
404 case GDK_KEY_Left:
406 return TRUE;
407
408 case GDK_KEY_Right:
410 return TRUE;
411
412 case GDK_KEY_Up:
414 return TRUE;
415
416 case GDK_KEY_Down:
418 return TRUE;
419
420 case GDK_KEY_Home:
422 return TRUE;
423
424 case GDK_KEY_Page_Up:
427 return TRUE;
428
432 return TRUE;
433
434 default:
435 break;
436 }
437 } else if (!(ev->state & ACCL_MOD_KEY)) {
438 switch (ev->keyval) {
439 default:
440 break;
441 }
442 }
443
444 if (ev->state & GDK_SHIFT_MASK) {
445 bool volchange = FALSE;
446
447 switch (ev->keyval) {
448 case GDK_KEY_KP_Add:
450 volchange = TRUE;
451 break;
452
455 volchange = TRUE;
456 break;
457
458 default:
459 break;
460 }
461
462 if (volchange) {
463 struct option *poption = optset_option_by_name(client_optset, "sound_effects_volume");
464
467
468 return TRUE;
469 }
470 }
471 if (!(ev->state & ACCL_MOD_KEY)) {
472 switch (ev->keyval) {
473 case GDK_KEY_plus:
474 case GDK_KEY_KP_Add:
475 zoom_step_up();
476 return TRUE;
477
478 case GDK_KEY_minus:
481 return TRUE;
482
483 default:
484 break;
485 }
486 }
487
488 /* Return here if observer */
489 if (client_is_observer()) {
490 return FALSE;
491 }
492
493 switch (ev->keyval) {
494
495 case GDK_KEY_KP_Up:
496 case GDK_KEY_KP_8:
497 case GDK_KEY_Up:
498 case GDK_KEY_8:
500 return TRUE;
501
503 case GDK_KEY_KP_9:
504 case GDK_KEY_Page_Up:
505 case GDK_KEY_9:
507 return TRUE;
508
509 case GDK_KEY_KP_Right:
510 case GDK_KEY_KP_6:
511 case GDK_KEY_Right:
512 case GDK_KEY_6:
514 return TRUE;
515
517 case GDK_KEY_KP_3:
519 case GDK_KEY_3:
521 return TRUE;
522
523 case GDK_KEY_KP_Down:
524 case GDK_KEY_KP_2:
525 case GDK_KEY_Down:
526 case GDK_KEY_2:
528 return TRUE;
529
530 case GDK_KEY_KP_End:
531 case GDK_KEY_KP_1:
532 case GDK_KEY_End:
533 case GDK_KEY_1:
535 return TRUE;
536
537 case GDK_KEY_KP_Left:
538 case GDK_KEY_KP_4:
539 case GDK_KEY_Left:
540 case GDK_KEY_4:
542 return TRUE;
543
544 case GDK_KEY_KP_Home:
545 case GDK_KEY_KP_7:
546 case GDK_KEY_Home:
547 case GDK_KEY_7:
549 return TRUE;
550
551 case GDK_KEY_KP_Begin:
552 case GDK_KEY_KP_5:
553 case GDK_KEY_5:
555 return TRUE;
556
557 case GDK_KEY_Escape:
559 return TRUE;
560
561 case GDK_KEY_b:
564 return TRUE;
565 }
566 break;
567
568 default:
569 break;
570 };
571
572 return FALSE;
573}
574
575/**********************************************************************/
579 gpointer data)
580{
581 /* inputline history code */
583 return FALSE;
584 }
585
586 if (editor_is_active()) {
588 }
589
590 return FALSE;
591}
592
593/**********************************************************************/
597 gpointer data)
598{
599 if (inputline_has_focus()) {
600 return FALSE;
601 }
602
603 if (ev->keyval == GDK_KEY_apostrophe) {
604 /* Allow this even if not in main map view; chatline is present on
605 * some other pages too */
606
607 /* Make the chatline visible if it's not currently.
608 * FIXME: should find the correct window, even when detached, from any
609 * other window; should scroll to the bottom automatically showing the
610 * latest text from other players; MUST NOT make spurious text windows
611 * at the bottom of other dialogs. */
613 /* The main game view is visible. May need to switch notebook. */
616 } else {
618 }
619 }
620
621 /* If the chatline is (now) visible, focus it. */
622 if (inputline_is_visible()) {
624 return TRUE;
625 }
626 }
627
630 return FALSE;
631 }
632
633 if (editor_is_active()) {
635 return TRUE;
636 }
637 }
638
639 if (ev->state & GDK_SHIFT_MASK) {
640 switch (ev->keyval) {
641
642 case GDK_KEY_Return:
643 case GDK_KEY_KP_Enter:
644 key_end_turn();
645 return TRUE;
646
647 default:
648 break;
649 }
650 }
651
653 /* 0 means the map view is focused. */
654 return key_press_map_canvas(w, ev, data);
655 }
656
657#if 0
658 /* We are focused some other dialog, tab, or widget. */
659 if ((ev->state & GDK_CONTROL_MASK)) {
660 } else if ((ev->state & GDK_SHIFT_MASK)) {
661 } else {
662 switch (ev->keyval) {
663
664 case GDK_KEY_F4:
666 return TRUE;
667
668 default:
669 break;
670 };
671 }
672#endif /* 0 */
673
674 return FALSE;
675}
676
677/**********************************************************************/
681{
683
684 if (!can_client_change_view()) {
685 return FALSE;
686 }
687
690
691 switch (ev->direction) {
692 case GDK_SCROLL_UP:
693 scroll_y -= ystep*2;
694 break;
695 case GDK_SCROLL_DOWN:
696 scroll_y += ystep*2;
697 break;
698 case GDK_SCROLL_RIGHT:
699 scroll_x += xstep*2;
700 break;
701 case GDK_SCROLL_LEFT:
702 scroll_x -= xstep*2;
703 break;
704 default:
705 return FALSE;
706 };
707
709
710 /* Emulating mouse move now */
713 }
714
715 update_line(ev->x, ev->y);
716 if (rbutton_down && (ev->state & GDK_BUTTON3_MASK)) {
718 }
719
722 }
723
725
726 return TRUE;
727}
728
729/**********************************************************************/
733{
735
736 return FALSE;
737}
738
739/**********************************************************************/
743{
745
746 return FALSE;
747}
748
749/**********************************************************************/
752static void tearoff_destroy(GtkWidget *w, gpointer data)
753{
754 GtkWidget *p, *b, *box;
756
757 box = GTK_WIDGET(data);
759 p = g_object_get_data(G_OBJECT(w), "parent");
760 b = g_object_get_data(G_OBJECT(w), "toggle");
762
764
765 g_object_ref(box); /* Make sure reference count stays above 0
766 * during the transition to new parent. */
769 g_object_unref(box);
770}
771
772/**********************************************************************/
776{
778
779 return FALSE;
780}
781
782/**********************************************************************/
787{
788 GtkWidget *box = GTK_WIDGET(data);
789
792 GtkWidget *w;
794
798 gtk_widget_set_name(w, "Freeciv");
799 gtk_window_set_title(GTK_WINDOW(w), _("Freeciv"));
801 g_signal_connect(w, "destroy", G_CALLBACK(tearoff_destroy), box);
802 g_signal_connect(w, "key_press_event",
804
806 g_object_set_data(G_OBJECT(w), "toggle", b);
807
808 temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent");
809 if (temp_hide != NULL) {
811 }
812
813 g_object_ref(box); /* Make sure reference count stays above 0
814 * during the transition to new parent. */
817 g_object_unref(box);
819
820 if (temp_hide != NULL) {
822 }
823 } else {
825 }
826}
827
828/**********************************************************************/
837
838/**********************************************************************/
843{
844 GtkWidget *b, *fillbox;
846
849
850 /* These toggle buttons run vertically down the side of many UI
851 * elements, so they need to be thin horizontally. */
853 ".detach_button {\n"
854 " padding: 0px 0px 0px 0px;\n"
855 " min-width: 6px;\n"
856 "}",
857 -1, NULL);
858 }
859
865 "detach_button");
866 gtk_widget_set_tooltip_text(b, _("Detach/Attach the pane."));
867
870
874
876
877 return fillbox;
878}
879
880/**********************************************************************/
888{
889 int i, width;
891 GdkPixbuf *pix;
892 int ttw;
893
894 /* Get width of the overview window */
898
900
902 /* We want arrow to appear if there is other units in addition
903 to active one in tile. Active unit is not counted, so there
904 can be 0 other units to not to display arrow. */
905 num_units_below = 1 - 1;
906 } else {
909 }
910
911 /* Top row: the active unit. */
912 /* Note, we ref this and other widgets here so that we can unref them
913 * in reset_unit_table. */
923 g_signal_connect(unit_image_button, "button_press_event",
925 GINT_TO_POINTER(-1));
926
928 /* Bottom row: other units in the same tile. */
929 for (i = 0; i < num_units_below; i++) {
937 FALSE);
941 "button_press_event",
944
946 i, 1, 1, 1);
947 }
948 }
949
950 /* Create arrow (popup for all units on the selected tile) */
957 FALSE);
961 "button_press_event",
963 /* An extra layer so that we can hide the clickable button but keep
964 * an explicit size request to avoid the layout jumping around */
973 gdk_pixbuf_get_width(pix), -1);
975
977 /* Display on bottom row. */
979 num_units_below, 1, 1, 1);
980 } else {
981 /* Display on top row (there is no bottom row). */
983 1, 0, 1, 1);
984 }
985
987}
988
989/**********************************************************************/
1016
1017/**********************************************************************/
1021{
1022 /* Unreference all of the widgets that we're about to reallocate, thus
1023 * avoiding a memory leak. Remove them from the container first, just
1024 * to be safe. Note, the widgets are ref'd in
1025 * populate_unit_image_table. */
1027
1029
1030 /* We have to force a redraw of the units. And we explicitly have
1031 * to force a redraw of the focus unit, which is normally only
1032 * redrawn when the focus changes. We also have to force the 'more'
1033 * arrow to go away, both by explicitly hiding it and telling it to
1034 * do so (this will be reset immediately afterwards if necessary,
1035 * but we have to make the *internal* state consistent). */
1038 if (get_num_units_in_focus() == 1) {
1040 } else {
1041 set_unit_icon(-1, NULL);
1042 }
1044}
1045
1046/**********************************************************************/
1050{
1051 if (enable) {
1053 /* Ensure the menus are really created before performing any operations
1054 * on them. */
1055 while (gtk_events_pending()) {
1057 }
1059 menus_init();
1061 } else {
1063 }
1064}
1065
1066/**********************************************************************/
1074{
1075 if (event->type != GDK_BUTTON_RELEASE) {
1076 return FALSE;
1077 }
1078
1081 /* Make sure the default gtk handler
1082 * does NOT get called in this case. */
1083 return TRUE;
1084 }
1085
1086 return FALSE;
1087}
1088
1089/**********************************************************************/
1092#if 0
1094{
1099}
1100#endif
1101
1102/**********************************************************************/
1106{
1107 struct option *opt = optset_option_by_name(server_optset, "fixedlength");
1108
1109 if (opt != NULL && option_bool_get(opt)) {
1111 _("Fixed length turns"));
1112 } else {
1113 char buf[256];
1114
1115 fc_snprintf(buf, sizeof(buf), "%s:\n%s",
1116 _("Turn Done"), _("Shift+Return"));
1118 }
1119}
1120
1121/**********************************************************************/
1124static void setup_widgets(void)
1125{
1126 GtkWidget *page, *ebox, *hgrid, *hgrid2, *label;
1127 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1128 GtkWidget *button, *view, *vgrid, *right_vbox = NULL;
1129 int i;
1130 GtkWidget *notebook, *statusbar;
1132 struct sprite *spr;
1133
1135
1136 notebook = gtk_notebook_new();
1137
1138 /* Stop mouse wheel notebook page switching. */
1139 g_signal_connect(notebook, "scroll_event",
1141
1142 toplevel_tabs = notebook;
1145 vgrid = gtk_grid_new();
1153
1164
1166
1168 g_object_set(ingame_votebar, "margin", 2, NULL);
1169
1170 /* *** everything in the top *** */
1171
1177 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1178
1183 hgrid = gtk_grid_new();
1184
1186 /* The window is divided into two horizontal panels: overview +
1187 * civinfo + unitinfo, main view + message window. */
1192
1198
1199 /* Overview size designed for small displays (netbooks). */
1202 } else {
1203 /* The window is divided into two vertical panes: overview +
1204 * + civinfo + unitinfo + main view, message window. */
1209
1210 /* Overview size designed for big displays (desktops). */
1213 }
1214
1215 /* this holds the overview canvas, production info, etc. */
1216 vgrid = gtk_grid_new();
1220 /* Put vgrid to the left of anything else in hgrid -- right_vbox is either
1221 * the chat/messages pane, or NULL which is OK */
1223 GTK_POS_LEFT, 1, 1);
1224
1225 /* Overview canvas */
1231
1236
1246
1251
1254
1257
1258 g_signal_connect(overview_canvas, "motion_notify_event",
1260
1261 g_signal_connect(overview_canvas, "button_press_event",
1263
1264 /* The rest */
1265
1272
1273 /* Info on player's civilization, when game is running. */
1274 frame = gtk_frame_new("");
1276
1277 main_frame_civ_name = frame;
1278
1279 vgrid = gtk_grid_new();
1284
1285 ebox = gtk_event_box_new();
1288 g_signal_connect(ebox, "button_press_event",
1291
1292 label = gtk_label_new(NULL);
1296 gtk_widget_set_margin_end(label, 2);
1297 gtk_widget_set_margin_top(label, 2);
1299 gtk_container_add(GTK_CONTAINER(ebox), label);
1300 main_label_info = label;
1301
1302 /* Production status */
1303 table = gtk_grid_new();
1307
1308 /* Citizens for taxrates */
1309 ebox = gtk_event_box_new();
1311 gtk_grid_attach(GTK_GRID(table), ebox, 0, 0, 10, 1);
1312 econ_ebox = ebox;
1313
1314 table2 = gtk_grid_new();
1316
1317 for (i = 0; i < 10; i++) {
1318 ebox = gtk_event_box_new();
1321
1322 gtk_grid_attach(GTK_GRID(table2), ebox, i, 0, 1, 1);
1323
1324 g_signal_connect(ebox, "button_press_event",
1326
1330 }
1331
1332 /* Science, environmental, govt, timeout */
1334 if (spr != NULL) {
1336 } else {
1338 }
1339
1341 if (spr != NULL) {
1343 } else {
1345 }
1346
1348 if (spr != NULL) {
1350 } else {
1352 }
1353
1355 if (spr != NULL) {
1357 } else {
1359 }
1360
1361 for (i = 0; i < 4; i++) {
1362 GtkWidget *w;
1363
1364 ebox = gtk_event_box_new();
1366
1367 switch (i) {
1368 case 0:
1369 w = bulb_label;
1370 bulb_ebox = ebox;
1371 break;
1372 case 1:
1373 w = sun_label;
1374 sun_ebox = ebox;
1375 break;
1376 case 2:
1377 w = flake_label;
1378 flake_ebox = ebox;
1379 break;
1380 default:
1381 case 3:
1382 w = government_label;
1383 government_ebox = ebox;
1384 break;
1385 }
1386
1394 gtk_grid_attach(GTK_GRID(table), ebox, i, 1, 1, 1);
1395 }
1396
1398
1399 frame = gtk_frame_new(NULL);
1400 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1402
1403
1404 /* Turn done */
1406
1408
1412
1413 /* Selected unit status */
1414
1420
1421 /* In edit mode the unit_info_box widget is replaced by the
1422 * editinfobox, so we need to add a ref here so that it is
1423 * not destroyed when removed from its container.
1424 * See editinfobox_refresh(). */
1426
1429
1436
1437 label = gtk_label_new(NULL);
1442 gtk_widget_set_margin_end(label, 2);
1443 gtk_widget_set_margin_top(label, 2);
1445 gtk_container_add(GTK_CONTAINER(sw), label);
1446 unit_info_label = label;
1447
1448 hgrid2 = gtk_grid_new();
1450
1451 table = gtk_grid_new();
1452 g_object_set(table, "margin", 5, NULL);
1454
1457
1459
1460 /* Map canvas, editor toolbar, and scrollbars */
1461
1462 /* The top notebook containing the map view and dialogs. */
1463
1467
1468
1475
1479 } else {
1481 }
1482
1484
1485 vgrid = gtk_grid_new();
1489
1491 g_object_set(editgui_get_editbar()->widget, "margin", 4, NULL);
1492
1493 label = gtk_label_new(Q_("?noun:View"));
1495
1496 frame = gtk_frame_new(NULL);
1497 gtk_grid_attach(GTK_GRID(map_widget), frame, 0, 0, 1, 1);
1498
1504
1505#if 0
1514#endif /* 0 */
1515
1522
1524
1528
1532
1535
1536 g_signal_connect(map_canvas, "configure_event",
1538
1539 g_signal_connect(map_canvas, "motion_notify_event",
1541
1542 g_signal_connect(toplevel, "enter_notify_event",
1544
1545 g_signal_connect(map_canvas, "button_press_event",
1547
1548 g_signal_connect(map_canvas, "button_release_event",
1550
1551 g_signal_connect(map_canvas, "scroll_event",
1553
1554 g_signal_connect(toplevel, "key_press_event",
1556
1557 g_signal_connect(toplevel, "key_release_event",
1559
1560 /* *** The message window -- this is a detachable widget *** */
1561
1564 } else {
1566
1570
1571 vgrid = gtk_grid_new();
1576 }
1578
1581 } else {
1583 }
1585 g_object_set(hpaned, "margin", 4, NULL);
1586
1591
1596 g_signal_connect(right_notebook, "button-release-event",
1600 }
1601 }
1602
1603 vgrid = gtk_grid_new();
1606
1613
1614 label = gtk_label_new(_("Chat"));
1616
1623 g_signal_connect(text, "size-allocate",
1625
1626 gtk_widget_set_name(text, "chatline");
1627
1629 gtk_widget_realize(text);
1631
1633 if (dtach_lowbox != NULL) {
1635 }
1636
1638
1639 /* the chat line */
1642 g_object_set(view, "margin", 3, NULL);
1643
1644 button = gtk_check_button_new_with_label(_("Allies Only"));
1648 g_signal_connect(button, "toggled",
1652
1653 button = gtk_button_new_with_label(_("Clear links"));
1654 g_signal_connect(button, "clicked",
1657
1658 /* Other things to take care of */
1659
1661
1664 }
1665
1668
1672 }
1673}
1674
1675/**********************************************************************/
1680 const gchar *message,
1681 gpointer user_data)
1682{
1683 enum log_level fllvl = LOG_ERROR;
1684
1685 switch (log_level) {
1686 case G_LOG_LEVEL_DEBUG:
1687 fllvl = LOG_DEBUG;
1688 break;
1690 fllvl = LOG_WARN;
1691 break;
1692 default:
1693 break;
1694 }
1695
1696 if (log_domain != NULL) {
1697 log_base(fllvl, "%s: %s", log_domain, message);
1698 } else {
1699 log_base(fllvl, "%s", message);
1700 }
1701}
1702
1703/**********************************************************************/
1707 const GLogField *fields,
1709 gpointer user_data)
1710{
1711 /* No need to have formatter of our own - let's use glib's default one. */
1713
1715
1716 return G_LOG_WRITER_HANDLED;
1717}
1718
1719/**********************************************************************/
1730
1731/**********************************************************************/
1734static void set_g_log_callbacks(void)
1735{
1736 /* Old API, still used by many log producers */
1738
1742
1743 /* glib >= 2.50 API */
1745}
1746
1747/**********************************************************************/
1756
1757/**********************************************************************/
1760int main(int argc, char **argv)
1761{
1762 return client_main(argc, argv, FALSE);
1763}
1764
1765/**********************************************************************/
1769{
1770 log_normal(_("Migrating options from gtk2 to gtk3 client"));
1771
1772#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1773#define MIGRATE_STR_OPTION(opt) \
1774 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1775 sizeof(gui_options.gui_gtk3_##opt));
1776
1777 /* Default theme name is never migrated */
1778 /* 'fullscreen', 'small_display_layout', and 'message_chat_location'
1779 * not migrated, as (unlike Gtk2), Gtk3-client tries to pick better
1780 * defaults for these in fresh installations based on screen size (see
1781 * adjust_default_options()); so user is probably better served by
1782 * getting these adaptive defaults than whatever they had for Gtk2.
1783 * Since 'fullscreen' isn't migrated, we don't need to worry about
1784 * preserving gui_gtk2_migrated_from_2_5 either. */
1798 MIGRATE_OPTION(popup_tech_help);
1799
1813
1814#undef MIGRATE_OPTION
1815#undef MIGRATE_STR_OPTION
1816
1818}
1819
1820/**********************************************************************/
1824{
1825 log_normal(_("Migrating options from gtk3 to gtk3.22 client"));
1826
1827#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk3_##opt;
1828#define MIGRATE_STR_OPTION(opt) \
1829 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_##opt, \
1830 sizeof(GUI_GTK_OPTION(opt)));
1831
1832 /* Default theme name is never migrated */
1833
1834 /* Simulate gui-gtk3's migrate_options_from_2_5() */
1836 log_normal(_("Migrating gtk3-client options from freeciv-2.5 options."));
1839 }
1840
1857 MIGRATE_OPTION(popup_tech_help);
1858
1872
1873#undef MIGRATE_OPTION
1874#undef MIGRATE_STR_OPTION
1875
1877}
1878
1879/**********************************************************************/
1882int ui_main(int argc, char **argv)
1883{
1885 guint sig;
1886
1887 if (parse_options(argc, argv)) {
1888 char window_name[1024];
1889
1890 /* The locale has already been set in init_nls() and the windows-specific
1891 * locale logic in gtk_init() causes problems with zh_CN (see PR#39475) */
1893
1894 /* GTK withdraw gtk options. Process GTK arguments */
1895 if (!gtk_init_check(&argc, &argv)) {
1896 log_fatal(_("Failed to open graphical mode."));
1897 return EXIT_FAILURE;
1898 }
1899
1900 g_set_prgname("org.freeciv.gtk322");
1901
1903
1905
1908 if (vmode.width > 0 && vmode.height > 0) {
1910 }
1911 g_signal_connect(toplevel, "key_press_event",
1913
1914 g_signal_connect(toplevel, "focus_out_event",
1916 g_signal_connect(toplevel, "focus_in_event",
1918
1921 gtk_widget_set_name(toplevel, "Freeciv");
1923
1924 if (gui_options.first_boot) {
1926 /* We're using fresh defaults for this version of this client,
1927 * so prevent any future migrations from other clients / versions */
1929 /* Avoid also marking gtk3 as migrated, so that it can have its own
1930 * run of its adjust_default_options() if it is ever run (as a
1931 * side effect of Gtk2->Gtk3 migration). */
1932 } else {
1936 /* We want a fresh look at screen-size-related options after Gtk2 */
1938 /* We don't ever want to consider pre-2.6 fullscreen option again
1939 * (even for gui-gtk3) */
1941 }
1943 }
1944 }
1945
1948 }
1949
1950 fc_snprintf(window_name, sizeof(window_name), _("Freeciv (%s)"), GUI_NAME_SHORT);
1952
1953 g_signal_connect(toplevel, "delete_event",
1955
1956 /* Disable GTK+ cursor key focus movement */
1959 0, 0, 0, 0);
1961
1963 if (OT_FONT == option_type(poption)) {
1964 /* Force to call the appropriate callback. */
1966 }
1968
1971
1972 if (NULL == city_names_style) {
1974 log_error("city_names_style should have been set by options.");
1975 }
1978 log_error("city_productions_style should have been set by options.");
1979 }
1980 if (NULL == reqtree_text_style) {
1982 log_error("reqtree_text_style should have been set by options.");
1983 }
1984
1987
1988 /* Keep the icon of the executable on Windows (see PR#36491) */
1989#ifndef FREECIV_MSWINDOWS
1990 {
1992
1993 /* Only call this after tileset_load_tiles is called. */
1996 }
1997#endif /* FREECIV_MSWINDOWS */
1998
1999 setup_widgets();
2000 load_cursors();
2001 cma_fe_init();
2008 chatline_init();
2010
2012
2014
2015 /* Assumes toplevel showing */
2017
2018 /* Assumes client_state is set */
2020
2021 gui_up = TRUE;
2022 gtk_main();
2023 gui_up = FALSE;
2024
2033 cma_fe_done();
2035
2036 /* We have extra ref for unit_info_box that has protected
2037 * it from getting destroyed when editinfobox_refresh()
2038 * moves widgets around. Free that extra ref here. */
2040
2041 editgui_free();
2044 menus_free();
2045 message_buffer = NULL; /* Result of destruction of everything */
2047 }
2048
2049 return EXIT_SUCCESS;
2050}
2051
2052/**********************************************************************/
2055bool is_gui_up(void)
2056{
2057 return gui_up;
2058}
2059
2060/**********************************************************************/
2063void ui_exit(void)
2064{
2065 if (message_buffer != NULL) {
2068 }
2069}
2070
2071/**********************************************************************/
2074enum gui_type get_gui_type(void)
2075{
2076 return GUI_GTK3_22;
2077}
2078
2079/**********************************************************************/
2086
2087/**********************************************************************/
2093void set_unit_icon(int idx, struct unit *punit)
2094{
2095 GtkWidget *w;
2096
2097 fc_assert_ret(idx >= -1 && idx < num_units_below);
2098
2099 if (idx == -1) {
2100 w = unit_image;
2101 unit_id_top = punit ? punit->id : 0;
2102 } else {
2103 w = unit_below_image[idx];
2104 unit_ids[idx] = punit ? punit->id : 0;
2105 }
2106
2107 if (!w) {
2108 return;
2109 }
2110
2111 if (punit) {
2113 } else {
2115 }
2116}
2117
2118/**********************************************************************/
2124{
2125 static bool showing = FALSE;
2126
2128 return;
2129 }
2130
2131 if (onoff && !showing) {
2133 showing = TRUE;
2134 } else if (!onoff && showing) {
2136 showing = FALSE;
2137 }
2138}
2139
2140/**********************************************************************/
2150
2151/**********************************************************************/
2156 gpointer data)
2157{
2158 int i = GPOINTER_TO_INT(data);
2159 struct unit *punit;
2160
2161 if (i == -1) {
2163 if (punit && unit_is_in_focus(punit)) {
2164 /* Clicking on the currently selected unit will center it. */
2166 }
2167 return TRUE;
2168 }
2169
2170 if (unit_ids[i] == 0) /* no unit displayed at this place */
2171 return TRUE;
2172
2174 if (NULL != punit && unit_owner(punit) == client.conn.playing) {
2175 /* Unit shouldn't be NULL but may be owned by an ally. */
2177 }
2178
2179 return TRUE;
2180}
2181
2182/**********************************************************************/
2187 gpointer data)
2188{
2190
2191 if (punit) {
2193 }
2194
2195 return TRUE;
2196}
2197
2198/**********************************************************************/
2202 gpointer data)
2203{
2204 gtk_grab_remove(w);
2207
2208 return FALSE;
2209}
2210
2211/**********************************************************************/
2215{
2216 if (ev->button == 1) {
2217 GtkWidget *p;
2218
2223
2224 gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", p,
2225 "GtkLabel::label", get_info_label_text_popup(),
2226 "GtkWidget::visible", TRUE,
2227 NULL);
2228 gtk_widget_show(p);
2229
2232 TRUE, NULL, (GdkEvent *)ev, NULL, NULL);
2233 gtk_grab_add(p);
2234
2235 g_signal_connect_after(p, "button_release_event",
2237 }
2238
2239 return TRUE;
2240}
2241
2242/**********************************************************************/
2250
2251/**********************************************************************/
2255 gpointer data)
2256{
2258
2259 return TRUE;
2260}
2261
2262/**********************************************************************/
2266 bool socket_writable)
2267{
2268 static bool previous_state = FALSE;
2269
2271
2273 return;
2274
2275 log_debug("set_wait_for_writable_socket(%d)", socket_writable);
2276
2281 NULL);
2282
2284}
2285
2286/**********************************************************************/
2290void add_net_input(int sock)
2291{
2292#ifdef FREECIV_MSWINDOWS
2294#else
2296#endif
2298 G_IO_IN | G_IO_ERR,
2300 NULL);
2302}
2303
2304/**********************************************************************/
2314
2315/**********************************************************************/
2319static void quit_dialog_response(GtkWidget *dialog, gint response)
2320{
2321 gtk_widget_destroy(dialog);
2322 if (response == GTK_RESPONSE_YES) {
2324 if (client.conn.used) {
2326 }
2327 quit_gtk_main();
2328 }
2329}
2330
2331/**********************************************************************/
2335{
2336 /* Quit gtk main loop. After this it will return to finish
2337 * ui_main() */
2338
2339 gtk_main_quit();
2340}
2341
2342/**********************************************************************/
2347{
2348 static GtkWidget *dialog;
2349
2350 if (!dialog) {
2352 0,
2355 _("Are you sure you want to quit?"));
2356 setup_dialog(dialog, toplevel);
2357
2359
2360 g_signal_connect(dialog, "response",
2362 g_signal_connect(dialog, "destroy",
2364 }
2365
2367}
2368
2369/**********************************************************************/
2373{
2375 /* Stop emission of event. */
2376 return TRUE;
2377}
2378
2379struct callback {
2380 void (*callback)(void *data);
2381 void *data;
2382};
2383
2384/**********************************************************************/
2388{
2389 struct callback *cb = data;
2390
2391 (cb->callback)(cb->data);
2392 free(cb);
2393
2394 return FALSE;
2395}
2396
2397/**********************************************************************/
2402void add_idle_callback(void (callback)(void *), void *data)
2403{
2404 struct callback *cb = fc_malloc(sizeof(*cb));
2405
2406 cb->callback = callback;
2407 cb->data = data;
2409}
2410
2411/**********************************************************************/
2416{
2417 GtkWidget *button;
2418
2420 fc_assert_ret(button != NULL);
2422
2425}
2426
2427/**********************************************************************/
2438
2439/**********************************************************************/
2449
2450/**********************************************************************/
2460
2461/**********************************************************************/
2471
2472/**********************************************************************/
2477{
2478 struct option *poption;
2479
2480#define option_var_set_callback(var, callback) \
2481 if ((poption = optset_option_by_name(client_optset, \
2482 GUI_GTK_OPTION_STR(var)))) { \
2483 option_set_changed_callback(poption, callback); \
2484 } else { \
2485 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2486 }
2487
2492
2499#undef option_var_set_callback
2500}
2501
2502/**********************************************************************/
2507{
2508 GtkWidget *button;
2509
2511 fc_assert_ret(button != NULL);
2513
2514 /* Hide the "Allies Only" button for local games. */
2515 if (is_server_running()) {
2516 gtk_widget_hide(button);
2517 } else {
2518 gtk_widget_show(button);
2521 }
2522}
2523
2524/**********************************************************************/
2532
2533/**********************************************************************/
2537{
2538 cat_snprintf(outbuf, outlen, _("\nBuilt against gtk+ %d.%d.%d, using %d.%d.%d"
2539 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2544}
2545
2546/**********************************************************************/
2551{
2554
2556 if (!display) {
2557 return FALSE;
2558 }
2559
2561 if (!monitor) {
2562 return FALSE;
2563 }
2564
2566 return TRUE;
2567}
2568
2569/**********************************************************************/
2573{
2574 GdkRectangle rect;
2575
2576 if (vmode.width > 0) {
2577 return vmode.width;
2578 }
2579
2580 if (monitor_size(&rect)) {
2581 return rect.width;
2582 } else {
2583 return 0;
2584 }
2585}
2586
2587/**********************************************************************/
2591{
2592 GdkRectangle rect;
2593
2594 if (vmode.height > 0) {
2595 return vmode.height;
2596 }
2597
2598 if (monitor_size(&rect)) {
2599 return rect.height;
2600 } else {
2601 return 0;
2602 }
2603}
2604
2605/**********************************************************************/
2609{
2610 if (vmode.width > 0 && vmode.height > 0) {
2611 return &vmode;
2612 }
2613
2614 return NULL;
2615}
2616
2617/**********************************************************************/
2620static void adjust_default_options(void)
2621{
2622 int scr_height = screen_height();
2623
2624 if (scr_height > 0) {
2625 /* Adjust these options only if we do know the screen height. */
2626
2627 if (scr_height <= 480) {
2628 /* Freeciv is practically unusable outside fullscreen mode in so
2629 * small display */
2630 log_verbose("Changing default to fullscreen due to very small screen");
2632 }
2633 if (scr_height < 1024) {
2634 /* This is a small display */
2635 log_verbose("Defaulting to small widget layout due to small screen");
2637 log_verbose("Defaulting to merged messages/chat due to small screen");
2639 }
2640 }
2641}
void audio_pause(void)
Definition audio.c:607
void audio_resume(void)
Definition audio.c:615
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void chat_welcome_message(bool gui_has_copying_mitem)
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 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: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:73
bool editor_is_active(void)
Definition editor.c:347
enum event_type event
Definition events.c:81
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_release(GdkEventKey *ev)
Definition editgui.c:1782
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:78
GtkWidget * map_vertical_scrollbar
Definition gui_main.c:109
int ui_main(int argc, char **argv)
Definition gui_main.c:1882
const char * client_string
Definition gui_main.c:105
GtkTextBuffer * message_buffer
Definition gui_main.c:177
static void quit_dialog_response(GtkWidget *dialog, gint response)
Definition gui_main.c:2319
void real_focus_units_changed(void)
Definition gui_main.c:2146
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2123
static void print_usage(void)
Definition gui_main.c:263
#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK
Definition gui_main.c:116
#define option_var_set_callback(var, callback)
static gboolean select_unit_image_callback(GtkWidget *w, GdkEvent *ev, gpointer data)
Definition gui_main.c:2155
static gboolean quit_dialog_callback(void)
Definition gui_main.c:2372
static GIOChannel * srv_channel
Definition gui_main.c:180
GtkWidget * main_label_info
Definition gui_main.c:137
static bool monitor_size(GdkRectangle *rect_p)
Definition gui_main.c:2550
GtkWidget * bottom_notebook
Definition gui_main.c:129
GtkWidget * unit_info_label
Definition gui_main.c:150
static gboolean timer_callback(gpointer data)
Definition gui_main.c:240
struct video_mode * resolution_request_get(void)
Definition gui_main.c:2608
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2093
static int unit_ids[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:174
GtkWidget * timeout_label
Definition gui_main.c:147
static bool gui_up
Definition gui_main.c:184
static guint srv_id
Definition gui_main.c:181
static gboolean mouse_scroll_mapcanvas(GtkWidget *w, GdkEventScroll *ev)
Definition gui_main.c:680
PangoFontDescription * city_productions_style
Definition gui_main.c:133
GtkWidget * overview_scrolled_window
Definition gui_main.c:112
static GtkWidget * more_arrow_pixmap
Definition gui_main.c:169
static GtkWidget * detached_widget_fill(GtkWidget *tearbox)
Definition gui_main.c:842
void enable_menus(bool enable)
Definition gui_main.c:1049
static gboolean select_more_arrow_pixmap_callback(GtkWidget *w, GdkEvent *ev, gpointer data)
Definition gui_main.c:2186
GtkWidget * top_notebook
Definition gui_main.c:129
static gboolean propagate_keypress(GtkWidget *w, GdkEvent *ev)
Definition gui_main.c:775
#define MIGRATE_STR_OPTION(opt)
GtkWidget * econ_ebox
Definition gui_main.c:154
GtkWidget * unit_info_box
Definition gui_main.c:151
gboolean fc_lost_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:732
void ui_exit(void)
Definition gui_main.c:2063
enum gui_type get_gui_type(void)
Definition gui_main.c:2074
static GtkWidget * detached_widget_new(void)
Definition gui_main.c:831
gint cur_y
Definition gui_main.c:182
int main(int argc, char **argv)
Definition gui_main.c:1760
void fullscreen_opt_refresh(struct option *poption)
Definition gui_main.c:2430
static void main_message_area_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
Definition gui_main.c:340
static gboolean toplevel_handler(GtkWidget *w, GdkEvent *ev, gpointer data)
Definition gui_main.c:374
void ui_init(void)
Definition gui_main.c:1750
static GtkWidget * unit_below_image_button[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:168
static void free_unit_table(void)
Definition gui_main.c:992
static gboolean idle_callback_wrapper(gpointer data)
Definition gui_main.c:2387
static void apply_city_names_font(struct option *poption)
Definition gui_main.c:2442
static void apply_city_productions_font(struct option *poption)
Definition gui_main.c:2453
gboolean fc_gained_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:742
static GtkWidget * unit_below_image[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:167
static void tearoff_destroy(GtkWidget *w, gpointer data)
Definition gui_main.c:752
GtkWidget * government_label
Definition gui_main.c:146
GtkWidget * sun_label
Definition gui_main.c:144
PangoFontDescription * city_names_style
Definition gui_main.c:132
void refresh_chat_buttons(void)
Definition gui_main.c:2506
gboolean map_canvas_focus(void)
Definition gui_main.c:357
GtkWidget * turn_done_button
Definition gui_main.c:148
static GtkWidget * main_menubar
Definition gui_main.c:163
int screen_width(void)
Definition gui_main.c:2572
GtkWidget * scroll_panel
Definition gui_main.c:140
static void end_turn_callback(GtkWidget *w, gpointer data)
Definition gui_main.c:2245
#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:228
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2402
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2214
static void set_g_log_callbacks(void)
Definition gui_main.c:1734
void reset_unit_table(void)
Definition gui_main.c:1020
static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:398
GtkWidget * unit_info_frame
Definition gui_main.c:152
void options_extra_init(void)
Definition gui_main.c:2476
GtkWidget * top_vbox
Definition gui_main.c:128
static void allied_chat_only_callback(struct option *poption)
Definition gui_main.c:2415
GdkWindow * root_window
Definition gui_main.c:126
static void adjust_default_options(void)
Definition gui_main.c:2620
static void set_wait_for_writable_socket(struct connection *pc, bool socket_writable)
Definition gui_main.c:2265
static GtkWidget * more_arrow_pixmap_button
Definition gui_main.c:170
GtkWidget * ahbox
Definition gui_main.c:139
static void apply_reqtree_text_font(struct option *poption)
Definition gui_main.c:2464
static gboolean show_info_button_release(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2201
bool is_gui_up(void)
Definition gui_main.c:2055
static gboolean toplevel_focus(GtkWidget *w, GtkDirectionType arg)
Definition gui_main.c:313
PangoFontDescription * reqtree_text_style
Definition gui_main.c:134
GtkWidget * sun_ebox
Definition gui_main.c:156
GtkWidget * bulb_ebox
Definition gui_main.c:155
GtkWidget * flake_label
Definition gui_main.c:145
static void g_log_to_freelog_cb(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
Definition gui_main.c:1678
GtkWidget * avbox
Definition gui_main.c:139
gint cur_x
Definition gui_main.c:182
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2536
static GtkWidget * unit_image_button
Definition gui_main.c:166
static GtkWidget * unit_image_table
Definition gui_main.c:164
static gboolean right_notebook_button_release(GtkWidget *widget, GdkEventButton *event)
Definition gui_main.c:1072
static void set_g_log_callback_domain(const char *domain)
Definition gui_main.c:1722
GtkWidget * bulb_label
Definition gui_main.c:143
GtkWidget * overview_canvas
Definition gui_main.c:111
GtkWidget * toplevel
Definition gui_main.c:125
static void setup_widgets(void)
Definition gui_main.c:1124
#define OVERVIEW_CANVAS_STORE_WIDTH
Definition gui_main.c:118
static gboolean toplevel_key_release_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:578
void remove_net_input(void)
Definition gui_main.c:2308
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:596
void sound_bell(void)
Definition gui_main.c:2082
static void migrate_options_from_gtk2(void)
Definition gui_main.c:1768
GtkWidget * econ_label[10]
Definition gui_main.c:142
GtkWidget * government_ebox
Definition gui_main.c:158
void popup_quit_dialog(void)
Definition gui_main.c:2346
static void migrate_options_from_gtk3(void)
Definition gui_main.c:1823
const char *const gui_character_encoding
Definition gui_main.c:160
static int unit_id_top
Definition gui_main.c:173
static gboolean get_net_input(GIOChannel *source, GIOCondition condition, gpointer data)
Definition gui_main.c:2254
static bool audio_paused
Definition gui_main.c:186
static GtkWidget * more_arrow_pixmap_container
Definition gui_main.c:171
GtkWidget * map_widget
Definition gui_main.c:130
static bool client_focus
Definition gui_main.c:187
GtkWidget * right_notebook
Definition gui_main.c:129
void quit_gtk_main(void)
Definition gui_main.c:2334
static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data)
Definition gui_main.c:2527
static struct video_mode vmode
Definition gui_main.c:189
void add_net_input(int sock)
Definition gui_main.c:2290
static GLogWriterOutput g_log_writer_to_freelog_cb(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data)
Definition gui_main.c:1706
GtkWidget * toplevel_tabs
Definition gui_main.c:127
static GtkWidget * allied_chat_toggle_button
Definition gui_main.c:178
GtkWidget * flake_ebox
Definition gui_main.c:157
int overview_canvas_store_width
Definition gui_main.c:122
void update_turn_done_tooltip(void)
Definition gui_main.c:1105
static void tearoff_callback(GtkWidget *b, gpointer data)
Definition gui_main.c:786
static GtkWidget * unit_image
Definition gui_main.c:165
GtkTextView * main_message_area
Definition gui_main.c:176
int overview_canvas_store_height
Definition gui_main.c:123
int screen_height(void)
Definition gui_main.c:2590
static bool parse_options(int argc, char **argv)
Definition gui_main.c:284
GtkWidget * conn_box
Definition gui_main.c:139
#define OVERVIEW_CANVAS_STORE_HEIGHT
Definition gui_main.c:120
GtkWidget * main_frame_civ_name
Definition gui_main.c:136
#define MIGRATE_OPTION(opt)
const bool gui_use_transliteration
Definition gui_main.c:161
static void populate_unit_image_table(void)
Definition gui_main.c:887
#define GUI_NAME_FULL
Definition gui_main.h:29
#define ACCL_MOD_KEY
Definition gui_main.h:26
#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:158
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 butt_release_mapcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition mapctrl.c:221
gboolean move_overviewcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
Definition mapctrl.c:463
gboolean butt_down_overviewcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition mapctrl.c:473
gboolean butt_down_mapcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition mapctrl.c:242
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 map_canvas_configure(GtkWidget *w, GdkEventConfigure *ev, gpointer data)
Definition mapview.c:403
void put_unit_image(struct unit *punit, GtkImage *p, int height)
Definition mapview.c:496
gboolean overview_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data)
Definition mapview.c:356
GtkWidget * setup_menus(GtkWidget *window)
Definition menu.c:2184
void menus_free(void)
Definition menu.c:3260
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
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)
#define enable(id)
Definition widget.h:223
log_callback_fn log_set_callback(log_callback_fn callback)
Definition log.c:298
#define fc_assert_ret(condition)
Definition log.h:191
#define log_verbose(message,...)
Definition log.h:109
#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 set_frame_by_frame_animation(void)
void link_marks_clear_all(void)
#define fc_malloc(sz)
Definition mem.h:34
void menus_init(void)
void option_changed(struct option *poption)
Definition options.c:752
const struct option_set * server_optset
Definition options.c:4020
const struct option_set * client_optset
Definition options.c:1284
bool option_bool_get(const struct option *poption)
Definition options.c:801
enum option_type option_type(const struct option *poption)
Definition options.c:662
const char * option_font_target(const struct option *poption)
Definition options.c:1167
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6564
struct client_options gui_options
Definition options.c:72
const char * option_font_get(const struct option *poption)
Definition options.c:1145
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:435
#define GUI_GTK_OVERVIEW_MIN_XSIZE
Definition options.h:600
#define options_iterate(poptset, poption)
Definition options.h:553
@ GUI_GTK_MSGCHAT_MERGED
Definition options.h:69
@ GUI_GTK_MSGCHAT_SPLIT
Definition options.h:67
#define options_iterate_end
Definition options.h:558
const char * get_info_label_text_popup(void)
Definition text.c:975
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
#define CLIP(lower, current, upper)
Definition shared.h:57
void * data
Definition gui_main.c:2381
void(* callback)(void *data)
Definition gui_main.c:2380
struct connection conn
Definition client_main.h:96
bool silent_when_not_in_focus
Definition options.h:191
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
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
struct player * playing
Definition connection.h:151
void(* notify_of_writable_data)(struct connection *pc, bool data_available_and_socket_full)
Definition connection.h:181
Definition unit.h:137
int id
Definition unit.h:144
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:6615
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7080
struct sprite * get_icon_sprite(const struct tileset *t, enum icon_type icon)
Definition tilespec.c:6990
void tileset_init(struct tileset *t)
Definition tilespec.c:7137
struct sprite * get_arrow_sprite(const struct tileset *t, enum arrow_type arrow)
Definition tilespec.c:6879
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:6890
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:753
@ ARROW_RIGHT
Definition tilespec.h:201
@ ICON_FREECIV
Definition tilespec.h:314
#define unit_tile(_pu)
Definition unit.h:396
#define unit_owner(_pu)
Definition unit.h:395
float mouse_zoom
Definition zoom.c:28
void zoom_step_down(void)
Definition zoom.c:130
void zoom_step_up(void)
Definition zoom.c:106