Freeciv-3.3
Loading...
Searching...
No Matches
gui_main.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#ifdef AUDIO_SDL
19/* Though it would happily compile without this include,
20 * it is needed for sound to work.
21 * It defines "main" macro to rename our main() so that
22 * it can install SDL's own. */
23#ifdef SDL2_PLAIN_INCLUDE
24#include <SDL.h>
25#else /* PLAIN_INCLUDE */
26#include <SDL2/SDL.h>
27#endif /* PLAIN_INCLUDE */
28#endif /* AUDIO_SDL */
29
30#ifdef HAVE_LOCALE_H
31#include <locale.h>
32#endif
33#include <stdarg.h>
34#include <stdio.h>
35#include <stdlib.h>
36#include <string.h>
37#include <time.h>
38
39#ifdef HAVE_UNISTD_H
40#include <unistd.h>
41#endif
42
43#include <gtk/gtk.h>
44#include <gdk/gdkkeysyms.h>
45
46/* utility */
47#include "fc_cmdline.h"
48#include "fciconv.h"
49#include "fcintl.h"
50#include "log.h"
51#include "mem.h"
52#include "support.h"
53
54/* common */
55#include "dataio.h"
56#include "featured_text.h"
57#include "game.h"
58#include "government.h"
59#include "map.h"
60#include "unitlist.h"
61#include "version.h"
62
63/* client */
64#include "audio.h"
65#include "client_main.h"
66#include "climisc.h"
67#include "clinet.h"
68#include "colors.h"
69#include "connectdlg_common.h"
70#include "control.h"
71#include "editor.h"
72#include "gui_properties.h"
73#include "options.h"
74#include "text.h"
75#include "tilespec.h"
76#include "zoom.h"
77
78/* client/gui-gtk-3.22 */
79#include "chatline.h"
80#include "citizensinfo.h"
81#include "connectdlg.h"
82#include "cma_fe.h"
83#include "dialogs.h"
84#include "diplodlg.h"
85#include "editgui.h"
86#include "gotodlg.h"
87#include "graphics.h"
88#include "gui_stuff.h"
89#include "happiness.h"
90#include "helpdlg.h"
91#include "inteldlg.h"
92#include "mapctrl.h"
93#include "mapview.h"
94#include "menu.h"
95#include "messagewin.h"
96#include "optiondlg.h"
97#include "pages.h"
98#include "plrdlg.h"
99#include "luaconsole.h"
100#include "spaceshipdlg.h"
101#include "repodlgs.h"
102#include "voteinfo_bar.h"
103
104#include "gui_main.h"
105
107
108GtkWidget *map_canvas; /* GtkDrawingArea */
111
112GtkWidget *overview_canvas; /* GtkDrawingArea */
113GtkWidget *overview_scrolled_window; /* GtkScrolledWindow */
114/* The two values below define the width and height of the map overview. The
115 * first set of values (2*62, 2*46) define the size for a netbook display. For
116 * bigger displays the values are doubled (default). */
117#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK (2 * 64)
118#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK (2 * 46)
119#define OVERVIEW_CANVAS_STORE_WIDTH \
120 (2 * OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK)
121#define OVERVIEW_CANVAS_STORE_HEIGHT \
122 (2 * OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK)
125
133
137
140
143
151
155
161
162const char *const gui_character_encoding = "UTF-8";
164
174
175static int unit_id_top;
176static int unit_ids[MAX_NUM_UNITS_BELOW]; /* ids of the units icons in
177 * information display: (or 0) */
181
182static gint timer_id; /* ditto */
186
187static bool gui_up = FALSE;
188
189static bool audio_paused = FALSE;
190static bool client_focus = TRUE;
191
192static struct video_mode vmode = { -1, -1 };
193
194static void set_g_log_callbacks(void);
195
198
199static void end_turn_callback(GtkWidget *w, gpointer data);
201 gpointer data);
202static void set_wait_for_writable_socket(struct connection *pc,
203 bool socket_writable);
204
205static void print_usage(void);
206static bool parse_options(int argc, char **argv);
210
211static void tearoff_callback(GtkWidget *b, gpointer data);
212static GtkWidget *detached_widget_new(void);
214
216 gpointer data);
218 gpointer data);
219static gboolean quit_dialog_callback(void);
220
222 gpointer user_data);
223
224static void free_unit_table(void);
225
226static void adjust_default_options(void);
227
228/**********************************************************************/
231static void log_callback_utf8(enum log_level level, const char *message,
232 bool file_too)
233{
234 if (!file_too || level <= LOG_FATAL) {
235 fc_fprintf(stderr, "%d: %s\n", level, message);
236 }
237}
238
239/**********************************************************************/
244{
245 double seconds = real_timer_callback();
246
248 if (!audio_paused && !client_focus) {
249 audio_pause();
251 } else if (audio_paused && client_focus) {
252 audio_resume();
254 }
255 }
256
258
259 return FALSE;
260}
261
262/**********************************************************************/
266static void print_usage(void)
267{
268 /* add client-specific usage information here */
270 _("This client accepts the standard Gtk command-line options\n"
271 "after '--'. See the Gtk documentation.\n\n"));
272
274 _("Other gui-specific options are:\n"));
275
277 _("-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
278 "screen\n\n"));
279
280 /* TRANS: No full stop after the URL, could cause confusion. */
281 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
282}
283
284/**********************************************************************/
287static bool parse_options(int argc, char **argv)
288{
289 int i = 1;
290
291 while (i < argc) {
292 char *option = NULL;
293
294 if (is_option("--help", argv[i])) {
295 print_usage();
296
297 return FALSE;
298 } else if ((option = get_option_malloc("--resolution", argv, &i, argc, FALSE))) {
300 fc_fprintf(stderr, _("Illegal video mode '%s'\n"), option);
302 }
303 free(option);
304 }
305 /* Can't check against unknown options, as those might be gtk options */
306
307 i++;
308 }
309
310 return TRUE;
311}
312
313/**********************************************************************/
317{
318 switch (arg) {
321
322 if (!gtk_widget_get_can_focus(w)) {
323 return FALSE;
324 }
325
326 if (!gtk_widget_is_focus(w)) {
328 return TRUE;
329 }
330 break;
331
332 default:
333 break;
334 }
335 return FALSE;
336}
337
338/**********************************************************************/
345 gpointer data)
346{
347 static int old_width = 0, old_height = 0;
348
349 if (allocation->width != old_width
350 || allocation->height != old_height) {
352 old_width = allocation->width;
353 old_height = allocation->height;
354 }
355}
356
357/**********************************************************************/
367
368/**********************************************************************/
378{
379 GtkWidget *focus;
380
382 if (focus) {
383 if (GTK_IS_ENTRY(focus)
384 || (GTK_IS_TEXT_VIEW(focus)
386 /* Propagate event to currently focused entry widget. */
387 if (gtk_widget_event(focus, ev)) {
388 /* Do not propagate event to our children. */
389 return TRUE;
390 }
391 }
392 }
393
394 /* Continue propagating event to our children. */
395 return FALSE;
396}
397
398/**********************************************************************/
402 gpointer data)
403{
404 if ((ev->state & GDK_SHIFT_MASK)) {
405 switch (ev->keyval) {
406
407 case GDK_KEY_Left:
409 return TRUE;
410
411 case GDK_KEY_Right:
413 return TRUE;
414
415 case GDK_KEY_Up:
417 return TRUE;
418
419 case GDK_KEY_Down:
421 return TRUE;
422
423 case GDK_KEY_Home:
425 return TRUE;
426
427 case GDK_KEY_Page_Up:
430 return TRUE;
431
435 return TRUE;
436
437 default:
438 break;
439 }
440 } else if (!(ev->state & GDK_CONTROL_MASK)) {
441 switch (ev->keyval) {
442 default:
443 break;
444 }
445 }
446
447 if (ev->state & GDK_SHIFT_MASK) {
448 bool volchange = FALSE;
449
450 switch (ev->keyval) {
451 case GDK_KEY_plus:
452 case GDK_KEY_KP_Add:
454 volchange = TRUE;
455 break;
456
457 case GDK_KEY_minus:
460 volchange = TRUE;
461 break;
462
463 default:
464 break;
465 }
466
467 if (volchange) {
468 struct option *poption = optset_option_by_name(client_optset, "sound_effects_volume");
469
472
473 return TRUE;
474 }
475 } else if (!(ev->state & GDK_CONTROL_MASK)) {
476 switch (ev->keyval) {
477 case GDK_KEY_plus:
478 case GDK_KEY_KP_Add:
479 zoom_step_up();
480 return TRUE;
481
482 case GDK_KEY_minus:
485 return TRUE;
486
487 default:
488 break;
489 }
490 }
491
492 /* Return here if observer */
493 if (client_is_observer()) {
494 return FALSE;
495 }
496
497 switch (ev->keyval) {
498
499 case GDK_KEY_KP_Up:
500 case GDK_KEY_KP_8:
501 case GDK_KEY_Up:
502 case GDK_KEY_8:
504 return TRUE;
505
507 case GDK_KEY_KP_9:
508 case GDK_KEY_Page_Up:
509 case GDK_KEY_9:
511 return TRUE;
512
513 case GDK_KEY_KP_Right:
514 case GDK_KEY_KP_6:
515 case GDK_KEY_Right:
516 case GDK_KEY_6:
518 return TRUE;
519
521 case GDK_KEY_KP_3:
523 case GDK_KEY_3:
525 return TRUE;
526
527 case GDK_KEY_KP_Down:
528 case GDK_KEY_KP_2:
529 case GDK_KEY_Down:
530 case GDK_KEY_2:
532 return TRUE;
533
534 case GDK_KEY_KP_End:
535 case GDK_KEY_KP_1:
536 case GDK_KEY_End:
537 case GDK_KEY_1:
539 return TRUE;
540
541 case GDK_KEY_KP_Left:
542 case GDK_KEY_KP_4:
543 case GDK_KEY_Left:
544 case GDK_KEY_4:
546 return TRUE;
547
548 case GDK_KEY_KP_Home:
549 case GDK_KEY_KP_7:
550 case GDK_KEY_Home:
551 case GDK_KEY_7:
553 return TRUE;
554
555 case GDK_KEY_KP_Begin:
556 case GDK_KEY_KP_5:
557 case GDK_KEY_5:
559 return TRUE;
560
561 case GDK_KEY_Escape:
563 return TRUE;
564
565 case GDK_KEY_b:
568 return TRUE;
569 }
570 break;
571
572 default:
573 break;
574 };
575
576 return FALSE;
577}
578
579/**********************************************************************/
583 gpointer data)
584{
585 /* inputline history code */
587 return FALSE;
588 }
589
590 if (editor_is_active()) {
592 }
593
594 return FALSE;
595}
596
597/**********************************************************************/
601 gpointer data)
602{
603 if (inputline_has_focus()) {
604 return FALSE;
605 }
606
607 if (ev->keyval == GDK_KEY_apostrophe) {
608 /* Allow this even if not in main map view; chatline is present on
609 * some other pages too */
610
611 /* Make the chatline visible if it's not currently.
612 * FIXME: should find the correct window, even when detached, from any
613 * other window; should scroll to the bottom automatically showing the
614 * latest text from other players; MUST NOT make spurious text windows
615 * at the bottom of other dialogs. */
617 /* The main game view is visible. May need to switch notebook. */
620 } else {
622 }
623 }
624
625 /* If the chatline is (now) visible, focus it. */
626 if (inputline_is_visible()) {
628 return TRUE;
629 }
630 }
631
634 return FALSE;
635 }
636
637 if (editor_is_active()) {
639 return TRUE;
640 }
641 }
642
643 if (ev->state & GDK_SHIFT_MASK) {
644 switch (ev->keyval) {
645
646 case GDK_KEY_Return:
647 case GDK_KEY_KP_Enter:
648 key_end_turn();
649 return TRUE;
650
651 default:
652 break;
653 }
654 }
655
657 /* 0 means the map view is focused. */
658 return key_press_map_canvas(w, ev, data);
659 }
660
661#if 0
662 /* We are focused some other dialog, tab, or widget. */
663 if ((ev->state & GDK_CONTROL_MASK)) {
664 } else if ((ev->state & GDK_SHIFT_MASK)) {
665 } else {
666 switch (ev->keyval) {
667
668 case GDK_KEY_F4:
670 return TRUE;
671
672 default:
673 break;
674 };
675 }
676#endif /* 0 */
677
678 return FALSE;
679}
680
681/**********************************************************************/
685{
687
688 if (!can_client_change_view()) {
689 return FALSE;
690 }
691
694
695 switch (ev->direction) {
696 case GDK_SCROLL_UP:
697 scroll_y -= ystep*2;
698 break;
699 case GDK_SCROLL_DOWN:
700 scroll_y += ystep*2;
701 break;
702 case GDK_SCROLL_RIGHT:
703 scroll_x += xstep*2;
704 break;
705 case GDK_SCROLL_LEFT:
706 scroll_x -= xstep*2;
707 break;
708 default:
709 return FALSE;
710 };
711
713
714 /* Emulating mouse move now */
717 }
718
719 update_line(ev->x, ev->y);
720 if (rbutton_down && (ev->state & GDK_BUTTON3_MASK)) {
722 }
723
726 }
727
729
730 return TRUE;
731}
732
733/**********************************************************************/
737{
739
740 return TRUE;
741}
742
743/**********************************************************************/
747{
749
750 return TRUE;
751}
752
753/**********************************************************************/
756static void tearoff_destroy(GtkWidget *w, gpointer data)
757{
758 GtkWidget *p, *b, *box;
760
761 box = GTK_WIDGET(data);
763 p = g_object_get_data(G_OBJECT(w), "parent");
764 b = g_object_get_data(G_OBJECT(w), "toggle");
766
768
769 g_object_ref(box); /* Make sure reference count stays above 0
770 * during the transition to new parent. */
773 g_object_unref(box);
774}
775
776/**********************************************************************/
780{
782
783 return FALSE;
784}
785
786/**********************************************************************/
791{
792 GtkWidget *box = GTK_WIDGET(data);
793
796 GtkWidget *w;
798
802 gtk_widget_set_name(w, "Freeciv");
803 gtk_window_set_title(GTK_WINDOW(w), _("Freeciv"));
805 g_signal_connect(w, "destroy", G_CALLBACK(tearoff_destroy), box);
806 g_signal_connect(w, "key_press_event",
808
810 g_object_set_data(G_OBJECT(w), "toggle", b);
811
812 temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent");
813 if (temp_hide != NULL) {
815 }
816
817 g_object_ref(box); /* Make sure reference count stays above 0
818 * during the transition to new parent. */
821 g_object_unref(box);
823
824 if (temp_hide != NULL) {
826 }
827 } else {
829 }
830}
831
832/**********************************************************************/
841
842/**********************************************************************/
847{
848 GtkWidget *b, *fillbox;
850
853
854 /* These toggle buttons run vertically down the side of many UI
855 * elements, so they need to be thin horizontally. */
857 ".detach_button {\n"
858 " padding: 0px 0px 0px 0px;\n"
859 " min-width: 6px;\n"
860 "}",
861 -1, NULL);
862 }
863
869 "detach_button");
870 gtk_widget_set_tooltip_text(b, _("Detach/Attach the pane."));
871
874
878
880
881 return fillbox;
882}
883
884/**********************************************************************/
892{
893 int i, width;
895 GdkPixbuf *pix;
896 int ttw;
897
898 /* Get width of the overview window */
902
904
906 /* We want arrow to appear if there is other units in addition
907 to active one in tile. Active unit is not counted, so there
908 can be 0 other units to not to display arrow. */
909 num_units_below = 1 - 1;
910 } else {
913 }
914
915 /* Top row: the active unit. */
916 /* Note, we ref this and other widgets here so that we can unref them
917 * in reset_unit_table. */
927 g_signal_connect(unit_image_button, "button_press_event",
929 GINT_TO_POINTER(-1));
930
932 /* Bottom row: other units in the same tile. */
933 for (i = 0; i < num_units_below; i++) {
941 FALSE);
945 "button_press_event",
948
950 i, 1, 1, 1);
951 }
952 }
953
954 /* Create arrow (popup for all units on the selected tile) */
961 FALSE);
965 "button_press_event",
967 /* An extra layer so that we can hide the clickable button but keep
968 * an explicit size request to avoid the layout jumping around */
977 gdk_pixbuf_get_width(pix), -1);
979
981 /* Display on bottom row. */
983 num_units_below, 1, 1, 1);
984 } else {
985 /* Display on top row (there is no bottom row). */
987 1, 0, 1, 1);
988 }
989
991}
992
993/**********************************************************************/
1020
1021/**********************************************************************/
1025{
1026 /* Unreference all of the widgets that we're about to reallocate, thus
1027 * avoiding a memory leak. Remove them from the container first, just
1028 * to be safe. Note, the widgets are ref'd in
1029 * populate_unit_image_table. */
1031
1033
1034 /* We have to force a redraw of the units. And we explicitly have
1035 * to force a redraw of the focus unit, which is normally only
1036 * redrawn when the focus changes. We also have to force the 'more'
1037 * arrow to go away, both by expicitly hiding it and telling it to
1038 * do so (this will be reset immediately afterwards if necessary,
1039 * but we have to make the *internal* state consistent). */
1042 if (get_num_units_in_focus() == 1) {
1044 } else {
1045 set_unit_icon(-1, NULL);
1046 }
1048}
1049
1050/**********************************************************************/
1054{
1055 if (enable) {
1057 /* Ensure the menus are really created before performing any operations
1058 * on them. */
1059 while (gtk_events_pending()) {
1061 }
1063 menus_init();
1065 } else {
1067 }
1068}
1069
1070/**********************************************************************/
1078{
1079 if (event->type != GDK_BUTTON_RELEASE) {
1080 return FALSE;
1081 }
1082
1085 /* Make sure the default gtk handler
1086 * does NOT get called in this case. */
1087 return TRUE;
1088 }
1089
1090 return FALSE;
1091}
1092
1093/**********************************************************************/
1096#if 0
1098{
1103}
1104#endif
1105
1106/**********************************************************************/
1110{
1111 struct option *opt = optset_option_by_name(server_optset, "fixedlength");
1112
1113 if (opt != NULL && option_bool_get(opt)) {
1115 _("Fixed length turns"));
1116 } else {
1117 char buf[256];
1118
1119 fc_snprintf(buf, sizeof(buf), "%s:\n%s",
1120 _("Turn Done"), _("Shift+Return"));
1122 }
1123}
1124
1125/**********************************************************************/
1128static void setup_widgets(void)
1129{
1130 GtkWidget *page, *ebox, *hgrid, *hgrid2, *label;
1131 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1132 GtkWidget *button, *view, *vgrid, *right_vbox = NULL;
1133 int i;
1134 GtkWidget *notebook, *statusbar;
1136 struct sprite *spr;
1137
1139
1140 notebook = gtk_notebook_new();
1141
1142 /* Stop mouse wheel notebook page switching. */
1143 g_signal_connect(notebook, "scroll_event",
1145
1146 toplevel_tabs = notebook;
1149 vgrid = gtk_grid_new();
1157
1168
1170
1172 g_object_set(ingame_votebar, "margin", 2, NULL);
1173
1174 /* *** everything in the top *** */
1175
1181 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1182
1187 hgrid = gtk_grid_new();
1188
1190 /* The window is divided into two horizontal panels: overview +
1191 * civinfo + unitinfo, main view + message window. */
1196
1202
1203 /* Overview size designed for small displays (netbooks). */
1206 } else {
1207 /* The window is divided into two vertical panes: overview +
1208 * + civinfo + unitinfo + main view, message window. */
1213
1214 /* Overview size designed for big displays (desktops). */
1217 }
1218
1219 /* this holds the overview canvas, production info, etc. */
1220 vgrid = gtk_grid_new();
1224 /* Put vgrid to the left of anything else in hgrid -- right_vbox is either
1225 * the chat/messages pane, or NULL which is OK */
1227 GTK_POS_LEFT, 1, 1);
1228
1229 /* Overview canvas */
1235
1240
1250
1255
1258
1261
1262 g_signal_connect(overview_canvas, "motion_notify_event",
1264
1265 g_signal_connect(overview_canvas, "button_press_event",
1267
1268 /* The rest */
1269
1276
1277 /* Info on player's civilization, when game is running. */
1278 frame = gtk_frame_new("");
1280
1281 main_frame_civ_name = frame;
1282
1283 vgrid = gtk_grid_new();
1288
1289 ebox = gtk_event_box_new();
1292 g_signal_connect(ebox, "button_press_event",
1295
1296 label = gtk_label_new(NULL);
1300 gtk_widget_set_margin_end(label, 2);
1301 gtk_widget_set_margin_top(label, 2);
1303 gtk_container_add(GTK_CONTAINER(ebox), label);
1304 main_label_info = label;
1305
1306 /* Production status */
1307 table = gtk_grid_new();
1311
1312 /* Citizens for taxrates */
1313 ebox = gtk_event_box_new();
1315 gtk_grid_attach(GTK_GRID(table), ebox, 0, 0, 10, 1);
1316 econ_ebox = ebox;
1317
1318 table2 = gtk_grid_new();
1320
1321 for (i = 0; i < 10; i++) {
1322 ebox = gtk_event_box_new();
1325
1326 gtk_grid_attach(GTK_GRID(table2), ebox, i, 0, 1, 1);
1327
1328 g_signal_connect(ebox, "button_press_event",
1330
1334 }
1335
1336 /* Science, environmental, govt, timeout */
1338 if (spr != NULL) {
1340 } else {
1342 }
1343
1345 if (spr != NULL) {
1347 } else {
1349 }
1350
1352 if (spr != NULL) {
1354 } else {
1356 }
1357
1359 if (spr != NULL) {
1361 } else {
1363 }
1364
1365 for (i = 0; i < 4; i++) {
1366 GtkWidget *w;
1367
1368 ebox = gtk_event_box_new();
1370
1371 switch (i) {
1372 case 0:
1373 w = bulb_label;
1374 bulb_ebox = ebox;
1375 break;
1376 case 1:
1377 w = sun_label;
1378 sun_ebox = ebox;
1379 break;
1380 case 2:
1381 w = flake_label;
1382 flake_ebox = ebox;
1383 break;
1384 default:
1385 case 3:
1386 w = government_label;
1387 government_ebox = ebox;
1388 break;
1389 }
1390
1398 gtk_grid_attach(GTK_GRID(table), ebox, i, 1, 1, 1);
1399 }
1400
1402
1403 frame = gtk_frame_new(NULL);
1404 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1406
1407
1408 /* Turn done */
1410
1412
1416
1417 /* Selected unit status */
1418
1424
1425 /* In edit mode the unit_info_box widget is replaced by the
1426 * editinfobox, so we need to add a ref here so that it is
1427 * not destroyed when removed from its container.
1428 * See editinfobox_refresh(). */
1430
1433
1440
1441 label = gtk_label_new(NULL);
1446 gtk_widget_set_margin_end(label, 2);
1447 gtk_widget_set_margin_top(label, 2);
1449 gtk_container_add(GTK_CONTAINER(sw), label);
1450 unit_info_label = label;
1451
1452 hgrid2 = gtk_grid_new();
1454
1455 table = gtk_grid_new();
1456 g_object_set(table, "margin", 5, NULL);
1458
1461
1463
1464 /* Map canvas, editor toolbar, and scrollbars */
1465
1466 /* The top notebook containing the map view and dialogs. */
1467
1471
1472
1479
1483 } else {
1485 }
1486
1488
1489 vgrid = gtk_grid_new();
1493
1495 g_object_set(editgui_get_editbar()->widget, "margin", 4, NULL);
1496
1497 label = gtk_label_new(Q_("?noun:View"));
1499
1500 frame = gtk_frame_new(NULL);
1501 gtk_grid_attach(GTK_GRID(map_widget), frame, 0, 0, 1, 1);
1502
1508
1509#if 0
1518#endif /* 0 */
1519
1526
1528
1532
1536
1539
1540 g_signal_connect(map_canvas, "configure_event",
1542
1543 g_signal_connect(map_canvas, "motion_notify_event",
1545
1546 g_signal_connect(toplevel, "enter_notify_event",
1548
1549 g_signal_connect(map_canvas, "button_press_event",
1551
1552 g_signal_connect(map_canvas, "button_release_event",
1554
1555 g_signal_connect(map_canvas, "scroll_event",
1557
1558 g_signal_connect(toplevel, "key_press_event",
1560
1561 g_signal_connect(toplevel, "key_release_event",
1563
1564 /* *** The message window -- this is a detachable widget *** */
1565
1569 } else {
1571
1575
1576 vgrid = gtk_grid_new();
1581 }
1583
1586 } else {
1588 }
1590 g_object_set(hpaned, "margin", 4, NULL);
1592
1597
1602 g_signal_connect(right_notebook, "button-release-event",
1606 }
1607 }
1608
1609 vgrid = gtk_grid_new();
1612
1619
1620 label = gtk_label_new(_("Chat"));
1622
1629 g_signal_connect(text, "size-allocate",
1631
1632 gtk_widget_set_name(text, "chatline");
1633
1635 gtk_widget_realize(text);
1637
1639 if (dtach_lowbox != NULL) {
1641 }
1642
1644
1645 /* the chat line */
1648 g_object_set(view, "margin", 3, NULL);
1649
1650 button = gtk_check_button_new_with_label(_("Allies Only"));
1654 g_signal_connect(button, "toggled",
1658
1659 button = gtk_button_new_with_label(_("Clear links"));
1660 g_signal_connect(button, "clicked",
1663
1664 /* Other things to take care of */
1665
1667
1670 }
1671
1674
1678 }
1679}
1680
1681/**********************************************************************/
1686 const gchar *message,
1687 gpointer user_data)
1688{
1689 enum log_level fllvl = LOG_ERROR;
1690
1691 switch (log_level) {
1692 case G_LOG_LEVEL_DEBUG:
1693 fllvl = LOG_DEBUG;
1694 break;
1696 fllvl = LOG_WARN;
1697 break;
1698 default:
1699 break;
1700 }
1701
1702 if (log_domain != NULL) {
1703 log_base(fllvl, "%s: %s", log_domain, message);
1704 } else {
1705 log_base(fllvl, "%s", message);
1706 }
1707}
1708
1709/**********************************************************************/
1713 const GLogField *fields,
1715 gpointer user_data)
1716{
1717 /* No need to have formatter of our own - let's use glib's default one. */
1719
1721
1722 return G_LOG_WRITER_HANDLED;
1723}
1724
1725/**********************************************************************/
1736
1737/**********************************************************************/
1740static void set_g_log_callbacks(void)
1741{
1742 /* Old API, still used by many log producers */
1744
1748
1749 /* glib >= 2.50 API */
1751}
1752
1753/**********************************************************************/
1762
1763/**********************************************************************/
1766int main(int argc, char **argv)
1767{
1768 return client_main(argc, argv, FALSE);
1769}
1770
1771/**********************************************************************/
1775{
1776 log_normal(_("Migrating options from gtk2 to gtk3 client"));
1777
1778#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1779#define MIGRATE_STR_OPTION(opt) \
1780 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1781 sizeof(gui_options.gui_gtk3_##opt));
1782
1783 /* Default theme name is never migrated */
1784 /* 'fullscreen', 'small_display_layout', and 'message_chat_location'
1785 * not migrated, as (unlike Gtk2), Gtk3-client tries to pick better
1786 * defaults for these in fresh installations based on screen size (see
1787 * adjust_default_options()); so user is probably better served by
1788 * getting these adaptive defaults than whatever they had for Gtk2.
1789 * Since 'fullscreen' isn't migrated, we don't need to worry about
1790 * preserving gui_gtk2_migrated_from_2_5 either. */
1804 MIGRATE_OPTION(popup_tech_help);
1805
1819
1820#undef MIGRATE_OPTION
1821#undef MIGRATE_STR_OPTION
1822
1824}
1825
1826/**********************************************************************/
1830{
1831 log_normal(_("Migrating options from gtk3 to gtk3.22 client"));
1832
1833#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk3_##opt;
1834#define MIGRATE_STR_OPTION(opt) \
1835 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_##opt, \
1836 sizeof(GUI_GTK_OPTION(opt)));
1837
1838 /* Default theme name is never migrated */
1839
1840 /* Simulate gui-gtk3's migrate_options_from_2_5() */
1842 log_normal(_("Migrating gtk3-client options from freeciv-2.5 options."));
1845 }
1846
1863 MIGRATE_OPTION(popup_tech_help);
1864
1878
1879#undef MIGRATE_OPTION
1880#undef MIGRATE_STR_OPTION
1881
1883}
1884
1885/**********************************************************************/
1888int ui_main(int argc, char **argv)
1889{
1891 guint sig;
1892
1893 if (parse_options(argc, argv)) {
1894 char window_name[1024];
1895
1896 /* The locale has already been set in init_nls() and the windows-specific
1897 * locale logic in gtk_init() causes problems with zh_CN (see PR#39475) */
1899
1900 /* GTK withdraw gtk options. Process GTK arguments */
1901 if (!gtk_init_check(&argc, &argv)) {
1902 log_fatal(_("Failed to open graphical mode."));
1903 return EXIT_FAILURE;
1904 }
1905
1907
1909
1912 if (vmode.width > 0 && vmode.height > 0) {
1914 }
1915 g_signal_connect(toplevel, "key_press_event",
1917
1918 g_signal_connect(toplevel, "focus_out_event",
1920 g_signal_connect(toplevel, "focus_in_event",
1922
1925 gtk_widget_set_name(toplevel, "Freeciv");
1927
1928 if (gui_options.first_boot) {
1930 /* We're using fresh defaults for this version of this client,
1931 * so prevent any future migrations from other clients / versions */
1933 /* Avoid also marking gtk3 as migrated, so that it can have its own
1934 * run of its adjust_default_options() if it is ever run (as a
1935 * side effect of Gtk2->Gtk3 migration). */
1936 } else {
1940 /* We want a fresh look at screen-size-related options after Gtk2 */
1942 /* We don't ever want to consider pre-2.6 fullscreen option again
1943 * (even for gui-gtk3) */
1945 }
1947 }
1948 }
1949
1952 }
1953
1954 fc_snprintf(window_name, sizeof(window_name), _("Freeciv (%s)"), GUI_NAME_SHORT);
1956
1957 g_signal_connect(toplevel, "delete_event",
1959
1960 /* Disable GTK+ cursor key focus movement */
1963 0, 0, 0, 0);
1965
1967 if (OT_FONT == option_type(poption)) {
1968 /* Force to call the appropriate callback. */
1970 }
1972
1975
1976 if (NULL == city_names_style) {
1978 log_error("city_names_style should have been set by options.");
1979 }
1982 log_error("city_productions_style should have been set by options.");
1983 }
1984 if (NULL == reqtree_text_style) {
1986 log_error("reqtree_text_style should have been set by options.");
1987 }
1988
1991
1992 /* Keep the icon of the executable on Windows (see PR#36491) */
1993#ifndef FREECIV_MSWINDOWS
1994 {
1996
1997 /* Only call this after tileset_load_tiles is called. */
2000 }
2001#endif /* FREECIV_MSWINDOWS */
2002
2003 setup_widgets();
2004 load_cursors();
2005 cma_fe_init();
2012 chatline_init();
2014
2016
2018
2019 /* Assumes toplevel showing */
2021
2022 /* Assumes client_state is set */
2024
2025 gui_up = TRUE;
2026 gtk_main();
2027 gui_up = FALSE;
2028
2037 cma_fe_done();
2039
2040 /* We have extra ref for unit_info_box that has protected
2041 * it from getting destroyed when editinfobox_refresh()
2042 * moves widgets around. Free that extra ref here. */
2044
2045 editgui_free();
2048 menus_free();
2049 message_buffer = NULL; /* Result of destruction of everything */
2051 }
2052
2053 return EXIT_SUCCESS;
2054}
2055
2056/**********************************************************************/
2059bool is_gui_up(void)
2060{
2061 return gui_up;
2062}
2063
2064/**********************************************************************/
2067void ui_exit(void)
2068{
2069 if (message_buffer != NULL) {
2072 }
2073}
2074
2075/**********************************************************************/
2078enum gui_type get_gui_type(void)
2079{
2080 return GUI_GTK3_22;
2081}
2082
2083/**********************************************************************/
2090
2091/**********************************************************************/
2097void set_unit_icon(int idx, struct unit *punit)
2098{
2099 GtkWidget *w;
2100
2101 fc_assert_ret(idx >= -1 && idx < num_units_below);
2102
2103 if (idx == -1) {
2104 w = unit_image;
2105 unit_id_top = punit ? punit->id : 0;
2106 } else {
2107 w = unit_below_image[idx];
2108 unit_ids[idx] = punit ? punit->id : 0;
2109 }
2110
2111 if (!w) {
2112 return;
2113 }
2114
2115 if (punit) {
2117 } else {
2119 }
2120}
2121
2122/**********************************************************************/
2128{
2129 static bool showing = FALSE;
2130
2132 return;
2133 }
2134
2135 if (onoff && !showing) {
2137 showing = TRUE;
2138 } else if (!onoff && showing) {
2140 showing = FALSE;
2141 }
2142}
2143
2144/**********************************************************************/
2154
2155/**********************************************************************/
2160 gpointer data)
2161{
2162 int i = GPOINTER_TO_INT(data);
2163 struct unit *punit;
2164
2165 if (i == -1) {
2167 if (punit && unit_is_in_focus(punit)) {
2168 /* Clicking on the currently selected unit will center it. */
2170 }
2171 return TRUE;
2172 }
2173
2174 if (unit_ids[i] == 0) /* no unit displayed at this place */
2175 return TRUE;
2176
2178 if (NULL != punit && unit_owner(punit) == client.conn.playing) {
2179 /* Unit shouldn't be NULL but may be owned by an ally. */
2181 }
2182
2183 return TRUE;
2184}
2185
2186/**********************************************************************/
2191 gpointer data)
2192{
2194
2195 if (punit) {
2197 }
2198
2199 return TRUE;
2200}
2201
2202/**********************************************************************/
2206 gpointer data)
2207{
2208 gtk_grab_remove(w);
2211
2212 return FALSE;
2213}
2214
2215/**********************************************************************/
2219{
2220 if (ev->button == 1) {
2221 GtkWidget *p;
2222
2227
2228 gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", p,
2229 "GtkLabel::label", get_info_label_text_popup(),
2230 "GtkWidget::visible", TRUE,
2231 NULL);
2232 gtk_widget_show(p);
2233
2236 TRUE, NULL, (GdkEvent *)ev, NULL, NULL);
2237 gtk_grab_add(p);
2238
2239 g_signal_connect_after(p, "button_release_event",
2241 }
2242
2243 return TRUE;
2244}
2245
2246/**********************************************************************/
2254
2255/**********************************************************************/
2259 gpointer data)
2260{
2262
2263 return TRUE;
2264}
2265
2266/**********************************************************************/
2270 bool socket_writable)
2271{
2272 static bool previous_state = FALSE;
2273
2275
2277 return;
2278
2279 log_debug("set_wait_for_writable_socket(%d)", socket_writable);
2280
2285 NULL);
2286
2288}
2289
2290/**********************************************************************/
2294void add_net_input(int sock)
2295{
2296#ifdef FREECIV_MSWINDOWS
2298#else
2300#endif
2302 G_IO_IN | G_IO_ERR,
2304 NULL);
2306}
2307
2308/**********************************************************************/
2318
2319/**********************************************************************/
2323static void quit_dialog_response(GtkWidget *dialog, gint response)
2324{
2325 gtk_widget_destroy(dialog);
2326 if (response == GTK_RESPONSE_YES) {
2328 if (client.conn.used) {
2330 }
2331 quit_gtk_main();
2332 }
2333}
2334
2335/**********************************************************************/
2339{
2340 /* Quit gtk main loop. After this it will return to finish
2341 * ui_main() */
2342
2343 gtk_main_quit();
2344}
2345
2346/**********************************************************************/
2351{
2352 static GtkWidget *dialog;
2353
2354 if (!dialog) {
2356 0,
2359 _("Are you sure you want to quit?"));
2360 setup_dialog(dialog, toplevel);
2361
2363
2364 g_signal_connect(dialog, "response",
2366 g_signal_connect(dialog, "destroy",
2368 }
2369
2371}
2372
2373/**********************************************************************/
2377{
2379 /* Stop emission of event. */
2380 return TRUE;
2381}
2382
2383struct callback {
2384 void (*callback)(void *data);
2385 void *data;
2386};
2387
2388/**********************************************************************/
2392{
2393 struct callback *cb = data;
2394
2395 (cb->callback)(cb->data);
2396 free(cb);
2397
2398 return FALSE;
2399}
2400
2401/**********************************************************************/
2406void add_idle_callback(void (callback)(void *), void *data)
2407{
2408 struct callback *cb = fc_malloc(sizeof(*cb));
2409
2410 cb->callback = callback;
2411 cb->data = data;
2413}
2414
2415/**********************************************************************/
2420{
2421 GtkWidget *button;
2422
2424 fc_assert_ret(button != NULL);
2426
2429}
2430
2431/**********************************************************************/
2442
2443/**********************************************************************/
2453
2454/**********************************************************************/
2464
2465/**********************************************************************/
2475
2476/**********************************************************************/
2481{
2482 struct option *poption;
2483
2484#define option_var_set_callback(var, callback) \
2485 if ((poption = optset_option_by_name(client_optset, \
2486 GUI_GTK_OPTION_STR(var)))) { \
2487 option_set_changed_callback(poption, callback); \
2488 } else { \
2489 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2490 }
2491
2496
2503#undef option_var_set_callback
2504}
2505
2506/**********************************************************************/
2511{
2512 GtkWidget *button;
2513
2515 fc_assert_ret(button != NULL);
2517
2518 /* Hide the "Allies Only" button for local games. */
2519 if (is_server_running()) {
2520 gtk_widget_hide(button);
2521 } else {
2522 gtk_widget_show(button);
2525 }
2526}
2527
2528/**********************************************************************/
2536
2537/**********************************************************************/
2541{
2542 cat_snprintf(outbuf, outlen, _("\nBuilt against gtk+ %d.%d.%d, using %d.%d.%d"
2543 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2548}
2549
2550/**********************************************************************/
2555{
2558
2560 if (!display) {
2561 return FALSE;
2562 }
2563
2565 if (!monitor) {
2566 return FALSE;
2567 }
2568
2570 return TRUE;
2571}
2572
2573/**********************************************************************/
2577{
2578 GdkRectangle rect;
2579
2580 if (vmode.width > 0) {
2581 return vmode.width;
2582 }
2583
2584 if (monitor_size(&rect)) {
2585 return rect.width;
2586 } else {
2587 return 0;
2588 }
2589}
2590
2591/**********************************************************************/
2595{
2596 GdkRectangle rect;
2597
2598 if (vmode.height > 0) {
2599 return vmode.height;
2600 }
2601
2602 if (monitor_size(&rect)) {
2603 return rect.height;
2604 } else {
2605 return 0;
2606 }
2607}
2608
2609/**********************************************************************/
2613{
2614 if (vmode.width > 0 && vmode.height > 0) {
2615 return &vmode;
2616 }
2617
2618 return NULL;
2619}
2620
2621/**********************************************************************/
2624static void adjust_default_options(void)
2625{
2626 int scr_height = screen_height();
2627
2628 if (scr_height > 0) {
2629 /* Adjust these options only if we do know the screen height. */
2630
2631 if (scr_height <= 480) {
2632 /* Freeciv is practically unusable outside fullscreen mode in so
2633 * small display */
2634 log_verbose("Changing default to fullscreen due to very small screen");
2636 }
2637 if (scr_height < 1024) {
2638 /* This is a small display */
2639 log_verbose("Defaulting to small widget layout due to small screen");
2641 log_verbose("Defaulting to merged messages/chat due to small screen");
2643 }
2644 }
2645}
2646
2647/**********************************************************************/
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:1317
struct sprite * client_warming_sprite(void)
Definition climisc.c:377
struct sprite * client_cooling_sprite(void)
Definition climisc.c:394
struct sprite * client_research_sprite(void)
Definition climisc.c:354
struct sprite * client_government_sprite(void)
Definition climisc.c:412
void disconnect_from_server(bool leaving_sound)
Definition clinet.c:306
void input_from_server(int fd)
Definition clinet.c:411
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
char * incite_cost
Definition comments.c:76
bool is_server_running(void)
void key_recall_previous_focus_unit(void)
Definition control.c:3320
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:388
void key_cancel_action(void)
Definition control.c:3258
int num_units_below
Definition control.c:76
void unit_focus_set(struct unit *punit)
Definition control.c:506
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void key_end_turn(void)
Definition control.c:3312
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:985
void key_unit_move(enum direction8 gui_dir)
Definition control.c:3341
enum cursor_hover_state hover_state
Definition control.c:89
struct unit * head_of_units_in_focus(void)
Definition control.c:410
int get_num_units_in_focus(void)
Definition control.c:185
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1215
void key_center_capital(void)
Definition control.c:3295
#define MAX_NUM_UNITS_BELOW
Definition control.h:295
@ HOVER_NONE
Definition control.h:26
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
bool editor_is_active(void)
Definition editor.c:346
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:115
bool inputline_has_focus(void)
Definition chatline.c:72
void inputline_toolkit_view_append_button(GtkWidget *toolkit_view, GtkWidget *button)
Definition chatline.c:1293
GtkWidget * inputline_toolkit_view_new(void)
Definition chatline.c:1271
void set_message_buffer_view_link_handlers(GtkWidget *view)
Definition chatline.c:745
bool inputline_is_visible(void)
Definition chatline.c:88
void chatline_init(void)
Definition chatline.c:1303
void inputline_grab_focus(void)
Definition chatline.c:80
void chatline_scroll_to_bottom(bool delayed)
Definition chatline.c:1007
void citizens_dialog_init(void)
void citizens_dialog_done(void)
void cma_fe_init(void)
Definition cma_fe.c:88
void cma_fe_done(void)
Definition cma_fe.c:96
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
gboolean taxrates_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition dialogs.c:1425
void diplomacy_dialog_init(void)
Definition diplodlg.c:1206
void diplomacy_dialog_done(void)
Definition diplodlg.c:1215
gboolean handle_edit_key_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:84
GtkWidget * map_vertical_scrollbar
Definition gui_main.c:110
int ui_main(int argc, char **argv)
Definition gui_main.c:1888
const char * client_string
Definition gui_main.c:106
GtkTextBuffer * message_buffer
Definition gui_main.c:179
static void quit_dialog_response(GtkWidget *dialog, gint response)
Definition gui_main.c:2323
void real_focus_units_changed(void)
Definition gui_main.c:2150
void set_unit_icons_more_arrow(bool onoff)
Definition gui_main.c:2127
static void print_usage(void)
Definition gui_main.c:266
#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK
Definition gui_main.c:117
#define option_var_set_callback(var, callback)
static gboolean select_unit_image_callback(GtkWidget *w, GdkEvent *ev, gpointer data)
Definition gui_main.c:2159
static gboolean quit_dialog_callback(void)
Definition gui_main.c:2376
static GIOChannel * srv_channel
Definition gui_main.c:183
GtkWidget * main_label_info
Definition gui_main.c:139
static bool monitor_size(GdkRectangle *rect_p)
Definition gui_main.c:2554
GtkWidget * bottom_notebook
Definition gui_main.c:130
GtkWidget * unit_info_label
Definition gui_main.c:152
static gboolean timer_callback(gpointer data)
Definition gui_main.c:243
struct video_mode * resolution_request_get(void)
Definition gui_main.c:2612
void set_unit_icon(int idx, struct unit *punit)
Definition gui_main.c:2097
static int unit_ids[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:176
GtkWidget * timeout_label
Definition gui_main.c:149
static bool gui_up
Definition gui_main.c:187
static guint srv_id
Definition gui_main.c:184
static gboolean mouse_scroll_mapcanvas(GtkWidget *w, GdkEventScroll *ev)
Definition gui_main.c:684
PangoFontDescription * city_productions_style
Definition gui_main.c:135
GtkWidget * overview_scrolled_window
Definition gui_main.c:113
static GtkWidget * more_arrow_pixmap
Definition gui_main.c:171
static GtkWidget * detached_widget_fill(GtkWidget *tearbox)
Definition gui_main.c:846
void enable_menus(bool enable)
Definition gui_main.c:1053
static gboolean select_more_arrow_pixmap_callback(GtkWidget *w, GdkEvent *ev, gpointer data)
Definition gui_main.c:2190
GtkWidget * top_notebook
Definition gui_main.c:130
static gboolean propagate_keypress(GtkWidget *w, GdkEvent *ev)
Definition gui_main.c:779
#define MIGRATE_STR_OPTION(opt)
GtkWidget * econ_ebox
Definition gui_main.c:156
GtkWidget * unit_info_box
Definition gui_main.c:153
gboolean fc_lost_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:736
void ui_exit(void)
Definition gui_main.c:2067
enum gui_type get_gui_type(void)
Definition gui_main.c:2078
static GtkWidget * detached_widget_new(void)
Definition gui_main.c:835
gint cur_y
Definition gui_main.c:185
int main(int argc, char **argv)
Definition gui_main.c:1766
void fullscreen_opt_refresh(struct option *poption)
Definition gui_main.c:2434
static void main_message_area_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
Definition gui_main.c:343
static gboolean toplevel_handler(GtkWidget *w, GdkEvent *ev, gpointer data)
Definition gui_main.c:377
void ui_init(void)
Definition gui_main.c:1756
static GtkWidget * unit_below_image_button[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:170
static void free_unit_table(void)
Definition gui_main.c:996
static gboolean idle_callback_wrapper(gpointer data)
Definition gui_main.c:2391
static void apply_city_names_font(struct option *poption)
Definition gui_main.c:2446
static void apply_city_productions_font(struct option *poption)
Definition gui_main.c:2457
gboolean fc_gained_focus(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:746
static GtkWidget * unit_below_image[MAX_NUM_UNITS_BELOW]
Definition gui_main.c:169
static void tearoff_destroy(GtkWidget *w, gpointer data)
Definition gui_main.c:756
GtkWidget * government_label
Definition gui_main.c:148
GtkWidget * sun_label
Definition gui_main.c:146
PangoFontDescription * city_names_style
Definition gui_main.c:134
void refresh_chat_buttons(void)
Definition gui_main.c:2510
gboolean map_canvas_focus(void)
Definition gui_main.c:360
GtkWidget * turn_done_button
Definition gui_main.c:150
static GtkWidget * bottom_hpaned
Definition gui_main.c:132
static gint timer_id
Definition gui_main.c:182
static GtkWidget * main_menubar
Definition gui_main.c:165
int screen_width(void)
Definition gui_main.c:2576
GtkWidget * scroll_panel
Definition gui_main.c:142
static void end_turn_callback(GtkWidget *w, gpointer data)
Definition gui_main.c:2249
#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK
Definition gui_main.c:118
static void log_callback_utf8(enum log_level level, const char *message, bool file_too)
Definition gui_main.c:231
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2406
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2218
static void set_g_log_callbacks(void)
Definition gui_main.c:1740
void reset_unit_table(void)
Definition gui_main.c:1024
static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:401
GtkWidget * unit_info_frame
Definition gui_main.c:154
void options_extra_init(void)
Definition gui_main.c:2480
GtkWidget * top_vbox
Definition gui_main.c:129
static void allied_chat_only_callback(struct option *poption)
Definition gui_main.c:2419
GdkWindow * root_window
Definition gui_main.c:127
static void adjust_default_options(void)
Definition gui_main.c:2624
static void set_wait_for_writable_socket(struct connection *pc, bool socket_writable)
Definition gui_main.c:2269
static GtkWidget * more_arrow_pixmap_button
Definition gui_main.c:172
GtkWidget * ahbox
Definition gui_main.c:141
static void apply_reqtree_text_font(struct option *poption)
Definition gui_main.c:2468
static gboolean show_info_button_release(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition gui_main.c:2205
bool is_gui_up(void)
Definition gui_main.c:2059
static gboolean toplevel_focus(GtkWidget *w, GtkDirectionType arg)
Definition gui_main.c:316
PangoFontDescription * reqtree_text_style
Definition gui_main.c:136
GtkWidget * sun_ebox
Definition gui_main.c:158
GtkWidget * bulb_ebox
Definition gui_main.c:157
GtkWidget * flake_label
Definition gui_main.c:147
static void g_log_to_freelog_cb(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
Definition gui_main.c:1684
GtkWidget * avbox
Definition gui_main.c:141
gint cur_x
Definition gui_main.c:185
void setup_gui_properties(void)
Definition gui_main.c:2650
void insert_client_build_info(char *outbuf, size_t outlen)
Definition gui_main.c:2540
static GtkWidget * unit_image_button
Definition gui_main.c:168
static GtkWidget * unit_image_table
Definition gui_main.c:166
static gboolean right_notebook_button_release(GtkWidget *widget, GdkEventButton *event)
Definition gui_main.c:1076
static void set_g_log_callback_domain(const char *domain)
Definition gui_main.c:1728
GtkWidget * bulb_label
Definition gui_main.c:145
GtkWidget * overview_canvas
Definition gui_main.c:112
GtkWidget * toplevel
Definition gui_main.c:126
static void setup_widgets(void)
Definition gui_main.c:1128
#define OVERVIEW_CANVAS_STORE_WIDTH
Definition gui_main.c:119
static gboolean toplevel_key_release_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:582
void remove_net_input(void)
Definition gui_main.c:2312
GtkWidget * map_horizontal_scrollbar
Definition gui_main.c:109
GtkWidget * map_canvas
Definition gui_main.c:108
static gboolean toplevel_key_press_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
Definition gui_main.c:600
void sound_bell(void)
Definition gui_main.c:2086
static void migrate_options_from_gtk2(void)
Definition gui_main.c:1774
GtkWidget * econ_label[10]
Definition gui_main.c:144
GtkWidget * government_ebox
Definition gui_main.c:160
void popup_quit_dialog(void)
Definition gui_main.c:2350
static void migrate_options_from_gtk3(void)
Definition gui_main.c:1829
const char *const gui_character_encoding
Definition gui_main.c:162
static int unit_id_top
Definition gui_main.c:175
static gboolean get_net_input(GIOChannel *source, GIOCondition condition, gpointer data)
Definition gui_main.c:2258
static bool audio_paused
Definition gui_main.c:189
static GtkWidget * more_arrow_pixmap_container
Definition gui_main.c:173
GtkWidget * map_widget
Definition gui_main.c:131
static bool client_focus
Definition gui_main.c:190
GtkWidget * right_notebook
Definition gui_main.c:130
void quit_gtk_main(void)
Definition gui_main.c:2338
static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data)
Definition gui_main.c:2531
static struct video_mode vmode
Definition gui_main.c:192
void add_net_input(int sock)
Definition gui_main.c:2294
static GLogWriterOutput g_log_writer_to_freelog_cb(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data)
Definition gui_main.c:1712
GtkWidget * toplevel_tabs
Definition gui_main.c:128
static GtkWidget * allied_chat_toggle_button
Definition gui_main.c:180
GtkWidget * flake_ebox
Definition gui_main.c:159
int overview_canvas_store_width
Definition gui_main.c:123
void update_turn_done_tooltip(void)
Definition gui_main.c:1109
static void tearoff_callback(GtkWidget *b, gpointer data)
Definition gui_main.c:790
static GtkWidget * unit_image
Definition gui_main.c:167
GtkTextView * main_message_area
Definition gui_main.c:178
int overview_canvas_store_height
Definition gui_main.c:124
int screen_height(void)
Definition gui_main.c:2594
static bool parse_options(int argc, char **argv)
Definition gui_main.c:287
GtkWidget * conn_box
Definition gui_main.c:141
#define OVERVIEW_CANVAS_STORE_HEIGHT
Definition gui_main.c:121
GtkWidget * main_frame_civ_name
Definition gui_main.c:138
#define MIGRATE_OPTION(opt)
const bool gui_use_transliteration
Definition gui_main.c:163
static void populate_unit_image_table(void)
Definition gui_main.c:891
#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
struct client_properties gui_properties
log_callback_fn log_set_callback(log_callback_fn callback)
Definition log.c:290
#define fc_assert_ret(condition)
Definition log.h:192
#define log_verbose(message,...)
Definition log.h:110
#define log_fatal(message,...)
Definition log.h:101
#define log_debug(message,...)
Definition log.h:116
#define log_normal(message,...)
Definition log.h:108
#define log_base(level, message,...)
Definition log.h:95
log_level
Definition log.h:29
@ LOG_ERROR
Definition log.h:31
@ LOG_DEBUG
Definition log.h:35
@ LOG_FATAL
Definition log.h:30
@ LOG_WARN
Definition log.h:32
#define log_error(message,...)
Definition log.h:104
void update_line(int canvas_x, int canvas_y)
void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
bool rbutton_down
bool tiles_hilited_cities
void scroll_mapview(enum direction8 gui_dir)
bool keyboardless_goto_button_down
void update_selection_rectangle(float canvas_x, float canvas_y)
void init_mapcanvas_and_overview(void)
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
void free_mapcanvas_and_overview(void)
void get_mapview_scroll_pos(int *scroll_x, int *scroll_y)
void get_mapview_scroll_step(int *xstep, int *ystep)
void set_mapview_scroll_pos(int scroll_x, int scroll_y, float zoom)
void center_tile_mapcanvas(const struct tile *ptile)
void 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:784
const struct option_set * server_optset
Definition options.c:4278
const struct option_set * client_optset
Definition options.c:1316
bool option_bool_get(const struct option *poption)
Definition options.c:833
enum option_type option_type(const struct option *poption)
Definition options.c:694
const char * option_font_target(const struct option *poption)
Definition options.c:1199
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6760
struct client_options gui_options
Definition options.c:71
const char * option_font_get(const struct option *poption)
Definition options.c:1177
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:467
@ GUI_GTK_MSGCHAT_MERGED
Definition options.h:69
@ GUI_GTK_MSGCHAT_SPLIT
Definition options.h:67
#define GUI_GTK_OVERVIEW_MIN_XSIZE
Definition options.h:634
#define options_iterate(poptset, poption)
Definition options.h:587
#define options_iterate_end
Definition options.h:592
const char * get_info_label_text_popup(void)
Definition text.c:1016
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
#define CLIP(lower, current, upper)
Definition shared.h:57
void * data
Definition gui_main.c:2385
void(* callback)(void *data)
Definition gui_main.c:2384
struct connection conn
Definition client_main.h:96
bool silent_when_not_in_focus
Definition options.h:192
bool gui_gtk3_migrated_from_2_5
Definition options.h:140
int sound_effects_volume
Definition options.h:191
bool first_boot
Definition options.h:128
bool gui_gtk3_fullscreen
Definition options.h:267
bool migrate_fullscreen
Definition options.h:146
bool gui_gtk3_migrated_from_gtk2
Definition options.h:133
Definition colors.h:21
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:140
int id
Definition unit.h:147
int height
Definition options.h:48
int width
Definition options.h:47
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:986
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
void tileset_load_tiles(struct tileset *t)
Definition tilespec.c:3804
void tileset_free_tiles(struct tileset *t)
Definition tilespec.c:6819
void tileset_use_preferred_theme(const struct tileset *t)
Definition tilespec.c:7293
struct sprite * get_icon_sprite(const struct tileset *t, enum icon_type icon)
Definition tilespec.c:7203
void tileset_init(struct tileset *t)
Definition tilespec.c:7354
struct sprite * get_arrow_sprite(const struct tileset *t, enum arrow_type arrow)
Definition tilespec.c:7092
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:7103
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:779
@ ARROW_RIGHT
Definition tilespec.h:202
@ ICON_FREECIV
Definition tilespec.h:315
#define unit_tile(_pu)
Definition unit.h:404
#define unit_owner(_pu)
Definition unit.h:403
float mouse_zoom
Definition zoom.c:28
void zoom_step_down(void)
Definition zoom.c:130
void zoom_step_up(void)
Definition zoom.c:106