Freeciv-3.1
Loading...
Searching...
No Matches
diplodlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdio.h>
19#include <stdlib.h>
20
21#include <gtk/gtk.h>
22
23/* utility */
24#include "log.h"
25#include "mem.h"
26#include "shared.h"
27#include "support.h"
28
29/* common */
30#include "diptreaty.h"
31#include "fcintl.h"
32#include "game.h"
33#include "government.h"
34#include "map.h"
35#include "packets.h"
36#include "player.h"
37#include "research.h"
38
39/* client */
40#include "chatline.h"
41#include "client_main.h"
42#include "climisc.h"
43#include "options.h"
44
45/* client/gui-gtk-3.22 */
46#include "diplodlg.h"
47#include "gui_main.h"
48#include "gui_stuff.h"
49#include "mapview.h"
50#include "plrdlg.h"
51
52struct Diplomacy_dialog {
53 struct Treaty treaty;
54 struct gui_dialog* dialog;
55
56 GtkWidget *menu0;
57 GtkWidget *menu1;
58
59 GtkWidget *image0;
60 GtkWidget *image1;
61
62 GtkListStore *store;
63};
64
65struct Diplomacy_notebook {
66 struct gui_dialog* dialog;
67 GtkWidget *notebook;
68};
69
70struct city_deal {
71 int giver;
72 int receiver;
73 int id;
74};
75
76#define SPECLIST_TAG dialog
77#define SPECLIST_TYPE struct Diplomacy_dialog
78#include "speclist.h"
79
80#define dialog_list_iterate(dialoglist, pdialog) \
81 TYPED_LIST_ITERATE(struct Diplomacy_dialog, dialoglist, pdialog)
82#define dialog_list_iterate_end LIST_ITERATE_END
83
84static struct dialog_list *dialog_list;
86
87static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0,
88 struct player *plr1);
89
90static struct Diplomacy_dialog *find_diplomacy_dialog(int other_player_id);
91static void popup_diplomacy_dialog(int other_player_id, int initiated_from);
92static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data);
93static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data);
94static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data);
95static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data);
96static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data);
97static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data);
98static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data);
99static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data);
100static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data);
101static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
102static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
103static void diplo_dialog_returnkey(GtkWidget *w, gpointer data);
104
105static struct Diplomacy_notebook *diplomacy_main_create(void);
106static void diplomacy_main_destroy(void);
107static void diplomacy_main_response(struct gui_dialog *dlg, int response,
108 gpointer data);
109
110#define RESPONSE_CANCEL_MEETING 100
111#define RESPONSE_CANCEL_MEETING_ALL 101
112
113/************************************************************************/
117 bool other_accepted)
118{
120
121 if (!pdialog) {
122 return;
123 }
124
125 pdialog->treaty.accept0 = I_accepted;
126 pdialog->treaty.accept1 = other_accepted;
127
129 gui_dialog_alert(pdialog->dialog);
130}
131
132/************************************************************************/
135void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
136{
137 popup_diplomacy_dialog(counterpart, initiated_from);
138}
139
140/************************************************************************/
143void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
144{
146
147 if (!pdialog) {
148 return;
149 }
150
151 close_diplomacy_dialog(pdialog);
152}
153
154/************************************************************************/
158 enum clause_type type, int value)
159{
161
162 if (!pdialog) {
163 return;
164 }
165
166 add_clause(&pdialog->treaty, player_by_number(giver), type, value,
167 client_player());
169 gui_dialog_alert(pdialog->dialog);
170}
171
172/************************************************************************/
176 enum clause_type type, int value)
177{
179
180 if (!pdialog) {
181 return;
182 }
183
184 remove_clause(&pdialog->treaty, player_by_number(giver), type, value);
186 gui_dialog_alert(pdialog->dialog);
187}
188
189/************************************************************************/
192static void popup_diplomacy_dialog(int other_player_id, int initiated_from)
193{
194 struct Diplomacy_dialog *pdialog = find_diplomacy_dialog(other_player_id);
195
197 return;
198 }
199
200 if (!is_human(client.conn.playing)) {
201 return; /* Don't show if we are not human controlled. */
202 }
203
204 if (!pdialog) {
206 player_by_number(other_player_id));
207 }
208
209 gui_dialog_present(pdialog->dialog);
210 /* We initated the meeting - Make the tab active */
211 if (player_by_number(initiated_from) == client.conn.playing) {
212 /* we have to raise the diplomacy meeting tab as well as the selected
213 * meeting. */
214 fc_assert_ret(dipl_main != NULL);
216 gui_dialog_raise(pdialog->dialog);
217
218 if (players_dialog_shell != NULL) {
220 }
221 }
222}
223
224/************************************************************************/
227static gint sort_advance_names(gconstpointer a, gconstpointer b)
228{
229 const struct advance *padvance1 = (const struct advance *) a;
230 const struct advance *padvance2 = (const struct advance *) b;
231
232 return fc_strcoll(advance_name_translation(padvance1),
233 advance_name_translation(padvance2));
234}
235
236/************************************************************************/
239static void popup_add_menu(GtkMenuShell *parent, gpointer data)
240{
241 struct Diplomacy_dialog *pdialog;
242 struct player *pgiver, *pother;
243 GtkWidget *item, *menu;
244 bool any_map = FALSE;
245
246 /* Init. */
247 gtk_container_foreach(GTK_CONTAINER(parent),
248 (GtkCallback) gtk_widget_destroy, NULL);
249
250 pdialog = (struct Diplomacy_dialog *) data;
251 pgiver = (struct player *) g_object_get_data(G_OBJECT(parent), "plr");
252 pother = (pgiver == pdialog->treaty.plr0
253 ? pdialog->treaty.plr1 : pdialog->treaty.plr0);
254
255
256 /* Maps. */
257 if (clause_enabled(CLAUSE_MAP)) {
258 menu = gtk_menu_new();
259
260 item = gtk_menu_item_new_with_mnemonic(_("World-map"));
261 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
262 g_object_set_data(G_OBJECT(item), "plr", pgiver);
263 g_signal_connect(item, "activate",
264 G_CALLBACK(diplomacy_dialog_map_callback), pdialog);
265 any_map = TRUE;
266 }
267
268 if (clause_enabled(CLAUSE_SEAMAP)) {
269 if (!any_map) {
270 menu = gtk_menu_new();
271 }
272
273 item = gtk_menu_item_new_with_mnemonic(_("Sea-map"));
274 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
275 g_object_set_data(G_OBJECT(item), "plr", pgiver);
276 g_signal_connect(item, "activate",
277 G_CALLBACK(diplomacy_dialog_seamap_callback), pdialog);
278 any_map = TRUE;
279 }
280
281 if (any_map) {
282 item = gtk_menu_item_new_with_mnemonic(_("_Maps"));
283 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
284 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
285 gtk_widget_show_all(item);
286 }
287
288 /* Trading: advances */
289 if (clause_enabled(CLAUSE_ADVANCE)) {
290 const struct research *gresearch = research_get(pgiver);
291 const struct research *oresearch = research_get(pother);
292 GtkWidget *advance_item;
293 GList *sorting_list = NULL;
294 bool team_embassy = team_has_embassy(pgiver->team, pother);
295
296 advance_item = gtk_menu_item_new_with_mnemonic(_("_Advances"));
297 gtk_menu_shell_append(GTK_MENU_SHELL(parent), advance_item);
298
299 advance_iterate(A_FIRST, padvance) {
300 Tech_type_id i = advance_number(padvance);
301
302 if (research_invention_state(gresearch, i) == TECH_KNOWN
303 && (!team_embassy /* We don't know what the other could actually receive */
304 || research_invention_gettable(oresearch, i,
306 && (research_invention_state(oresearch, i) == TECH_UNKNOWN
307 || research_invention_state(oresearch, i)
308 == TECH_PREREQS_KNOWN)) {
309 sorting_list = g_list_prepend(sorting_list, padvance);
310 }
312
313 if (NULL == sorting_list) {
314 /* No advance. */
315 gtk_widget_set_sensitive(advance_item, FALSE);
316 } else {
317 GList *list_item;
318 const struct advance *padvance;
319
320 sorting_list = g_list_sort(sorting_list, sort_advance_names);
321 menu = gtk_menu_new();
322
323 /* TRANS: All technologies menu item in the diplomatic dialog. */
324 item = gtk_menu_item_new_with_label(_("All advances"));
325 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
326 g_object_set_data(G_OBJECT(item), "player_from",
327 GINT_TO_POINTER(player_number(pgiver)));
328 g_object_set_data(G_OBJECT(item), "player_to",
329 GINT_TO_POINTER(player_number(pother)));
330 g_signal_connect(item, "activate",
332 GINT_TO_POINTER(A_LAST));
333 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
334 gtk_separator_menu_item_new());
335
336 for (list_item = sorting_list; NULL != list_item;
337 list_item = g_list_next(list_item)) {
338 padvance = (const struct advance *) list_item->data;
339 item = gtk_menu_item_new_with_label(advance_name_translation(padvance));
340 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
341 g_object_set_data(G_OBJECT(item), "player_from",
342 GINT_TO_POINTER(player_number(pgiver)));
343 g_object_set_data(G_OBJECT(item), "player_to",
344 GINT_TO_POINTER(player_number(pother)));
345 g_signal_connect(item, "activate",
347 GINT_TO_POINTER(advance_number(padvance)));
348 }
349
350 gtk_menu_item_set_submenu(GTK_MENU_ITEM(advance_item), menu);
351 g_list_free(sorting_list);
352 }
353
354 gtk_widget_show_all(advance_item);
355 }
356
357 /* Trading: cities. */
358
359 /****************************************************************
360 Creates a sorted list of plr0's cities, excluding the capital and
361 any cities not visible to plr1. This means that you can only trade
362 cities visible to requesting player.
363
364 - Kris Bubendorfer
365 *****************************************************************/
366 if (clause_enabled(CLAUSE_CITY)) {
367 int i = 0;
368 int n = city_list_size(pgiver->cities);
369
370 menu = gtk_menu_new();
371
372 if (n > 0) {
373 struct city **city_list_ptrs;
374
375 city_list_ptrs = fc_malloc(sizeof(struct city *) * n);
376
377 city_list_iterate(pgiver->cities, pcity) {
378 if (!is_capital(pcity)) {
379 city_list_ptrs[i] = pcity;
380 i++;
381 }
383
384 if (i > 0) { /* Cities other than capitals */
385 int j;
386
387 qsort(city_list_ptrs, i, sizeof(struct city *), city_name_compare);
388
389 for (j = 0; j < i; j++) {
390 struct city_deal *deal = fc_malloc(sizeof(struct city_deal));
391
392 item = gtk_menu_item_new_with_label(city_name_get(city_list_ptrs[j]));
393
394 deal->giver = player_number(pgiver);
395 deal->receiver = player_number(pother);
396 deal->id = city_list_ptrs[j]->id;
397
398 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
399 g_signal_connect(item, "activate",
401 (gpointer)deal);
402 }
403 }
404
405 free(city_list_ptrs);
406 }
407
408 item = gtk_menu_item_new_with_mnemonic(_("_Cities"));
409 gtk_widget_set_sensitive(item, (i > 0));
410 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
411 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
412 gtk_widget_show_all(item);
413 }
414
415 /* Give shared vision. */
416 if (clause_enabled(CLAUSE_VISION)) {
417 item = gtk_menu_item_new_with_mnemonic(_("_Give shared vision"));
418 g_object_set_data(G_OBJECT(item), "plr", pgiver);
419 g_signal_connect(item, "activate",
420 G_CALLBACK(diplomacy_dialog_vision_callback), pdialog);
421
422 if (gives_shared_vision(pgiver, pother)) {
423 gtk_widget_set_sensitive(item, FALSE);
424 }
425 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
426 gtk_widget_show(item);
427 }
428
429 /* Give embassy. */
430 if (clause_enabled(CLAUSE_EMBASSY)) {
431 item = gtk_menu_item_new_with_mnemonic(_("Give _embassy"));
432 g_object_set_data(G_OBJECT(item), "plr", pgiver);
433 g_signal_connect(item, "activate",
434 G_CALLBACK(diplomacy_dialog_embassy_callback), pdialog);
435
436 /* Don't take in account the embassy effects. */
437 if (player_has_real_embassy(pother, pgiver)) {
438 gtk_widget_set_sensitive(item, FALSE);
439 }
440 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
441 gtk_widget_show(item);
442 }
443
444 /* Pacts. */
445 if (pgiver == pdialog->treaty.plr0) {
446 enum diplstate_type ds;
447 int pact_clauses = 0;
448
449 ds = player_diplstate_get(pgiver, pother)->type;
450
451 menu = gtk_menu_new();
452
453 if (clause_enabled(CLAUSE_CEASEFIRE)) {
454 item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Cease-fire"));
455 gtk_menu_shell_append(GTK_MENU_SHELL(menu),item);
456 g_signal_connect(item, "activate",
457 G_CALLBACK(diplomacy_dialog_ceasefire_callback), pdialog);
458 gtk_widget_set_sensitive(item, ds != DS_CEASEFIRE && ds != DS_TEAM);
459 pact_clauses++;
460 }
461
462 if (clause_enabled(CLAUSE_PEACE)) {
463 item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Peace"));
464 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
465 g_signal_connect(item, "activate",
466 G_CALLBACK(diplomacy_dialog_peace_callback), pdialog);
467 gtk_widget_set_sensitive(item, ds != DS_PEACE && ds != DS_TEAM);
468 pact_clauses++;
469 }
470
471 if (clause_enabled(CLAUSE_ALLIANCE)) {
472 item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Alliance"));
473 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
474 g_signal_connect(item, "activate",
475 G_CALLBACK(diplomacy_dialog_alliance_callback), pdialog);
476 gtk_widget_set_sensitive(item, ds != DS_ALLIANCE && ds != DS_TEAM);
477 pact_clauses++;
478 }
479
480 if (pact_clauses > 0) {
481 item = gtk_menu_item_new_with_mnemonic(_("_Pacts"));
482 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
483 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
484 gtk_widget_show_all(item);
485 } else {
486 g_object_unref(menu);
487 }
488 }
489}
490
491/************************************************************************/
494static void row_callback(GtkTreeView *view, GtkTreePath *path,
495 GtkTreeViewColumn *col, gpointer data)
496{
497 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
498 gint i;
499 gint *index;
500
501 index = gtk_tree_path_get_indices(path);
502
503 i = 0;
504 clause_list_iterate(pdialog->treaty.clauses, pclause) {
505 if (i == index[0]) {
507 player_number(pdialog->treaty.plr1),
508 player_number(pclause->from),
509 pclause->type,
510 pclause->value);
511 return;
512 }
513 i++;
515}
516
517/************************************************************************/
521{
522 /* Collect all meetings in one main tab. */
523 if (!dipl_main) {
524 GtkWidget *dipl_box, *dipl_sw;
525
526 dipl_main = fc_malloc(sizeof(*dipl_main));
527 gui_dialog_new(&(dipl_main->dialog), GTK_NOTEBOOK(top_notebook),
529 dipl_main->notebook = gtk_notebook_new();
530 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(dipl_main->notebook),
531 GTK_POS_RIGHT);
532 gtk_notebook_set_scrollable(GTK_NOTEBOOK(dipl_main->notebook), TRUE);
533
534 dipl_sw = gtk_scrolled_window_new(NULL, NULL);
535 g_object_set(dipl_sw, "margin", 2, NULL);
536 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dipl_sw),
537 GTK_POLICY_AUTOMATIC,
538 GTK_POLICY_AUTOMATIC);
539 gtk_container_add(GTK_CONTAINER(dipl_sw), dipl_main->notebook);
540
541 /* Buttons */
543 _("Cancel _all meetings"),
545
546 /* Responses for _all_ meetings. */
551
552 dipl_box = dipl_main->dialog->vbox;
553 gtk_container_add(GTK_CONTAINER(dipl_box), dipl_sw);
554
557 }
558
559 return dipl_main;
560}
561
562/************************************************************************/
565static void diplomacy_main_destroy(void)
566{
567 if (dipl_main->dialog) {
569 }
570 free(dipl_main);
571 dipl_main = NULL;
572}
573
574/************************************************************************/
577static void diplomacy_main_response(struct gui_dialog *dlg, int response,
578 gpointer data)
579{
580 if (!dipl_main) {
581 return;
582 }
583
584 switch (response) {
585 default:
586 log_error("unhandled response in %s: %d", __FUNCTION__, response);
587 fc__fallthrough; /* No break. */
588 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
589 case RESPONSE_CANCEL_MEETING_ALL: /* Cancel all meetings. */
591 /* This will do a round trip to the server ans close the dialog in the
592 * client. Closing the last dialog will also close the main tab.*/
595 adialog->treaty.plr1));
597 break;
598 }
599}
600
601/************************************************************************/
604static void diplomacy_destroy(struct Diplomacy_dialog* pdialog)
605{
606 if (NULL != pdialog->dialog) {
607 /* pdialog->dialog may be NULL if the tab has been destroyed
608 * by an other way. */
609 gui_dialog_destroy(pdialog->dialog);
610 pdialog->dialog = NULL;
611 }
612 dialog_list_remove(dialog_list, pdialog);
613
614 if (dialog_list) {
615 /* Diplomatic meetings in one main tab. */
616 if (dialog_list_size(dialog_list) > 0) {
617 if (dipl_main && dipl_main->dialog) {
618 gchar *buf;
619
620 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
622 g_free(buf);
623 }
624 } else if (dipl_main) {
625 /* No meeting left - destroy main tab. */
627 }
628 }
629
630 /* Last sub-tab must not be freed before diplomacy_main_destroy() call. */
631 free(pdialog);
632}
633
634/************************************************************************/
637static void diplomacy_response(struct gui_dialog *dlg, int response,
638 gpointer data)
639{
640 struct Diplomacy_dialog *pdialog = NULL;
641
642 fc_assert_ret(data);
643 pdialog = (struct Diplomacy_dialog *)data;
644
645 switch (response) {
646 case GTK_RESPONSE_ACCEPT: /* Accept treaty. */
649 pdialog->treaty.plr1));
650 break;
651
652 default:
653 log_error("unhandled response in %s: %d", __FUNCTION__, response);
654 fc__fallthrough; /* No break. */
655 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
656 case GTK_RESPONSE_CANCEL: /* GTK: cancel button. */
657 case RESPONSE_CANCEL_MEETING: /* Cancel meetings. */
660 pdialog->treaty.plr1));
661 break;
662 }
663}
664
665/************************************************************************/
669 struct player *plr1)
670{
671 struct Diplomacy_notebook *dipl_dialog;
672 GtkWidget *vbox, *hbox, *table, *mainbox;
673 GtkWidget *label, *sw, *view, *image, *spin;
674 GtkWidget *menubar, *menuitem, *menu, *notebook;
675 struct sprite *flag_spr;
676 GtkListStore *store;
677 GtkCellRenderer *rend;
678 int i;
679
680 struct Diplomacy_dialog *pdialog;
681 char plr_buf[4 * MAX_LEN_NAME];
682 gchar *buf;
683
684 pdialog = fc_malloc(sizeof(*pdialog));
685
686 dialog_list_prepend(dialog_list, pdialog);
687 init_treaty(&pdialog->treaty, plr0, plr1);
688
689 /* Get main diplomacy tab. */
690 dipl_dialog = diplomacy_main_create();
691
692 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
693 gui_dialog_set_title(dipl_dialog->dialog, buf);
694 g_free(buf);
695
696 notebook = dipl_dialog->notebook;
697
698 gui_dialog_new(&(pdialog->dialog), GTK_NOTEBOOK(notebook), pdialog, FALSE);
699
700 /* Buttons */
701 gui_dialog_add_button(pdialog->dialog, NULL,
702 _("Accept treaty"), GTK_RESPONSE_ACCEPT);
703 gui_dialog_add_button(pdialog->dialog, NULL,
704 _("Cancel meeting"), RESPONSE_CANCEL_MEETING);
705
706 /* Responses for one meeting. */
709
710 /* Label for the new meeting. */
711 buf = g_strdup_printf("%s", nation_plural_for_player(plr1));
712 gui_dialog_set_title(pdialog->dialog, buf);
713
714 /* Sort meeting tabs alphabetically by the tab label. */
715 for (i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i++) {
716 GtkWidget *prev_page
717 = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i);
718 struct gui_dialog *prev_dialog
719 = g_object_get_data(G_OBJECT(prev_page), "gui-dialog-data");
720 const char *prev_label
721 = gtk_label_get_text(GTK_LABEL(prev_dialog->v.tab.label));
722
723 if (fc_strcasecmp(buf, prev_label) < 0) {
724 gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook),
725 pdialog->dialog->vbox, i);
726 break;
727 }
728 }
729 g_free(buf);
730
731 /* Content. */
732 mainbox = pdialog->dialog->vbox;
733
734 /* us. */
735 vbox = gtk_grid_new();
736 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
737 GTK_ORIENTATION_VERTICAL);
738 gtk_grid_set_row_spacing(GTK_GRID(vbox), 5);
739 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
740 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
741
742 /* Our nation. */
743 label = gtk_label_new(NULL);
744 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
745 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
746 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
748 gtk_label_set_markup(GTK_LABEL(label), buf);
749 g_free(buf);
750 gtk_container_add(GTK_CONTAINER(vbox), label);
751
752 hbox = gtk_grid_new();
753 gtk_grid_set_column_spacing(GTK_GRID(hbox), 5);
754 gtk_container_add(GTK_CONTAINER(vbox), hbox);
755
756 /* Our flag */
758
759 image = gtk_image_new_from_surface(flag_spr->surface);
760 gtk_container_add(GTK_CONTAINER(hbox), image);
761
762 /* Our name. */
763 label = gtk_label_new(NULL);
764 gtk_widget_set_hexpand(label, TRUE);
765 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
766 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
767 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
768 ruler_title_for_player(plr0, plr_buf, sizeof(plr_buf)));
769 gtk_label_set_markup(GTK_LABEL(label), buf);
770 g_free(buf);
771 gtk_container_add(GTK_CONTAINER(hbox), label);
772
773 image = gtk_image_new();
774 pdialog->image0 = image;
775 gtk_container_add(GTK_CONTAINER(hbox), image);
776
777 /* Menu for clauses: we. */
778 menubar = gtk_aux_menu_bar_new();
779
780 menu = gtk_menu_new();
781 pdialog->menu0 = menu;
782
783 menuitem = gtk_menu_item_new_with_label(_("Add Clause..."));
784 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
785 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
786 g_object_set_data(G_OBJECT(menu), "plr", plr0);
787 g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), pdialog);
788
789 /* Main table for clauses and (if activated) gold trading: we. */
790 table = gtk_grid_new();
791 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
792 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
793 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
794 gtk_container_add(GTK_CONTAINER(vbox), table);
795
796 if (clause_enabled(CLAUSE_GOLD)) {
797 spin = gtk_spin_button_new_with_range(0.0, plr0->economic.gold + 0.1,
798 1.0);
799 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
800 gtk_entry_set_width_chars(GTK_ENTRY(spin), 16);
801 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
802 g_object_set_data(G_OBJECT(spin), "plr", plr0);
803 g_signal_connect_after(spin, "value-changed",
804 G_CALLBACK(diplo_dialog_returnkey), pdialog);
805
806 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
807 "mnemonic-widget", spin, "label", _("Gold:"),
808 "xalign", 0.0, "yalign", 0.5, NULL);
809 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
810
811 gtk_grid_attach(GTK_GRID(table), menubar, 2, 0, 1, 1);
812 } else {
813 gtk_grid_attach(GTK_GRID(table), menubar, 0, 0, 1, 1);
814 }
815
816 /* them. */
817 vbox = gtk_grid_new();
818 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
819 GTK_ORIENTATION_VERTICAL);
820 gtk_grid_set_row_spacing(GTK_GRID(vbox), 5);
821 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
822 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
823
824 /* Their nation. */
825 label = gtk_label_new(NULL);
826 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
827 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
828 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
830 gtk_label_set_markup(GTK_LABEL(label), buf);
831 g_free(buf);
832 gtk_container_add(GTK_CONTAINER(vbox), label);
833
834 hbox = gtk_grid_new();
835 gtk_grid_set_column_spacing(GTK_GRID(hbox), 5);
836 gtk_container_add(GTK_CONTAINER(vbox), hbox);
837
838 /* Their flag */
840
841 image = gtk_image_new_from_surface(flag_spr->surface);
842 gtk_container_add(GTK_CONTAINER(hbox), image);
843
844 /* Their name. */
845 label = gtk_label_new(NULL);
846 gtk_widget_set_hexpand(label, TRUE);
847 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
848 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
849 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
850 title_for_player(plr1, plr_buf, sizeof(plr_buf)));
851 gtk_label_set_markup(GTK_LABEL(label), buf);
852 g_free(buf);
853 gtk_container_add(GTK_CONTAINER(hbox), label);
854
855 image = gtk_image_new();
856 pdialog->image1 = image;
857 gtk_container_add(GTK_CONTAINER(hbox), image);
858
859 /* Menu for clauses: they. */
860 menubar = gtk_aux_menu_bar_new();
861
862 menu = gtk_menu_new();
863 pdialog->menu1 = menu;
864
865 menuitem = gtk_menu_item_new_with_label(_("Add Clause..."));
866 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
867 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
868 g_object_set_data(G_OBJECT(menu), "plr", plr1);
869 g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), pdialog);
870
871 /* Main table for clauses and (if activated) gold trading: they. */
872 table = gtk_grid_new();
873 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
874 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
875 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
876 gtk_container_add(GTK_CONTAINER(vbox), table);
877
878 if (clause_enabled(CLAUSE_GOLD)) {
879 spin = gtk_spin_button_new_with_range(0.0, plr1->economic.gold + 0.1,
880 1.0);
881 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
882 gtk_entry_set_width_chars(GTK_ENTRY(spin), 16);
883 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
884 g_object_set_data(G_OBJECT(spin), "plr", plr1);
885 g_signal_connect_after(spin, "value-changed",
886 G_CALLBACK(diplo_dialog_returnkey), pdialog);
887
888 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
889 "mnemonic-widget", spin, "label", _("Gold:"),
890 "xalign", 0.0, "yalign", 0.5, NULL);
891 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
892
893 gtk_grid_attach(GTK_GRID(table), menubar, 2, 0, 1, 1);
894 } else {
895 gtk_grid_attach(GTK_GRID(table), menubar, 0, 0, 1, 1);
896 }
897
898 /* Clauses. */
899 mainbox = gtk_grid_new();
900 gtk_orientable_set_orientation(GTK_ORIENTABLE(mainbox),
901 GTK_ORIENTATION_VERTICAL);
902 gtk_container_add(GTK_CONTAINER(pdialog->dialog->vbox), mainbox);
903
904 store = gtk_list_store_new(1, G_TYPE_STRING);
905 pdialog->store = store;
906
907 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
908 gtk_widget_set_hexpand(view, TRUE);
909 gtk_widget_set_vexpand(view, TRUE);
910 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
911 g_object_unref(store);
912 gtk_widget_set_size_request(view, 320, 100);
913
914 rend = gtk_cell_renderer_text_new();
915 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, NULL,
916 rend, "text", 0, NULL);
917
918 sw = gtk_scrolled_window_new(NULL, NULL);
919 g_object_set(sw, "margin", 2, NULL);
920 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
921 GTK_SHADOW_ETCHED_IN);
922 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
923 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
924 gtk_container_add(GTK_CONTAINER(sw), view);
925
926 label = g_object_new(GTK_TYPE_LABEL,
927 "use-underline", TRUE,
928 "mnemonic-widget", view,
929 "label", _("C_lauses:"),
930 "xalign", 0.0,
931 "yalign", 0.5,
932 NULL);
933
934 vbox = gtk_grid_new();
935 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
936 GTK_ORIENTATION_VERTICAL);
937 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
938 gtk_container_add(GTK_CONTAINER(vbox), label);
939 gtk_container_add(GTK_CONTAINER(vbox), sw);
940
941 gtk_widget_show_all(mainbox);
942
943 g_signal_connect(view, "row_activated", G_CALLBACK(row_callback), pdialog);
944
946 gui_dialog_show_all(pdialog->dialog);
947
948 return pdialog;
949}
950
951/************************************************************************/
954static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
955{
956 GtkListStore *store;
957 GtkTreeIter it;
958 bool blank = TRUE;
959 GdkPixbuf *pixbuf;
960
961 store = pdialog->store;
962
963 gtk_list_store_clear(store);
964 clause_list_iterate(pdialog->treaty.clauses, pclause) {
965 char buf[128];
966
967 client_diplomacy_clause_string(buf, sizeof(buf), pclause);
968
969 gtk_list_store_append(store, &it);
970 gtk_list_store_set(store, &it, 0, buf, -1);
971 blank = FALSE;
973
974 if (blank) {
975 gtk_list_store_append(store, &it);
976 gtk_list_store_set(store, &it, 0,
977 _("--- This treaty is blank. "
978 "Please add some clauses. ---"), -1);
979 }
980
981 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept0);
982 gtk_image_set_from_pixbuf(GTK_IMAGE(pdialog->image0), pixbuf);
983 g_object_unref(G_OBJECT(pixbuf));
984 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept1);
985 gtk_image_set_from_pixbuf(GTK_IMAGE(pdialog->image1), pixbuf);
986 g_object_unref(G_OBJECT(pixbuf));
987}
988
989/************************************************************************/
992static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data)
993{
994 int giver, dest, other, tech;
995
996 giver = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "player_from"));
997 dest = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "player_to"));
998 tech = GPOINTER_TO_INT(data);
1000 other = dest;
1001 } else {
1002 other = giver;
1003 }
1004
1005 if (A_LAST == tech) {
1006 /* All techs. */
1007 struct player *pgiver = player_by_number(giver);
1008 struct player *pdest = player_by_number(dest);
1009 const struct research *dresearch, *gresearch;
1010
1011 fc_assert_ret(NULL != pgiver);
1012 fc_assert_ret(NULL != pdest);
1013
1014 dresearch = research_get(pdest);
1015 gresearch = research_get(pgiver);
1016 advance_iterate(A_FIRST, padvance) {
1017 Tech_type_id i = advance_number(padvance);
1018
1019 if (research_invention_state(gresearch, i) == TECH_KNOWN
1020 && research_invention_gettable(dresearch, i,
1022 && (research_invention_state(dresearch, i) == TECH_UNKNOWN
1023 || research_invention_state(dresearch, i)
1024 == TECH_PREREQS_KNOWN)) {
1026 CLAUSE_ADVANCE, i);
1027 }
1029 } else {
1030 /* Only one tech. */
1032 CLAUSE_ADVANCE, tech);
1033 }
1034}
1035
1036/************************************************************************/
1040static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data)
1041{
1042 struct city_deal *deal_data = (struct city_deal *)data;
1043 int other;
1044
1045 if (player_by_number(deal_data->giver) == client_player()) {
1046 other = deal_data->receiver;
1047 } else {
1048 other = deal_data->giver;
1049 }
1050
1052 CLAUSE_CITY, deal_data->id);
1053
1054 free(deal_data);
1055}
1056
1057/************************************************************************/
1060static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data)
1061{
1062 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1063 struct player *pgiver;
1064
1065 pgiver = (struct player *)g_object_get_data(G_OBJECT(w), "plr");
1066
1068 player_number(pdialog->treaty.plr1),
1069 player_number(pgiver), CLAUSE_MAP, 0);
1070}
1071
1072/************************************************************************/
1075static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data)
1076{
1077 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1078 struct player *pgiver;
1079
1080 pgiver = (struct player *)g_object_get_data(G_OBJECT(w), "plr");
1081
1083 player_number(pdialog->treaty.plr1),
1084 player_number(pgiver), CLAUSE_SEAMAP,
1085 0);
1086}
1087
1088/************************************************************************/
1091static void diplomacy_dialog_add_pact_clause(GtkWidget *w, gpointer data,
1092 int type)
1093{
1094 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1095
1097 player_number(pdialog->treaty.plr1),
1098 player_number(pdialog->treaty.plr0),
1099 type, 0);
1100}
1101
1102/************************************************************************/
1105static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data)
1106{
1107 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_CEASEFIRE);
1108}
1109
1110/************************************************************************/
1113static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data)
1114{
1115 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_PEACE);
1116}
1117
1118/************************************************************************/
1121static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data)
1122{
1123 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_ALLIANCE);
1124}
1125
1126/************************************************************************/
1129static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data)
1130{
1131 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1132 struct player *pgiver =
1133 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1134
1136 player_number(pdialog->treaty.plr1),
1137 player_number(pgiver), CLAUSE_VISION,
1138 0);
1139}
1140
1141/************************************************************************/
1144static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data)
1145{
1146 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1147 struct player *pgiver =
1148 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1149
1151 player_number(pdialog->treaty.plr1),
1152 player_number(pgiver), CLAUSE_EMBASSY,
1153 0);
1154}
1155
1156/************************************************************************/
1160{
1161 diplomacy_destroy(pdialog);
1162}
1163
1164/************************************************************************/
1168{
1169 dialog_list = dialog_list_new();
1170 dipl_main = NULL;
1171}
1172
1173/************************************************************************/
1177{
1178 dialog_list_destroy(dialog_list);
1179}
1180
1181/************************************************************************/
1184static struct Diplomacy_dialog *find_diplomacy_dialog(int other_player_id)
1185{
1186 struct player *plr0 = client.conn.playing;
1187 struct player *plr1 = player_by_number(other_player_id);
1188
1190 if ((pdialog->treaty.plr0 == plr0 && pdialog->treaty.plr1 == plr1)
1191 || (pdialog->treaty.plr0 == plr1 && pdialog->treaty.plr1 == plr0)) {
1192 return pdialog;
1193 }
1195
1196 return NULL;
1197}
1198
1199/************************************************************************/
1202static void diplo_dialog_returnkey(GtkWidget *w, gpointer data)
1203{
1204 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1205 struct player *pgiver =
1206 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1207 int amount = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w));
1208
1209 if (amount >= 0 && amount <= pgiver->economic.gold) {
1211 player_number(pdialog->treaty.plr1),
1212 player_number(pgiver),
1213 CLAUSE_GOLD, amount);
1214 } else {
1215 output_window_append(ftc_client, _("Invalid amount of gold specified."));
1216 }
1217}
1218
1219/************************************************************************/
1223{
1224 while (dialog_list_size(dialog_list) > 0) {
1225 close_diplomacy_dialog(dialog_list_get(dialog_list, 0));
1226 }
1227}
#define n
Definition astring.c:77
void output_window_append(const struct ft_color color, const char *featured_text)
bool is_capital(const struct city *pcity)
Definition city.c:1552
const char * city_name_get(const struct city *pcity)
Definition city.c:1115
int city_name_compare(const void *p1, const void *p2)
Definition city.c:1684
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define city_list_iterate_end
Definition city.h:490
struct civclient client
bool can_client_issue_orders(void)
const char * title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
#define client_player()
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
Definition climisc.c:241
int int initiated_from int int giver
Definition diplodlg_g.h:28
int int initiated_from handle_diplomacy_remove_clause
Definition diplodlg_g.h:28
handle_diplomacy_cancel_meeting
Definition diplodlg_g.h:24
int counterpart
Definition diplodlg_g.h:25
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diptreaty.c:96
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
Definition diptreaty.c:142
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:286
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Definition diptreaty.c:120
#define clause_list_iterate_end
Definition diptreaty.h:68
#define clause_list_iterate(clauselist, pclause)
Definition diptreaty.h:66
int Tech_type_id
Definition fc_types.h:347
#define MAX_LEN_NAME
Definition fc_types.h:66
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:57
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:390
static void diplomacy_dialog_add_pact_clause(GtkWidget *w, gpointer data, int type)
Definition diplodlg.c:1099
#define RESPONSE_CANCEL_MEETING
Definition diplodlg.c:110
static gint sort_advance_names(gconstpointer a, gconstpointer b)
Definition diplodlg.c:227
static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:1167
static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1000
static void row_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition diplodlg.c:496
static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1113
static void popup_add_menu(GtkMenuShell *parent, gpointer data)
Definition diplodlg.c:239
static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:962
static struct Diplomacy_dialog * find_diplomacy_dialog(int other_player_id)
Definition diplodlg.c:1192
static struct Diplomacy_dialog * create_diplomacy_dialog(struct player *plr0, struct player *plr1)
Definition diplodlg.c:670
static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1083
static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1048
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
Definition diplodlg.c:135
static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1068
void diplomacy_dialog_init(void)
Definition diplodlg.c:1175
static void diplomacy_destroy(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:606
#define dialog_list_iterate_end
Definition diplodlg.c:82
static struct Diplomacy_notebook * diplomacy_main_create(void)
Definition diplodlg.c:522
void handle_diplomacy_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition diplodlg.c:157
static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1137
void close_all_diplomacy_dialogs(void)
Definition diplodlg.c:1230
#define RESPONSE_CANCEL_MEETING_ALL
Definition diplodlg.c:111
static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1152
static void diplomacy_response(struct gui_dialog *dlg, int response, gpointer data)
Definition diplodlg.c:639
#define dialog_list_iterate(dialoglist, pdialog)
Definition diplodlg.c:80
static struct dialog_list * dialog_list
Definition diplodlg.c:84
static void diplomacy_main_response(struct gui_dialog *dlg, int response, gpointer data)
Definition diplodlg.c:579
static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1121
void diplomacy_dialog_done(void)
Definition diplodlg.c:1184
static void diplo_dialog_returnkey(GtkWidget *w, gpointer data)
Definition diplodlg.c:1210
static void diplomacy_main_destroy(void)
Definition diplodlg.c:567
void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition diplodlg.c:116
static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1129
static void popup_diplomacy_dialog(int other_player_id, int initiated_from)
Definition diplodlg.c:192
static struct Diplomacy_notebook * dipl_main
Definition diplodlg.c:85
GtkWidget * top_notebook
Definition gui_main.c:128
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:951
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:834
void gui_dialog_set_default_response(struct gui_dialog *dlg, int response)
Definition gui_stuff.c:733
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:864
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:504
void gui_dialog_set_return_dialog(struct gui_dialog *dlg, struct gui_dialog *return_dialog)
Definition gui_stuff.c:994
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:985
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *text, int response)
Definition gui_stuff.c:706
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:794
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:932
void gui_dialog_alert(struct gui_dialog *dlg)
Definition gui_stuff.c:887
GtkWidget * gtk_aux_menu_bar_new(void)
Definition gui_stuff.c:249
GdkPixbuf * get_thumb_pixbuf(int onoff)
Definition mapview.c:275
struct gui_dialog * players_dialog_shell
Definition plrdlg.c:58
GType type
Definition repodlgs.c:1312
#define fc_assert_ret(condition)
Definition log.h:191
#define log_error(message,...)
Definition log.h:103
#define fc_malloc(sz)
Definition mem.h:34
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:443
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:177
int dsend_packet_diplomacy_create_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_cancel_meeting_req(struct connection *pc, int counterpart)
int dsend_packet_diplomacy_remove_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_accept_treaty_req(struct connection *pc, int counterpart)
struct player * player_by_number(const int player_id)
Definition player.c:840
int player_number(const struct player *pplayer)
Definition player.c:828
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:234
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player)
Definition player.c:214
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1461
#define is_human(plr)
Definition player.h:233
struct research * research_get(const struct player *pplayer)
Definition research.c:126
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:690
GtkWidget * image0
Definition diplodlg.c:59
GtkWidget * image1
Definition diplodlg.c:60
struct Treaty treaty
Definition diplodlg.c:53
struct gui_dialog * dialog
Definition diplodlg.c:54
GtkWidget * menu1
Definition diplodlg.c:57
GtkWidget * menu0
Definition diplodlg.c:56
GtkListStore * store
Definition diplodlg.c:62
struct gui_dialog * dialog
Definition diplodlg.c:66
GtkWidget * notebook
Definition diplodlg.c:67
struct player * plr0
Definition diptreaty.h:77
bool accept0
Definition diptreaty.h:78
bool accept1
Definition diptreaty.h:78
struct clause_list * clauses
Definition diptreaty.h:79
struct player * plr1
Definition diptreaty.h:77
int giver
Definition diplodlg.c:71
int receiver
Definition diplodlg.c:72
Definition city.h:309
int id
Definition city.h:315
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:156
union gui_dialog::@149 v
GtkWidget * vbox
Definition gui_stuff.h:71
GtkWidget * label
Definition gui_stuff.h:86
struct gui_dialog::@149::@150 tab
GtkWidget * notebook
Definition gui_stuff.h:87
Definition climisc.h:82
bool tech_trade_allow_holes
enum diplstate_type type
Definition player.h:201
struct city_list * cities
Definition player.h:281
struct team * team
Definition player.h:261
struct player_economic economic
Definition player.h:284
cairo_surface_t * surface
Definition sprite.h:23
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:472
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc__fallthrough
Definition support.h:109
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_iterate(_start, _p)
Definition tech.h:264
#define A_FIRST
Definition tech.h:44
#define advance_iterate_end
Definition tech.h:270
#define A_LAST
Definition tech.h:45
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6467