151 enum client_pages page = PAGE_MAIN;
166 static PangoLayout *
layout;
167 PangoFontDescription* desc;
169 static bool left =
FALSE;
170 GtkAllocation allocation;
173 cairo_set_source_surface(cr, intro->
surface, 0, 0);
180 layout = pango_layout_new(gtk_widget_create_pango_context(w));
181 desc = pango_font_description_from_string(
"Sans Bold 10");
182 pango_layout_set_font_description(
layout, desc);
183 pango_font_description_free(desc);
187 if (rev_ver == NULL) {
189 fc_snprintf(msgbuf,
sizeof(msgbuf),
_(
"%s%s, %s client"),
195 fc_snprintf(msgbuf,
sizeof(msgbuf),
_(
"%s%s\ncommit: %s\n%s client"),
199 pango_layout_set_text(
layout, msgbuf, -1);
203 gtk_widget_get_allocation(w, &allocation);
205 cairo_set_source_rgb(cr, 0, 0, 0);
206 cairo_move_to(cr, left ? 4 : allocation.width -
width - 3,
207 allocation.height -
height - 3);
208 pango_cairo_show_layout(cr,
layout);
210 cairo_set_source_rgb(cr, 1, 1, 1);
211 cairo_move_to(cr, left ? 3 : allocation.width -
width - 4,
212 allocation.height -
height - 4);
213 pango_cairo_show_layout(cr,
layout);
233 GtkWidget *
widget, *vbox, *frame, *darea, *button, *table;
235 struct sprite *intro_in, *intro;
240 size = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
242 vbox = gtk_grid_new();
243 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
244 GTK_ORIENTATION_VERTICAL);
247 frame = gtk_frame_new(NULL);
248 g_object_set(frame,
"margin", 18, NULL);
249 gtk_widget_set_halign(frame, GTK_ALIGN_CENTER);
250 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
251 gtk_container_add(GTK_CONTAINER(vbox), frame);
263#if IS_BETA_VERSION || IS_DEVEL_VERSION
268 if (sh -
height < space_needed) {
271 if (sh < (space_needed + 0.2 *
height)) {
275 scale = (double)(sh - space_needed) /
height;
284 darea = gtk_drawing_area_new();
286 g_signal_connect(darea,
"draw",
288 g_signal_connect(
widget,
"destroy",
290 gtk_container_add(GTK_CONTAINER(frame), darea);
292#if IS_BETA_VERSION || IS_DEVEL_VERSION
297 gtk_widget_set_name(label,
"beta_label");
298 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
299 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
300 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
301 gtk_container_add(GTK_CONTAINER(vbox), label);
305 table = gtk_grid_new();
306 g_object_set(table,
"margin", 12, NULL);
307 gtk_widget_set_hexpand(table,
TRUE);
308 gtk_widget_set_vexpand(table,
TRUE);
309 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
310 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
312 gtk_grid_set_row_spacing(GTK_GRID(table), 8);
313 gtk_grid_set_column_spacing(GTK_GRID(table), 18);
314 gtk_container_add(GTK_CONTAINER(vbox), table);
316 button = gtk_button_new_with_mnemonic(
_(
"Start _New Game"));
317 gtk_size_group_add_widget(
size, button);
318 gtk_grid_attach(GTK_GRID(table), button, 0, 0, 1, 1);
319 gtk_widget_set_tooltip_text(button,
320 _(
"Launches local server, and connects to it for a single-player game."));
321 g_signal_connect(button,
"clicked",
324 button = gtk_button_new_with_mnemonic(
_(
"Start _Scenario Game"));
325 gtk_size_group_add_widget(
size, button);
326 gtk_grid_attach(GTK_GRID(table), button, 0, 1, 1, 1);
327 gtk_widget_set_tooltip_text(button,
328 _(
"Loads one of the scenarios for a single-player game. "
329 "Tutorial is one of the scenarios."));
330 g_signal_connect(button,
"clicked",
333 button = gtk_button_new_with_mnemonic(
_(
"_Load Saved Game"));
334 gtk_size_group_add_widget(
size, button);
335 gtk_grid_attach(GTK_GRID(table), button, 0, 2, 1, 1);
336 gtk_widget_set_tooltip_text(button,
337 _(
"Continues previously saved single-player game."));
338 g_signal_connect(button,
"clicked",
341 button = gtk_button_new_with_mnemonic(
_(
"C_onnect to Network Game"));
342 gtk_size_group_add_widget(
size, button);
343 gtk_grid_attach(GTK_GRID(table), button, 1, 0, 1, 1);
344 gtk_widget_set_tooltip_text(button,
345 _(
"Connects to outside server. "
346 "Sometimes you want to launch a separate server even for local games."));
347 g_signal_connect(button,
"clicked",
350 button = gtk_button_new_with_mnemonic(
_(
"Client Settings"));
351 gtk_size_group_add_widget(
size, button);
352 gtk_grid_attach(GTK_GRID(table), button, 1, 1, 1, 1);
353 gtk_widget_set_tooltip_text(button,
354 _(
"Adjusting client-side options."));
357 button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
358 gtk_size_group_add_widget(
size, button);
359 g_object_unref(
size);
360 gtk_grid_attach(GTK_GRID(table), button, 1, 2, 1, 1);
361 gtk_widget_set_tooltip_text(button,
362 _(
"Gives you a break from playing freeciv."));
363 g_signal_connect(button,
"clicked",
373typedef struct fileinfo_list * (*save_dialog_files_fn_t) (void);
410 const struct fileinfo_list *files)
414 gtk_list_store_clear(store);
416 gtk_list_store_append(store, &iter);
417 gtk_list_store_set(store, &iter,
429 struct fileinfo_list *files;
434 files = pdialog->
files();
436 (gtk_tree_view_get_model(pdialog->
tree_view)),
438 fileinfo_list_destroy(files);
445 gint response, gpointer data)
447 if (response == GTK_RESPONSE_OK) {
449 gchar *filename = g_filename_to_utf8(gtk_file_chooser_get_filename
450 (GTK_FILE_CHOOSER(
widget)),
451 -1, NULL, NULL, NULL);
453 if (NULL != filename) {
458 gtk_widget_destroy(
widget);
465 GtkFileChooserAction
action,
468 GtkWidget *filechoose;
472 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
473 action == GTK_FILE_CHOOSER_ACTION_SAVE ? GTK_STOCK_SAVE : GTK_STOCK_OPEN,
474 GTK_RESPONSE_OK, NULL);
476 gtk_window_set_position(GTK_WINDOW(filechoose), GTK_WIN_POS_MOUSE);
478 g_signal_connect(filechoose,
"response",
482 gtk_window_present(GTK_WINDOW(filechoose));
496 GTK_FILE_CHOOSER_ACTION_SAVE,
501 GtkTreeSelection *selection;
504 const gchar *full_path;
506 selection = gtk_tree_view_get_selection(pdialog->
tree_view);
507 if (!gtk_tree_selection_get_selected(selection, &model, &iter)) {
518 const char *text = gtk_entry_get_text(pdialog->
entry);
519 gchar *filename = g_filename_from_utf8(text, -1, NULL, NULL, NULL);
521 if (NULL == filename) {
524 pdialog->
action(filename);
531 gtk_widget_destroy(GTK_WIDGET(pdialog->
shell));
539 GtkTreeViewColumn *column,
562 const gchar *filename;
564 if (!gtk_tree_selection_get_selected(selection, &model, &iter)) {
571 gtk_entry_set_text(pdialog->
entry, filename);
578 const char *savefilelabel,
585 GtkCellRenderer *rend;
586 GtkTreeSelection *selection;
598 shell = gtk_dialog_new_with_buttons(
title, NULL, 0,
601 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
604 g_object_set_data_full(G_OBJECT(
shell),
"save_dialog", pdialog,
605 (GDestroyNotify) free);
606 gtk_dialog_set_default_response(GTK_DIALOG(
shell), GTK_RESPONSE_CANCEL);
609 g_signal_connect(
shell,
"response",
612 vbox = GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(
shell)));
616 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
619 g_object_unref(store);
620 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(
view),
FALSE);
621 g_signal_connect(
view,
"row-activated",
625 sbox = gtk_grid_new();
626 gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox),
627 GTK_ORIENTATION_VERTICAL);
628 gtk_grid_set_row_spacing(GTK_GRID(sbox), 2);
629 gtk_container_add(vbox, sbox);
631 label = g_object_new(GTK_TYPE_LABEL,
632 "use-underline",
TRUE,
633 "mnemonic-widget",
view,
638 gtk_container_add(GTK_CONTAINER(sbox), label);
640 sw = gtk_scrolled_window_new(NULL, NULL);
641 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(sw), 300);
642 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sw), 300);
643 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
644 GTK_SHADOW_ETCHED_IN);
645 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
646 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
647 gtk_container_add(GTK_CONTAINER(sw),
view);
648 gtk_container_add(GTK_CONTAINER(sbox), sw);
650 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
view));
651 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
652 g_signal_connect(selection,
"changed",
655 rend = gtk_cell_renderer_text_new();
656 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(
view),
657 -1, NULL, rend,
"text",
661 entry = gtk_entry_new();
663 g_signal_connect(
entry,
"activate",
667 sbox = gtk_grid_new();
668 g_object_set(sbox,
"margin", 12, NULL);
669 gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox),
670 GTK_ORIENTATION_VERTICAL);
671 gtk_grid_set_row_spacing(GTK_GRID(sbox), 2);
673 label = g_object_new(GTK_TYPE_LABEL,
674 "use-underline",
TRUE,
675 "mnemonic-widget",
entry,
676 "label", savefilelabel,
680 gtk_container_add(GTK_CONTAINER(sbox), label);
682 gtk_container_add(GTK_CONTAINER(sbox),
entry);
683 gtk_container_add(vbox, sbox);
686 gtk_window_set_focus(GTK_WINDOW(
shell),
entry);
687 gtk_widget_show_all(GTK_WIDGET(vbox));
706 GtkTreeSelection *sel = NULL;
710 const gchar *host, *portstr;
728 view = gtk_tree_selection_get_tree_view(sel);
729 store = GTK_LIST_STORE(gtk_tree_view_get_model(
view));
730 gtk_list_store_clear(store);
738 port = atoi(portstr);
743 if (pserver->humans >= 0) {
744 fc_snprintf(buf,
sizeof(buf),
"%d", pserver->humans);
748 gtk_list_store_append(store, &it);
749 gtk_list_store_set(store, &it,
753 3,
_(pserver->state),
754 4, pserver->nplayers,
758 if (strcmp(host, pserver->host) == 0 && port == pserver->port) {
759 gtk_tree_selection_select_iter(sel, &it);
815 scan_data->
timer = 0;
869 gtk_label_set_text(GTK_LABEL(
statusbar), txt);
887 gtk_label_set_text(GTK_LABEL(
statusbar),
"");
898 gtk_label_set_text(GTK_LABEL(
statusbar), text);
914 gtk_widget_set_margin_left(
statusbar, 2);
915 gtk_widget_set_margin_right(
statusbar, 2);
917 gtk_widget_set_margin_bottom(
statusbar, 2);
1054 errbuf,
sizeof(errbuf)) != -1) {
1099 GtkTreeViewColumn *arg2,
1111 GtkListStore *store;
1118 gtk_list_store_clear(store);
1119 if (!pserver || !pserver->
players) {
1124 for (i = 0; i <
n; i++) {
1125 gtk_list_store_append(store, &iter);
1126 gtk_list_store_set(store, &iter,
1140 GtkTreeModel *model;
1145 const struct server *pserver = NULL;
1147 if (!gtk_tree_selection_get_selected(select, &model, &it)) {
1156 path = gtk_tree_model_get_path(model, &it);
1162 gint
pos = gtk_tree_path_get_indices(path)[0];
1163 pserver = server_list_get(srvrs->
servers,
pos);
1169 gtk_tree_path_free(path);
1173 gtk_tree_model_get(model, &it, 0, &host, 1, &port, -1);
1176 fc_snprintf(portstr,
sizeof(portstr),
"%d", port);
1201 GtkWidget *box, *sbox, *bbox, *hbox, *notebook;
1202 GtkWidget *button, *label, *
view, *sw, *table;
1203 GtkTreeSelection *selection;
1204 GtkListStore *store;
1206 box = gtk_grid_new();
1207 gtk_orientable_set_orientation(GTK_ORIENTABLE(box),
1208 GTK_ORIENTATION_VERTICAL);
1209 gtk_container_set_border_width(GTK_CONTAINER(box), 4);
1211 notebook = gtk_notebook_new();
1212 gtk_container_add(GTK_CONTAINER(box), notebook);
1215 lan_store = gtk_list_store_new(7, G_TYPE_STRING,
1223 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
lan_store));
1224 gtk_widget_set_hexpand(
view,
TRUE);
1225 gtk_widget_set_vexpand(
view,
TRUE);
1227 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(
view));
1229 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
view));
1231 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
1232 g_signal_connect(
view,
"focus",
1233 G_CALLBACK(gtk_true), NULL);
1234 g_signal_connect(
view,
"row-activated",
1236 g_signal_connect(selection,
"changed",
1247 label = gtk_label_new_with_mnemonic(
_(
"Local _Area Network"));
1249 sw = gtk_scrolled_window_new(NULL, NULL);
1250 gtk_container_set_border_width(GTK_CONTAINER(sw), 4);
1251 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1252 GTK_SHADOW_ETCHED_IN);
1253 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1254 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1255 gtk_container_add(GTK_CONTAINER(sw),
view);
1256 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sw, label);
1260 meta_store = gtk_list_store_new(7, G_TYPE_STRING,
1269 gtk_widget_set_hexpand(
view,
TRUE);
1270 gtk_widget_set_vexpand(
view,
TRUE);
1272 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(
view));
1274 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
view));
1276 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
1277 g_signal_connect(
view,
"focus",
1278 G_CALLBACK(gtk_true), NULL);
1279 g_signal_connect(
view,
"row-activated",
1281 g_signal_connect(selection,
"changed",
1292 label = gtk_label_new_with_mnemonic(
_(
"Internet _Metaserver"));
1294 sw = gtk_scrolled_window_new(NULL, NULL);
1295 gtk_container_set_border_width(GTK_CONTAINER(sw), 4);
1296 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1297 GTK_SHADOW_ETCHED_IN);
1298 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1299 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1300 gtk_container_add(GTK_CONTAINER(sw),
view);
1302 gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), sw, label);
1304 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sw, label);
1308 sbox = gtk_grid_new();
1309 gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox),
1310 GTK_ORIENTATION_VERTICAL);
1311 gtk_container_add(GTK_CONTAINER(box), sbox);
1313 hbox = gtk_grid_new();
1314 gtk_grid_set_column_spacing(GTK_GRID(hbox), 12);
1315 g_object_set(hbox,
"margin", 8, NULL);
1316 gtk_container_add(GTK_CONTAINER(sbox), hbox);
1318 table = gtk_grid_new();
1319 gtk_grid_set_row_spacing(GTK_GRID(table), 2);
1320 gtk_grid_set_column_spacing(GTK_GRID(table), 12);
1321 gtk_container_add(GTK_CONTAINER(hbox), table);
1326 gtk_grid_attach(GTK_GRID(table),
network_host, 1, 0, 1, 1);
1328 label = g_object_new(GTK_TYPE_LABEL,
1329 "use-underline",
TRUE,
1331 "label",
_(
"_Host:"),
1336 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
1341 gtk_grid_attach(GTK_GRID(table),
network_port, 1, 1, 1, 1);
1343 label = g_object_new(GTK_TYPE_LABEL,
1344 "use-underline",
TRUE,
1346 "label",
_(
"_Port:"),
1351 gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
1357 gtk_grid_attach(GTK_GRID(table),
network_login, 1, 3, 1, 1);
1359 label = g_object_new(GTK_TYPE_LABEL,
1360 "use-underline",
TRUE,
1362 "label",
_(
"_Login:"),
1366 gtk_widget_set_margin_top(label, 10);
1368 gtk_grid_attach(GTK_GRID(table), label, 0, 3, 1, 1);
1376 label = g_object_new(GTK_TYPE_LABEL,
1377 "use-underline",
TRUE,
1379 "label",
_(
"Pass_word:"),
1384 gtk_grid_attach(GTK_GRID(table), label, 0, 4, 1, 1);
1392 label = g_object_new(GTK_TYPE_LABEL,
1393 "use-underline",
TRUE,
1395 "label",
_(
"Conf_irm Password:"),
1400 gtk_grid_attach(GTK_GRID(table), label, 0, 5, 1, 1);
1403 store = gtk_list_store_new(4, G_TYPE_STRING,
1409 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1410 gtk_widget_set_hexpand(
view,
TRUE);
1417 sw = gtk_scrolled_window_new(NULL, NULL);
1418 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1419 GTK_SHADOW_ETCHED_IN);
1420 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1421 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1422 gtk_container_add(GTK_CONTAINER(sw),
view);
1423 gtk_container_add(GTK_CONTAINER(hbox), sw);
1426 bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
1427 g_object_set(bbox,
"margin", 2, NULL);
1428 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
1429 gtk_box_set_spacing(GTK_BOX(bbox), 12);
1430 gtk_container_add(GTK_CONTAINER(sbox), bbox);
1432 button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
1433 gtk_container_add(GTK_CONTAINER(bbox), button);
1434 gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), button,
TRUE);
1435 g_signal_connect(button,
"clicked",
1438 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
1439 gtk_container_add(GTK_CONTAINER(bbox), button);
1440 g_signal_connect(button,
"clicked",
1443 button = gtk_button_new_with_mnemonic(
_(
"C_onnect"));
1444 gtk_container_add(GTK_CONTAINER(bbox), button);
1445 g_signal_connect(button,
"clicked",
1540 g_object_set_data(
object,
"player_id",
1541 GINT_TO_POINTER(NULL != pplayer
1544 g_object_set_data(
object,
"connection_id",
1545 GINT_TO_POINTER(NULL != pconn ? pconn->
id : 0));
1558 if (NULL != ppplayer) {
1559 id = GPOINTER_TO_INT(g_object_get_data(
object,
"player_id"));
1561 if (NULL != *ppplayer) {
1565 if (NULL != ppconn) {
1566 id = GPOINTER_TO_INT(g_object_get_data(
object,
"connection_id"));
1568 if (NULL != *ppconn) {
1589 enum ai_level *levels = (
enum ai_level *)data;
1593 i = gtk_combo_box_get_active(GTK_COMBO_BOX(w));
1596 enum ai_level
level = levels[i];
1627 const char *
name = NULL;
1644 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w)));
1729 (
char *) g_object_get_data(G_OBJECT(data),
"command"),
1756 (
char *) g_object_get_data(G_OBJECT(data),
"command"),
1767 char buf[4096] =
"";
1783 popup = gtk_message_dialog_new(NULL, 0,
1784 GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
1786 gtk_window_set_title(GTK_WINDOW(popup),
_(
"Player/conn info"));
1788 g_signal_connect(popup,
"response", G_CALLBACK(gtk_widget_destroy), NULL);
1789 gtk_window_present(GTK_WINDOW(popup));
1816 menu = gtk_menu_new();
1819 buf = g_strdup_printf(
_(
"%s info"),
1821 item = gtk_menu_item_new_with_label(buf);
1823 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1824 g_signal_connect_swapped(
item,
"activate",
1827 if (NULL != pplayer) {
1828 item = gtk_menu_item_new_with_label(
_(
"Toggle player ready"));
1830 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1831 g_signal_connect_swapped(
item,
"activate",
1834 item = gtk_menu_item_new_with_label(
_(
"Pick nation"));
1835 gtk_widget_set_sensitive(
item,
1838 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1839 g_signal_connect_swapped(
item,
"activate",
1842 item = gtk_menu_item_new_with_label(
_(
"Observe this player"));
1843 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1844 g_object_set_data_full(G_OBJECT(
item),
"command", g_strdup(
"observe"),
1845 (GDestroyNotify) g_free);
1846 g_signal_connect_swapped(
item,
"activate",
1849 item = gtk_menu_item_new_with_label(
_(
"Take this player"));
1850 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1851 g_signal_connect_swapped(
item,
"activate",
1857 item = gtk_separator_menu_item_new();
1858 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1861 item = gtk_menu_item_new_with_label(
_(
"Cut connection"));
1862 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1863 g_object_set_data_full(G_OBJECT(
item),
"command", g_strdup(
"cut"),
1864 (GDestroyNotify) g_free);
1865 g_signal_connect_swapped(
item,
"activate",
1872 item = gtk_menu_item_new_with_label(
_(
"Aitoggle player"));
1873 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1874 g_object_set_data_full(G_OBJECT(
item),
"command", g_strdup(
"aitoggle"),
1875 (GDestroyNotify) g_free);
1876 g_signal_connect_swapped(
item,
"activate",
1880 item = gtk_menu_item_new_with_label(
_(
"Remove player"));
1881 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1882 g_object_set_data_full(G_OBJECT(
item),
"command", g_strdup(
"remove"),
1883 (GDestroyNotify) g_free);
1884 g_signal_connect_swapped(
item,
"activate",
1891 enum cmdlevel
level;
1896 buf = g_strdup_printf(
_(
"Give %s access"),
1897 cmdlevel_name(
level));
1898 item = gtk_menu_item_new_with_label(buf);
1900 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1901 g_object_set_data_full(G_OBJECT(
item),
"command",
1902 g_strdup_printf(
"cmdlevel %s",
1903 cmdlevel_name(
level)),
1904 (GDestroyNotify) g_free);
1905 g_signal_connect_swapped(
item,
"activate",
1912 && NULL != pplayer &&
is_ai(pplayer)) {
1913 enum ai_level
level;
1915 item = gtk_separator_menu_item_new();
1916 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1920 const char *level_name = ai_level_translated_name(
level);
1923 item = gtk_menu_item_new_with_label(level_name);
1924 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1925 g_object_set_data_full(G_OBJECT(
item),
"command",
1926 g_strdup(level_cmd), (GDestroyNotify) g_free);
1927 g_signal_connect_swapped(
item,
"activate",
1934 const int count = pplayer->
team
1936 bool need_empty_team = (count != 1);
1938 item = gtk_separator_menu_item_new();
1939 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1944 if (!need_empty_team) {
1947 need_empty_team =
FALSE;
1951 buf = g_strdup_printf(
_(
"Put on %s"),
1953 item = gtk_menu_item_new_with_label(buf);
1955 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
1962 gtk_widget_show_all(menu);
1973 GtkTreeSelection *selection =
1975 GtkTreePath *path = data;
1977 gtk_tree_selection_unselect_path(selection, path);
1978 gtk_tree_path_free(path);
1987 GdkEventButton *
event,
1990 GtkTreeView *tree = GTK_TREE_VIEW(
widget);
1991 GtkTreePath *path = NULL;
1992 GtkTreeSelection *selection = gtk_tree_view_get_selection(tree);
1993 gboolean ret =
FALSE;
1995 if ((1 !=
event->button && 3 !=
event->button)
1996 || GDK_BUTTON_PRESS !=
event->type
1997 || !gtk_tree_view_get_path_at_pos(tree,
1999 &path, NULL, NULL, NULL)) {
2003 if (1 ==
event->button) {
2004 if (gtk_tree_selection_path_is_selected(selection, path)) {
2009 }
else if (3 ==
event->button) {
2010 GtkTreeModel *model = gtk_tree_view_get_model(tree);
2013 int player_no, conn_id;
2017 if (!gtk_tree_selection_path_is_selected(selection, path)) {
2018 gtk_tree_selection_select_path(selection, path);
2020 gtk_tree_model_get_iter(model, &iter, path);
2029 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
2034 gtk_tree_path_free(path);
2046 GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(tree_view));
2048 gtk_tree_store_set(store, iter,
2061 GtkTreeModel *model;
2062 GtkTreeSelection *selection =
2065 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
2068 if (NULL != ppplayer) {
2072 if (NULL != ppconn) {
2080 if (NULL != ppplayer) {
2083 if (NULL != ppconn) {
2094 GtkTreeModel *model;
2095 GtkTreeIter parent, child, *iter = NULL;
2096 GtkTreeSelection *selection;
2098 const int search_id = pconn->
id;
2109 valid = gtk_tree_model_get_iter_first(model, &parent);
2110 while (valid && NULL == iter) {
2112 if (search_id ==
id) {
2118 valid = gtk_tree_model_iter_children(model, &child, &parent);
2119 while (valid && NULL == iter) {
2121 if (search_id ==
id) {
2125 valid = gtk_tree_model_iter_next(model, &child);
2128 valid = gtk_tree_model_iter_next(model, &parent);
2133 gtk_tree_selection_select_iter(selection, iter);
2135 log_error(
"%s(): connection %s not found.",
2159 struct player *selected_plr;
2162 if (row_selected && NULL != selected_plr) {
2179 struct player *selected_plr;
2182 if (row_selected && NULL != selected_plr) {
2201 struct player *selected_plr;
2209 text =
_(
"Not _ready");
2211 int num_unready = 0;
2214 if (
is_human(pplayer) && !pplayer->is_ready) {
2219 if (num_unready > 1) {
2247 if (row_selected && NULL != selected_plr) {
2252 text =
_(
"Pick _Nation");
2255 text =
_(
"_Take a Player");
2262 if (row_selected && NULL != selected_plr) {
2268 text =
_(
"_Observe");
2271 text =
_(
"Do not _observe");
2285 const struct player *pplayer)
2290 if (NULL != start) {
2292 if (!gtk_tree_model_iter_next(model, iter)) {
2295 }
else if (!gtk_tree_model_get_iter_first(model, iter)) {
2301 if (
id == search_id) {
2304 }
while (gtk_tree_model_iter_next(model, iter));
2314 GtkTreeIter *parent, GtkTreeIter *start,
2317 const int search_id = pconn->
id;
2320 if (NULL != start) {
2322 if (!gtk_tree_model_iter_next(model, iter)) {
2325 }
else if (!gtk_tree_model_iter_children(model, iter, parent)) {
2331 if (
id == search_id) {
2334 }
while (gtk_tree_model_iter_next(model, iter));
2348 GtkTreeModel *model = GTK_TREE_MODEL(store);
2350 GtkTreeIter child, prev_child, *pprev_child;
2351 GtkTreeIter parent, prev_parent, *pprev_parent = NULL;
2352 GdkPixbuf *flag, *
color;
2354 struct player *pselected_player;
2357 const char *nation, *plr_name, *
team;
2369 if (
level == new_level) {
2376 if (
level == AI_LEVEL_COUNT) {
2390 flag = pplayer->nation ?
get_flag(pplayer->nation) : NULL;
2394 if (pconn->playing == pplayer && !pconn->observer) {
2395 conn_id = pconn->id;
2401 if (
is_ai(pplayer) && !pplayer->was_created
2402 && !pplayer->is_connected) {
2405 ai_level_translated_name(pplayer->ai_common.skill_level));
2413 is_ready = !
is_human(pplayer) ?
TRUE : pplayer->is_ready;
2416 nation =
_(
"Random");
2417 if (pplayer->was_created) {
2430 gtk_tree_store_move_after(store, &parent, pprev_parent);
2432 gtk_tree_store_insert_after(store, &parent, NULL, pprev_parent);
2435 gtk_tree_store_set(store, &parent,
2452 if (pconn->id == conn_id) {
2456 pprev_child, pconn)) {
2457 gtk_tree_store_move_after(store, &child, pprev_child);
2459 gtk_tree_store_insert_after(store, &child, &parent, pprev_child);
2462 gtk_tree_store_set(store, &child,
2472 pprev_child = &prev_child;
2476 if (NULL != pprev_child) {
2479 path = gtk_tree_model_get_path(model, &parent);
2482 gtk_tree_path_free(path);
2487 if (NULL != pprev_child) {
2489 if (gtk_tree_model_iter_next(model, &child)) {
2490 while (gtk_tree_store_remove(store, &child)) {
2494 }
else if (gtk_tree_model_iter_children(model, &child, &parent)) {
2495 while (gtk_tree_store_remove(store, &child)) {
2500 prev_parent = parent;
2501 pprev_parent = &prev_parent;
2503 g_object_unref(flag);
2506 g_object_unref(
color);
2513 if (NULL != pconn->playing || !pconn->observer) {
2518 gtk_tree_store_move_after(store, &parent, pprev_parent);
2520 gtk_tree_store_insert_after(store, &parent, NULL, pprev_parent);
2523 gtk_tree_store_set(store, &parent,
2532 prev_parent = parent;
2533 pprev_parent = &prev_parent;
2538 if (NULL != pconn->playing || pconn->observer) {
2543 gtk_tree_store_move_after(store, &parent, pprev_parent);
2545 gtk_tree_store_insert_after(store, &parent, NULL, pprev_parent);
2548 gtk_tree_store_set(store, &parent,
2557 prev_parent = parent;
2558 pprev_parent = &prev_parent;
2562 if (NULL != pprev_parent) {
2563 parent = prev_parent;
2564 if (gtk_tree_model_iter_next(model, &parent)) {
2565 while (gtk_tree_store_remove(store, &parent)) {
2570 gtk_tree_store_clear(store);
2574 if (NULL == pselected_player && NULL != pselected_conn) {
2588 const char *
title,
int colnum,
const char *key)
2590 GtkCellRenderer *rend;
2591 GtkTreeViewColumn *col;
2593 if (gtype == G_TYPE_BOOLEAN) {
2594 rend = gtk_cell_renderer_toggle_new();
2595 col = gtk_tree_view_column_new_with_attributes(
title, rend,
2596 "active", colnum, NULL);
2597 }
else if (gtype == GDK_TYPE_PIXBUF) {
2598 rend = gtk_cell_renderer_pixbuf_new();
2599 col = gtk_tree_view_column_new_with_attributes(
title, rend,
2600 "pixbuf", colnum, NULL);
2602 rend = gtk_cell_renderer_text_new();
2603 col = gtk_tree_view_column_new_with_attributes(
title, rend,
2610 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
2611 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), col);
2614 g_object_set_data(G_OBJECT(treeview), key, col);
2623 GtkWidget *box, *sbox, *table, *vbox;
2624 GtkWidget *
view, *sw, *text, *toolkit_view, *button, *spin;
2626 GtkTreeSelection *selection;
2627 enum ai_level
level;
2631 static enum ai_level levels[AI_LEVEL_COUNT];
2634 box = gtk_grid_new();
2635 gtk_orientable_set_orientation(GTK_ORIENTABLE(box),
2636 GTK_ORIENTATION_VERTICAL);
2637 gtk_grid_set_row_spacing(GTK_GRID(box), 8);
2638 gtk_container_set_border_width(GTK_CONTAINER(box), 4);
2640 sbox = gtk_grid_new();
2641 gtk_grid_set_column_spacing(GTK_GRID(sbox), 12);
2642 gtk_container_add(GTK_CONTAINER(box), sbox);
2644 vbox = gtk_grid_new();
2645 g_object_set(vbox,
"margin", 12, NULL);
2646 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
2647 GTK_ORIENTATION_VERTICAL);
2648 gtk_grid_set_row_spacing(GTK_GRID(vbox), 2);
2649 gtk_widget_set_halign(vbox, GTK_ALIGN_CENTER);
2650 gtk_widget_set_valign(vbox, GTK_ALIGN_CENTER);
2651 gtk_container_add(GTK_CONTAINER(sbox), vbox);
2653 table = gtk_grid_new();
2655 gtk_grid_set_row_spacing(GTK_GRID(table), 2);
2656 gtk_grid_set_column_spacing(GTK_GRID(table), 12);
2657 gtk_container_add(GTK_CONTAINER(vbox), table);
2661 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
2662 gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(spin),
2663 GTK_UPDATE_IF_VALID);
2667 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
2671 g_signal_connect_after(spin,
"value_changed",
2674 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
2676 label = g_object_new(GTK_TYPE_LABEL,
2677 "use-underline",
TRUE,
2678 "mnemonic-widget", spin,
2680 "label",
_(
"Number of _Players\n(including AI):"),
2684 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
2690 const char *level_name = ai_level_translated_name(
level);
2692 gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(
ai_lvl_combobox), i, level_name);
2703 label = g_object_new(GTK_TYPE_LABEL,
2704 "use-underline",
TRUE,
2706 "label",
_(
"AI Skill _Level:"),
2710 gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
2716 gtk_grid_attach(GTK_GRID(table),
ruleset_combo, 1, 2, 1, 1);
2718 label = g_object_new(GTK_TYPE_LABEL,
2719 "use-underline",
TRUE,
2721 "label",
_(
"Ruleset:"),
2725 gtk_grid_attach(GTK_GRID(table), label, 0, 2, 1, 1);
2728 _(
"_More Game Options..."));
2729 g_object_set(button,
"margin", 8, NULL);
2730 gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
2731 gtk_widget_set_valign(button, GTK_ALIGN_CENTER);
2732 g_signal_connect(button,
"clicked",
2734 gtk_container_add(GTK_CONTAINER(vbox), button);
2738 gtk_widget_set_hexpand(
view,
TRUE);
2740 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(
view),
TRUE);
2743 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
view));
2744 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
2745 g_signal_connect(selection,
"changed",
2763 g_signal_connect(
view,
"button-press-event",
2765 g_signal_connect(
view,
"row-collapsed",
2767 GINT_TO_POINTER(
TRUE));
2768 g_signal_connect(
view,
"row-expanded",
2770 GINT_TO_POINTER(
FALSE));
2772 sw = gtk_scrolled_window_new(NULL, NULL);
2773 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
2774 GTK_SHADOW_ETCHED_IN);
2775 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
2776 GTK_POLICY_AUTOMATIC,
2778 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sw), 200);
2779 gtk_container_add(GTK_CONTAINER(sw),
view);
2780 gtk_container_add(GTK_CONTAINER(sbox), sw);
2783 sw = gtk_scrolled_window_new(NULL, NULL);
2784 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
2785 GTK_SHADOW_ETCHED_IN);
2786 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
2787 GTK_POLICY_AUTOMATIC,
2789 gtk_container_add(GTK_CONTAINER(box), sw);
2792 gtk_widget_set_hexpand(text,
TRUE);
2793 gtk_widget_set_vexpand(text,
TRUE);
2795 gtk_widget_set_name(text,
"chatline");
2796 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
2797 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);
2798 gtk_text_view_set_editable(GTK_TEXT_VIEW(text),
FALSE);
2799 gtk_container_add(GTK_CONTAINER(sw), text);
2810 gtk_container_add(GTK_CONTAINER(box), toolkit_view);
2812 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
2814 g_signal_connect(button,
"clicked", G_CALLBACK(
main_callback), NULL);
2841 if (load_successful) {
2865 const gchar *filename;
2867 if (!gtk_tree_selection_get_selected(
load_selection, NULL, &it)) {
2871 gtk_tree_model_get(GTK_TREE_MODEL(
load_store), &it,
2882 GTK_FILE_CHOOSER_ACTION_OPEN,
2896 fileinfo_list_destroy(files);
2904 GtkWidget *box, *sbox, *bbox;
2906 GtkWidget *button, *label, *
view, *sw;
2907 GtkCellRenderer *rend;
2909 box = gtk_grid_new();
2910 gtk_orientable_set_orientation(GTK_ORIENTABLE(box),
2911 GTK_ORIENTATION_VERTICAL);
2912 gtk_grid_set_row_spacing(GTK_GRID(box), 18);
2913 gtk_container_set_border_width(GTK_CONTAINER(box), 4);
2917 gtk_widget_set_vexpand(
view,
TRUE);
2920 rend = gtk_cell_renderer_text_new();
2921 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(
view),
2922 -1, NULL, rend,
"text", 0, NULL);
2925 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(
view),
FALSE);
2927 gtk_tree_selection_set_mode(
load_selection, GTK_SELECTION_SINGLE);
2929 g_signal_connect(
view,
"row-activated",
2932 sbox = gtk_grid_new();
2933 gtk_widget_set_halign(sbox, GTK_ALIGN_CENTER);
2934 gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox),
2935 GTK_ORIENTATION_VERTICAL);
2936 gtk_grid_set_row_spacing(GTK_GRID(sbox), 2);
2937 gtk_container_add(GTK_CONTAINER(box), sbox);
2939 label = g_object_new(GTK_TYPE_LABEL,
2940 "use-underline",
TRUE,
2941 "mnemonic-widget",
view,
2942 "label",
_(
"Choose Saved Game to _Load:"),
2946 gtk_container_add(GTK_CONTAINER(sbox), label);
2948 sw = gtk_scrolled_window_new(NULL, NULL);
2949 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(sw), 300);
2950 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
2951 GTK_SHADOW_ETCHED_IN);
2952 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
2953 GTK_POLICY_AUTOMATIC);
2954 gtk_container_add(GTK_CONTAINER(sw),
view);
2955 gtk_container_add(GTK_CONTAINER(sbox), sw);
2957 bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
2958 gtk_widget_set_hexpand(bbox,
TRUE);
2959 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
2960 gtk_box_set_spacing(GTK_BOX(bbox), 12);
2961 gtk_container_add(GTK_CONTAINER(box), bbox);
2963 button = gtk_button_new_with_mnemonic(
_(
"_Browse..."));
2964 gtk_container_add(GTK_CONTAINER(bbox), button);
2965 gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), button,
TRUE);
2966 g_signal_connect(button,
"clicked",
2969 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
2970 gtk_container_add(GTK_CONTAINER(bbox), button);
2971 g_signal_connect(button,
"clicked",
2974 button = gtk_button_new_from_stock(GTK_STOCK_OK);
2975 gtk_container_add(GTK_CONTAINER(bbox), button);
2976 g_signal_connect(button,
"clicked",
2989 GtkTextBuffer *buffer;
2998 2, &description, -1);
3010 maj = ver / 1000000;
3016 fc_snprintf(vername,
sizeof(vername),
"%d.%d+", maj, min);
3018 fc_snprintf(vername,
sizeof(vername),
"%d.%d", maj, min);
3032 gtk_text_buffer_set_text(buffer, description, -1);
3034 gtk_text_buffer_set_text(buffer, authors, -1);
3051 gtk_tree_model_get(GTK_TREE_MODEL(
scenario_store), &it, 1, &filename, -1);
3061 GTK_FILE_CHOOSER_ACTION_OPEN,
3070 struct fileinfo_list *files;
3081 const char *sname, *sdescription, *sauthors;
3084 int current_ver = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000;
3087 current_dev = current_ver;
3088 if (PATCH_VERSION >= 90) {
3090 current_dev += PATCH_VERSION * 100;
3094 if (fcver < 30000) {
3100 if (fcver % 10000 >= 9000) {
3101 fcdev = fcver - (fcver % 100);
3103 fcdev = fcver - (fcver % 10000);
3107 "scenario.description");
3109 log_debug(
"scenario file: %s from %s", sname, pfile->fullname);
3112 if (fcdev <= current_dev) {
3113 bool add_new =
TRUE;
3115 if (sname != NULL) {
3119 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(
scenario_store), &it);
3126 if (!strcmp(sname, oname)) {
3132 log_debug(
"Duplicate %s (%d vs %d)", sname, existing, fcver);
3134 if (existing > fcver) {
3137 }
else if (existing < fcver) {
3142 0, sname && strlen(sname) ?
Q_(sname) : pfile->name,
3144 2, (NULL != sdescription &&
'\0' != sdescription[0]
3145 ?
Q_(sdescription) :
""),
3146 3, (NULL != sauthors && sauthors[0] !=
'\0'
3147 ?
Q_(sauthors) :
""),
3154 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(
scenario_store), &it);
3163 0, sname && strlen(sname) ?
Q_(sname) : pfile->name,
3165 2, (NULL != sdescription &&
'\0' != sdescription[0]
3166 ?
Q_(sdescription) :
""),
3167 3, (NULL != sauthors && sauthors[0] !=
'\0'
3168 ?
Q_(sauthors) :
""),
3178 fileinfo_list_destroy(files);
3186 GtkWidget *vbox, *hbox, *sbox, *bbox, *filenamebox, *descbox;
3187 GtkWidget *versionbox, *vertext;
3188 GtkWidget *button, *label, *
view, *sw, *swa, *text;
3189 GtkCellRenderer *rend;
3191 vbox = gtk_grid_new();
3192 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
3193 GTK_ORIENTATION_VERTICAL);
3194 gtk_grid_set_row_spacing(GTK_GRID(vbox), 18);
3195 gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
3203 gtk_widget_set_hexpand(
view,
TRUE);
3204 gtk_widget_set_vexpand(
view,
TRUE);
3207 rend = gtk_cell_renderer_text_new();
3208 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(
view),
3209 -1, NULL, rend,
"text", 0, NULL);
3214 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(
view),
FALSE);
3218 g_signal_connect(
view,
"row-activated",
3221 label = g_object_new(GTK_TYPE_LABEL,
3222 "use-underline",
TRUE,
3223 "mnemonic-widget",
view,
3224 "label",
_(
"Choose a _Scenario:"),
3228 gtk_container_add(GTK_CONTAINER(vbox), label);
3230 sbox = gtk_grid_new();
3231 gtk_grid_set_column_spacing(GTK_GRID(sbox), 12);
3232 gtk_grid_set_row_homogeneous(GTK_GRID(sbox),
TRUE);
3233 gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox),
3234 GTK_ORIENTATION_VERTICAL);
3235 gtk_grid_set_row_spacing(GTK_GRID(sbox), 2);
3236 gtk_container_add(GTK_CONTAINER(vbox), sbox);
3238 hbox = gtk_grid_new();
3239 gtk_grid_set_column_homogeneous(GTK_GRID(hbox),
TRUE);
3240 gtk_grid_set_column_spacing(GTK_GRID(hbox), 12);
3242 sw = gtk_scrolled_window_new(NULL, NULL);
3243 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
3244 GTK_SHADOW_ETCHED_IN);
3245 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
3246 GTK_POLICY_AUTOMATIC);
3247 gtk_container_add(GTK_CONTAINER(sw),
view);
3248 gtk_grid_attach(GTK_GRID(sbox), sw, 0, 0, 1, 2);
3250 text = gtk_text_view_new();
3251 gtk_widget_set_hexpand(text,
TRUE);
3252 gtk_widget_set_vexpand(text,
TRUE);
3253 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
3254 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 2);
3255 gtk_text_view_set_editable(GTK_TEXT_VIEW(text),
FALSE);
3258 sw = gtk_scrolled_window_new(NULL, NULL);
3259 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
3260 GTK_SHADOW_ETCHED_IN);
3261 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
3262 GTK_POLICY_AUTOMATIC);
3263 gtk_container_add(GTK_CONTAINER(sw), text);
3265 text = gtk_text_view_new();
3266 gtk_widget_set_hexpand(text,
TRUE);
3267 gtk_widget_set_vexpand(text,
TRUE);
3268 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
3269 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 2);
3270 gtk_text_view_set_editable(GTK_TEXT_VIEW(text),
FALSE);
3273 swa = gtk_scrolled_window_new(NULL, NULL);
3274 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swa),
3275 GTK_SHADOW_ETCHED_IN);
3276 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swa), GTK_POLICY_AUTOMATIC,
3277 GTK_POLICY_AUTOMATIC);
3278 gtk_container_add(GTK_CONTAINER(swa), text);
3280 text = gtk_label_new(
_(
"Filename:"));
3286 filenamebox = gtk_grid_new();
3287 gtk_grid_set_column_spacing(GTK_GRID(hbox), 12);
3288 g_object_set(filenamebox,
"margin", 5, NULL);
3290 gtk_container_add(GTK_CONTAINER(filenamebox), text);
3294 vertext = gtk_label_new(
_(
"Format:"));
3300 versionbox = gtk_grid_new();
3301 gtk_grid_set_column_spacing(GTK_GRID(hbox), 12);
3302 g_object_set(versionbox,
"margin", 5, NULL);
3304 gtk_container_add(GTK_CONTAINER(versionbox), vertext);
3307 descbox = gtk_grid_new();
3308 gtk_orientable_set_orientation(GTK_ORIENTABLE(descbox),
3309 GTK_ORIENTATION_VERTICAL);
3310 gtk_grid_set_row_spacing(GTK_GRID(descbox), 6);
3311 gtk_container_add(GTK_CONTAINER(descbox), sw);
3312 gtk_container_add(GTK_CONTAINER(descbox), swa);
3313 gtk_container_add(GTK_CONTAINER(descbox), filenamebox);
3314 gtk_container_add(GTK_CONTAINER(descbox), versionbox);
3315 gtk_grid_attach(GTK_GRID(sbox), descbox, 1, 0, 1, 2);
3317 bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
3318 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
3319 gtk_box_set_spacing(GTK_BOX(bbox), 12);
3320 gtk_container_add(GTK_CONTAINER(vbox), bbox);
3322 button = gtk_button_new_with_mnemonic(
_(
"_Browse..."));
3323 gtk_container_add(GTK_CONTAINER(bbox), button);
3324 gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), button,
TRUE);
3325 g_signal_connect(button,
"clicked",
3328 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
3329 gtk_container_add(GTK_CONTAINER(bbox), button);
3330 g_signal_connect(button,
"clicked",
3333 button = gtk_button_new_from_stock(GTK_STOCK_OK);
3334 gtk_container_add(GTK_CONTAINER(bbox), button);
3335 g_signal_connect(button,
"clicked",
3364 log_debug(
"Switching client page from %s to %s.",
3366 client_pages_name(new_page));
3379 if (
vmode == NULL) {
3380 gtk_window_unmaximize(GTK_WINDOW(
toplevel));
3411 if (
vmode == NULL) {
3412 gtk_window_maximize(GTK_WINDOW(
toplevel));
3430 if (new_page == PAGE_START || new_page == PAGE_GAME) {
3437 gtk_notebook_set_current_page(GTK_NOTEBOOK(
toplevel_tabs), new_page);
3440 while (gtk_events_pending()) {
3441 gtk_main_iteration();
3489 static GtkWidget *
shell = NULL;
3491 if (NULL !=
shell) {
3498 g_signal_connect(
shell,
"destroy", G_CALLBACK(gtk_widget_destroyed),
3500 gtk_window_present(GTK_WINDOW(
shell));
3524 static GtkWidget *
shell = NULL;
3526 if (NULL !=
shell) {
3533 g_signal_connect(
shell,
"destroy", G_CALLBACK(gtk_widget_destroyed),
3535 gtk_window_present(GTK_WINDOW(
shell));
3553 static GtkWidget *
shell = NULL;
3555 if (NULL !=
shell) {
3562 g_signal_connect(
shell,
"destroy", G_CALLBACK(gtk_widget_destroyed),
3564 gtk_window_present(GTK_WINDOW(
shell));
3577 _(
"Error Creating the Map Image!"), msg);
3591 gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(
ruleset_combo));
3592 for (i = 0; i < num_rulesets; i++) {
3594 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(
ruleset_combo), rulesets[i]);
3595 if (!strcmp(
"default", rulesets[i])) {
3603 gtk_combo_box_set_active(GTK_COMBO_BOX(
ruleset_combo), def_idx);
struct canvas int int struct sprite int int int int height
struct canvas int int struct sprite int int int width
int send_chat_printf(const char *format,...)
int send_chat(const char *message)
void output_window_append(const struct ft_color color, const char *featured_text)
bool can_client_control(void)
bool client_is_global_observer(void)
bool client_is_observer(void)
enum client_states client_state(void)
char fc_password[MAX_LEN_PASSWORD]
enum ai_level server_ai_level(void)
bool mapimg_client_createmap(const char *filename)
void center_on_something(void)
static struct fc_sockaddr_list * list
int connect_to_server(const char *username, const char *hostname, int port, char *errbuf, int errbufsize)
void disconnect_from_server(void)
void send_save_game(const char *filename)
void set_ruleset(const char *ruleset)
bool is_server_running(void)
bool client_start_server(void)
bool can_client_access_hack(void)
const char * conn_description(const struct connection *pconn)
struct connection * conn_by_number(int id)
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
void fc_allocate_mutex(fc_mutex *mutex)
void fc_release_mutex(fc_mutex *mutex)
const struct ft_color ftc_client
static PangoLayout * layout
void inputline_toolkit_view_append_button(GtkWidget *toolkit_view, GtkWidget *button)
GtkWidget * inputline_toolkit_view_new(void)
void inputline_grab_focus(void)
void chatline_scroll_to_bottom(bool delayed)
void popup_races_dialog(struct player *pplayer)
const char * client_string
GtkTextBuffer * message_buffer
struct video_mode * resolution_request_get(void)
void enable_menus(bool enable)
void refresh_chat_buttons(void)
void reset_unit_table(void)
static struct video_mode vmode
GtkWidget * toplevel_tabs
#define GUI_GTK_OPTION(optname)
void gtk_tree_view_focus(GtkTreeView *view)
void gtk_stockbutton_set_label(GtkWidget *button, const gchar *label_text)
GtkWidget * gtk_stockbutton_new(const gchar *stock, const gchar *label_text)
GtkTreeViewColumn * add_treeview_column(GtkWidget *view, const char *title, GType gtype, int model_index)
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
void mapview_freeze(void)
void overview_size_changed(void)
static struct gui_dialog * shell
void option_dialog_popup(const char *name, const struct option_set *poptset)
static GtkListStore * load_store
static void update_network_page(void)
void handle_game_load(bool load_successful, const char *filename)
GtkWidget * create_start_page(void)
GtkWidget * create_network_page(void)
static void client_aitoggle_player(void *data)
static GtkWidget * nation_button
static void update_server_list(enum server_scan_type sstype, const struct server_list *list)
static void start_scenario_callback(GtkWidget *w, gpointer data)
static GtkTreeSelection * scenario_selection
static void update_start_page_buttons(void)
static void save_dialog_response_callback(GtkWidget *w, gint response, gpointer data)
GtkWidget * create_scenario_page(void)
static void show_conn_popup(struct player *pplayer, struct connection *pconn)
static GtkWidget * network_confirm_password_label
void save_mapimg_dialog_popup(void)
static void ruleset_selected(const char *name)
static void ready_button_callback(GtkWidget *w, gpointer data)
static bool conn_list_selection(struct player **ppplayer, struct connection **ppconn)
static struct server_scan_timer_data meta_scan
static void update_network_lists(void)
static GtkWidget * statusbar
static GtkWidget * server_playerlist_view
static GtkListStore * save_dialog_store_new(void)
void append_network_statusbar(const char *text, bool force)
static gboolean update_network_statusbar(gpointer data)
void set_rulesets(int num_rulesets, char **rulesets)
void mapimg_client_save(const char *filename)
static void conn_menu_player_command(GObject *object, gpointer data)
static void load_filename(const char *filename)
static void conn_menu_nation_chosen(GObject *object, gpointer data)
static GtkWidget * scenario_description
void save_game_dialog_popup(void)
enum client_pages get_current_client_page(void)
static GtkListStore * lan_store
static enum connection_state connection_status
static struct server_scan_timer_data lan_scan
static void save_dialog_list_callback(GtkTreeSelection *selection, gpointer data)
static void connect_network_game_callback(GtkWidget *w, gpointer data)
static GtkTreeView * connection_list_view
static GtkWidget * network_login
static GtkWidget * network_login_label
static void connect_callback(GtkWidget *w, gpointer data)
static void scenario_browse_callback(GtkWidget *w, gpointer data)
static GtkListStore * meta_store
static void update_load_page(void)
static void save_dialog_update(struct save_dialog *pdialog)
static GtkWidget * scenario_authors
static GtkWidget * start_aifill_spin
static void ruleset_entry_changed(GtkWidget *w, gpointer data)
void(* save_dialog_action_fn_t)(const char *filename)
static void open_settings(void)
static void set_connection_state(enum connection_state state)
static GtkWidget * ruleset_combo
static void observe_button_callback(GtkWidget *w, gpointer data)
static void conn_menu_ready_chosen(GObject *object, gpointer data)
static void server_scan_error(struct server_scan *scan, const char *message)
static void load_callback(void)
static void save_dialog_file_chooser_callback(GtkWidget *widget, gint response, gpointer data)
static void network_list_callback(GtkTreeSelection *select, gpointer data)
static GtkListStore * server_playerlist_store
static void nation_button_callback(GtkWidget *w, gpointer data)
void real_set_client_page(enum client_pages new_page)
static void conn_menu_connection_command(GObject *object, gpointer data)
static void scenario_list_callback(void)
static gboolean intro_expose(GtkWidget *w, cairo_t *cr, gpointer *data)
static void load_browse_callback(GtkWidget *w, gpointer data)
static void network_activate_callback(GtkTreeView *view, GtkTreePath *arg1, GtkTreeViewColumn *arg2, gpointer data)
static struct fileinfo_list * save_dialog_scenario_list(void)
static void connection_state_reset(void)
void real_conn_list_dialog_update(void *unused)
static gboolean connection_list_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
static bool holding_srv_list_mutex
static GtkTreeStore * connection_list_store
static struct fileinfo_list * save_dialog_savegame_list(void)
static void start_new_game_callback(GtkWidget *w, gpointer data)
void destroy_server_scans(void)
void save_scenario_dialog_popup(void)
static GtkTreeSelection * lan_selection
static void save_dialog_save_scenario(const char *filename)
struct fileinfo_list *(* save_dialog_files_fn_t)(void)
static gboolean check_server_scan(gpointer data)
static void save_dialog_store_update(GtkListStore *store, const struct fileinfo_list *files)
static void ai_fill_changed_by_user(GtkWidget *w, gpointer data)
static gboolean delayed_unselect_path(gpointer data)
static void conn_menu_player_take(GObject *object, gpointer data)
static void conn_menu_info_chosen(GObject *object, gpointer data)
static bool model_get_player_iter(GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *start, const struct player *pplayer)
static GtkTreeSelection * load_selection
static void ai_skill_callback(GtkWidget *w, gpointer data)
static enum client_pages current_page
static GtkWidget * statusbar_frame
static GtkWidget * network_confirm_password
static void client_take_player(struct player *pplayer)
static void clear_network_statusbar(void)
static GtkTreeSelection * meta_selection
static void save_dialog_row_callback(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data)
static void connection_list_row_callback(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
GtkWidget * create_load_page(void)
static GtkWidget * ai_lvl_combobox
static GtkWidget * network_password_label
static GtkWidget * save_dialog_new(const char *title, const char *savelabel, const char *savefilelabel, save_dialog_action_fn_t action, save_dialog_files_fn_t files)
static void intro_free(GtkWidget *w, gpointer *data)
static GtkWidget * network_password
static GtkWidget * network_host
void handle_authentication_req(enum authentication_type type, const char *message)
static GtkTreeStore * connection_list_store_new(void)
static bool send_new_aifill_to_server
static void save_dialog_file_chooser_popup(const char *title, GtkFileChooserAction action, save_dialog_action_fn_t cb)
static GtkWidget * network_port
static void add_tree_col(GtkWidget *treeview, GType gtype, const char *title, int colnum, const char *key)
static void save_dialog_entry_callback(GtkEntry *entry, gpointer data)
static void main_callback(GtkWidget *w, gpointer data)
void update_start_page(void)
static void scenario_callback(void)
static GtkWidget * start_options_table
static bool no_ruleset_callback
void ai_fill_changed_by_server(int aifill)
static void update_server_playerlist(const struct server *pserver)
static GtkWidget * observe_button
static GtkWidget * scenario_version
GtkWidget * create_statusbar(void)
static void game_options_callback(GtkWidget *w, gpointer data)
static GtkListStore * scenario_store
static GtkWidget * network_host_label
static bool model_get_conn_iter(GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *parent, GtkTreeIter *start, const struct connection *pconn)
static GQueue * statusbar_queue
GtkWidget * start_message_area
static GtkWidget * network_port_label
static void update_scenario_page(void)
static GtkWidget * scenario_filename
static void conn_menu_team_chosen(GObject *object, gpointer data)
static GtkWidget * create_conn_menu(struct player *pplayer, struct connection *pconn)
static void load_saved_game_callback(GtkWidget *w, gpointer data)
static guint statusbar_timer
static bool object_extract(GObject *object, struct player **ppplayer, struct connection **ppconn)
static void object_put(GObject *object, struct player *pplayer, struct connection *pconn)
static struct fileinfo_list * save_dialog_mapimg_list(void)
GtkWidget * create_main_page(void)
static void conn_list_select_conn(struct connection *pconn)
static GtkWidget * ready_button
GdkPixbuf * create_player_icon(const struct player *plr)
GdkPixbuf * get_flag(const struct nation_type *nation)
void get_sprite_dimensions(struct sprite *sprite, int *width, int *height)
void free_sprite(struct sprite *s)
struct sprite * sprite_scale(struct sprite *src, int new_w, int new_h)
struct sprite * load_gfxfile(const char *filename)
void voteinfo_gui_update(void)
GtkWidget * voteinfo_bar_new(bool split_bar)
GtkWidget * pregame_votebar
void(* save_dialog_action_fn_t)(const char *filename)
struct fileinfo_list *(* save_dialog_files_fn_t)(void)
static struct server_list * server_list
static enum client_pages old_page
void conn_list_dialog_update(void)
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
#define log_error(message,...)
const char * mapimg_error(void)
const char * nation_adjective_for_player(const struct player *pplayer)
bool can_conn_edit_players_nation(const struct connection *pconn, const struct player *pplayer)
#define NO_NATION_SELECTED
const struct option_set * server_optset
const struct option_set * client_optset
int option_int_get(const struct option *poption)
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
bool option_int_set(struct option *poption, int val)
int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
int dsend_packet_save_scenario(struct connection *pc, const char *name)
int dsend_packet_player_ready(struct connection *pc, int player_no, bool is_ready)
void client_start_server_and_set_page(enum client_pages page)
void set_client_page(enum client_pages page)
enum client_pages get_client_page(void)
bool is_settable_ai_level(enum ai_level level)
struct player * player_by_number(const int player_id)
int player_slot_count(void)
int player_number(const struct player *pplayer)
const char * player_name(const struct player *pplayer)
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
#define ai_level_cmd(_level_)
#define players_iterate_end
#define players_iterate(_pplayer)
#define players_iterate_alive_end
#define players_iterate_alive(_pplayer)
void secfile_destroy(struct section_file *secfile)
struct section_file * secfile_load_section(const char *filename, const char *section, bool allow_duplicates)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
struct srv_list * server_scan_get_list(struct server_scan *scan)
void server_scan_finish(struct server_scan *scan)
struct server_scan * server_scan_begin(enum server_scan_type type, ServerScanErrorFunc error_func)
enum server_scan_type server_scan_get_type(const struct server_scan *scan)
enum server_scan_status server_scan_poll(struct server_scan *scan)
#define server_list_iterate_end
#define server_list_iterate(serverlist, pserver)
struct setting_list * level[OLEVELS_NUM]
const struct strvec * get_scenario_dirs(void)
const struct strvec * get_save_dirs(void)
char * skip_to_basename(char *filepath)
struct fileinfo_list * fileinfolist_infix(const struct strvec *dirs, const char *infix, bool nodups)
#define fileinfo_list_iterate(list, pnode)
#define fileinfo_list_iterate_end
const char * aifill(int amount)
struct conn_list * est_connections
struct packet_game_info info
enum cmdlevel access_level
char username[MAX_LEN_NAME]
char password[MAX_LEN_PASSWORD]
save_dialog_action_fn_t action
save_dialog_files_fn_t files
struct server_scan * scan
struct server::players * players
cairo_surface_t * surface
struct server_list * servers
int fc_snprintf(char *str, size_t n, const char *format,...)
int cat_snprintf(char *str, size_t n, const char *format,...)
int fc_remove(const char *filename)
#define sz_strlcpy(dest, src)
#define sz_strlcat(dest, src)
const char * team_name_translation(const struct team *pteam)
const char * team_slot_name_translation(const struct team_slot *tslot)
int team_number(const struct team *pteam)
int team_slot_index(const struct team_slot *tslot)
const struct player_list * team_members(const struct team *pteam)
bool team_slot_is_used(const struct team_slot *tslot)
const char * team_slot_rule_name(const struct team_slot *tslot)
#define team_slots_iterate_end
#define team_slots_iterate(_tslot)
const char * tileset_main_intro_filename(const struct tileset *t)
void update_queue_connect_processing_finished(int request_id, uq_callback_t callback, void *data)
const char * fc_git_revision(void)
const char * unstable_message(void)
const char * word_version(void)