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-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
132
136
139
142
150
154
160
161const char *const gui_character_encoding = "UTF-8";
163
173
174static int unit_id_top;
175static int unit_ids[MAX_NUM_UNITS_BELOW]; /* ids of the units icons in
176 * information display: (or 0) */
180
181static gint timer_id; /* ditto */
185
186static bool gui_up = FALSE;
187
188static bool audio_paused = FALSE;
189static bool client_focus = TRUE;
190
191static struct video_mode vmode = { -1, -1 };
192
193static void set_g_log_callbacks(void);
194
197
198static void end_turn_callback(GtkWidget *w, gpointer data);
200 gpointer data);
201static void set_wait_for_writable_socket(struct connection *pc,
202 bool socket_writable);
203
204static void print_usage(void);
205static bool parse_options(int argc, char **argv);
209
210static void tearoff_callback(GtkWidget *b, gpointer data);
211static GtkWidget *detached_widget_new(void);
213
215 gpointer data);
217 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
227/**********************************************************************/
230static void log_callback_utf8(enum log_level level, const char *message,
231 bool file_too)
232{
233 if (!file_too || level <= LOG_FATAL) {
234 fc_fprintf(stderr, "%d: %s\n", level, message);
235 }
236}
237
238/**********************************************************************/
243{
244 double seconds = real_timer_callback();
245
247 if (!audio_paused && !client_focus) {
248 audio_pause();
250 } else if (audio_paused && client_focus) {
251 audio_resume();
253 }
254 }
255
257
258 return FALSE;
259}
260
261/**********************************************************************/
265static void print_usage(void)
266{
267 /* add client-specific usage information here */
269 _("This client accepts the standard Gtk command-line options\n"
270 "after '--'. See the Gtk documentation.\n\n"));
271
273 _("Other gui-specific options are:\n"));
274
276 _("-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
277 "screen\n\n"));
278
279 /* TRANS: No full stop after the URL, could cause confusion. */
280 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
281}
282
283/**********************************************************************/
286static bool parse_options(int argc, char **argv)
287{
288 int i = 1;
289
290 while (i < argc) {
291 char *option = NULL;
292
293 if (is_option("--help", argv[i])) {
294 print_usage();
295
296 return FALSE;
297 } else if ((option = get_option_malloc("--resolution", argv, &i, argc, FALSE))) {
299 fc_fprintf(stderr, _("Illegal video mode '%s'\n"), option);
301 }
302 free(option);
303 }
304 /* Can't check against unknown options, as those might be gtk options */
305
306 i++;
307 }
308
309 return TRUE;
310}
311
312/**********************************************************************/
316{
317 switch (arg) {
320
321 if (!gtk_widget_get_can_focus(w)) {
322 return FALSE;
323 }
324
325 if (!gtk_widget_is_focus(w)) {
327 return TRUE;
328 }
329 break;
330
331 default:
332 break;
333 }
334 return FALSE;
335}
336
337/**********************************************************************/
344 gpointer data)
345{
346 static int old_width = 0, old_height = 0;
347
348 if (allocation->width != old_width
349 || allocation->height != old_height) {
351 old_width = allocation->width;
352 old_height = allocation->height;
353 }
354}
355
356/**********************************************************************/
366
367/**********************************************************************/
377{
378 GtkWidget *focus;
379
381 if (focus) {
382 if (GTK_IS_ENTRY(focus)
383 || (GTK_IS_TEXT_VIEW(focus)
385 /* Propagate event to currently focused entry widget. */
386 if (gtk_widget_event(focus, ev)) {
387 /* Do not propagate event to our children. */
388 return TRUE;
389 }
390 }
391 }
392
393 /* Continue propagating event to our children. */
394 return FALSE;
395}
396
397/**********************************************************************/
401 gpointer data)
402{
403 if ((ev->state & GDK_SHIFT_MASK)) {
404 switch (ev->keyval) {
405
406 case GDK_KEY_Left:
408 return TRUE;
409
410 case GDK_KEY_Right:
412 return TRUE;
413
414 case GDK_KEY_Up:
416 return TRUE;
417
418 case GDK_KEY_Down:
420 return TRUE;
421
422 case GDK_KEY_Home:
424 return TRUE;
425
426 case GDK_KEY_Page_Up:
429 return TRUE;
430
434 return TRUE;
435
436 default:
437 break;
438 }
439 } else if (!(ev->state & GDK_CONTROL_MASK)) {
440 switch (ev->keyval) {
441 default:
442 break;
443 }
444 }
445
446 if (ev->state & GDK_SHIFT_MASK) {
447 bool volchange = FALSE;
448
449 switch (ev->keyval) {
450 case GDK_KEY_plus:
451 case GDK_KEY_KP_Add:
453 volchange = TRUE;
454 break;
455
456 case GDK_KEY_minus:
459 volchange = TRUE;
460 break;
461
462 default:
463 break;
464 }
465
466 if (volchange) {
467 struct option *poption = optset_option_by_name(client_optset, "sound_effects_volume");
468
471
472 return TRUE;
473 }
474 } else if (!(ev->state & GDK_CONTROL_MASK)) {
475 switch (ev->keyval) {
476 case GDK_KEY_plus:
477 case GDK_KEY_KP_Add:
478 zoom_step_up();
479 return TRUE;
480
481 case GDK_KEY_minus:
484 return TRUE;
485
486 default:
487 break;
488 }
489 }
490
491 /* Return here if observer */
492 if (client_is_observer()) {
493 return FALSE;
494 }
495
496 switch (ev->keyval) {
497
498 case GDK_KEY_KP_Up:
499 case GDK_KEY_KP_8:
500 case GDK_KEY_Up:
501 case GDK_KEY_8:
503 return TRUE;
504
506 case GDK_KEY_KP_9:
507 case GDK_KEY_Page_Up:
508 case GDK_KEY_9:
510 return TRUE;
511
512 case GDK_KEY_KP_Right:
513 case GDK_KEY_KP_6:
514 case GDK_KEY_Right:
515 case GDK_KEY_6:
517 return TRUE;
518
520 case GDK_KEY_KP_3:
522 case GDK_KEY_3:
524 return TRUE;
525
526 case GDK_KEY_KP_Down:
527 case GDK_KEY_KP_2:
528 case GDK_KEY_Down:
529 case GDK_KEY_2:
531 return TRUE;
532
533 case GDK_KEY_KP_End:
534 case GDK_KEY_KP_1:
535 case GDK_KEY_End:
536 case GDK_KEY_1:
538 return TRUE;
539
540 case GDK_KEY_KP_Left:
541 case GDK_KEY_KP_4:
542 case GDK_KEY_Left:
543 case GDK_KEY_4:
545 return TRUE;
546
547 case GDK_KEY_KP_Home:
548 case GDK_KEY_KP_7:
549 case GDK_KEY_Home:
550 case GDK_KEY_7:
552 return TRUE;
553
554 case GDK_KEY_KP_Begin:
555 case GDK_KEY_KP_5:
556 case GDK_KEY_5:
558 return TRUE;
559
560 case GDK_KEY_Escape:
562 return TRUE;
563
564 case GDK_KEY_b:
567 return TRUE;
568 }
569 break;
570
571 default:
572 break;
573 };
574
575 return FALSE;
576}
577
578/**********************************************************************/
582 gpointer data)
583{
584 /* inputline history code */
586 return FALSE;
587 }
588
589 if (editor_is_active()) {
591 }
592
593 return FALSE;
594}
595
596/**********************************************************************/
600 gpointer data)
601{
602 if (inputline_has_focus()) {
603 return FALSE;
604 }
605
606 if (ev->keyval == GDK_KEY_apostrophe) {
607 /* Allow this even if not in main map view; chatline is present on
608 * some other pages too */
609
610 /* Make the chatline visible if it's not currently.
611 * FIXME: should find the correct window, even when detached, from any
612 * other window; should scroll to the bottom automatically showing the
613 * latest text from other players; MUST NOT make spurious text windows
614 * at the bottom of other dialogs. */
616 /* The main game view is visible. May need to switch notebook. */
619 } else {
621 }
622 }
623
624 /* If the chatline is (now) visible, focus it. */
625 if (inputline_is_visible()) {
627 return TRUE;
628 }
629 }
630
633 return FALSE;
634 }
635
636 if (editor_is_active()) {
638 return TRUE;
639 }
640 }
641
642 if (ev->state & GDK_SHIFT_MASK) {
643 switch (ev->keyval) {
644
645 case GDK_KEY_Return:
646 case GDK_KEY_KP_Enter:
647 key_end_turn();
648 return TRUE;
649
650 default:
651 break;
652 }
653 }
654
656 /* 0 means the map view is focused. */
657 return key_press_map_canvas(w, ev, data);
658 }
659
660#if 0
661 /* We are focused some other dialog, tab, or widget. */
662 if ((ev->state & GDK_CONTROL_MASK)) {
663 } else if ((ev->state & GDK_SHIFT_MASK)) {
664 } else {
665 switch (ev->keyval) {
666
667 case GDK_KEY_F4:
669 return TRUE;
670
671 default:
672 break;
673 };
674 }
675#endif /* 0 */
676
677 return FALSE;
678}
679
680/**********************************************************************/
684{
686
687 if (!can_client_change_view()) {
688 return FALSE;
689 }
690
693
694 switch (ev->direction) {
695 case GDK_SCROLL_UP:
696 scroll_y -= ystep*2;
697 break;
698 case GDK_SCROLL_DOWN:
699 scroll_y += ystep*2;
700 break;
701 case GDK_SCROLL_RIGHT:
702 scroll_x += xstep*2;
703 break;
704 case GDK_SCROLL_LEFT:
705 scroll_x -= xstep*2;
706 break;
707 default:
708 return FALSE;
709 };
710
712
713 /* Emulating mouse move now */
716 }
717
718 update_line(ev->x, ev->y);
719 if (rbutton_down && (ev->state & GDK_BUTTON3_MASK)) {
721 }
722
725 }
726
728
729 return TRUE;
730}
731
732/**********************************************************************/
736{
738
739 return TRUE;
740}
741
742/**********************************************************************/
746{
748
749 return TRUE;
750}
751
752/**********************************************************************/
755static void tearoff_destroy(GtkWidget *w, gpointer data)
756{
757 GtkWidget *p, *b, *box;
759
760 box = GTK_WIDGET(data);
762 p = g_object_get_data(G_OBJECT(w), "parent");
763 b = g_object_get_data(G_OBJECT(w), "toggle");
765
767
768 g_object_ref(box); /* Make sure reference count stays above 0
769 * during the transition to new parent. */
772 g_object_unref(box);
773}
774
775/**********************************************************************/
779{
781
782 return FALSE;
783}
784
785/**********************************************************************/
790{
791 GtkWidget *box = GTK_WIDGET(data);
792
795 GtkWidget *w;
797
801 gtk_widget_set_name(w, "Freeciv");
802 gtk_window_set_title(GTK_WINDOW(w), _("Freeciv"));
804 g_signal_connect(w, "destroy", G_CALLBACK(tearoff_destroy), box);
805 g_signal_connect(w, "key_press_event",
807
809 g_object_set_data(G_OBJECT(w), "toggle", b);
810
811 temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent");
812 if (temp_hide != NULL) {
814 }
815
816 g_object_ref(box); /* Make sure reference count stays above 0
817 * during the transition to new parent. */
820 g_object_unref(box);
822
823 if (temp_hide != NULL) {
825 }
826 } else {
828 }
829}
830
831/**********************************************************************/
840
841/**********************************************************************/
846{
847 GtkWidget *b, *fillbox;
849
852
853 /* These toggle buttons run vertically down the side of many UI
854 * elements, so they need to be thin horizontally. */
856 ".detach_button {\n"
857 " padding: 0px 0px 0px 0px;\n"
858 " min-width: 6px;\n"
859 "}",
860 -1, NULL);
861 }
862
868 "detach_button");
869 gtk_widget_set_tooltip_text(b, _("Detach/Attach the pane."));
870
873
877
879
880 return fillbox;
881}
882
883/**********************************************************************/
891{
892 int i, width;
894 GdkPixbuf *pix;
895 int ttw;
896
897 /* Get width of the overview window */
901
903
905 /* We want arrow to appear if there is other units in addition
906 to active one in tile. Active unit is not counted, so there
907 can be 0 other units to not to display arrow. */
908 num_units_below = 1 - 1;
909 } else {
912 }
913
914 /* Top row: the active unit. */
915 /* Note, we ref this and other widgets here so that we can unref them
916 * in reset_unit_table. */
926 g_signal_connect(unit_image_button, "button_press_event",
928 GINT_TO_POINTER(-1));
929
931 /* Bottom row: other units in the same tile. */
932 for (i = 0; i < num_units_below; i++) {
940 FALSE);
944 "button_press_event",
947
949 i, 1, 1, 1);
950 }
951 }
952
953 /* Create arrow (popup for all units on the selected tile) */
960 FALSE);
964 "button_press_event",
966 /* An extra layer so that we can hide the clickable button but keep
967 * an explicit size request to avoid the layout jumping around */
976 gdk_pixbuf_get_width(pix), -1);
978
980 /* Display on bottom row. */
982 num_units_below, 1, 1, 1);
983 } else {
984 /* Display on top row (there is no bottom row). */
986 1, 0, 1, 1);
987 }
988
990}
991
992/**********************************************************************/
1019
1020/**********************************************************************/
1024{
1025 /* Unreference all of the widgets that we're about to reallocate, thus
1026 * avoiding a memory leak. Remove them from the container first, just
1027 * to be safe. Note, the widgets are ref'd in
1028 * populate_unit_image_table. */
1030
1032
1033 /* We have to force a redraw of the units. And we explicitly have
1034 * to force a redraw of the focus unit, which is normally only
1035 * redrawn when the focus changes. We also have to force the 'more'
1036 * arrow to go away, both by expicitly hiding it and telling it to
1037 * do so (this will be reset immediately afterwards if necessary,
1038 * but we have to make the *internal* state consistent). */
1041 if (get_num_units_in_focus() == 1) {
1043 } else {
1044 set_unit_icon(-1, NULL);
1045 }
1047}
1048
1049/**********************************************************************/
1053{
1054 if (enable) {
1056 /* Ensure the menus are really created before performing any operations
1057 * on them. */
1058 while (gtk_events_pending()) {
1060 }
1062 menus_init();
1064 } else {
1066 }
1067}
1068
1069/**********************************************************************/
1077{
1078 if (event->type != GDK_BUTTON_RELEASE) {
1079 return FALSE;
1080 }
1081
1084 /* Make sure the default gtk handler
1085 * does NOT get called in this case. */
1086 return TRUE;
1087 }
1088
1089 return FALSE;
1090}
1091
1092/**********************************************************************/
1095#if 0
1097{
1102}
1103#endif
1104
1105/**********************************************************************/
1109{
1110 struct option *opt = optset_option_by_name(server_optset, "fixedlength");
1111
1112 if (opt != NULL && option_bool_get(opt)) {
1114 _("Fixed length turns"));
1115 } else {
1116 char buf[256];
1117
1118 fc_snprintf(buf, sizeof(buf), "%s:\n%s",
1119 _("Turn Done"), _("Shift+Return"));
1121 }
1122}
1123
1124/**********************************************************************/
1127static void setup_widgets(void)
1128{
1129 GtkWidget *page, *ebox, *hgrid, *hgrid2, *label;
1130 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1131 GtkWidget *button, *view, *vgrid, *right_vbox = NULL;
1132 int i;
1133 GtkWidget *notebook, *statusbar;
1135 struct sprite *spr;
1136
1138
1139 notebook = gtk_notebook_new();
1140
1141 /* Stop mouse wheel notebook page switching. */
1142 g_signal_connect(notebook, "scroll_event",
1144
1145 toplevel_tabs = notebook;
1148 vgrid = gtk_grid_new();
1156
1167
1169
1171 g_object_set(ingame_votebar, "margin", 2, NULL);
1172
1173 /* *** everything in the top *** */
1174
1180 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1181
1186 hgrid = gtk_grid_new();
1187
1189 /* The window is divided into two horizontal panels: overview +
1190 * civinfo + unitinfo, main view + message window. */
1195
1201
1202 /* Overview size designed for small displays (netbooks). */
1205 } else {
1206 /* The window is divided into two vertical panes: overview +
1207 * + civinfo + unitinfo + main view, message window. */
1212
1213 /* Overview size designed for big displays (desktops). */
1216 }
1217
1218 /* this holds the overview canvas, production info, etc. */
1219 vgrid = gtk_grid_new();
1223 /* Put vgrid to the left of anything else in hgrid -- right_vbox is either
1224 * the chat/messages pane, or NULL which is OK */
1226 GTK_POS_LEFT, 1, 1);
1227
1228 /* Overview canvas */
1234
1239
1249
1254
1257
1260
1261 g_signal_connect(overview_canvas, "motion_notify_event",
1263
1264 g_signal_connect(overview_canvas, "button_press_event",
1266
1267 /* The rest */
1268
1275
1276 /* Info on player's civilization, when game is running. */
1277 frame = gtk_frame_new("");
1279
1280 main_frame_civ_name = frame;
1281
1282 vgrid = gtk_grid_new();
1287
1288 ebox = gtk_event_box_new();
1291 g_signal_connect(ebox, "button_press_event",
1294
1295 label = gtk_label_new(NULL);
1299 gtk_widget_set_margin_end(label, 2);
1300 gtk_widget_set_margin_top(label, 2);
1302 gtk_container_add(GTK_CONTAINER(ebox), label);
1303 main_label_info = label;
1304
1305 /* Production status */
1306 table = gtk_grid_new();
1310
1311 /* Citizens for taxrates */
1312 ebox = gtk_event_box_new();
1314 gtk_grid_attach(GTK_GRID(table), ebox, 0, 0, 10, 1);
1315 econ_ebox = ebox;
1316
1317 table2 = gtk_grid_new();
1319
1320 for (i = 0; i < 10; i++) {
1321 ebox = gtk_event_box_new();
1324
1325 gtk_grid_attach(GTK_GRID(table2), ebox, i, 0, 1, 1);
1326
1327 g_signal_connect(ebox, "button_press_event",
1329
1333 }
1334
1335 /* Science, environmental, govt, timeout */
1337 if (spr != NULL) {
1339 } else {
1341 }
1342
1344 if (spr != NULL) {
1346 } else {
1348 }
1349
1351 if (spr != NULL) {
1353 } else {
1355 }
1356
1358 if (spr != NULL) {
1360 } else {
1362 }
1363
1364 for (i = 0; i < 4; i++) {
1365 GtkWidget *w;
1366
1367 ebox = gtk_event_box_new();
1369
1370 switch (i) {
1371 case 0:
1372 w = bulb_label;
1373 bulb_ebox = ebox;
1374 break;
1375 case 1:
1376 w = sun_label;
1377 sun_ebox = ebox;
1378 break;
1379 case 2:
1380 w = flake_label;
1381 flake_ebox = ebox;
1382 break;
1383 default:
1384 case 3:
1385 w = government_label;
1386 government_ebox = ebox;
1387 break;
1388 }
1389
1397 gtk_grid_attach(GTK_GRID(table), ebox, i, 1, 1, 1);
1398 }
1399
1401
1402 frame = gtk_frame_new(NULL);
1403 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1405
1406
1407 /* Turn done */
1409
1411
1415
1416 /* Selected unit status */
1417
1423
1424 /* In edit mode the unit_info_box widget is replaced by the
1425 * editinfobox, so we need to add a ref here so that it is
1426 * not destroyed when removed from its container.
1427 * See editinfobox_refresh(). */
1429
1432
1439
1440 label = gtk_label_new(NULL);
1445 gtk_widget_set_margin_end(label, 2);
1446 gtk_widget_set_margin_top(label, 2);
1448 gtk_container_add(GTK_CONTAINER(sw), label);
1449 unit_info_label = label;
1450
1451 hgrid2 = gtk_grid_new();
1453
1454 table = gtk_grid_new();
1455 g_object_set(table, "margin", 5, NULL);
1457
1460
1462
1463 /* Map canvas, editor toolbar, and scrollbars */
1464
1465 /* The top notebook containing the map view and dialogs. */
1466
1470
1471
1478
1482 } else {
1484 }
1485
1487
1488 vgrid = gtk_grid_new();
1492
1494 g_object_set(editgui_get_editbar()->widget, "margin", 4, NULL);
1495
1496 label = gtk_label_new(Q_("?noun:View"));
1498
1499 frame = gtk_frame_new(NULL);
1500 gtk_grid_attach(GTK_GRID(map_widget), frame, 0, 0, 1, 1);
1501
1507
1508#if 0
1517#endif /* 0 */
1518
1525
1527
1531
1535
1538
1539 g_signal_connect(map_canvas, "configure_event",
1541
1542 g_signal_connect(map_canvas, "motion_notify_event",
1544
1545 g_signal_connect(toplevel, "enter_notify_event",
1547
1548 g_signal_connect(map_canvas, "button_press_event",
1550
1551 g_signal_connect(map_canvas, "button_release_event",
1553
1554 g_signal_connect(map_canvas, "scroll_event",
1556
1557 g_signal_connect(toplevel, "key_press_event",
1559
1560 g_signal_connect(toplevel, "key_release_event",
1562
1563 /* *** The message window -- this is a detachable widget *** */
1564
1568 } else {
1570
1574
1575 vgrid = gtk_grid_new();
1580 }
1582
1585 } else {
1587 }
1589 g_object_set(hpaned, "margin", 4, NULL);
1591
1596
1601 g_signal_connect(right_notebook, "button-release-event",
1605 }
1606 }
1607
1608 vgrid = gtk_grid_new();
1611
1618
1619 label = gtk_label_new(_("Chat"));
1621
1628 g_signal_connect(text, "size-allocate",
1630
1631 gtk_widget_set_name(text, "chatline");
1632
1634 gtk_widget_realize(text);
1636
1638 if (dtach_lowbox != NULL) {
1640 }
1641
1643
1644 /* the chat line */
1647 g_object_set(view, "margin", 3, NULL);
1648
1649 button = gtk_check_button_new_with_label(_("Allies Only"));
1653 g_signal_connect(button, "toggled",
1657
1658 button = gtk_button_new_with_label(_("Clear links"));
1659 g_signal_connect(button, "clicked",
1662
1663 /* Other things to take care of */
1664
1666
1669 }
1670
1673
1677 }
1678}
1679
1680/**********************************************************************/
1685 const gchar *message,
1686 gpointer user_data)
1687{
1688 enum log_level fllvl = LOG_ERROR;
1689
1690 switch (log_level) {
1691 case G_LOG_LEVEL_DEBUG:
1692 fllvl = LOG_DEBUG;
1693 break;
1695 fllvl = LOG_WARN;
1696 break;
1697 default:
1698 break;
1699 }
1700
1701 if (log_domain != NULL) {
1702 log_base(fllvl, "%s: %s", log_domain, message);
1703 } else {
1704 log_base(fllvl, "%s", message);
1705 }
1706}
1707
1708/**********************************************************************/
1712 const GLogField *fields,
1714 gpointer user_data)
1715{
1716 /* No need to have formatter of our own - let's use glib's default one. */
1718
1720
1721 return G_LOG_WRITER_HANDLED;
1722}
1723
1724/**********************************************************************/
1735
1736/**********************************************************************/
1739static void set_g_log_callbacks(void)
1740{
1741 /* Old API, still used by many log producers */
1743
1747
1748 /* glib >= 2.50 API */
1750}
1751
1752/**********************************************************************/
1761
1762/**********************************************************************/
1765int main(int argc, char **argv)
1766{
1767 return client_main(argc, argv, FALSE);
1768}
1769
1770/**********************************************************************/
1774{
1775 log_normal(_("Migrating options from gtk2 to gtk3 client"));
1776
1777#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1778#define MIGRATE_STR_OPTION(opt) \
1779 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1780 sizeof(gui_options.gui_gtk3_##opt));
1781
1782 /* Default theme name is never migrated */
1783 /* 'fullscreen', 'small_display_layout', and 'message_chat_location'
1784 * not migrated, as (unlike Gtk2), Gtk3-client tries to pick better
1785 * defaults for these in fresh installations based on screen size (see
1786 * adjust_default_options()); so user is probably better served by
1787 * getting these adaptive defaults than whatever they had for Gtk2.
1788 * Since 'fullscreen' isn't migrated, we don't need to worry about
1789 * preserving gui_gtk2_migrated_from_2_5 either. */
1803 MIGRATE_OPTION(popup_tech_help);
1804
1818
1819#undef MIGRATE_OPTION
1820#undef MIGRATE_STR_OPTION
1821
1823}
1824
1825/**********************************************************************/
1829{
1830 log_normal(_("Migrating options from gtk3 to gtk3.22 client"));
1831
1832#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk3_##opt;
1833#define MIGRATE_STR_OPTION(opt) \
1834 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_##opt, \
1835 sizeof(GUI_GTK_OPTION(opt)));
1836
1837 /* Default theme name is never migrated */
1838
1839 /* Simulate gui-gtk3's migrate_options_from_2_5() */
1841 log_normal(_("Migrating gtk3-client options from freeciv-2.5 options."));
1844 }
1845
1862 MIGRATE_OPTION(popup_tech_help);
1863
1877
1878#undef MIGRATE_OPTION
1879#undef MIGRATE_STR_OPTION
1880
1882}
1883
1884/**********************************************************************/
1887int ui_main(int argc, char **argv)
1888{
1890 guint sig;
1891
1892 if (parse_options(argc, argv)) {
1893 char window_name[1024];
1894
1895 /* The locale has already been set in init_nls() and the windows-specific
1896 * locale logic in gtk_init() causes problems with zh_CN (see PR#39475) */
1898
1899 /* GTK withdraw gtk options. Process GTK arguments */
1900 if (!gtk_init_check(&argc, &argv)) {
1901 log_fatal(_("Failed to open graphical mode."));
1902 return EXIT_FAILURE;
1903 }
1904
1906
1908
1911 if (vmode.width > 0 && vmode.height > 0) {
1913 }
1914 g_signal_connect(toplevel, "key_press_event",
1916
1917 g_signal_connect(toplevel, "focus_out_event",
1919 g_signal_connect(toplevel, "focus_in_event",
1921
1924 gtk_widget_set_name(toplevel, "Freeciv");
1926
1927 if (gui_options.first_boot) {
1929 /* We're using fresh defaults for this version of this client,
1930 * so prevent any future migrations from other clients / versions */
1932 /* Avoid also marking gtk3 as migrated, so that it can have its own
1933 * run of its adjust_default_options() if it is ever run (as a
1934 * side effect of Gtk2->Gtk3 migration). */
1935 } else {
1939 /* We want a fresh look at screen-size-related options after Gtk2 */
1941 /* We don't ever want to consider pre-2.6 fullscreen option again
1942 * (even for gui-gtk3) */
1944 }
1946 }
1947 }
1948
1951 }
1952
1953 fc_snprintf(window_name, sizeof(window_name), _("Freeciv (%s)"), GUI_NAME_SHORT);
1955
1956 g_signal_connect(toplevel, "delete_event",
1958
1959 /* Disable GTK+ cursor key focus movement */
1962 0, 0, 0, 0);
1964
1966 if (OT_FONT == option_type(poption)) {
1967 /* Force to call the appropriate callback. */
1969 }
1971
1974
1975 if (NULL == city_names_style) {
1977 log_error("city_names_style should have been set by options.");
1978 }
1981 log_error("city_productions_style should have been set by options.");
1982 }
1983 if (NULL == reqtree_text_style) {
1985 log_error("reqtree_text_style should have been set by options.");
1986 }
1987
1990
1991 /* Keep the icon of the executable on Windows (see PR#36491) */
1992#ifndef FREECIV_MSWINDOWS
1993 {
1995
1996 /* Only call this after tileset_load_tiles is called. */
1999 }
2000#endif /* FREECIV_MSWINDOWS */
2001
2002 setup_widgets();
2003 load_cursors();
2004 cma_fe_init();
2011 chatline_init();
2013
2015
2017
2018 /* Assumes toplevel showing */
2020
2021 /* Assumes client_state is set */
2023
2024 gui_up = TRUE;
2025 gtk_main();
2026 gui_up = FALSE;
2027
2036 cma_fe_done();
2038
2039 /* We have extra ref for unit_info_box that has protected
2040 * it from getting destroyed when editinfobox_refresh()
2041 * moves widgets around. Free that extra ref here. */
2043
2044 editgui_free();
2047 menus_free();
2048 message_buffer = NULL; /* Result of destruction of everything */
2050 }
2051
2052 return EXIT_SUCCESS;
2053}
2054
2055/**********************************************************************/
2058bool is_gui_up(void)
2059{
2060 return gui_up;
2061}
2062
2063/**********************************************************************/
2066void ui_exit(void)
2067{
2068 if (message_buffer != NULL) {
2071 }
2072}
2073
2074/**********************************************************************/
2077enum gui_type get_gui_type(void)
2078{
2079 return GUI_GTK3_22;
2080}
2081
2082/**********************************************************************/
2089
2090/**********************************************************************/
2096void set_unit_icon(int idx, struct unit *punit)
2097{
2098 GtkWidget *w;
2099
2100 fc_assert_ret(idx >= -1 && idx < num_units_below);
2101
2102 if (idx == -1) {
2103 w = unit_image;
2104 unit_id_top = punit ? punit->id : 0;
2105 } else {
2106 w = unit_below_image[idx];
2107 unit_ids[idx] = punit ? punit->id : 0;
2108 }
2109
2110 if (!w) {
2111 return;
2112 }
2113
2114 if (punit) {
2116 } else {
2118 }
2119}
2120
2121/**********************************************************************/
2127{
2128 static bool showing = FALSE;
2129
2131 return;
2132 }
2133
2134 if (onoff && !showing) {
2136 showing = TRUE;
2137 } else if (!onoff && showing) {
2139 showing = FALSE;
2140 }
2141}
2142
2143/**********************************************************************/
2153
2154/**********************************************************************/
2159 gpointer data)
2160{
2161 int i = GPOINTER_TO_INT(data);
2162 struct unit *punit;
2163
2164 if (i == -1) {
2166 if (punit && unit_is_in_focus(punit)) {
2167 /* Clicking on the currently selected unit will center it. */
2169 }
2170 return TRUE;
2171 }
2172
2173 if (unit_ids[i] == 0) /* no unit displayed at this place */
2174 return TRUE;
2175
2177 if (NULL != punit && unit_owner(punit) == client.conn.playing) {
2178 /* Unit shouldn't be NULL but may be owned by an ally. */
2180 }
2181
2182 return TRUE;
2183}
2184
2185/**********************************************************************/
2190 gpointer data)
2191{
2193
2194 if (punit) {
2196 }
2197
2198 return TRUE;
2199}
2200
2201/**********************************************************************/
2205 gpointer data)
2206{
2207 gtk_grab_remove(w);
2210
2211 return FALSE;
2212}
2213
2214/**********************************************************************/
2218{
2219 if (ev->button == 1) {
2220 GtkWidget *p;
2221
2226
2227 gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", p,
2228 "GtkLabel::label", get_info_label_text_popup(),
2229 "GtkWidget::visible", TRUE,
2230 NULL);
2231 gtk_widget_show(p);
2232
2235 TRUE, NULL, (GdkEvent *)ev, NULL, NULL);
2236 gtk_grab_add(p);
2237
2238 g_signal_connect_after(p, "button_release_event",
2240 }
2241
2242 return TRUE;
2243}
2244
2245/**********************************************************************/
2253
2254/**********************************************************************/
2258 gpointer data)
2259{
2261
2262 return TRUE;
2263}
2264
2265/**********************************************************************/
2269 bool socket_writable)
2270{
2271 static bool previous_state = FALSE;
2272
2274
2276 return;
2277
2278 log_debug("set_wait_for_writable_socket(%d)", socket_writable);
2279
2284 NULL);
2285
2287}
2288
2289/**********************************************************************/
2293void add_net_input(int sock)
2294{
2295#ifdef FREECIV_MSWINDOWS
2297#else
2299#endif
2301 G_IO_IN | G_IO_ERR,
2303 NULL);
2305}
2306
2307/**********************************************************************/
2317
2318/**********************************************************************/
2322static void quit_dialog_response(GtkWidget *dialog, gint response)
2323{
2324 gtk_widget_destroy(dialog);
2325 if (response == GTK_RESPONSE_YES) {
2327 if (client.conn.used) {
2329 }
2330 quit_gtk_main();
2331 }
2332}
2333
2334/**********************************************************************/
2338{
2339 /* Quit gtk main loop. After this it will return to finish
2340 * ui_main() */
2341
2342 gtk_main_quit();
2343}
2344
2345/**********************************************************************/
2350{
2351 static GtkWidget *dialog;
2352
2353 if (!dialog) {
2355 0,
2358 _("Are you sure you want to quit?"));
2359 setup_dialog(dialog, toplevel);
2360
2362
2363 g_signal_connect(dialog, "response",
2365 g_signal_connect(dialog, "destroy",
2367 }
2368
2370}
2371
2372/**********************************************************************/
2376{
2378 /* Stop emission of event. */
2379 return TRUE;
2380}
2381
2382struct callback {
2383 void (*callback)(void *data);
2384 void *data;
2385};
2386
2387/**********************************************************************/
2391{
2392 struct callback *cb = data;
2393
2394 (cb->callback)(cb->data);
2395 free(cb);
2396
2397 return FALSE;
2398}
2399
2400/**********************************************************************/
2405void add_idle_callback(void (callback)(void *), void *data)
2406{
2407 struct callback *cb = fc_malloc(sizeof(*cb));
2408
2409 cb->callback = callback;
2410 cb->data = data;
2412}
2413
2414/**********************************************************************/
2419{
2420 GtkWidget *button;
2421
2423 fc_assert_ret(button != NULL);
2425
2428}
2429
2430/**********************************************************************/
2441
2442/**********************************************************************/
2452
2453/**********************************************************************/
2463
2464/**********************************************************************/
2474
2475/**********************************************************************/
2480{
2481 struct option *poption;
2482
2483#define option_var_set_callback(var, callback) \
2484 if ((poption = optset_option_by_name(client_optset, \
2485 GUI_GTK_OPTION_STR(var)))) { \
2486 option_set_changed_callback(poption, callback); \
2487 } else { \
2488 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2489 }
2490
2495
2502#undef option_var_set_callback
2503}
2504
2505/**********************************************************************/
2510{
2511 GtkWidget *button;
2512
2514 fc_assert_ret(button != NULL);
2516
2517 /* Hide the "Allies Only" button for local games. */
2518 if (is_server_running()) {
2519 gtk_widget_hide(button);
2520 } else {
2521 gtk_widget_show(button);
2524 }
2525}
2526
2527/**********************************************************************/
2535
2536/**********************************************************************/
2540{
2541 cat_snprintf(outbuf, outlen, _("\nBuilt against gtk+ %d.%d.%d, using %d.%d.%d"
2542 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2547}
2548
2549/**********************************************************************/
2554{
2557
2559 if (!display) {
2560 return FALSE;
2561 }
2562
2564 if (!monitor) {
2565 return FALSE;
2566 }
2567
2569 return TRUE;
2570}
2571
2572/**********************************************************************/
2576{
2577 GdkRectangle rect;
2578
2579 if (vmode.width > 0) {
2580 return vmode.width;
2581 }
2582
2583 if (monitor_size(&rect)) {
2584 return rect.width;
2585 } else {
2586 return 0;
2587 }
2588}
2589
2590/**********************************************************************/
2594{
2595 GdkRectangle rect;
2596
2597 if (vmode.height > 0) {
2598 return vmode.height;
2599 }
2600
2601 if (monitor_size(&rect)) {
2602 return rect.height;
2603 } else {
2604 return 0;
2605 }
2606}
2607
2608/**********************************************************************/
2612{
2613 if (vmode.width > 0 && vmode.height > 0) {
2614 return &vmode;
2615 }
2616
2617 return NULL;
2618}
2619
2620/**********************************************************************/
2623static void adjust_default_options(void)
2624{
2625 int scr_height = screen_height();
2626
2627 if (scr_height > 0) {
2628 /* Adjust these options only if we do know the screen height. */
2629
2630 if (scr_height <= 480) {
2631 /* Freeciv is practically unusable outside fullscreen mode in so
2632 * small display */
2633 log_verbose("Changing default to fullscreen due to very small screen");
2635 }
2636 if (scr_height < 1024) {
2637 /* This is a small display */
2638 log_verbose("Defaulting to small widget layout due to small screen");
2640 log_verbose("Defaulting to merged messages/chat due to small screen");
2642 }
2643 }
2644}
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 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: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
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:1780
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 select_unit_image_callback(GtkWidget *w, GdkEvent *ev, gpointer data)
Definition gui_main.c:2158
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 * more_arrow_pixmap
Definition gui_main.c:170
static GtkWidget * detached_widget_fill(GtkWidget *tearbox)
Definition gui_main.c:845
void enable_menus(bool enable)
Definition gui_main.c:1052
static gboolean select_more_arrow_pixmap_callback(GtkWidget *w, GdkEvent *ev, gpointer data)
Definition gui_main.c:2189
GtkWidget * top_notebook
Definition gui_main.c:129
static gboolean propagate_keypress(GtkWidget *w, GdkEvent *ev)
Definition gui_main.c:778
#define MIGRATE_STR_OPTION(opt)
GtkWidget * econ_ebox
Definition gui_main.c:155
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
static void main_message_area_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
Definition gui_main.c:342
static gboolean toplevel_handler(GtkWidget *w, GdkEvent *ev, gpointer data)
Definition gui_main.c:376
void ui_init(void)
Definition gui_main.c:1755
static GtkWidget * unit_below_image_button[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:169
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
static GtkWidget * unit_below_image[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:168
static void tearoff_destroy(GtkWidget *w, gpointer data)
Definition gui_main.c:755
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
static GtkWidget * main_menubar
Definition gui_main.c:164
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
GdkWindow * root_window
Definition gui_main.c:126
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
static GtkWidget * more_arrow_pixmap_button
Definition gui_main.c:171
GtkWidget * ahbox
Definition gui_main.c:140
static void apply_reqtree_text_font(struct option *poption)
Definition gui_main.c:2467
static gboolean show_info_button_release(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2204
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 * sun_ebox
Definition gui_main.c:157
GtkWidget * bulb_ebox
Definition gui_main.c:156
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 GtkWidget * unit_image_button
Definition gui_main.c:167
static GtkWidget * unit_image_table
Definition gui_main.c:165
static gboolean right_notebook_button_release(GtkWidget *widget, GdkEventButton *event)
Definition gui_main.c:1075
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
static gboolean toplevel_key_release_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:581
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
GtkWidget * government_ebox
Definition gui_main.c:159
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
static GtkWidget * more_arrow_pixmap_container
Definition gui_main.c:172
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
GtkWidget * flake_ebox
Definition gui_main.c:158
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
static GtkWidget * unit_image
Definition gui_main.c:166
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
static void populate_unit_image_table(void)
Definition gui_main.c:890
#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 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:2151
void menus_free(void)
Definition menu.c:3224
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:290
#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: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
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_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: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
struct sprite * get_icon_sprite(const struct tileset *t, enum icon_type icon)
Definition tilespec.c:6979
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
@ ICON_FREECIV
Definition tilespec.h:313
#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_step_down(void)
Definition zoom.c:130
void zoom_step_up(void)
Definition zoom.c:106