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)
192static gboolean
show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data);
198 bool socket_writable);
255 _(
"This client accepts the standard Gtk command-line options\n"
256 "after '--'. See the Gtk documentation.\n\n"));
259 _(
"Other gui-specific options are:\n"));
262 _(
"-r, --resolution WIDTHxHEIGHT\tAssume given resolution "
268 fc_fprintf(stderr,
_(
"Report bugs at %s\n"), BUG_URL);
306 case GTK_DIR_TAB_FORWARD:
307 case GTK_DIR_TAB_BACKWARD:
309 if (!gtk_widget_get_can_focus(w)) {
313 if (!gtk_widget_is_focus(w)) {
314 gtk_widget_grab_focus(w);
331 GtkAllocation *allocation,
334 static int old_width = 0, old_height = 0;
336 if (allocation->width != old_width
337 || allocation->height != old_height) {
339 old_width = allocation->width;
340 old_height = allocation->height;
349 gtk_window_present(GTK_WINDOW(
toplevel));
350 gtk_notebook_set_current_page(GTK_NOTEBOOK(
top_notebook), 0);
368 focus = gtk_window_get_focus(GTK_WINDOW(
toplevel));
370 if (GTK_IS_ENTRY(focus)
371 || (GTK_IS_TEXT_VIEW(focus)
372 && gtk_text_view_get_editable(GTK_TEXT_VIEW(focus)))) {
374 if (gtk_widget_event(focus, ev)) {
391 if ((ev->state & GDK_SHIFT_MASK)) {
392 switch (ev->keyval) {
414 case GDK_KEY_Page_Up:
416 GTK_MOVEMENT_PAGES, -1,
FALSE);
419 case GDK_KEY_Page_Down:
421 GTK_MOVEMENT_PAGES, 1,
FALSE);
427 }
else if (!(ev->state & GDK_CONTROL_MASK)) {
428 switch (ev->keyval) {
434 if (ev->state & GDK_SHIFT_MASK) {
435 bool volchange =
FALSE;
437 switch (ev->keyval) {
445 case GDK_KEY_KP_Subtract:
462 }
else if (!(ev->state & GDK_CONTROL_MASK)) {
463 switch (ev->keyval) {
470 case GDK_KEY_KP_Subtract:
484 switch (ev->keyval) {
493 case GDK_KEY_KP_Page_Up:
495 case GDK_KEY_Page_Up:
500 case GDK_KEY_KP_Right:
507 case GDK_KEY_KP_Page_Down:
509 case GDK_KEY_Page_Down:
514 case GDK_KEY_KP_Down:
528 case GDK_KEY_KP_Left:
535 case GDK_KEY_KP_Home:
542 case GDK_KEY_KP_Begin:
594 if (ev->keyval == GDK_KEY_apostrophe) {
603 if (gtk_widget_get_mapped(
top_vbox)) {
606 gtk_notebook_set_current_page(GTK_NOTEBOOK(
top_notebook), 1);
619 if (!gtk_widget_get_mapped(
top_vbox)
630 if (ev->state & GDK_SHIFT_MASK) {
631 switch (ev->keyval) {
634 case GDK_KEY_KP_Enter:
643 if (0 == gtk_notebook_get_current_page(GTK_NOTEBOOK(
top_notebook))) {
650 if ((ev->state & GDK_CONTROL_MASK)) {
651 }
else if ((ev->state & GDK_SHIFT_MASK)) {
653 switch (ev->keyval) {
673 int scroll_x, scroll_y, xstep, ystep;
682 switch (ev->direction) {
686 case GDK_SCROLL_DOWN:
689 case GDK_SCROLL_RIGHT:
692 case GDK_SCROLL_LEFT:
725 GtkWidget *p, *b, *box;
726 GtkWidget *old_parent;
728 box = GTK_WIDGET(data);
729 old_parent = gtk_widget_get_parent(box);
730 p = g_object_get_data(G_OBJECT(w),
"parent");
731 b = g_object_get_data(G_OBJECT(w),
"toggle");
732 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b),
FALSE);
738 gtk_container_remove(GTK_CONTAINER(old_parent), box);
739 gtk_container_add(GTK_CONTAINER(p), box);
759 GtkWidget *box = GTK_WIDGET(data);
761 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b))) {
762 GtkWidget *old_parent;
764 GtkWidget *temp_hide;
766 old_parent = gtk_widget_get_parent(box);
767 w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
769 gtk_widget_set_name(w,
"Freeciv");
770 gtk_window_set_title(GTK_WINDOW(w),
_(
"Freeciv"));
771 gtk_window_set_position(GTK_WINDOW(w), GTK_WIN_POS_MOUSE);
773 g_signal_connect(w,
"key_press_event",
776 g_object_set_data(G_OBJECT(w),
"parent", gtk_widget_get_parent(box));
777 g_object_set_data(G_OBJECT(w),
"toggle", b);
779 temp_hide = g_object_get_data(G_OBJECT(box),
"hide-over-reparent");
780 if (temp_hide != NULL) {
781 gtk_widget_hide(temp_hide);
786 gtk_container_remove(GTK_CONTAINER(old_parent), box);
787 gtk_container_add(GTK_CONTAINER(w), box);
791 if (temp_hide != NULL) {
792 gtk_widget_show(temp_hide);
795 gtk_widget_destroy(gtk_widget_get_parent(box));
804 GtkWidget *hgrid = gtk_grid_new();
805 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 2);
815 GtkWidget *b, *fillbox;
816 static GtkCssProvider *detach_button_provider = NULL;
818 if (detach_button_provider == NULL) {
819 detach_button_provider = gtk_css_provider_new();
823 gtk_css_provider_load_from_data(detach_button_provider,
825 " padding: 0px 0px 0px 0px;\n"
831 b = gtk_toggle_button_new();
832 gtk_style_context_add_provider(gtk_widget_get_style_context(b),
833 GTK_STYLE_PROVIDER(detach_button_provider),
834 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
835 gtk_style_context_add_class(gtk_widget_get_style_context(b),
837 gtk_widget_set_tooltip_text(b,
_(
"Detach/Attach the pane."));
839 gtk_container_add(GTK_CONTAINER(tearbox), b);
842 fillbox = gtk_grid_new();
843 gtk_orientable_set_orientation(GTK_ORIENTABLE(fillbox),
844 GTK_ORIENTATION_VERTICAL);
846 gtk_container_add(GTK_CONTAINER(tearbox), fillbox);
886 gtk_widget_add_events(
unit_image, GDK_BUTTON_PRESS_MASK);
896 GINT_TO_POINTER(-1));
912 "button_press_event",
932 "button_press_event",
944 gdk_pixbuf_get_width(pix), -1);
945 g_object_unref(G_OBJECT(pix));
957 gtk_widget_show_all(table);
1026 while (gtk_events_pending()) {
1027 gtk_main_iteration();
1044 GdkEventButton *
event)
1046 if (
event->type != GDK_BUTTON_RELEASE) {
1050 if (!GTK_IS_NOTEBOOK(
widget)
1051 || -1 == gtk_notebook_get_current_page(GTK_NOTEBOOK(
widget))) {
1066 gtk_widget_override_background_color(GTK_WIDGET(
overview_canvas), state,
1068 gtk_widget_override_background_color(GTK_WIDGET(
map_canvas), state,
1082 _(
"Fixed length turns"));
1087 _(
"Turn Done"),
_(
"Shift+Return"));
1097 GtkWidget *page, *ebox, *hgrid, *hgrid2, *label;
1098 GtkWidget *frame, *table, *table2, *paned, *sw, *text;
1099 GtkWidget *button, *
view, *vgrid, *right_vbox = NULL;
1102 GtkWidget *dtach_lowbox = NULL;
1107 notebook = gtk_notebook_new();
1110 g_signal_connect(notebook,
"scroll_event",
1111 G_CALLBACK(gtk_true), NULL);
1114 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook),
FALSE);
1115 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook),
FALSE);
1116 vgrid = gtk_grid_new();
1117 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1118 GTK_ORIENTATION_VERTICAL);
1119 gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4);
1120 gtk_container_add(GTK_CONTAINER(
toplevel), vgrid);
1121 gtk_container_add(GTK_CONTAINER(vgrid), notebook);
1123 gtk_container_add(GTK_CONTAINER(vgrid),
statusbar);
1125 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1127 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1129 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1131 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1133 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
1143 page = gtk_scrolled_window_new(NULL, NULL);
1144 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(page),
1145 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1146 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(page),
1147 GTK_SHADOW_ETCHED_IN);
1148 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, NULL);
1151 gtk_orientable_set_orientation(GTK_ORIENTABLE(
top_vbox),
1152 GTK_ORIENTATION_VERTICAL);
1153 gtk_grid_set_row_spacing(GTK_GRID(
top_vbox), 5);
1154 hgrid = gtk_grid_new();
1159 right_vbox = gtk_grid_new();
1160 gtk_orientable_set_orientation(GTK_ORIENTABLE(right_vbox),
1161 GTK_ORIENTATION_VERTICAL);
1162 gtk_container_add(GTK_CONTAINER(hgrid), right_vbox);
1164 paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
1165 gtk_container_add(GTK_CONTAINER(page),
top_vbox);
1166 gtk_container_add(GTK_CONTAINER(
top_vbox), hgrid);
1167 gtk_container_add(GTK_CONTAINER(right_vbox), paned);
1176 paned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
1177 gtk_container_add(GTK_CONTAINER(page), paned);
1179 gtk_container_add(GTK_CONTAINER(
top_vbox), hgrid);
1187 vgrid = gtk_grid_new();
1188 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1189 GTK_ORIENTATION_VERTICAL);
1190 gtk_grid_set_column_spacing(GTK_GRID(vgrid), 3);
1193 gtk_grid_attach_next_to(GTK_GRID(hgrid), vgrid, right_vbox,
1194 GTK_POS_LEFT, 1, 1);
1200 gtk_container_add(GTK_CONTAINER(vgrid),
ahbox);
1206 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1219 |GDK_BUTTON_PRESS_MASK
1220 |GDK_POINTER_MOTION_MASK);
1238 gtk_container_add(GTK_CONTAINER(vgrid),
ahbox);
1242 gtk_widget_set_valign(
avbox, GTK_ALIGN_FILL);
1245 frame = gtk_frame_new(
"");
1246 gtk_container_add(GTK_CONTAINER(
avbox), frame);
1250 vgrid = gtk_grid_new();
1251 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1252 GTK_ORIENTATION_VERTICAL);
1253 gtk_container_add(GTK_CONTAINER(frame), vgrid);
1254 gtk_widget_set_hexpand(vgrid,
TRUE);
1256 ebox = gtk_event_box_new();
1257 gtk_widget_add_events(ebox, GDK_BUTTON_PRESS_MASK);
1258 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox),
FALSE);
1259 g_signal_connect(ebox,
"button_press_event",
1261 gtk_container_add(GTK_CONTAINER(vgrid), ebox);
1263 label = gtk_label_new(NULL);
1264 gtk_widget_set_halign(label, GTK_ALIGN_START);
1265 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1266 gtk_widget_set_margin_start(label, 2);
1267 gtk_widget_set_margin_end(label, 2);
1268 gtk_widget_set_margin_top(label, 2);
1269 gtk_widget_set_margin_bottom(label, 2);
1270 gtk_container_add(GTK_CONTAINER(ebox), label);
1274 table = gtk_grid_new();
1275 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
1276 gtk_grid_set_column_homogeneous(GTK_GRID(table),
TRUE);
1277 gtk_container_add(GTK_CONTAINER(
avbox), table);
1280 ebox = gtk_event_box_new();
1281 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox),
FALSE);
1282 gtk_grid_attach(GTK_GRID(table), ebox, 0, 0, 10, 1);
1285 table2 = gtk_grid_new();
1286 gtk_container_add(GTK_CONTAINER(ebox), table2);
1288 for (i = 0; i < 10; i++) {
1289 ebox = gtk_event_box_new();
1290 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox),
FALSE);
1291 gtk_widget_add_events(ebox, GDK_BUTTON_PRESS_MASK);
1293 gtk_grid_attach(GTK_GRID(table2), ebox, i, 0, 1, 1);
1295 g_signal_connect(ebox,
"button_press_event",
1300 gtk_container_add(GTK_CONTAINER(ebox),
econ_label[i]);
1332 for (i = 0; i < 4; i++) {
1335 ebox = gtk_event_box_new();
1336 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox),
FALSE);
1358 gtk_widget_set_halign(w, GTK_ALIGN_START);
1359 gtk_widget_set_valign(w, GTK_ALIGN_START);
1360 gtk_widget_set_margin_start(w, 0);
1361 gtk_widget_set_margin_end(w, 0);
1362 gtk_widget_set_margin_top(w, 0);
1363 gtk_widget_set_margin_bottom(w, 0);
1364 gtk_container_add(GTK_CONTAINER(ebox), w);
1365 gtk_grid_attach(GTK_GRID(table), ebox, i, 1, 1, 1);
1370 frame = gtk_frame_new(NULL);
1371 gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1);
1388 gtk_orientable_set_orientation(GTK_ORIENTABLE(
unit_info_box),
1389 GTK_ORIENTATION_VERTICAL);
1401 sw = gtk_scrolled_window_new(NULL, NULL);
1402 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1404 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1405 GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
1408 label = gtk_label_new(NULL);
1409 gtk_widget_set_hexpand(label,
TRUE);
1410 gtk_widget_set_halign(label, GTK_ALIGN_START);
1411 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1412 gtk_widget_set_margin_start(label, 2);
1413 gtk_widget_set_margin_end(label, 2);
1414 gtk_widget_set_margin_top(label, 2);
1415 gtk_widget_set_margin_bottom(label, 2);
1416 gtk_container_add(GTK_CONTAINER(sw), label);
1419 hgrid2 = gtk_grid_new();
1422 table = gtk_grid_new();
1423 g_object_set(table,
"margin", 5, NULL);
1424 gtk_container_add(GTK_CONTAINER(hgrid2), table);
1426 gtk_grid_set_row_spacing(GTK_GRID(table), 2);
1427 gtk_grid_set_column_spacing(GTK_GRID(table), 2);
1436 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(
top_notebook), GTK_POS_BOTTOM);
1443 right_vbox = gtk_grid_new();
1444 gtk_orientable_set_orientation(GTK_ORIENTABLE(right_vbox),
1445 GTK_ORIENTATION_VERTICAL);
1447 gtk_container_add(GTK_CONTAINER(right_vbox),
top_notebook);
1449 gtk_container_add(GTK_CONTAINER(hgrid), right_vbox);
1456 vgrid = gtk_grid_new();
1457 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1458 GTK_ORIENTATION_VERTICAL);
1459 gtk_container_add(GTK_CONTAINER(vgrid),
map_widget);
1464 label = gtk_label_new(
Q_(
"?noun:View"));
1465 gtk_notebook_append_page(GTK_NOTEBOOK(
top_notebook), vgrid, label);
1467 frame = gtk_frame_new(NULL);
1468 gtk_grid_attach(GTK_GRID(
map_widget), frame, 0, 0, 1, 1);
1473 gtk_widget_set_size_request(
map_canvas, 300, 300);
1487 gtk_widget_add_events(
map_canvas, GDK_EXPOSURE_MASK
1488 |GDK_BUTTON_PRESS_MASK
1489 |GDK_BUTTON_RELEASE_MASK
1491 |GDK_POINTER_MOTION_MASK
1494 gtk_container_add(GTK_CONTAINER(frame),
map_canvas);
1497 gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
1501 gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
1507 g_signal_connect(
map_canvas,
"configure_event",
1510 g_signal_connect(
map_canvas,
"motion_notify_event",
1513 g_signal_connect(
toplevel,
"enter_notify_event",
1516 g_signal_connect(
map_canvas,
"button_press_event",
1519 g_signal_connect(
map_canvas,
"button_release_event",
1525 g_signal_connect(
toplevel,
"key_press_event",
1528 g_signal_connect(
toplevel,
"key_release_event",
1540 gtk_paned_pack2(GTK_PANED(paned), dtach_lowbox,
FALSE,
TRUE);
1543 vgrid = gtk_grid_new();
1544 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1545 GTK_ORIENTATION_VERTICAL);
1549 gtk_container_add(GTK_CONTAINER(
avbox), vgrid);
1552 hpaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
1554 hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
1556 gtk_container_add(GTK_CONTAINER(vgrid), hpaned);
1557 g_object_set(hpaned,
"margin", 4, NULL);
1567 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(
right_notebook), GTK_POS_TOP);
1576 vgrid = gtk_grid_new();
1577 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1578 GTK_ORIENTATION_VERTICAL);
1580 sw = gtk_scrolled_window_new(NULL, NULL);
1581 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1582 GTK_SHADOW_ETCHED_IN);
1583 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
1585 gtk_container_add(GTK_CONTAINER(vgrid), sw);
1587 label = gtk_label_new(
_(
"Chat"));
1588 gtk_notebook_append_page(GTK_NOTEBOOK(
bottom_notebook), vgrid, label);
1591 gtk_widget_set_hexpand(text,
TRUE);
1592 gtk_widget_set_vexpand(text,
TRUE);
1594 gtk_text_view_set_editable(GTK_TEXT_VIEW(text),
FALSE);
1595 gtk_container_add(GTK_CONTAINER(sw), text);
1596 g_signal_connect(text,
"size-allocate",
1599 gtk_widget_set_name(text,
"chatline");
1601 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
1602 gtk_widget_realize(text);
1603 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);
1606 if (dtach_lowbox != NULL) {
1607 g_object_set_data(G_OBJECT(dtach_lowbox),
"hide-over-reparent",
main_message_area);
1614 gtk_container_add(GTK_CONTAINER(vgrid),
view);
1615 g_object_set(
view,
"margin", 3, NULL);
1617 button = gtk_check_button_new_with_label(
_(
"Allies Only"));
1618 gtk_widget_set_focus_on_click(button,
FALSE);
1619 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
1621 g_signal_connect(button,
"toggled",
1626 button = gtk_button_new_with_label(
_(
"Clear links"));
1627 g_signal_connect(button,
"clicked",
1633 gtk_widget_show_all(gtk_bin_get_child(GTK_BIN(
toplevel)));
1639 gtk_notebook_set_current_page(GTK_NOTEBOOK(
top_notebook), 0);
1659 case G_LOG_LEVEL_DEBUG:
1662 case G_LOG_LEVEL_WARNING:
1669 if (log_domain != NULL) {
1680 const GLogField *fields,
1685 gchar *out = g_log_writer_format_fields(
log_level, fields, n_fields,
FALSE);
1689 return G_LOG_WRITER_HANDLED;
1697 g_log_set_handler(domain,
1698 G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING
1700 | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
1743 log_normal(
_(
"Migrating options from gtk2 to gtk3 client"));
1745#define MIGRATE_OPTION(opt) gui_options.gui_gtk3_##opt = gui_options.gui_gtk2_##opt;
1746#define MIGRATE_STR_OPTION(opt) \
1747 strncpy(gui_options.gui_gtk3_##opt, gui_options.gui_gtk2_##opt, \
1748 sizeof(gui_options.gui_gtk3_##opt));
1787#undef MIGRATE_OPTION
1788#undef MIGRATE_STR_OPTION
1798 log_normal(
_(
"Migrating options from gtk3 to gtk3.22 client"));
1800#define MIGRATE_OPTION(opt) GUI_GTK_OPTION(opt) = gui_options.gui_gtk3_##opt;
1801#define MIGRATE_STR_OPTION(opt) \
1802 strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_##opt, \
1803 sizeof(GUI_GTK_OPTION(opt)));
1809 log_normal(
_(
"Migrating gtk3-client options from freeciv-2.5 options."));
1846#undef MIGRATE_OPTION
1847#undef MIGRATE_STR_OPTION
1857 PangoFontDescription *toplevel_font_name;
1861 char window_name[1024];
1865 gtk_disable_setlocale();
1868 if (!gtk_init_check(&argc, &argv)) {
1869 log_fatal(
_(
"Failed to open graphical mode."));
1877 toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1878 gtk_window_set_position(GTK_WINDOW(
toplevel), GTK_WIN_POS_CENTER);
1882 g_signal_connect(
toplevel,
"key_press_event",
1885 gtk_window_set_role(GTK_WINDOW(
toplevel),
"toplevel");
1887 gtk_widget_set_name(
toplevel,
"Freeciv");
1913 gtk_window_fullscreen(GTK_WINDOW(
toplevel));
1917 gtk_window_set_title(GTK_WINDOW(
toplevel), window_name);
1919 g_signal_connect(
toplevel,
"delete_event",
1923 sig = g_signal_lookup(
"focus", GTK_TYPE_WIDGET);
1924 g_signal_handlers_disconnect_matched(
toplevel, G_SIGNAL_MATCH_ID, sig,
1935 toplevel_font_name = pango_context_get_font_description(
1936 gtk_widget_get_pango_context(
toplevel));
1940 log_error(
"city_names_style should have been set by options.");
1944 log_error(
"city_productions_style should have been set by options.");
1948 log_error(
"reqtree_text_style should have been set by options.");
1955#ifndef FREECIV_MSWINDOWS
1960 gtk_window_set_icon(GTK_WINDOW(
toplevel), pixbuf);
1961 g_object_unref(pixbuf);
2015 return EXIT_SUCCESS;
2050 gdk_display_beep(gdk_display_get_default());
2080 gtk_image_clear(GTK_IMAGE(w));
2091 static bool showing =
FALSE;
2097 if (onoff && !showing) {
2100 }
else if (!onoff && showing) {
2124 int i = GPOINTER_TO_INT(data);
2171 gdk_seat_ungrab(gdk_device_get_seat(ev->device));
2172 gtk_widget_destroy(w);
2182 if (ev->button == 1) {
2185 p = gtk_window_new(GTK_WINDOW_POPUP);
2186 gtk_container_set_border_width(GTK_CONTAINER(p), 4);
2187 gtk_window_set_transient_for(GTK_WINDOW(p), GTK_WINDOW(
toplevel));
2188 gtk_window_set_position(GTK_WINDOW(p), GTK_WIN_POS_MOUSE);
2190 gtk_widget_new(GTK_TYPE_LABEL,
"GtkWidget::parent", p,
2192 "GtkWidget::visible",
TRUE,
2196 gdk_seat_grab(gdk_device_get_seat(ev->device), gtk_widget_get_window(p),
2197 GDK_SEAT_CAPABILITY_ALL_POINTING,
2198 TRUE, NULL, (GdkEvent *)ev, NULL, NULL);
2201 g_signal_connect_after(p,
"button_release_event",
2232 bool socket_writable)
2234 static bool previous_state =
FALSE;
2238 if (previous_state == socket_writable)
2241 log_debug(
"set_wait_for_writable_socket(%d)", socket_writable);
2245 G_IO_IN | (socket_writable ? G_IO_OUT : 0) | G_IO_ERR,
2249 previous_state = socket_writable;
2258#ifdef FREECIV_MSWINDOWS
2259 srv_channel = g_io_channel_win32_new_socket(sock);
2287 gtk_widget_destroy(dialog);
2288 if (response == GTK_RESPONSE_YES) {
2314 static GtkWidget *dialog;
2317 dialog = gtk_message_dialog_new(NULL,
2319 GTK_MESSAGE_WARNING,
2321 _(
"Are you sure you want to quit?"));
2324 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
2326 g_signal_connect(dialog,
"response",
2328 g_signal_connect(dialog,
"destroy",
2329 G_CALLBACK(gtk_widget_destroyed), &dialog);
2332 gtk_window_present(GTK_WINDOW(dialog));
2389 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2399 gtk_window_fullscreen(GTK_WINDOW(
toplevel));
2401 gtk_window_unfullscreen(GTK_WINDOW(
toplevel));
2447#define option_var_set_callback(var, callback) \
2448 if ((poption = optset_option_by_name(client_optset, GUI_GTK_OPTION_STR(var)))) { \
2449 option_set_changed_callback(poption, callback); \
2451 log_error("Didn't find option %s!", GUI_GTK_OPTION_STR(var)); \
2465#undef option_var_set_callback
2482 gtk_widget_hide(button);
2484 gtk_widget_show(button);
2485 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2496 GUI_GTK_OPTION(allied_chat_only) = gtk_toggle_button_get_active(button);
2504 cat_snprintf(outbuf, outlen,
_(
"\nBuilt against gtk+ %d.%d.%d, using %d.%d.%d"
2505 "\nBuilt against glib %d.%d.%d, using %d.%d.%d"),
2506 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
2507 gtk_get_major_version(), gtk_get_minor_version(), gtk_get_micro_version(),
2508 GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
2509 glib_major_version, glib_minor_version, glib_micro_version);
2518 GdkDisplay *display;
2519 GdkMonitor *monitor;
2521 display = gdk_display_get_default();
2526 monitor = gdk_display_get_primary_monitor(display);
2531 gdk_monitor_get_geometry(monitor, rect_p);
2590 if (scr_height > 0) {
2593 if (scr_height <= 480) {
2596 log_verbose(
"Changing default to fullscreen due to very small screen");
2599 if (scr_height < 1024) {
2601 log_verbose(
"Defaulting to small widget layout due to small screen");
2603 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 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
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)
static bool monitor_size(GdkRectangle *rect_p)
static void set_g_log_callbacks(void)
static void g_log_to_freelog_cb(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
static void set_g_log_callback_domain(const char *domain)
static void migrate_options_from_gtk3(void)
static GLogWriterOutput g_log_writer_to_freelog_cb(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data)
void dlg_tab_provider_prepare(void)
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_base(level, 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)
bool gui_gtk3_migrated_from_2_5
bool gui_gtk3_migrated_from_gtk2
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)