23#ifdef SDL2_PLAIN_INCLUDE
44#include <gdk/gdkkeysyms.h>
115#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK (2 * 64)
116#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK (2 * 46)
117#define OVERVIEW_CANVAS_STORE_WIDTH \
118 (2 * OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK)
119#define OVERVIEW_CANVAS_STORE_HEIGHT \
120 (2 * OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK)
190static gboolean
show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data);
196 bool socket_writable);
253 _(
"This client accepts the standard Gtk command-line options\n"
254 "after '--'. See the Gtk documentation.\n\n"));
257 _(
"Other gui-specific options are:\n"));
260 _(
"-g, --gtk-warnings\tAllow Gtk+ to print warnings "
264 _(
"-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
270 fc_fprintf(stderr,
_(
"Report bugs at %s\n"), BUG_URL);
289 bool gtk_warns_enabled =
FALSE;
298 }
else if (
is_option(
"--gtk-warnings", argv[i])) {
299 gtk_warns_enabled =
TRUE;
312 if (!gtk_warns_enabled) {
313 g_log_set_handler(
"Gtk", G_LOG_LEVEL_WARNING,
log_gtk_warns, NULL);
325 case GTK_DIR_TAB_FORWARD:
326 case GTK_DIR_TAB_BACKWARD:
328 if (!gtk_widget_get_can_focus(w)) {
332 if (!gtk_widget_is_focus(w)) {
333 gtk_widget_grab_focus(w);
350 GtkAllocation *allocation,
353 static int old_width = 0, old_height = 0;
355 if (allocation->width != old_width
356 || allocation->height != old_height) {
358 old_width = allocation->width;
359 old_height = allocation->height;
368 gtk_window_present(GTK_WINDOW(
toplevel));
369 gtk_notebook_set_current_page(GTK_NOTEBOOK(
top_notebook), 0);
387 focus = gtk_window_get_focus(GTK_WINDOW(
toplevel));
389 if (GTK_IS_ENTRY(focus)
390 || (GTK_IS_TEXT_VIEW(focus)
391 && gtk_text_view_get_editable(GTK_TEXT_VIEW(focus)))) {
393 if (gtk_widget_event(focus, ev)) {
410 if ((ev->state & GDK_SHIFT_MASK)) {
411 switch (ev->keyval) {
433 case GDK_KEY_Page_Up:
435 GTK_MOVEMENT_PAGES, -1,
FALSE);
438 case GDK_KEY_Page_Down:
440 GTK_MOVEMENT_PAGES, 1,
FALSE);
446 }
else if (!(ev->state & GDK_CONTROL_MASK)) {
447 switch (ev->keyval) {
453 if (ev->state & GDK_SHIFT_MASK) {
454 bool volchange =
FALSE;
456 switch (ev->keyval) {
464 case GDK_KEY_KP_Subtract:
481 }
else if (!(ev->state & GDK_CONTROL_MASK)) {
482 switch (ev->keyval) {
489 case GDK_KEY_KP_Subtract:
503 switch (ev->keyval) {
512 case GDK_KEY_KP_Page_Up:
514 case GDK_KEY_Page_Up:
519 case GDK_KEY_KP_Right:
526 case GDK_KEY_KP_Page_Down:
528 case GDK_KEY_Page_Down:
533 case GDK_KEY_KP_Down:
547 case GDK_KEY_KP_Left:
554 case GDK_KEY_KP_Home:
561 case GDK_KEY_KP_Begin:
613 if (ev->keyval == GDK_KEY_apostrophe) {
622 if (gtk_widget_get_mapped(
top_vbox)) {
625 gtk_notebook_set_current_page(GTK_NOTEBOOK(
top_notebook), 1);
638 if (!gtk_widget_get_mapped(
top_vbox)
649 if (ev->state & GDK_SHIFT_MASK) {
650 switch (ev->keyval) {
653 case GDK_KEY_KP_Enter:
662 if (0 == gtk_notebook_get_current_page(GTK_NOTEBOOK(
top_notebook))) {
669 if ((ev->state & GDK_CONTROL_MASK)) {
670 }
else if ((ev->state & GDK_SHIFT_MASK)) {
672 switch (ev->keyval) {
692 int scroll_x, scroll_y, xstep, ystep;
701 switch (ev->direction) {
705 case GDK_SCROLL_DOWN:
708 case GDK_SCROLL_RIGHT:
711 case GDK_SCROLL_LEFT:
744 GtkWidget *p, *b, *box;
746 box = GTK_WIDGET(data);
747 p = g_object_get_data(G_OBJECT(w),
"parent");
748 b = g_object_get_data(G_OBJECT(w),
"toggle");
749 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b),
FALSE);
752 gtk_widget_reparent(box, p);
771 GtkWidget *box = GTK_WIDGET(data);
774 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b))) {
775 GtkWidget *temp_hide;
777 w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
779 gtk_widget_set_name(w,
"Freeciv");
780 gtk_window_set_title(GTK_WINDOW(w),
_(
"Freeciv"));
781 gtk_window_set_position(GTK_WINDOW(w), GTK_WIN_POS_MOUSE);
783 g_signal_connect(w,
"key_press_event",
786 g_object_set_data(G_OBJECT(w),
"parent", gtk_widget_get_parent(box));
787 g_object_set_data(G_OBJECT(w),
"toggle", b);
788 temp_hide = g_object_get_data(G_OBJECT(box),
"hide-over-reparent");
789 if (temp_hide != NULL) {
790 gtk_widget_hide(temp_hide);
792 gtk_widget_reparent(box, w);
794 if (temp_hide != NULL) {
795 gtk_widget_show(temp_hide);
798 gtk_widget_destroy(gtk_widget_get_parent(box));
807 GtkWidget *hgrid = gtk_grid_new();
809 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 2);
819 GtkWidget *b, *fillbox;
821 b = gtk_toggle_button_new();
822 gtk_container_add(GTK_CONTAINER(tearbox), b);
824 gtk_widget_set_tooltip_text(b,
_(
"Detach/Attach the pane."));
826 fillbox = gtk_grid_new();
827 gtk_orientable_set_orientation(GTK_ORIENTABLE(fillbox),
828 GTK_ORIENTATION_VERTICAL);
830 gtk_container_add(GTK_CONTAINER(tearbox), fillbox);
870 gtk_widget_add_events(
unit_image, GDK_BUTTON_PRESS_MASK);
880 GINT_TO_POINTER(-1));
896 "button_press_event",
916 "button_press_event",
925 gdk_pixbuf_get_width(pix), -1);
926 g_object_unref(G_OBJECT(pix));
938 gtk_widget_show_all(table);
1007 while (gtk_events_pending()) {
1008 gtk_main_iteration();
1025 GdkEventButton *
event)
1027 if (
event->type != GDK_BUTTON_RELEASE) {
1031 if (!GTK_IS_NOTEBOOK(
widget)
1032 || -1 == gtk_notebook_get_current_page(GTK_NOTEBOOK(
widget))) {
1046 gtk_widget_override_background_color(GTK_WIDGET(
overview_canvas), state,
1048 gtk_widget_override_background_color(GTK_WIDGET(
map_canvas), state,
1061 _(
"Fixed length turns"));
1066 _(
"Turn Done"),
_(
"Shift+Return"));
1076 GtkWidget *page, *ebox, *hgrid, *hgrid2, *label;
1077 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1078 GtkWidget *button, *
view, *vgrid, *right_vbox = NULL;
1082 GtkWidget *dtach_lowbox = NULL;
1086 notebook = gtk_notebook_new();
1089 g_signal_connect(notebook,
"scroll_event",
1090 G_CALLBACK(gtk_true), NULL);
1093 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook),
FALSE);
1094 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook),
FALSE);
1095 vgrid = gtk_grid_new();
1096 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1097 GTK_ORIENTATION_VERTICAL);
1098 gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4);
1099 gtk_container_add(GTK_CONTAINER(
toplevel), vgrid);
1100 gtk_container_add(GTK_CONTAINER(vgrid), notebook);
1102 gtk_container_add(GTK_CONTAINER(vgrid),
statusbar);
1104 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1106 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1108 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1110 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1112 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1122 page = gtk_scrolled_window_new(NULL, NULL);
1123 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(page),
1124 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1125 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(page),
1126 GTK_SHADOW_ETCHED_IN);
1127 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1130 gtk_orientable_set_orientation(GTK_ORIENTABLE(
top_vbox),
1131 GTK_ORIENTATION_VERTICAL);
1132 gtk_grid_set_row_spacing(GTK_GRID(
top_vbox), 5);
1133 hgrid = gtk_grid_new();
1138 right_vbox = gtk_grid_new();
1139 gtk_orientable_set_orientation(GTK_ORIENTABLE(right_vbox),
1140 GTK_ORIENTATION_VERTICAL);
1141 gtk_container_add(GTK_CONTAINER(hgrid), right_vbox);
1143 paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
1144 gtk_container_add(GTK_CONTAINER(page),
top_vbox);
1145 gtk_container_add(GTK_CONTAINER(
top_vbox), hgrid);
1146 gtk_container_add(GTK_CONTAINER(right_vbox), paned);
1155 paned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
1156 gtk_container_add(GTK_CONTAINER(page), paned);
1158 gtk_container_add(GTK_CONTAINER(
top_vbox), hgrid);
1166 vgrid = gtk_grid_new();
1167 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1168 GTK_ORIENTATION_VERTICAL);
1169 gtk_grid_set_column_spacing(GTK_GRID(vgrid), 3);
1172 gtk_grid_attach_next_to(GTK_GRID(hgrid), vgrid, right_vbox,
1173 GTK_POS_LEFT, 1, 1);
1179 gtk_container_add(GTK_CONTAINER(vgrid),
ahbox);
1185 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1198 |GDK_BUTTON_PRESS_MASK
1199 |GDK_POINTER_MOTION_MASK);
1217 gtk_container_add(GTK_CONTAINER(vgrid),
ahbox);
1221 gtk_widget_set_valign(
avbox, GTK_ALIGN_FILL);
1224 frame = gtk_frame_new(
"");
1225 gtk_container_add(GTK_CONTAINER(
avbox), frame);
1229 vgrid = gtk_grid_new();
1230 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1231 GTK_ORIENTATION_VERTICAL);
1232 gtk_container_add(GTK_CONTAINER(frame), vgrid);
1233 gtk_widget_set_hexpand(vgrid,
TRUE);
1235 ebox = gtk_event_box_new();
1236 gtk_widget_add_events(ebox, GDK_BUTTON_PRESS_MASK);
1237 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox),
FALSE);
1238 g_signal_connect(ebox,
"button_press_event",
1240 gtk_container_add(GTK_CONTAINER(vgrid), ebox);
1242 label = gtk_label_new(NULL);
1243 gtk_widget_set_halign(label, GTK_ALIGN_START);
1244 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1245 gtk_widget_set_margin_left(label, 2);
1246 gtk_widget_set_margin_right(label, 2);
1247 gtk_widget_set_margin_top(label, 2);
1248 gtk_widget_set_margin_bottom(label, 2);
1249 gtk_container_add(GTK_CONTAINER(ebox), label);
1253 table = gtk_grid_new();
1254 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
1255 gtk_grid_set_column_homogeneous(GTK_GRID(table),
TRUE);
1256 gtk_container_add(GTK_CONTAINER(
avbox), table);
1259 ebox = gtk_event_box_new();
1260 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox),
FALSE);
1261 gtk_grid_attach(GTK_GRID(table), ebox, 0, 0, 10, 1);
1264 table2 = gtk_grid_new();
1265 gtk_container_add(GTK_CONTAINER(ebox), table2);
1267 for (i = 0; i < 10; i++) {
1268 ebox = gtk_event_box_new();
1269 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox),
FALSE);
1270 gtk_widget_add_events(ebox, GDK_BUTTON_PRESS_MASK);
1272 gtk_grid_attach(GTK_GRID(table2), ebox, i, 0, 1, 1);
1274 g_signal_connect(ebox,
"button_press_event",
1279 gtk_container_add(GTK_CONTAINER(ebox),
econ_label[i]);
1300 for (i = 0; i < 4; i++) {
1303 ebox = gtk_event_box_new();
1304 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox),
FALSE);
1326 gtk_widget_set_halign(w, GTK_ALIGN_START);
1327 gtk_widget_set_valign(w, GTK_ALIGN_START);
1328 gtk_widget_set_margin_left(w, 0);
1329 gtk_widget_set_margin_right(w, 0);
1330 gtk_widget_set_margin_top(w, 0);
1331 gtk_widget_set_margin_bottom(w, 0);
1332 gtk_container_add(GTK_CONTAINER(ebox), w);
1333 gtk_grid_attach(GTK_GRID(table), ebox, i, 1, 1, 1);
1338 frame = gtk_frame_new(NULL);
1339 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1357 gtk_orientable_set_orientation(GTK_ORIENTABLE(
unit_info_box),
1358 GTK_ORIENTATION_VERTICAL);
1370 sw = gtk_scrolled_window_new(NULL, NULL);
1371 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1373 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1374 GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
1377 label = gtk_label_new(NULL);
1378 gtk_widget_set_hexpand(label,
TRUE);
1379 gtk_widget_set_halign(label, GTK_ALIGN_START);
1380 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1381 gtk_widget_set_margin_left(label, 2);
1382 gtk_widget_set_margin_right(label, 2);
1383 gtk_widget_set_margin_top(label, 2);
1384 gtk_widget_set_margin_bottom(label, 2);
1385 gtk_container_add(GTK_CONTAINER(sw), label);
1388 hgrid2 = gtk_grid_new();
1391 table = gtk_grid_new();
1392 g_object_set(table,
"margin", 5, NULL);
1393 gtk_container_add(GTK_CONTAINER(hgrid2), table);
1395 gtk_grid_set_row_spacing(GTK_GRID(table), 2);
1396 gtk_grid_set_column_spacing(GTK_GRID(table), 2);
1405 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(
top_notebook), GTK_POS_BOTTOM);
1412 right_vbox = gtk_grid_new();
1413 gtk_orientable_set_orientation(GTK_ORIENTABLE(right_vbox),
1414 GTK_ORIENTATION_VERTICAL);
1416 gtk_container_add(GTK_CONTAINER(right_vbox),
top_notebook);
1418 gtk_container_add(GTK_CONTAINER(hgrid), right_vbox);
1425 vgrid = gtk_grid_new();
1426 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1427 GTK_ORIENTATION_VERTICAL);
1428 gtk_container_add(GTK_CONTAINER(vgrid),
map_widget);
1433 label = gtk_label_new(
Q_(
"?noun:View"));
1434 gtk_notebook_append_page(GTK_NOTEBOOK(
top_notebook), vgrid, label);
1436 frame = gtk_frame_new(NULL);
1437 gtk_grid_attach(GTK_GRID(
map_widget), frame, 0, 0, 1, 1);
1442 gtk_widget_set_size_request(
map_canvas, 300, 300);
1454 gtk_widget_add_events(
map_canvas, GDK_EXPOSURE_MASK
1455 |GDK_BUTTON_PRESS_MASK
1456 |GDK_BUTTON_RELEASE_MASK
1458 |GDK_POINTER_MOTION_MASK
1461 gtk_container_add(GTK_CONTAINER(frame),
map_canvas);
1464 gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
1468 gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
1474 g_signal_connect(
map_canvas,
"configure_event",
1477 g_signal_connect(
map_canvas,
"motion_notify_event",
1480 g_signal_connect(
toplevel,
"enter_notify_event",
1483 g_signal_connect(
map_canvas,
"button_press_event",
1486 g_signal_connect(
map_canvas,
"button_release_event",
1492 g_signal_connect(
toplevel,
"key_press_event",
1495 g_signal_connect(
toplevel,
"key_release_event",
1507 gtk_paned_pack2(GTK_PANED(paned), dtach_lowbox,
FALSE,
TRUE);
1510 vgrid = gtk_grid_new();
1511 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1512 GTK_ORIENTATION_VERTICAL);
1516 gtk_container_add(GTK_CONTAINER(
avbox), vgrid);
1519 hpaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
1521 hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
1523 gtk_container_add(GTK_CONTAINER(vgrid), hpaned);
1524 g_object_set(hpaned,
"margin", 4, NULL);
1534 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(
right_notebook), GTK_POS_TOP);
1543 vgrid = gtk_grid_new();
1544 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1545 GTK_ORIENTATION_VERTICAL);
1547 sw = gtk_scrolled_window_new(NULL, NULL);
1548 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1549 GTK_SHADOW_ETCHED_IN);
1550 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
1552 gtk_container_add(GTK_CONTAINER(vgrid), sw);
1554 label = gtk_label_new(
_(
"Chat"));
1555 gtk_notebook_append_page(GTK_NOTEBOOK(
bottom_notebook), vgrid, label);
1558 gtk_widget_set_hexpand(text,
TRUE);
1559 gtk_widget_set_vexpand(text,
TRUE);
1561 gtk_text_view_set_editable(GTK_TEXT_VIEW(text),
FALSE);
1562 gtk_container_add(GTK_CONTAINER(sw), text);
1563 g_signal_connect(text,
"size-allocate",
1566 gtk_widget_set_name(text,
"chatline");
1568 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
1569 gtk_widget_realize(text);
1570 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);
1573 if (dtach_lowbox != NULL) {
1574 g_object_set_data(G_OBJECT(dtach_lowbox),
"hide-over-reparent",
main_message_area);
1581 gtk_container_add(GTK_CONTAINER(vgrid),
view);
1582 g_object_set(
view,
"margin", 3, NULL);
1584 button = gtk_check_button_new_with_label(
_(
"Allies Only"));
1585 gtk_button_set_focus_on_click(GTK_BUTTON(button),
FALSE);
1586 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
1588 g_signal_connect(button,
"toggled",
1593 button = gtk_button_new_with_label(
_(
"Clear links"));
1594 g_signal_connect(button,
"clicked",
1600 gtk_widget_show_all(gtk_bin_get_child(GTK_BIN(
toplevel)));
1606 gtk_notebook_set_current_page(GTK_NOTEBOOK(
top_notebook), 0);
1637 log_normal(
_(
"Migrating options from gtk2 to gtk3 client"));
1639#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk2_##opt;
1640#define MIGRATE_STR_OPTION(opt) \
1641 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk2_##opt, \
1642 sizeof(GUI_GTK_OPTION(opt)));
1681#undef MIGRATE_OPTION
1682#undef MIGRATE_STR_OPTION
1692 log_normal(
_(
"Migrating gtk3-client options from freeciv-2.5 options."));
1704 PangoFontDescription *toplevel_font_name;
1708 char window_name[1024];
1712 gtk_disable_setlocale();
1715 if (!gtk_init_check(&argc, &argv)) {
1716 log_fatal(
_(
"Failed to open graphical mode."));
1722 toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1723 gtk_window_set_position(GTK_WINDOW(
toplevel), GTK_WIN_POS_CENTER);
1727 g_signal_connect(
toplevel,
"key_press_event",
1730 gtk_window_set_role(GTK_WINDOW(
toplevel),
"toplevel");
1732 gtk_widget_set_name(
toplevel,
"Freeciv");
1756 gtk_window_fullscreen(GTK_WINDOW(
toplevel));
1760 gtk_window_set_title(GTK_WINDOW(
toplevel), window_name);
1762 g_signal_connect(
toplevel,
"delete_event",
1766 sig = g_signal_lookup(
"focus", GTK_TYPE_WIDGET);
1767 g_signal_handlers_disconnect_matched(
toplevel, G_SIGNAL_MATCH_ID, sig,
1778 toplevel_font_name = pango_context_get_font_description(
1779 gtk_widget_get_pango_context(
toplevel));
1783 log_error(
"city_names_style should have been set by options.");
1787 log_error(
"city_productions_style should have been set by options.");
1791 log_error(
"reqtree_text_style should have been set by options.");
1798#ifndef FREECIV_MSWINDOWS
1803 gtk_window_set_icon(GTK_WINDOW(
toplevel), pixbuf);
1804 g_object_unref(pixbuf);
1858 return EXIT_SUCCESS;
1893 gdk_display_beep(gdk_display_get_default());
1923 gtk_image_clear(GTK_IMAGE(w));
1934 static bool showing =
FALSE;
1940 if (onoff && !showing) {
1943 }
else if (!onoff && showing) {
1967 int i = GPOINTER_TO_INT(data);
2013 gdk_device_ungrab(ev->device, ev->time);
2014 gtk_widget_destroy(w);
2023 if (ev->button == 1) {
2026 p = gtk_window_new(GTK_WINDOW_POPUP);
2027 gtk_container_set_border_width(GTK_CONTAINER(p), 4);
2028 gtk_window_set_transient_for(GTK_WINDOW(p), GTK_WINDOW(
toplevel));
2029 gtk_window_set_position(GTK_WINDOW(p), GTK_WIN_POS_MOUSE);
2031 gtk_widget_new(GTK_TYPE_LABEL,
"GtkWidget::parent", p,
2033 "GtkWidget::visible",
TRUE,
2037 gdk_device_grab(ev->device, gtk_widget_get_window(p),
2038 GDK_OWNERSHIP_NONE,
TRUE, GDK_BUTTON_RELEASE_MASK, NULL,
2042 g_signal_connect_after(p,
"button_release_event",
2073 bool socket_writable)
2075 static bool previous_state =
FALSE;
2079 if (previous_state == socket_writable) {
2083 log_debug(
"set_wait_for_writable_socket(%d)", socket_writable);
2087 G_IO_IN | (socket_writable ? G_IO_OUT : 0) | G_IO_ERR,
2091 previous_state = socket_writable;
2100#ifdef FREECIV_MSWINDOWS
2101 srv_channel = g_io_channel_win32_new_socket(sock);
2129 gtk_widget_destroy(dialog);
2130 if (response == GTK_RESPONSE_YES) {
2156 static GtkWidget *dialog;
2159 dialog = gtk_message_dialog_new(NULL,
2161 GTK_MESSAGE_WARNING,
2163 _(
"Are you sure you want to quit?"));
2166 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
2168 g_signal_connect(dialog,
"response",
2170 g_signal_connect(dialog,
"destroy",
2171 G_CALLBACK(gtk_widget_destroyed), &dialog);
2174 gtk_window_present(GTK_WINDOW(dialog));
2231 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2241 gtk_window_fullscreen(GTK_WINDOW(
toplevel));
2243 gtk_window_unfullscreen(GTK_WINDOW(
toplevel));
2288#define option_var_set_callback(var, callback) \
2289 if ((poption = optset_option_by_name(client_optset, GUI_GTK_OPTION_STR(var)))) { \
2290 option_set_changed_callback(poption, callback); \
2292 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2306#undef option_var_set_callback
2323 gtk_widget_hide(button);
2325 gtk_widget_show(button);
2326 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2337 GUI_GTK_OPTION(allied_chat_only) = gtk_toggle_button_get_active(button);
2345 cat_snprintf(outbuf, outlen,
_(
"\nBuilt against gtk+ %d.%d.%d, using %d.%d.%d"
2346 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2347 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
2348 gtk_get_major_version(), gtk_get_minor_version(), gtk_get_micro_version(),
2349 GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
2350 glib_major_version, glib_minor_version, glib_micro_version);
2364 screen = gdk_screen_get_default();
2366 if (screen == NULL) {
2370 return gdk_screen_get_width(screen);
2384 screen = gdk_screen_get_default();
2386 if (screen == NULL) {
2390 return gdk_screen_get_height(screen);
2412 if (scr_height > 0) {
2415 if (scr_height <= 480) {
2418 log_verbose(
"Changing default to fullscreen due to very small screen");
2421 if (scr_height < 1024) {
2423 log_verbose(
"Defaulting to small widget layout due to small screen");
2425 log_verbose(
"Defaulting to merged messages/chat due to small screen");
struct canvas int int struct sprite int int int width
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)
void start_quitting(void)
void set_client_state(enum client_states newstate)
bool can_client_change_view(void)
void buy_production_in_selected_cities(void)
struct sprite * client_warming_sprite(void)
struct sprite * client_cooling_sprite(void)
struct sprite * client_research_sprite(void)
struct sprite * client_government_sprite(void)
void input_from_server(int fd)
void disconnect_from_server(void)
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
bool is_server_running(void)
void key_recall_previous_focus_unit(void)
bool unit_is_in_focus(const struct unit *punit)
void key_cancel_action(void)
void unit_focus_set(struct unit *punit)
struct unit_list * get_units_in_focus(void)
void update_unit_pix_label(struct unit_list *punitlist)
void key_unit_move(enum direction8 gui_dir)
enum cursor_hover_state hover_state
struct unit * head_of_units_in_focus(void)
int get_num_units_in_focus(void)
void control_mouse_cursor(struct tile *ptile)
void key_center_capital(void)
#define MAX_NUM_UNITS_BELOW
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
bool editor_is_active(void)
bool is_option(const char *option_name, char *option)
char * get_option_malloc(const char *option_name, char **argv, int *i, int argc, bool gc)
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
struct unit * game_unit_by_number(int id)
bool inputline_has_focus(void)
void inputline_toolkit_view_append_button(GtkWidget *toolkit_view, GtkWidget *button)
GtkWidget * inputline_toolkit_view_new(void)
void set_message_buffer_view_link_handlers(GtkWidget *view)
bool inputline_is_visible(void)
void inputline_grab_focus(void)
void chatline_scroll_to_bottom(bool delayed)
void citizens_dialog_init(void)
void citizens_dialog_done(void)
void unit_select_dialog_popup(struct tile *ptile)
gboolean taxrates_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
void diplomacy_dialog_init(void)
void diplomacy_dialog_done(void)
gboolean handle_edit_key_release(GdkEventKey *ev)
gboolean handle_edit_key_press(GdkEventKey *ev)
void editgui_create_widgets(void)
struct editbar * editgui_get_editbar(void)
void goto_dialog_focus_units_changed(void)
static GtkWidget * source
GtkWidget * map_vertical_scrollbar
int ui_main(int argc, char **argv)
const char * client_string
GtkTextBuffer * message_buffer
static void log_gtk_warns(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
static void quit_dialog_response(GtkWidget *dialog, gint response)
void real_focus_units_changed(void)
void set_unit_icons_more_arrow(bool onoff)
static void print_usage(void)
#define OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK
#define option_var_set_callback(var, callback)
static gboolean select_unit_image_callback(GtkWidget *w, GdkEvent *ev, gpointer data)
static gboolean quit_dialog_callback(void)
static GIOChannel * srv_channel
GtkWidget * main_label_info
GtkWidget * bottom_notebook
GtkWidget * unit_info_label
static gboolean timer_callback(gpointer data)
struct video_mode * resolution_request_get(void)
void set_unit_icon(int idx, struct unit *punit)
static int unit_ids[MAX_NUM_UNITS_BELOW]
GtkWidget * timeout_label
static gboolean mouse_scroll_mapcanvas(GtkWidget *w, GdkEventScroll *ev)
PangoFontDescription * city_productions_style
GtkWidget * overview_scrolled_window
static GtkWidget * more_arrow_pixmap
static GtkWidget * detached_widget_fill(GtkWidget *tearbox)
void enable_menus(bool enable)
static gboolean select_more_arrow_pixmap_callback(GtkWidget *w, GdkEvent *ev, gpointer data)
static gboolean propagate_keypress(GtkWidget *w, GdkEvent *ev)
#define MIGRATE_STR_OPTION(opt)
GtkWidget * unit_info_box
enum gui_type get_gui_type(void)
static GtkWidget * detached_widget_new(void)
int main(int argc, char **argv)
void fullscreen_opt_refresh(struct option *poption)
static void main_message_area_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
static gboolean toplevel_handler(GtkWidget *w, GdkEvent *ev, gpointer data)
static GtkWidget * unit_below_image_button[MAX_NUM_UNITS_BELOW]
static void free_unit_table(void)
static gboolean idle_callback_wrapper(gpointer data)
static void apply_city_names_font(struct option *poption)
static void apply_city_productions_font(struct option *poption)
static GtkWidget * unit_below_image[MAX_NUM_UNITS_BELOW]
static void tearoff_destroy(GtkWidget *w, gpointer data)
GtkWidget * government_label
PangoFontDescription * city_names_style
void refresh_chat_buttons(void)
gboolean map_canvas_focus(void)
GtkWidget * turn_done_button
static GtkWidget * bottom_hpaned
static GtkWidget * main_menubar
static void end_turn_callback(GtkWidget *w, gpointer data)
#define OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK
static void log_callback_utf8(enum log_level level, const char *message, bool file_too)
void add_idle_callback(void(callback)(void *), void *data)
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
void reset_unit_table(void)
static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, gpointer data)
GtkWidget * unit_info_frame
void options_extra_init(void)
static void allied_chat_only_callback(struct option *poption)
static void adjust_default_options(void)
static void set_wait_for_writable_socket(struct connection *pc, bool socket_writable)
static GtkWidget * more_arrow_pixmap_button
static void apply_reqtree_text_font(struct option *poption)
static gboolean show_info_button_release(GtkWidget *w, GdkEventButton *ev, gpointer data)
static gboolean toplevel_focus(GtkWidget *w, GtkDirectionType arg)
PangoFontDescription * reqtree_text_style
void insert_client_build_info(char *outbuf, size_t outlen)
static GtkWidget * unit_image_button
static GtkWidget * unit_image_table
static gboolean right_notebook_button_release(GtkWidget *widget, GdkEventButton *event)
GtkWidget * overview_canvas
static void setup_widgets(void)
#define OVERVIEW_CANVAS_STORE_WIDTH
static gboolean toplevel_key_release_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
void remove_net_input(void)
GtkWidget * map_horizontal_scrollbar
static void setup_canvas_color_for_state(GtkStateFlags state)
static gboolean toplevel_key_press_handler(GtkWidget *w, GdkEventKey *ev, gpointer data)
static void migrate_options_from_gtk2(void)
GtkWidget * econ_label[10]
GtkWidget * government_ebox
static void migrate_options_from_2_5(void)
void popup_quit_dialog(void)
const char *const gui_character_encoding
static gboolean get_net_input(GIOChannel *source, GIOCondition condition, gpointer data)
static GtkWidget * more_arrow_pixmap_container
GtkWidget * right_notebook
static void allied_chat_button_toggled(GtkToggleButton *button, gpointer user_data)
static struct video_mode vmode
void add_net_input(int sock)
GtkWidget * toplevel_tabs
static GtkWidget * allied_chat_toggle_button
int overview_canvas_store_width
void update_turn_done_tooltip(void)
static void tearoff_callback(GtkWidget *b, gpointer data)
static GtkWidget * unit_image
GtkTextView * main_message_area
int overview_canvas_store_height
static bool parse_options(int argc, char **argv)
#define OVERVIEW_CANVAS_STORE_HEIGHT
GtkWidget * main_frame_civ_name
#define MIGRATE_OPTION(opt)
const bool gui_use_transliteration
static void populate_unit_image_table(void)
#define GUI_GTK_OPTION(optname)
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
void gui_update_font_full(const char *font_name, const char *font_value, PangoFontDescription **font_desc)
void happiness_dialog_init(void)
void happiness_dialog_done(void)
void help_system_init(void)
void intel_dialog_done(void)
void intel_dialog_init(void)
void luaconsole_dialog_init(void)
void luaconsole_dialog_done(void)
gboolean butt_release_mapcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
gboolean move_overviewcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
gboolean butt_down_overviewcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
gboolean butt_down_mapcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
gboolean move_mapcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
gboolean leave_mapcanvas(GtkWidget *widget, GdkEventCrossing *event)
void update_city_descriptions(void)
gboolean map_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data)
gboolean map_canvas_configure(GtkWidget *w, GdkEventConfigure *ev, gpointer data)
void put_unit_image(struct unit *punit, GtkImage *p, int height)
gboolean overview_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data)
void meswin_dialog_popup(bool raise)
GtkWidget * create_start_page(void)
GtkWidget * create_network_page(void)
GtkWidget * create_scenario_page(void)
static GtkWidget * statusbar
void destroy_server_scans(void)
GtkWidget * create_load_page(void)
GtkWidget * create_statusbar(void)
GtkWidget * create_main_page(void)
void science_report_dialog_redraw(void)
void spaceship_dialog_init(void)
void spaceship_dialog_done(void)
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
GtkWidget * ingame_votebar
GtkWidget * voteinfo_bar_new(bool split_bar)
log_callback_fn log_set_callback(log_callback_fn callback)
#define fc_assert_ret(condition)
#define log_verbose(message,...)
#define log_fatal(message,...)
#define log_debug(message,...)
#define log_normal(message,...)
#define log_error(message,...)
void update_line(int canvas_x, int canvas_y)
void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
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)
void option_changed(struct option *poption)
const struct option_set * server_optset
const struct option_set * client_optset
bool option_bool_get(const struct option *poption)
enum option_type option_type(const struct option *poption)
const char * option_font_target(const struct option *poption)
bool string_to_video_mode(const char *buf, struct video_mode *mode)
struct client_options gui_options
const char * option_font_get(const struct option *poption)
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
#define GUI_GTK_OVERVIEW_MIN_XSIZE
#define options_iterate(poptset, poption)
#define options_iterate_end
const char * get_info_label_text_popup(void)
struct setting_list * level[OLEVELS_NUM]
#define CLIP(lower, current, upper)
void(* callback)(void *data)
void(* notify_of_writable_data)(struct connection *pc, bool data_available_and_socket_full)
cairo_surface_t * surface
int fc_snprintf(char *str, size_t n, const char *format,...)
int cat_snprintf(char *str, size_t n, const char *format,...)
void tileset_load_tiles(struct tileset *t)
void tileset_free_tiles(struct tileset *t)
void tileset_use_preferred_theme(const struct tileset *t)
struct sprite * get_icon_sprite(const struct tileset *t, enum icon_type icon)
void tileset_init(struct tileset *t)
struct sprite * get_arrow_sprite(const struct tileset *t, enum arrow_type arrow)
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
int tileset_tile_width(const struct tileset *t)
void zoom_step_down(void)