Freeciv-3.1
Loading...
Searching...
No Matches
cityrep.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#include <string.h>
21
22#include <gtk/gtk.h>
23#include <gdk/gdkkeysyms.h>
24
25/* utility */
26#include "fcintl.h"
27#include "log.h"
28#include "shared.h"
29#include "support.h"
30
31/* common */
32#include "city.h"
33#include "game.h"
34#include "packets.h"
35#include "unit.h"
36
37/* client/agents */
38#include "cma_fec.h"
39
40/* client */
41#include "citydlg_common.h"
42#include "cityrepdata.h"
43#include "client_main.h"
44#include "climisc.h"
45#include "global_worklist.h"
46#include "mapview_common.h"
47#include "options.h"
48
49/* client/gui-gtk-3.0 */
50#include "chatline.h"
51#include "citydlg.h"
52#include "gui_main.h"
53#include "gui_stuff.h"
54#include "mapview.h"
55#include "mapctrl.h" /* is_city_hilited() */
56#include "optiondlg.h"
57#include "repodlgs.h"
58
59#include "cityrep.h"
60
61#define NEG_VAL(x) ((x)<0 ? (x) : (-x))
62
63/* Some versions of gcc have problems with negative values here (PR#39722). */
64#define CMA_NONE (10000)
65#define CMA_CUSTOM (10001)
66
67struct sell_data {
68 int count; /* Number of cities. */
69 int gold; /* Amount of gold. */
70 const struct impr_type *target; /* The target for selling. */
71};
72
76
77/******************************************************************/
78static void create_city_report_dialog(bool make_modal);
79
80static void city_activated_callback(GtkTreeView *view, GtkTreePath *path,
81 GtkTreeViewColumn *col, gpointer data);
82
83static void city_command_callback(struct gui_dialog *dlg, int response,
84 gpointer data);
85
86static void city_selection_changed_callback(GtkTreeSelection *selection);
87static void city_clear_worklist_callback(GtkMenuItem *item, gpointer data);
88static void update_total_buy_cost(void);
89
90static void create_select_menu(GtkWidget *item);
91static void create_change_menu(GtkWidget *item);
92static void create_last_menu(GtkWidget *item);
93static void create_first_menu(GtkWidget *item);
94static void create_next_menu(GtkWidget *item);
95static void create_next_to_last_menu(GtkWidget *item);
96static void create_sell_menu(GtkWidget *item);
97
98static struct gui_dialog *city_dialog_shell = NULL;
99
100enum {
103
104static GtkWidget *city_view;
105static GtkTreeSelection *city_selection;
106static GtkListStore *city_model;
107#define CRD_COL_CITY_ID (0 + NUM_CREPORT_COLS)
108
109static void popup_select_menu(GtkMenuShell *menu, gpointer data);
110static void popup_change_menu(GtkMenuShell *menu, gpointer data);
111static void popup_last_menu(GtkMenuShell *menu, gpointer data);
112static void popup_first_menu(GtkMenuShell *menu, gpointer data);
113static void popup_next_menu(GtkMenuShell *menu, gpointer data);
114static void popup_next_to_last_menu(GtkMenuShell *menu, gpointer data);
115
116static void recreate_sell_menu(void);
117
118static GtkWidget *city_center_command;
119static GtkWidget *city_popup_command;
120static GtkWidget *city_buy_command;
121static GtkWidget *city_production_command;
122static GtkWidget *city_governor_command;
123static GtkWidget *city_sell_command;
125
126static GtkWidget *change_improvements_item;
127static GtkWidget *change_units_item;
128static GtkWidget *change_wonders_item;
129
130static GtkWidget *last_improvements_item;
131static GtkWidget *last_units_item;
132static GtkWidget *last_wonders_item;
133
134static GtkWidget *first_improvements_item;
135static GtkWidget *first_units_item;
136static GtkWidget *first_wonders_item;
137
138static GtkWidget *next_improvements_item;
139static GtkWidget *next_units_item;
140static GtkWidget *next_wonders_item;
141
143static GtkWidget *next_to_last_units_item;
145
146static GtkWidget *select_island_item;
147
148static GtkWidget *select_bunit_item;
149static GtkWidget *select_bimprovement_item;
150static GtkWidget *select_bwonder_item;
151
152static GtkWidget *select_supported_item;
153static GtkWidget *select_present_item;
156
157static GtkWidget *select_improvements_item;
158static GtkWidget *select_units_item;
159static GtkWidget *select_wonders_item;
160static GtkWidget *select_cma_item;
161
163
165
166/************************************************************************/
169static void get_city_table_header(char **text, int n)
170{
171 struct city_report_spec *spec;
172 int i;
173
174 for (i = 0, spec = city_report_specs; i < NUM_CREPORT_COLS; i++, spec++) {
175 fc_snprintf(text[i], n, "%*s\n%*s",
176 NEG_VAL(spec->width), spec->title1 ? spec->title1 : "",
177 NEG_VAL(spec->width), spec->title2 ? spec->title2 : "");
178 }
179}
180
181/****************************************************************************
182 CITY REPORT DIALOG
183****************************************************************************/
184
185/************************************************************************/
188static GtkListStore *city_report_dialog_store_new(void)
189{
190 GType model_types[NUM_CREPORT_COLS + 1];
191 gint i;
192
193 /* City report data. */
194 for (i = 0; i < NUM_CREPORT_COLS; i++) {
195 model_types[i] = G_TYPE_STRING;
196 }
197
198 /* Specific gtk client data. */
199 model_types[i++] = G_TYPE_INT; /* CRD_COL_CITY_ID */
200
201 return gtk_list_store_newv(i, model_types);
202}
203
204/************************************************************************/
207static void city_model_set(GtkListStore *store, GtkTreeIter *iter,
208 struct city *pcity)
209{
210 struct city_report_spec *spec;
211 char buf[64];
212 gint i;
213
214 for (i = 0; i < NUM_CREPORT_COLS; i++) {
215 spec = city_report_specs + i;
216 fc_snprintf(buf, sizeof(buf), "%*s", NEG_VAL(spec->width),
217 spec->func(pcity, spec->data));
218 gtk_list_store_set(store, iter, i, buf, -1);
219 }
220 gtk_list_store_set(store, iter, CRD_COL_CITY_ID, pcity->id, -1);
221}
222
223/************************************************************************/
226static struct city *city_model_get(GtkTreeModel *model, GtkTreeIter *iter)
227{
228 struct city *pcity;
229 int id;
230
231 gtk_tree_model_get(model, iter, CRD_COL_CITY_ID, &id, -1);
232 pcity = game_city_by_number(id);
233 return ((NULL != pcity
235 && city_owner(pcity) != client_player())
236 ? NULL : pcity);
237}
238
239/************************************************************************/
242static gboolean city_model_find(GtkTreeModel *model, GtkTreeIter *iter,
243 const struct city *pcity)
244{
245 const int searched = pcity->id;
246 int id;
247
248 if (gtk_tree_model_get_iter_first(model, iter)) {
249 do {
250 gtk_tree_model_get(model, iter, CRD_COL_CITY_ID, &id, -1);
251 if (searched == id) {
252 return TRUE;
253 }
254 } while (gtk_tree_model_iter_next(model, iter));
255 }
256 return FALSE;
257}
258
259/************************************************************************/
262static void city_model_fill(GtkListStore *store,
263 GtkTreeSelection *selection, GHashTable *select)
264{
265 GtkTreeIter iter;
266
267 if (client_has_player()) {
269 gtk_list_store_append(store, &iter);
270 city_model_set(store, &iter, pcity);
271 if (NULL != select
272 && g_hash_table_remove(select, GINT_TO_POINTER(pcity->id))) {
273 gtk_tree_selection_select_iter(selection, &iter);
274 }
276 } else {
277 /* Global observer case. */
278 cities_iterate(pcity) {
279 gtk_list_store_append(store, &iter);
280 city_model_set(store, &iter, pcity);
281 if (NULL != select
282 && g_hash_table_remove(select, GINT_TO_POINTER(pcity->id))) {
283 gtk_tree_selection_select_iter(selection, &iter);
284 }
286 }
287}
288
289/************************************************************************/
308
309/************************************************************************/
318
319/************************************************************************/
322static void append_impr_or_unit_to_menu_item(GtkMenuItem *parent_item,
323 bool append_units,
324 bool append_wonders,
326 city_operation,
328 GCallback callback,
329 int size)
330{
331 GtkWidget *menu;
333 struct item items[MAX_NUM_PRODUCTION_TARGETS];
334 int i, item, targets_used;
335 char *row[4];
336 char buf[4][64];
337
338 GtkSizeGroup *group[3];
339 const char *markup[3] = {
340 "weight=\"bold\"",
341 "",
342 ""
343 };
344
345 menu = gtk_menu_new();
346 gtk_menu_item_set_submenu(parent_item, menu);
347
348 if (city_operation != CO_NONE) {
349 GPtrArray *selected;
350 ITree it;
351 int num_selected = 0;
352 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
353 struct city **data;
354
355 selected = g_ptr_array_sized_new(size);
356
357 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
358 struct city *pcity;
359
361 || !(pcity = city_model_get(model, TREE_ITER_PTR(it)))) {
362 continue;
363 }
364
365 g_ptr_array_add(selected, pcity);
366 num_selected++;
367 }
368
369 data = (struct city **)g_ptr_array_free(selected, FALSE);
370 targets_used
371 = collect_production_targets(targets, data, num_selected, append_units,
372 append_wonders, TRUE, test_func);
373 g_free(data);
374 } else {
375 targets_used = collect_production_targets(targets, NULL, 0, append_units,
376 append_wonders, FALSE,
377 test_func);
378 }
379
380 name_and_sort_items(targets, targets_used, items,
381 city_operation != CO_NONE, NULL);
382
383 for (i = 0; i < 4; i++) {
384 row[i] = buf[i];
385 }
386
387 g_object_set_data(G_OBJECT(menu), "freeciv_test_func", test_func);
388 g_object_set_data(G_OBJECT(menu), "freeciv_city_operation",
389 GINT_TO_POINTER(city_operation));
390
391 for (i = 0; i < 3; i++) {
392 group[i] = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
393 }
394
395 for (item = 0; item < targets_used; item++) {
396 struct universal target = items[item].item;
397 GtkWidget *menu_item, *hbox, *label;
398 char txt[256];
399
400 get_city_dialog_production_row(row, sizeof(buf[0]), &target, NULL);
401
402 menu_item = gtk_menu_item_new();
403 hbox = gtk_grid_new();
404 gtk_grid_set_column_spacing(GTK_GRID(hbox), 18);
405 gtk_container_add(GTK_CONTAINER(menu_item), hbox);
406
407 for (i = 0; i < 3; i++) {
408 if (row[i][0] == '\0') {
409 continue;
410 }
411
412 if (city_operation == CO_SELL && i != 0) {
413 continue;
414 }
415
416 fc_snprintf(txt, ARRAY_SIZE(txt), "<span %s>%s</span>",
417 markup[i], row[i]);
418
419 label = gtk_label_new(NULL);
420 gtk_label_set_markup(GTK_LABEL(label), txt);
421
422 switch (i) {
423 case 0:
424 gtk_widget_set_halign(label, GTK_ALIGN_START);
425 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
426 break;
427 case 2:
428 gtk_widget_set_halign(label, GTK_ALIGN_END);
429 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
430 break;
431 default:
432 break;
433 }
434
435 gtk_container_add(GTK_CONTAINER(hbox), label);
436 gtk_size_group_add_widget(group[i], label);
437 }
438
439 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
440 g_signal_connect(menu_item, "activate", callback,
441 GINT_TO_POINTER(cid_encode(target)));
442 }
443
444 for (i = 0; i < 3; i++) {
445 g_object_unref(group[i]);
446 }
447
448 gtk_widget_show_all(menu);
449
450 gtk_widget_set_sensitive(GTK_WIDGET(parent_item), (targets_used > 0));
451}
452
453/************************************************************************/
456static void impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path,
457 GtkTreeIter *iter, gpointer data)
458{
459 struct universal target = cid_decode(GPOINTER_TO_INT(data));
460 struct city *pcity = city_model_get(model, iter);
461
462 if (NULL != pcity) {
463 city_change_production(pcity, &target);
464 }
465}
466
467/************************************************************************/
472static void worklist_last_impr_or_unit_iterate(GtkTreeModel *model,
473 GtkTreePath *path,
474 GtkTreeIter *iter,
475 gpointer data)
476{
477 struct universal target = cid_decode(GPOINTER_TO_INT(data));
478 struct city *pcity = city_model_get(model, iter);
479
480 if (NULL != pcity) {
481 (void) city_queue_insert(pcity, -1, &target);
482 }
483 /* perhaps should warn the user if not successful? */
484}
485
486/************************************************************************/
493static void worklist_first_impr_or_unit_iterate(GtkTreeModel *model,
494 GtkTreePath *path,
495 GtkTreeIter *iter,
496 gpointer data)
497{
498 struct universal target = cid_decode(GPOINTER_TO_INT(data));
499 struct city *pcity = city_model_get(model, iter);
500
501 if (NULL != pcity) {
502 (void) city_queue_insert(pcity, 0, &target);
503 }
504 /* perhaps should warn the user if not successful? */
505}
506
507/************************************************************************/
513static void worklist_next_impr_or_unit_iterate(GtkTreeModel *model,
514 GtkTreePath *path,
515 GtkTreeIter *iter,
516 gpointer data)
517{
518 struct universal target = cid_decode(GPOINTER_TO_INT(data));
519 struct city *pcity = city_model_get(model, iter);
520
521 if (NULL != pcity) {
522 (void) city_queue_insert(pcity, 1, &target);
523 }
524 /* perhaps should warn the user if not successful? */
525}
526
527/************************************************************************/
532static void worklist_next_to_last_impr_or_unit_iterate(GtkTreeModel *model,
533 GtkTreePath *path,
534 GtkTreeIter *iter,
535 gpointer data)
536{
537 struct universal target = cid_decode(GPOINTER_TO_INT(data));
538 struct city *pcity = city_model_get(model, iter);
539
540 if (NULL != pcity) {
541 city_queue_insert(pcity, worklist_length(&pcity->worklist), &target);
542 }
543}
544
545/************************************************************************/
548static void sell_impr_iterate(GtkTreeModel *model, GtkTreePath *path,
549 GtkTreeIter *iter, gpointer data)
550{
551 struct sell_data *sd = (struct sell_data *) data;
552 struct city *pcity = city_model_get(model, iter);
553
554 if (NULL != pcity
555 && !pcity->did_sell
556 && city_has_building(pcity, sd->target)) {
557 sd->count++;
558 sd->gold += impr_sell_gold(sd->target);
560 }
561}
562
563/************************************************************************/
567static void select_impr_or_unit_callback(GtkWidget *wdg, gpointer data)
568{
569 struct universal target = cid_decode(GPOINTER_TO_INT(data));
570 GObject *parent = G_OBJECT(gtk_widget_get_parent(wdg));
571 TestCityFunc test_func = g_object_get_data(parent, "freeciv_test_func");
572 enum city_operation_type city_operation =
573 GPOINTER_TO_INT(g_object_get_data(parent, "freeciv_city_operation"));
574
575 /* if this is not a city operation: */
576 if (city_operation == CO_NONE) {
577 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
578 ITree it;
579
580 gtk_tree_selection_unselect_all(city_selection);
581 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
582 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
583
584 if (NULL != pcity && test_func(pcity, &target)) {
586 }
587 }
588 } else {
589 GtkTreeSelectionForeachFunc foreach_func;
590
592 switch (city_operation) {
593 case CO_LAST:
594 gtk_tree_selection_selected_foreach(city_selection,
596 GINT_TO_POINTER(cid_encode(target)));
597 break;
598 case CO_CHANGE:
599 gtk_tree_selection_selected_foreach(city_selection,
601 GINT_TO_POINTER(cid_encode(target)));
602 break;
603 case CO_FIRST:
604 gtk_tree_selection_selected_foreach(city_selection,
606 GINT_TO_POINTER(cid_encode(target)));
607 break;
608 case CO_NEXT:
609 gtk_tree_selection_selected_foreach(city_selection,
611 GINT_TO_POINTER(cid_encode(target)));
612 break;
613 case CO_NEXT_TO_LAST:
615 gtk_tree_selection_selected_foreach(city_selection, foreach_func,
616 GINT_TO_POINTER(cid_encode(target)));
617 break;
618 case CO_SELL:
619 fc_assert_action(target.kind == VUT_IMPROVEMENT, break);
620 {
621 const struct impr_type *building = target.value.building;
622 struct sell_data sd = { 0, 0, building };
623 GtkWidget *w;
624 gint res;
625 gchar *buf;
626 const char *imprname = improvement_name_translation(building);
627
628 /* Ask confirmation */
629 buf = g_strdup_printf(_("Are you sure you want to sell those %s?"), imprname);
630 w = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
631 GTK_MESSAGE_QUESTION,
632 GTK_BUTTONS_YES_NO, "%s", buf);
633 g_free(buf);
634 res = gtk_dialog_run(GTK_DIALOG(w)); /* Synchron. */
635 gtk_widget_destroy(w);
636 if (res == GTK_RESPONSE_NO) {
637 break;
638 }
639
640 gtk_tree_selection_selected_foreach(city_selection,
641 sell_impr_iterate, &sd);
642 if (sd.count > 0) {
643 /* FIXME: plurality of sd.count is ignored! */
644 /* TRANS: "Sold 3 Harbor for 90 gold." (Pluralisation is in gold --
645 * second %d -- not in buildings.) */
646 w = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
647 GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
648 PL_("Sold %d %s for %d gold.",
649 "Sold %d %s for %d gold.",
650 sd.gold),
651 sd.count, imprname, sd.gold);
652 } else {
653 w = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
654 GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
655 _("No %s could be sold."),
656 imprname);
657 }
658
659 g_signal_connect(w, "response",
660 G_CALLBACK(gtk_widget_destroy), NULL);
661 gtk_window_present(GTK_WINDOW(w)); /* Asynchron. */
662 }
663 break;
664 case CO_NONE:
665 break;
666 }
668 }
669}
670
671/************************************************************************/
674static void cma_iterate(GtkTreeModel *model, GtkTreePath *path,
675 GtkTreeIter *iter, gpointer data)
676{
677 struct city *pcity = city_model_get(model, iter);
678 int idx = GPOINTER_TO_INT(data);
679
680 if (NULL != pcity) {
681 if (CMA_NONE == idx) {
682 cma_release_city(pcity);
683 } else {
685 }
686 refresh_city_dialog(pcity);
687 }
688}
689
690/************************************************************************/
694static void select_cma_callback(GtkWidget *w, gpointer data)
695{
696 int idx = GPOINTER_TO_INT(data);
697 GObject *parent = G_OBJECT(gtk_widget_get_parent(w));
698 bool change_cma =
699 GPOINTER_TO_INT(g_object_get_data(parent, "freeciv_change_cma"));
700 struct cm_parameter parameter;
701
702 /* If this is not the change button but the select cities button. */
703 if (!change_cma) {
704 ITree it;
705 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
706
707 gtk_tree_selection_unselect_all(city_selection);
708 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
709 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
710 int controlled;
711 bool select;
712
713 if (NULL == pcity) {
714 continue;
715 }
716 controlled = cma_is_city_under_agent(pcity, &parameter);
717 select = FALSE;
718
719 if (idx == CMA_NONE) {
720 /* CMA_NONE selects not-controlled, all others require controlled */
721 if (!controlled) {
722 select = TRUE;
723 }
724 } else if (controlled) {
725 if (idx == CMA_CUSTOM) {
726 if (cmafec_preset_get_index_of_parameter(&parameter) == -1) {
727 select = TRUE;
728 }
729 } else if (cm_are_parameter_equal(&parameter,
731 select = TRUE;
732 }
733 }
734
735 if (select) {
737 }
738 }
739 } else {
740 gtk_tree_selection_selected_foreach(city_selection,
741 cma_iterate, GINT_TO_POINTER(idx));
742 }
743}
744
745/************************************************************************/
751static void append_cma_to_menu_item(GtkMenuItem *parent_item, bool change_cma)
752{
753 GtkWidget *menu;
754 int i;
755 struct cm_parameter parameter;
756 GtkWidget *w;
757
758 w = gtk_menu_item_get_submenu(parent_item);
759 if (w != NULL && gtk_widget_get_visible(w)) {
760 return;
761 }
762
764 gtk_menu_item_set_submenu(parent_item, NULL);
765 return;
766 }
767 menu = gtk_menu_new();
768 gtk_menu_item_set_submenu(parent_item, menu);
769
770 if (change_cma) {
771 w = gtk_menu_item_new_with_label(Q_("?cma:none"));
772 gtk_menu_shell_append(GTK_MENU_SHELL(menu), w);
773 g_signal_connect(w, "activate", G_CALLBACK(select_cma_callback),
774 GINT_TO_POINTER(CMA_NONE));
775 fc_assert(GPOINTER_TO_INT(GINT_TO_POINTER(CMA_NONE)) == CMA_NONE);
776
777 for (i = 0; i < cmafec_preset_num(); i++) {
778 w = gtk_menu_item_new_with_label(cmafec_preset_get_descr(i));
779 gtk_menu_shell_append(GTK_MENU_SHELL(menu), w);
780 g_signal_connect(w, "activate", G_CALLBACK(select_cma_callback),
781 GINT_TO_POINTER(i));
782 fc_assert(GPOINTER_TO_INT(GINT_TO_POINTER(i)) == i);
783 }
784 } else {
785 /* Search for a "none" */
786 int found;
787
788 found = 0;
790 if (!cma_is_city_under_agent(pcity, NULL)) {
791 found = 1;
792 break;
793 }
795
796 if (found) {
797 w = gtk_menu_item_new_with_label(Q_("?cma:none"));
798 gtk_menu_shell_append(GTK_MENU_SHELL(menu), w);
799 g_signal_connect(w, "activate", G_CALLBACK(select_cma_callback),
800 GINT_TO_POINTER(CMA_NONE));
801 }
802
803 /*
804 * Search for a city that's under custom (not preset) agent. Might
805 * take a lonnggg time.
806 */
807 found = 0;
809 if (cma_is_city_under_agent(pcity, &parameter)
810 && cmafec_preset_get_index_of_parameter(&parameter) == -1) {
811 found = 1;
812 break;
813 }
815
816 if (found) {
817 /* We found city that's under agent but not a preset */
818 w = gtk_menu_item_new_with_label(Q_("?cma:custom"));
819
820 gtk_menu_shell_append(GTK_MENU_SHELL(menu), w);
821 g_signal_connect(w, "activate",
822 G_CALLBACK(select_cma_callback),
823 GINT_TO_POINTER(CMA_CUSTOM));
824 }
825
826 /* Only fill in presets that are being used. */
827 for (i = 0; i < cmafec_preset_num(); i++) {
828 found = 0;
830 if (cma_is_city_under_agent(pcity, &parameter)
831 && cm_are_parameter_equal(&parameter,
833 found = 1;
834 break;
835 }
837 if (found) {
838 w = gtk_menu_item_new_with_label(cmafec_preset_get_descr(i));
839
840 gtk_menu_shell_append(GTK_MENU_SHELL(menu), w);
841 g_signal_connect(w, "activate",
842 G_CALLBACK(select_cma_callback), GINT_TO_POINTER(i));
843 }
844 }
845 }
846
847 g_object_set_data(G_OBJECT(menu), "freeciv_change_cma",
848 GINT_TO_POINTER(change_cma));
849 gtk_widget_show_all(menu);
850}
851
852/************************************************************************/
857static void append_worklist_foreach(GtkTreeModel *model, GtkTreePath *path,
858 GtkTreeIter *iter, gpointer data)
859{
860 const struct worklist *pwl = data;
861 struct city *pcity = city_model_get(model, iter);
862
863 fc_assert_ret(pwl != NULL);
864
865 if (NULL != pcity) {
866 city_queue_insert_worklist(pcity, -1, pwl);
867 }
868}
869
870/************************************************************************/
875static void append_worklist_callback(GtkMenuItem *menuitem, gpointer data)
876{
877 struct global_worklist *pgwl =
878 global_worklist_by_id(GPOINTER_TO_INT(data));
879
881
882 if (!pgwl) {
883 /* Maybe removed by an other way, not an error. */
884 return;
885 }
886
887 gtk_tree_selection_selected_foreach(city_selection,
889 (gpointer) global_worklist_get(pgwl));
890}
891
892/************************************************************************/
896static void set_worklist_foreach(GtkTreeModel *model, GtkTreePath *path,
897 GtkTreeIter *iter, gpointer data)
898{
899 const struct worklist *pwl = data;
900 struct city *pcity = city_model_get(model, iter);
901
902 fc_assert_ret(pwl != NULL);
903
904 if (NULL != pcity) {
905 city_set_queue(pcity, pwl);
906 }
907}
908
909/************************************************************************/
913static void set_worklist_callback(GtkMenuItem *menuitem, gpointer data)
914{
915 struct global_worklist *pgwl =
916 global_worklist_by_id(GPOINTER_TO_INT(data));
917
919 gtk_tree_selection_selected_foreach(city_selection, set_worklist_foreach,
920 (gpointer) global_worklist_get(pgwl));
921
922 if (!pgwl) {
923 /* Maybe removed by an other way, not an error. */
924 return;
925 }
926
927 gtk_tree_selection_selected_foreach(city_selection,
929 (gpointer) global_worklist_get(pgwl));
930}
931
932/************************************************************************/
936static void production_menu_shown(GtkWidget *widget, gpointer data)
937{
938 GtkWidget *menu, *item;
939 GtkMenuItem *parent_item;
940 GCallback callback;
941 int count = 0;
942
943 parent_item = data;
944 fc_assert_ret(parent_item != NULL);
945 fc_assert_ret(GTK_IS_MENU_ITEM(parent_item));
946
947 callback = g_object_get_data(G_OBJECT(parent_item), "item_callback");
948 fc_assert_ret(callback != NULL);
949
950 menu = gtk_menu_item_get_submenu(parent_item);
951 if (menu != NULL && gtk_widget_get_visible(menu)) {
952 gtk_menu_shell_deactivate(GTK_MENU_SHELL(menu));
953 }
954
955 if (menu == NULL) {
956 menu = gtk_menu_new();
957 gtk_menu_item_set_submenu(parent_item, menu);
958 }
959
961 return;
962 }
963
964 gtk_container_forall(GTK_CONTAINER(menu),
965 (GtkCallback) gtk_widget_destroy, NULL);
966
968 item = gtk_menu_item_new_with_label(global_worklist_name(pgwl));
969 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
970 g_signal_connect(item, "activate", callback,
971 GINT_TO_POINTER(global_worklist_id(pgwl)));
972 count++;
974
975 if (count == 0) {
976 item = gtk_menu_item_new_with_label(_("(no worklists defined)"));
977 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
978 }
979
980 gtk_widget_show_all(menu);
981}
982
983/************************************************************************/
987{
988 struct city_report_spec *spec;
989 GtkTreeView *view;
990 GtkTreeViewColumn *col;
991 GList *columns, *p;
992
993 view = GTK_TREE_VIEW(city_view);
994 fc_assert_ret(view != NULL);
995
996 columns = gtk_tree_view_get_columns(view);
997
998 for (p = columns; p != NULL; p = p->next) {
999 col = p->data;
1000 spec = g_object_get_data(G_OBJECT(col), "city_report_spec");
1001 gtk_tree_view_column_set_visible(col, spec->show);
1002 }
1003
1004 g_list_free(columns);
1005}
1006
1007/************************************************************************/
1010static void toggle_view(GtkCheckMenuItem *item, gpointer data)
1011{
1012 struct city_report_spec *spec = data;
1013
1014 spec->show ^= 1;
1016}
1017
1018/************************************************************************/
1021static void update_view_menu(GtkWidget *show_item)
1022{
1023 GtkWidget *menu, *item;
1024 struct city_report_spec *spec;
1025 int i;
1026
1027 menu = gtk_menu_new();
1028 for (i = 0, spec = city_report_specs + i; i < NUM_CREPORT_COLS; i++, spec++) {
1029 item = gtk_check_menu_item_new_with_label(spec->explanation);
1030 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1031 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), spec->show);
1032 g_signal_connect(item, "toggled", G_CALLBACK(toggle_view), (gpointer)spec);
1033 }
1034 gtk_menu_item_set_submenu(GTK_MENU_ITEM(show_item), menu);
1035}
1036
1037/************************************************************************/
1040static GtkWidget *create_city_report_menubar(void)
1041{
1042 GtkWidget *vbox, *sep, *menubar, *menu, *item;
1043
1044 vbox = gtk_grid_new();
1045 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
1046 GTK_ORIENTATION_VERTICAL);
1047 sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
1048 gtk_container_add(GTK_CONTAINER(vbox), sep);
1049
1050 menubar = gtk_aux_menu_bar_new();
1051 gtk_container_add(GTK_CONTAINER(vbox), menubar);
1052
1053 item = gtk_menu_item_new_with_mnemonic(_("_Production"));
1055 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
1056
1057 menu = gtk_menu_new();
1058 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1059
1060 item = gtk_menu_item_new_with_mnemonic(_("Chan_ge"));
1061 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1063
1064 item = gtk_menu_item_new_with_mnemonic(_("Add _First"));
1065 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1067
1068 item = gtk_menu_item_new_with_mnemonic(_("Add _Next"));
1069 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1071
1072 item = gtk_menu_item_new_with_mnemonic(_("Add _2nd Last"));
1073 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1075
1076 item = gtk_menu_item_new_with_mnemonic(_("Add _Last"));
1077 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1079
1080 item = gtk_separator_menu_item_new();
1081 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1082
1083 item = gtk_menu_item_new_with_label(_("Set Worklist"));
1084 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1085 g_object_set_data(G_OBJECT(item), "item_callback",
1087 g_signal_connect(menu, "show", G_CALLBACK(production_menu_shown), item);
1088
1089 item = gtk_menu_item_new_with_label(_("Append Worklist"));
1090 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1091 g_object_set_data(G_OBJECT(item), "item_callback",
1093 g_signal_connect(menu, "show", G_CALLBACK(production_menu_shown), item);
1094
1095 item = gtk_menu_item_new_with_mnemonic(_("Clear _Worklist"));
1096 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1097 g_signal_connect(item, "activate",
1098 G_CALLBACK(city_clear_worklist_callback), NULL);
1099
1100 item = gtk_menu_item_new_with_mnemonic(_("Gover_nor"));
1102 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
1103 append_cma_to_menu_item(GTK_MENU_ITEM(item), TRUE);
1104
1105 item = gtk_menu_item_new_with_mnemonic(_("S_ell"));
1106 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
1109
1110 item = gtk_menu_item_new_with_mnemonic(_("_Select"));
1111 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
1113
1114 item = gtk_menu_item_new_with_mnemonic(_("_Display"));
1115 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
1117 return vbox;
1118}
1119
1120/************************************************************************/
1123static gint cityrep_sort_func(GtkTreeModel *model, GtkTreeIter *a,
1124 GtkTreeIter *b, gpointer data)
1125{
1126 gint col = GPOINTER_TO_INT(data);
1127 gchar *str1, *str2;
1128 int i;
1129
1130 gtk_tree_model_get(model, a, col, &str1, -1);
1131 gtk_tree_model_get(model, b, col, &str2, -1);
1132
1133 i = cityrepfield_compare(str1, str2);
1134 g_free(str1);
1135 g_free(str2);
1136 return i;
1137}
1138
1139/************************************************************************/
1142static void create_city_report_dialog(bool make_modal)
1143{
1144 static char **titles;
1145 static char (*buf)[128];
1146 struct city_report_spec *spec;
1147 GtkWidget *w, *sw, *menubar;
1148 int i;
1149
1150 gui_dialog_new(&city_dialog_shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
1152
1154
1157
1158 /* menubar */
1159 menubar = create_city_report_menubar();
1161
1162 /* buttons */
1163 city_total_buy_cost_label = gtk_label_new(NULL);
1164 gtk_widget_set_hexpand(city_total_buy_cost_label, TRUE);
1165 gtk_label_set_ellipsize(GTK_LABEL(city_total_buy_cost_label),
1166 PANGO_ELLIPSIZE_START);
1167 gtk_container_add(GTK_CONTAINER(city_dialog_shell->action_area),
1169
1170 w = gui_dialog_add_stockbutton(city_dialog_shell, GTK_STOCK_EXECUTE,
1171 _("_Buy"), CITY_BUY);
1172 city_buy_command = w;
1173
1174 w = gui_dialog_add_stockbutton(city_dialog_shell, GTK_STOCK_ZOOM_IN,
1175 _("_Inspect"), CITY_POPUP);
1177
1178 w = gui_dialog_add_stockbutton(city_dialog_shell, GTK_STOCK_ZOOM_FIT,
1179 _("Cen_ter"), CITY_CENTER);
1181
1183 GTK_RESPONSE_CLOSE);
1184
1185 /* tree view */
1186 buf = fc_realloc(buf, NUM_CREPORT_COLS * sizeof(buf[0]));
1187 titles = fc_realloc(titles, NUM_CREPORT_COLS * sizeof(titles[0]));
1188 for (i = 0; i < NUM_CREPORT_COLS; i++) {
1189 titles[i] = buf[i];
1190 }
1191 get_city_table_header(titles, sizeof(buf[0]));
1192
1194
1195 city_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(city_model));
1196 gtk_widget_set_hexpand(city_view, TRUE);
1197 gtk_widget_set_vexpand(city_view, TRUE);
1198 g_object_unref(city_model);
1199 gtk_widget_set_name(city_view, "small_font");
1200 g_signal_connect(city_view, "row_activated",
1201 G_CALLBACK(city_activated_callback), NULL);
1202 city_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(city_view));
1203 gtk_tree_selection_set_mode(city_selection, GTK_SELECTION_MULTIPLE);
1204 g_signal_connect(city_selection, "changed",
1205 G_CALLBACK(city_selection_changed_callback), NULL);
1206
1207 for (i = 0, spec = city_report_specs; i < NUM_CREPORT_COLS; i++, spec++) {
1208 GtkWidget *header;
1209 GtkCellRenderer *renderer;
1210 GtkTreeViewColumn *col;
1211
1212 renderer = gtk_cell_renderer_text_new();
1213 col = gtk_tree_view_column_new_with_attributes(NULL, renderer,
1214 "text", i, NULL);
1215 header = gtk_label_new(titles[i]);
1216 gtk_widget_set_tooltip_text(header, spec->explanation);
1217 gtk_widget_show(header);
1218 gtk_tree_view_column_set_widget(col, header);
1219 gtk_tree_view_column_set_visible(col, spec->show);
1220 gtk_tree_view_column_set_sort_column_id(col, i);
1221 gtk_tree_view_column_set_reorderable(col, TRUE);
1222 g_object_set_data(G_OBJECT(col), "city_report_spec", spec);
1223 gtk_tree_view_append_column(GTK_TREE_VIEW(city_view), col);
1224 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(city_model), i,
1225 cityrep_sort_func, GINT_TO_POINTER(i),
1226 NULL);
1227 }
1228
1229 sw = gtk_scrolled_window_new(NULL, NULL);
1230 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1231 GTK_SHADOW_ETCHED_IN);
1232 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1233 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1234 gtk_container_add(GTK_CONTAINER(sw), city_view);
1235
1236 gtk_container_add(GTK_CONTAINER(city_dialog_shell->vbox), sw);
1237
1238 city_model_fill(city_model, NULL, NULL);
1240
1242}
1243
1244/************************************************************************/
1247static void city_select_all_callback(GtkMenuItem *item, gpointer data)
1248{
1249 gtk_tree_selection_select_all(city_selection);
1250}
1251
1252/************************************************************************/
1255static void city_unselect_all_callback(GtkMenuItem *item, gpointer data)
1256{
1257 gtk_tree_selection_unselect_all(city_selection);
1258}
1259
1260/************************************************************************/
1263static void city_invert_selection_callback(GtkMenuItem *item, gpointer data)
1264{
1265 ITree it;
1266 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
1267
1268 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1271 } else {
1273 }
1274 }
1275}
1276
1277/************************************************************************/
1280static void city_select_coastal_callback(GtkMenuItem *item, gpointer data)
1281{
1282 ITree it;
1283 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
1284
1285 gtk_tree_selection_unselect_all(city_selection);
1286
1287 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1288 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
1289
1290 if (pcity != NULL
1291 && is_terrain_class_near_tile(&(wld.map), pcity->tile, TC_OCEAN)) {
1293 }
1294 }
1295}
1296
1297/************************************************************************/
1300static void same_island_iterate(GtkTreeModel *model, GtkTreePath *path,
1301 GtkTreeIter *iter, gpointer data)
1302{
1303 struct city *selected_pcity = city_model_get(model, iter);
1304 ITree it;
1305
1306 if (NULL == selected_pcity) {
1307 return;
1308 }
1309
1310 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1311 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
1312
1313 if (NULL != pcity
1314 && (tile_continent(pcity->tile)
1315 == tile_continent(selected_pcity->tile))) {
1317 }
1318 }
1319}
1320
1321/************************************************************************/
1324static void city_select_same_island_callback(GtkMenuItem *item, gpointer data)
1325{
1326 gtk_tree_selection_selected_foreach(city_selection,same_island_iterate,NULL);
1327}
1328
1329/************************************************************************/
1332static void city_select_building_callback(GtkMenuItem *item, gpointer data)
1333{
1334 enum production_class_type which = GPOINTER_TO_INT(data);
1335 ITree it;
1336 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
1337
1338 gtk_tree_selection_unselect_all(city_selection);
1339
1340 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1341 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
1342
1343 if (NULL != pcity
1344 && ((which == PCT_UNIT && VUT_UTYPE == pcity->production.kind)
1345 || (which == PCT_NORMAL_IMPROVEMENT
1346 && VUT_IMPROVEMENT == pcity->production.kind
1347 && !is_wonder(pcity->production.value.building))
1348 || (which == PCT_WONDER
1349 && VUT_IMPROVEMENT == pcity->production.kind
1350 && is_wonder(pcity->production.value.building)))) {
1352 }
1353 }
1354}
1355
1356/************************************************************************/
1359static void buy_iterate(GtkTreeModel *model, GtkTreePath *path,
1360 GtkTreeIter *iter, gpointer data)
1361{
1362 struct city *pcity = city_model_get(model, iter);
1363
1364 if (NULL != pcity) {
1365 cityrep_buy(pcity);
1366 }
1367}
1368
1369/************************************************************************/
1372static void center_iterate(GtkTreeModel *model, GtkTreePath *path,
1373 GtkTreeIter *iter, gpointer data)
1374{
1375 struct city *pcity = city_model_get(model, iter);
1376
1377 if (NULL != pcity) {
1379 }
1380}
1381
1382/************************************************************************/
1385static void popup_iterate(GtkTreeModel *model, GtkTreePath *path,
1386 GtkTreeIter *iter, gpointer data)
1387{
1388 struct city *pcity = city_model_get(model, iter);
1389
1390 if (NULL != pcity) {
1393 }
1394 popup_city_dialog(pcity);
1395 }
1396}
1397
1398/************************************************************************/
1401static void city_command_callback(struct gui_dialog *dlg, int response,
1402 gpointer data)
1403{
1404 switch (response) {
1405 case CITY_CENTER:
1406 if (1 == gtk_tree_selection_count_selected_rows(city_selection)) {
1407 /* Center to city doesn't make sense if many city are selected. */
1408 gtk_tree_selection_selected_foreach(city_selection, center_iterate,
1409 NULL);
1410 }
1411 break;
1412 case CITY_POPUP:
1413 gtk_tree_selection_selected_foreach(city_selection, popup_iterate, NULL);
1414 break;
1415 case CITY_BUY:
1416 gtk_tree_selection_selected_foreach(city_selection, buy_iterate, NULL);
1417 break;
1418 default:
1419 gui_dialog_destroy(dlg);
1420 break;
1421 }
1422}
1423
1424/************************************************************************/
1427static void city_activated_callback(GtkTreeView *view, GtkTreePath *path,
1428 GtkTreeViewColumn *col, gpointer data)
1429{
1430 GtkTreeModel *model;
1431 GtkTreeIter iter;
1432 GdkWindow *win;
1433 GdkDeviceManager *manager;
1434 GdkModifierType mask;
1435
1436 model = gtk_tree_view_get_model(view);
1437
1438 if (!gtk_tree_model_get_iter(model, &iter, path)) {
1439 return;
1440 }
1441
1442 win = gdk_get_default_root_window();
1443 manager = gdk_display_get_device_manager(gdk_window_get_display(win));
1444
1445 gdk_window_get_device_position(win,
1446 gdk_device_manager_get_client_pointer(manager),
1447 NULL, NULL, &mask);
1448
1449 if (!(mask & GDK_CONTROL_MASK)) {
1450 popup_iterate(model, path, &iter, NULL);
1451 } else {
1452 center_iterate(model, path, &iter, NULL);
1453 }
1454}
1455
1456/************************************************************************/
1460{
1461 GHashTable *selected;
1462 ITree iter;
1463 gint city_id;
1464
1465 if (NULL == city_dialog_shell) {
1466 return;
1467 }
1468
1469 /* Save the selection. */
1470 selected = g_hash_table_new(NULL, NULL);
1471 for (itree_begin(GTK_TREE_MODEL(city_model), &iter);
1472 !itree_end(&iter); itree_next(&iter)) {
1473 if (itree_is_selected(city_selection, &iter)) {
1474 itree_get(&iter, CRD_COL_CITY_ID, &city_id, -1);
1475 g_hash_table_insert(selected, GINT_TO_POINTER(city_id), NULL);
1476 }
1477 }
1478
1479 /* Update and restore the selection. */
1480 gtk_list_store_clear(city_model);
1482 g_hash_table_destroy(selected);
1483
1484 if (gtk_widget_get_sensitive(city_governor_command)) {
1486 }
1487
1489}
1490
1491/************************************************************************/
1495{
1496 GtkTreeIter iter;
1497
1498 if (NULL == city_dialog_shell) {
1499 return;
1500 }
1501
1502 if (!city_model_find(GTK_TREE_MODEL(city_model), &iter, pcity)) {
1503 gtk_list_store_prepend(city_model, &iter);
1504 }
1505 city_model_set(city_model, &iter, pcity);
1506
1508}
1509
1510/************************************************************************/
1513static void create_change_menu(GtkWidget *item)
1514{
1515 GtkWidget *menu;
1516
1517 menu = gtk_menu_new();
1518 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1519 g_signal_connect(menu, "show", G_CALLBACK(popup_change_menu), NULL);
1520
1521 change_units_item = gtk_menu_item_new_with_label(_("Units"));
1522 gtk_menu_shell_append(GTK_MENU_SHELL(menu), change_units_item);
1523 change_improvements_item = gtk_menu_item_new_with_label(_("Improvements"));
1524 gtk_menu_shell_append(GTK_MENU_SHELL(menu), change_improvements_item);
1525 change_wonders_item = gtk_menu_item_new_with_label(_("Wonders"));
1526 gtk_menu_shell_append(GTK_MENU_SHELL(menu), change_wonders_item);
1527}
1528
1529/************************************************************************/
1532static void create_last_menu(GtkWidget *item)
1533{
1534 GtkWidget *menu;
1535
1536 menu = gtk_menu_new();
1537 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1538 g_signal_connect(menu, "show", G_CALLBACK(popup_last_menu), NULL);
1539
1540 last_units_item = gtk_menu_item_new_with_label(_("Units"));
1541 gtk_menu_shell_append(GTK_MENU_SHELL(menu), last_units_item);
1542 last_improvements_item = gtk_menu_item_new_with_label(_("Improvements"));
1543 gtk_menu_shell_append(GTK_MENU_SHELL(menu), last_improvements_item);
1544 last_wonders_item = gtk_menu_item_new_with_label(_("Wonders"));
1545 gtk_menu_shell_append(GTK_MENU_SHELL(menu), last_wonders_item);
1546}
1547
1548/************************************************************************/
1551static void create_first_menu(GtkWidget *item)
1552{
1553 GtkWidget *menu;
1554
1555 menu = gtk_menu_new();
1556 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1557 g_signal_connect(menu, "show", G_CALLBACK(popup_first_menu), NULL);
1558
1559 first_units_item = gtk_menu_item_new_with_label(_("Units"));
1560 gtk_menu_shell_append(GTK_MENU_SHELL(menu), first_units_item);
1561 first_improvements_item = gtk_menu_item_new_with_label(_("Improvements"));
1562 gtk_menu_shell_append(GTK_MENU_SHELL(menu), first_improvements_item);
1563 first_wonders_item = gtk_menu_item_new_with_label(_("Wonders"));
1564 gtk_menu_shell_append(GTK_MENU_SHELL(menu), first_wonders_item);
1565}
1566
1567/************************************************************************/
1570static void create_next_menu(GtkWidget *item)
1571{
1572 GtkWidget *menu;
1573
1574 menu = gtk_menu_new();
1575 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1576 g_signal_connect(menu, "show", G_CALLBACK(popup_next_menu), NULL);
1577
1578 next_units_item = gtk_menu_item_new_with_label(_("Units"));
1579 gtk_menu_shell_append(GTK_MENU_SHELL(menu), next_units_item);
1580 next_improvements_item = gtk_menu_item_new_with_label(_("Improvements"));
1581 gtk_menu_shell_append(GTK_MENU_SHELL(menu), next_improvements_item);
1582 next_wonders_item = gtk_menu_item_new_with_label(_("Wonders"));
1583 gtk_menu_shell_append(GTK_MENU_SHELL(menu), next_wonders_item);
1584}
1585
1586/************************************************************************/
1589static void create_next_to_last_menu(GtkWidget *parent_item)
1590{
1591 GtkWidget *menu, *item;
1592
1593 menu = gtk_menu_new();
1594 gtk_menu_item_set_submenu(GTK_MENU_ITEM(parent_item), menu);
1595 g_signal_connect(menu, "show",
1596 G_CALLBACK(popup_next_to_last_menu), NULL);
1597
1598 item = gtk_menu_item_new_with_label(_("Units"));
1599 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1601
1602 item = gtk_menu_item_new_with_label(_("Improvements"));
1603 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1605
1606 item = gtk_menu_item_new_with_label(_("Wonders"));
1607 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1609}
1610
1611/************************************************************************/
1614static void create_sell_menu(GtkWidget *item)
1615{
1616 GtkWidget *menu;
1617
1618 menu = gtk_menu_new();
1619 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1620}
1621
1622/************************************************************************/
1625static void popup_change_menu(GtkMenuShell *menu, gpointer data)
1626{
1627 int n;
1628
1629 n = gtk_tree_selection_count_selected_rows(city_selection);
1630
1634 G_CALLBACK(select_impr_or_unit_callback), n);
1638 G_CALLBACK(select_impr_or_unit_callback), n);
1642 G_CALLBACK(select_impr_or_unit_callback), n);
1643}
1644
1645/************************************************************************/
1648static void popup_last_menu(GtkMenuShell *menu, gpointer data)
1649{
1650 int n;
1651
1652 n = gtk_tree_selection_count_selected_rows(city_selection);
1653
1657 G_CALLBACK(select_impr_or_unit_callback), n);
1659 TRUE, FALSE, CO_LAST,
1661 G_CALLBACK(select_impr_or_unit_callback), n);
1663 FALSE, TRUE, CO_LAST,
1665 G_CALLBACK(select_impr_or_unit_callback), n);
1666}
1667
1668/************************************************************************/
1671static void popup_first_menu(GtkMenuShell *menu, gpointer data)
1672{
1673 int n;
1674
1675 n = gtk_tree_selection_count_selected_rows(city_selection);
1676
1680 G_CALLBACK(select_impr_or_unit_callback), n);
1684 G_CALLBACK(select_impr_or_unit_callback), n);
1688 G_CALLBACK(select_impr_or_unit_callback), n);
1689}
1690
1691/************************************************************************/
1694static void popup_next_menu(GtkMenuShell *menu, gpointer data)
1695{
1696 int n;
1697
1698 n = gtk_tree_selection_count_selected_rows(city_selection);
1699
1703 G_CALLBACK(select_impr_or_unit_callback), n);
1705 TRUE, FALSE, CO_NEXT,
1707 G_CALLBACK(select_impr_or_unit_callback), n);
1709 FALSE, TRUE, CO_NEXT,
1711 G_CALLBACK(select_impr_or_unit_callback), n);
1712}
1713
1714/************************************************************************/
1717static void popup_next_to_last_menu(GtkMenuShell *menu, gpointer data)
1718{
1719 GtkWidget *item;
1720 GCallback callback;
1721 int n;
1722
1724
1725 n = gtk_tree_selection_count_selected_rows(city_selection);
1727
1732 callback, n);
1737 callback, n);
1742 callback, n);
1743}
1744
1745/************************************************************************/
1748static void recreate_sell_menu(void)
1749{
1750 int n;
1751 GList *children;
1752 GtkWidget *menu;
1753
1754 n = gtk_tree_selection_count_selected_rows(city_selection);
1755 menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(city_sell_command));
1756 gtk_menu_popdown(GTK_MENU(menu));
1757
1761 G_CALLBACK(select_impr_or_unit_callback),
1762 n);
1763
1764 menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(city_sell_command));
1765 children = gtk_container_get_children(GTK_CONTAINER(menu));
1766
1767 n = g_list_length(children);
1768 gtk_widget_set_sensitive(city_sell_command, n > 0);
1769 g_list_free(children);
1770}
1771
1772/************************************************************************/
1775static void create_select_menu(GtkWidget *item)
1776{
1777 GtkWidget *menu;
1778
1779 menu = gtk_menu_new();
1780 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1781 g_signal_connect(menu, "show", G_CALLBACK(popup_select_menu), NULL);
1782
1783 item = gtk_menu_item_new_with_label(_("All Cities"));
1784 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1785 g_signal_connect(item, "activate",
1786 G_CALLBACK(city_select_all_callback), NULL);
1787
1788 item = gtk_menu_item_new_with_label(_("No Cities"));
1789 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1790 g_signal_connect(item, "activate",
1791 G_CALLBACK(city_unselect_all_callback), NULL);
1792
1793 item = gtk_menu_item_new_with_label(_("Invert Selection"));
1794 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1795 g_signal_connect(item, "activate",
1796 G_CALLBACK(city_invert_selection_callback), NULL);
1797
1798
1799 item = gtk_separator_menu_item_new();
1800 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1801
1802
1803 item = gtk_menu_item_new_with_label(_("Building Units"));
1804 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1805 g_signal_connect(item, "activate",
1807 GINT_TO_POINTER(PCT_UNIT));
1808
1809 item = gtk_menu_item_new_with_label( _("Building Improvements"));
1810 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1811 g_signal_connect(item, "activate",
1813 GINT_TO_POINTER(PCT_NORMAL_IMPROVEMENT));
1814
1815 item = gtk_menu_item_new_with_label(_("Building Wonders"));
1816 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1817 g_signal_connect(item, "activate",
1819 GINT_TO_POINTER(PCT_WONDER));
1820
1821
1822 item = gtk_separator_menu_item_new();
1823 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1824
1825
1827 gtk_menu_item_new_with_label(_("Building Unit"));
1828 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_bunit_item);
1829
1831 gtk_menu_item_new_with_label( _("Building Improvement"));
1832 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_bimprovement_item);
1833
1835 gtk_menu_item_new_with_label(_("Building Wonder"));
1836 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_bwonder_item);
1837
1838
1839 item = gtk_separator_menu_item_new();
1840 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1841
1842
1843 item = gtk_menu_item_new_with_label(_("Coastal Cities"));
1844 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1845 g_signal_connect(item, "activate",
1846 G_CALLBACK(city_select_coastal_callback), NULL);
1847
1848 select_island_item = gtk_menu_item_new_with_label(_("Same Island"));
1849 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_island_item);
1850 g_signal_connect(select_island_item, "activate",
1851 G_CALLBACK(city_select_same_island_callback), NULL);
1852
1853
1854 item = gtk_separator_menu_item_new();
1855 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1856
1857
1858 select_supported_item = gtk_menu_item_new_with_label(_("Supported Units"));
1859 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_supported_item);
1860
1861 select_present_item = gtk_menu_item_new_with_label(_("Units Present"));
1862 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_present_item);
1863
1865 gtk_menu_item_new_with_label(_("Improvements in City"));
1866 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_built_improvements_item);
1867
1869 gtk_menu_item_new_with_label(_("Wonders in City"));
1870 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_built_wonders_item);
1871
1872
1873 item = gtk_separator_menu_item_new();
1874 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1875
1876
1878 gtk_menu_item_new_with_label(_("Available Units"));
1879 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_units_item);
1881 gtk_menu_item_new_with_label(_("Available Improvements"));
1882 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_improvements_item);
1884 gtk_menu_item_new_with_label(_("Available Wonders"));
1885 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_wonders_item);
1887 gtk_menu_item_new_with_label(_("Citizen Governor"));
1888 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_cma_item);
1889}
1890
1891/************************************************************************/
1894static bool city_building_impr_or_unit(const struct city *pcity,
1895 const struct universal *target)
1896{
1897 return are_universals_equal(&pcity->production, target);
1898}
1899
1900/************************************************************************/
1903static void popup_select_menu(GtkMenuShell *menu, gpointer data)
1904{
1905 int n;
1906
1908 return;
1909
1910 n = gtk_tree_selection_count_selected_rows(city_selection);
1911 gtk_widget_set_sensitive(select_island_item, (n > 0));
1912
1914 TRUE, FALSE, CO_NONE,
1916 G_CALLBACK(select_impr_or_unit_callback), -1);
1920 G_CALLBACK(select_impr_or_unit_callback), -1);
1922 FALSE, TRUE, CO_NONE,
1924 G_CALLBACK(select_impr_or_unit_callback), -1);
1925
1927 TRUE, FALSE, CO_NONE,
1929 G_CALLBACK(select_impr_or_unit_callback), -1);
1931 TRUE, FALSE, CO_NONE,
1933 G_CALLBACK(select_impr_or_unit_callback), -1);
1937 G_CALLBACK(select_impr_or_unit_callback), -1);
1939 FALSE, TRUE, CO_NONE,
1941 G_CALLBACK(select_impr_or_unit_callback), -1);
1942
1946 G_CALLBACK(select_impr_or_unit_callback), -1);
1948 TRUE, FALSE, CO_NONE,
1950 G_CALLBACK(select_impr_or_unit_callback), -1);
1952 FALSE, TRUE, CO_NONE,
1954 G_CALLBACK(select_impr_or_unit_callback), -1);
1956
1958}
1959
1960/************************************************************************/
1964static void update_total_buy_cost(void)
1965{
1966 GtkWidget *label, *view;
1967 GList *rows, *p;
1968 GtkTreeModel *model;
1969 GtkTreeSelection *sel;
1970 GtkTreePath *path;
1971 GtkTreeIter iter;
1972 struct city *pcity;
1973 int total = 0;
1974
1975 view = city_view;
1977
1978 if (!view || !label) {
1979 return;
1980 }
1981
1982 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1983 rows = gtk_tree_selection_get_selected_rows(sel, &model);
1984
1985 for (p = rows; p != NULL; p = p->next) {
1986 path = p->data;
1987 if (gtk_tree_model_get_iter(model, &iter, path)) {
1988 if ((pcity = city_model_get(model, &iter))) {
1989 total += pcity->client.buy_cost;
1990 }
1991 }
1992 gtk_tree_path_free(path);
1993 }
1994 g_list_free(rows);
1995
1996 if (total > 0) {
1997 gchar *buf = g_strdup_printf(_("Total Buy Cost: %d"), total);
1998
1999 gtk_label_set_text(GTK_LABEL(label), buf);
2000 g_free(buf);
2001 } else {
2002 gtk_label_set_text(GTK_LABEL(label), NULL);
2003 }
2004}
2005
2006/************************************************************************/
2010static void city_selection_changed_callback(GtkTreeSelection *selection)
2011{
2012 int n;
2013 bool obs_may, plr_may;
2014
2015 n = gtk_tree_selection_count_selected_rows(selection);
2016 obs_may = n > 0;
2017 plr_may = obs_may && can_client_issue_orders();
2018
2019 gtk_widget_set_sensitive(city_production_command, plr_may);
2020 gtk_widget_set_sensitive(city_governor_command, plr_may);
2021 gtk_widget_set_sensitive(city_center_command, obs_may);
2022 gtk_widget_set_sensitive(city_popup_command, obs_may);
2023 gtk_widget_set_sensitive(city_buy_command, plr_may);
2024 if (plr_may) {
2026 } else {
2027 gtk_widget_set_sensitive(city_sell_command, FALSE);
2028 }
2029
2031}
2032
2033/************************************************************************/
2036static void clear_worklist_foreach_func(GtkTreeModel *model,
2037 GtkTreePath *path,
2038 GtkTreeIter *iter,
2039 gpointer data)
2040{
2041 struct city *pcity = city_model_get(model, iter);
2042
2043 if (NULL != pcity) {
2044 struct worklist empty;
2045
2046 worklist_init(&empty);
2047 city_set_worklist(pcity, &empty);
2048 }
2049}
2050
2051/************************************************************************/
2054static void city_clear_worklist_callback(GtkMenuItem *item, gpointer data)
2055{
2056 struct connection *pconn = &client.conn;
2057
2059
2060 connection_do_buffer(pconn);
2061 gtk_tree_selection_selected_foreach(city_selection,
2064}
2065
2066/************************************************************************/
2072{
2073 ITree it;
2074 GtkTreeModel *model;
2075
2076 if (!city_dialog_shell) {
2077 return;
2078 }
2079
2080 model = GTK_TREE_MODEL(city_model);
2081
2082 gtk_tree_selection_unselect_all(city_selection);
2083
2084 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
2085 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
2086
2087 if (NULL != pcity && is_city_hilited(pcity)) {
2089 }
2090 }
2091}
2092
2093/************************************************************************/
2096void toggle_city_hilite(struct city *pcity, bool on_off)
2097{
2098 GtkTreeIter iter;
2099
2100 if (NULL == city_dialog_shell) {
2101 return;
2102 }
2103
2104 if (city_model_find(GTK_TREE_MODEL(city_model), &iter, pcity)) {
2105 if (on_off) {
2106 gtk_tree_selection_select_iter(city_selection, &iter);
2107 } else {
2108 gtk_tree_selection_unselect_iter(city_selection, &iter);
2109 }
2110 }
2111}
#define n
Definition astring.c:77
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1216
#define cities_iterate_end
Definition city.h:497
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define cities_iterate(pcity)
Definition city.h:492
#define city_owner(_pcity_)
Definition city.h:543
#define city_list_iterate_end
Definition city.h:490
production_class_type
Definition city.h:38
@ PCT_UNIT
Definition city.h:39
@ PCT_NORMAL_IMPROVEMENT
Definition city.h:40
@ PCT_WONDER
Definition city.h:41
void get_city_dialog_production_row(char *buf[], size_t column_size, struct universal *target, struct city *pcity)
int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
bool city_queue_insert(struct city *pcity, int position, struct universal *item)
bool city_queue_insert_worklist(struct city *pcity, int position, const struct worklist *worklist)
bool city_set_queue(struct city *pcity, const struct worklist *pqueue)
int city_change_production(struct city *pcity, struct universal *target)
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
void popup_city_dialog(struct city *pcity)
void refresh_city_dialog(struct city *pcity)
bool can_city_sell_universal(const struct city *pcity, const struct universal *target)
struct city_report_spec * city_report_specs
int cityrepfield_compare(const char *str1, const char *str2)
#define NUM_CREPORT_COLS
Definition cityrepdata.h:25
struct civclient client
bool can_client_issue_orders(void)
bool client_has_player(void)
#define client_player()
bool city_unit_supported(const struct city *pcity, const struct universal *target)
Definition climisc.c:538
void cityrep_buy(struct city *pcity)
Definition climisc.c:1148
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:643
cid cid_encode(struct universal target)
Definition climisc.c:476
bool city_building_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:576
struct universal cid_decode(cid id)
Definition climisc.c:519
bool can_city_build_now_client(const struct city *pcity, const struct universal *target)
Definition climisc.c:586
bool city_unit_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:557
int collect_production_targets(struct universal *targets, struct city **selected_cities, int num_selected_cities, bool append_units, bool append_wonders, bool change_prod, TestCityFunc test_func)
Definition climisc.c:693
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:89
bool(* TestCityFunc)(const struct city *, const struct universal *)
Definition climisc.h:87
bool cm_are_parameter_equal(const struct cm_parameter *const p1, const struct cm_parameter *const p2)
Definition cm.c:2139
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:551
void cma_put_city_under_agent(struct city *pcity, const struct cm_parameter *const parameter)
Definition cma_core.c:523
void cma_release_city(struct city *pcity)
Definition cma_core.c:541
char * cmafec_preset_get_descr(int idx)
Definition cma_fec.c:169
const struct cm_parameter * cmafec_preset_get_parameter(int idx)
Definition cma_fec.c:182
int cmafec_preset_get_index_of_parameter(const struct cm_parameter *const parameter)
Definition cma_fec.c:196
int cmafec_preset_num(void)
Definition cma_fec.c:213
void connection_do_buffer(struct connection *pc)
Definition connection.c:323
void connection_do_unbuffer(struct connection *pc)
Definition connection.c:335
int int id
Definition editgui_g.h:28
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
struct world wld
Definition game.c:58
struct city * game_city_by_number(int id)
Definition game.c:102
struct global_worklist * global_worklist_by_id(int id)
const char * global_worklist_name(const struct global_worklist *pgwl)
int global_worklist_id(const struct global_worklist *pgwl)
const struct worklist * global_worklist_get(const struct global_worklist *pgwl)
#define global_worklists_iterate(pgwl)
#define global_worklists_iterate_end
static void append_worklist_foreach(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:857
static GtkWidget * select_wonders_item
Definition cityrep.c:159
static void create_city_report_dialog(bool make_modal)
Definition cityrep.c:1142
static GtkWidget * next_to_last_wonders_item
Definition cityrep.c:144
static GtkWidget * city_governor_command
Definition cityrep.c:122
static void city_invert_selection_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1263
static GtkWidget * city_popup_command
Definition cityrep.c:119
static GtkWidget * select_cma_item
Definition cityrep.c:160
static void worklist_next_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:513
static GtkWidget * last_wonders_item
Definition cityrep.c:132
static void create_first_menu(GtkWidget *item)
Definition cityrep.c:1551
static void create_next_to_last_menu(GtkWidget *item)
Definition cityrep.c:1589
static GtkWidget * city_total_buy_cost_label
Definition cityrep.c:124
static GtkWidget * city_buy_command
Definition cityrep.c:120
static void update_total_buy_cost(void)
Definition cityrep.c:1964
static GtkWidget * change_units_item
Definition cityrep.c:127
void real_city_report_dialog_update(void *unused)
Definition cityrep.c:1459
#define CRD_COL_CITY_ID
Definition cityrep.c:107
static GtkWidget * last_units_item
Definition cityrep.c:131
static void popup_next_to_last_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1717
void real_city_report_update_city(struct city *pcity)
Definition cityrep.c:1494
static void create_next_menu(GtkWidget *item)
Definition cityrep.c:1570
static void city_select_building_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1332
static void popup_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1385
static void create_select_menu(GtkWidget *item)
Definition cityrep.c:1775
static void city_activated_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition cityrep.c:1427
static void select_impr_or_unit_callback(GtkWidget *wdg, gpointer data)
Definition cityrep.c:567
static void impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:456
static GtkWidget * select_improvements_item
Definition cityrep.c:157
static void city_model_fill(GtkListStore *store, GtkTreeSelection *selection, GHashTable *select)
Definition cityrep.c:262
static void center_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1372
@ CITY_POPUP
Definition cityrep.c:101
@ CITY_CENTER
Definition cityrep.c:101
@ CITY_BUY
Definition cityrep.c:101
void toggle_city_hilite(struct city *pcity, bool on_off)
Definition cityrep.c:2096
static bool city_building_impr_or_unit(const struct city *pcity, const struct universal *target)
Definition cityrep.c:1894
static GtkWidget * select_supported_item
Definition cityrep.c:152
static GtkWidget * select_bimprovement_item
Definition cityrep.c:149
#define CMA_NONE
Definition cityrep.c:64
static GtkWidget * select_units_item
Definition cityrep.c:158
static GtkWidget * select_island_item
Definition cityrep.c:146
static gint cityrep_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data)
Definition cityrep.c:1123
static GtkWidget * change_improvements_item
Definition cityrep.c:126
static struct city * city_model_get(GtkTreeModel *model, GtkTreeIter *iter)
Definition cityrep.c:226
static void append_impr_or_unit_to_menu_item(GtkMenuItem *parent_item, bool append_units, bool append_wonders, enum city_operation_type city_operation, TestCityFunc test_func, GCallback callback, int size)
Definition cityrep.c:322
static void city_select_coastal_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1280
static void production_menu_shown(GtkWidget *widget, gpointer data)
Definition cityrep.c:936
static void popup_select_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1903
static void popup_first_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1671
static void city_command_callback(struct gui_dialog *dlg, int response, gpointer data)
Definition cityrep.c:1401
static void city_model_set(GtkListStore *store, GtkTreeIter *iter, struct city *pcity)
Definition cityrep.c:207
static GtkWidget * last_improvements_item
Definition cityrep.c:130
static void city_clear_worklist_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:2054
static GtkListStore * city_model
Definition cityrep.c:106
static void clear_worklist_foreach_func(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:2036
static GtkWidget * city_sell_command
Definition cityrep.c:123
static void append_cma_to_menu_item(GtkMenuItem *parent_item, bool change_cma)
Definition cityrep.c:751
static GtkWidget * select_bwonder_item
Definition cityrep.c:150
#define NEG_VAL(x)
Definition cityrep.c:61
static void city_select_all_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1247
#define CMA_CUSTOM
Definition cityrep.c:65
static void popup_last_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1648
static void sell_impr_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:548
static GtkTreeSelection * city_selection
Definition cityrep.c:105
static void create_last_menu(GtkWidget *item)
Definition cityrep.c:1532
static void same_island_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1300
static GtkWidget * change_wonders_item
Definition cityrep.c:128
static GtkWidget * first_improvements_item
Definition cityrep.c:134
static void city_select_same_island_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1324
static GtkWidget * select_built_wonders_item
Definition cityrep.c:155
static void set_worklist_callback(GtkMenuItem *menuitem, gpointer data)
Definition cityrep.c:913
static void city_selection_changed_callback(GtkTreeSelection *selection)
Definition cityrep.c:2010
static gboolean city_model_find(GtkTreeModel *model, GtkTreeIter *iter, const struct city *pcity)
Definition cityrep.c:242
static void worklist_next_to_last_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:532
static GtkWidget * next_to_last_units_item
Definition cityrep.c:143
static GtkWidget * next_to_last_improvements_item
Definition cityrep.c:142
static GtkWidget * city_production_command
Definition cityrep.c:121
static GtkListStore * city_report_dialog_store_new(void)
Definition cityrep.c:188
static int city_dialog_shell_is_modal
Definition cityrep.c:162
static GtkWidget * create_city_report_menubar(void)
Definition cityrep.c:1040
static void city_report_update_views(void)
Definition cityrep.c:986
static void get_city_table_header(char **text, int n)
Definition cityrep.c:169
static GtkWidget * select_bunit_item
Definition cityrep.c:148
void hilite_cities_from_canvas(void)
Definition cityrep.c:2071
void city_report_dialog_popdown(void)
Definition cityrep.c:312
static void create_sell_menu(GtkWidget *item)
Definition cityrep.c:1614
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
static GtkWidget * city_view
Definition cityrep.c:104
static GtkWidget * select_present_item
Definition cityrep.c:153
static void update_view_menu(GtkWidget *show_item)
Definition cityrep.c:1021
static GtkWidget * select_built_improvements_item
Definition cityrep.c:154
static struct gui_dialog * city_dialog_shell
Definition cityrep.c:98
static void worklist_first_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:493
static GtkWidget * next_improvements_item
Definition cityrep.c:138
static void popup_change_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1625
static void cma_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:674
static void set_worklist_foreach(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:896
static void toggle_view(GtkCheckMenuItem *item, gpointer data)
Definition cityrep.c:1010
static void append_worklist_callback(GtkMenuItem *menuitem, gpointer data)
Definition cityrep.c:875
static void city_unselect_all_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1255
static void popup_next_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1694
static void worklist_last_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:472
static GtkWidget * next_wonders_item
Definition cityrep.c:140
static GtkWidget * first_units_item
Definition cityrep.c:135
static GtkWidget * next_units_item
Definition cityrep.c:139
static GtkWidget * first_wonders_item
Definition cityrep.c:136
static GtkWidget * city_center_command
Definition cityrep.c:118
static void buy_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1359
bool select_menu_cached
Definition cityrep.c:164
city_operation_type
Definition cityrep.c:73
@ CO_SELL
Definition cityrep.c:74
@ CO_NEXT_TO_LAST
Definition cityrep.c:74
@ CO_NEXT
Definition cityrep.c:74
@ CO_CHANGE
Definition cityrep.c:74
@ CO_FIRST
Definition cityrep.c:74
@ CO_LAST
Definition cityrep.c:74
@ CO_NONE
Definition cityrep.c:74
static void recreate_sell_menu(void)
Definition cityrep.c:1748
static void create_change_menu(GtkWidget *item)
Definition cityrep.c:1513
static void select_cma_callback(GtkWidget *w, gpointer data)
Definition cityrep.c:694
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 itree_get(ITree *it,...)
Definition gui_stuff.c:158
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
GtkWidget * gui_dialog_add_widget(struct gui_dialog *dlg, GtkWidget *widget)
Definition gui_stuff.c:721
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:985
void itree_begin(GtkTreeModel *model, ITree *it)
Definition gui_stuff.c:121
void itree_unselect(GtkTreeSelection *selection, ITree *it)
Definition gui_stuff.c:200
GtkWidget * gui_dialog_add_stockbutton(struct gui_dialog *dlg, const char *stock, const char *text, int response)
Definition gui_stuff.c:690
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:794
void itree_select(GtkTreeSelection *selection, ITree *it)
Definition gui_stuff.c:192
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:932
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:916
void itree_next(ITree *it)
Definition gui_stuff.c:138
gboolean itree_is_selected(GtkTreeSelection *selection, ITree *it)
Definition gui_stuff.c:184
GtkWidget * gtk_aux_menu_bar_new(void)
Definition gui_stuff.c:249
gboolean itree_end(ITree *it)
Definition gui_stuff.c:130
#define TREE_ITER_PTR(x)
Definition gui_stuff.h:37
int impr_sell_gold(const struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_action(condition, action)
Definition log.h:187
bool is_city_hilited(struct city *pcity)
void center_tile_mapcanvas(const struct tile *ptile)
#define fc_realloc(ptr, sz)
Definition mem.h:36
struct client_options gui_options
Definition options.c:71
struct city_list * cities
Definition packhand.c:117
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
#define ARRAY_SIZE(x)
Definition shared.h:85
size_t size
Definition specvec.h:72
const char *(* func)(const struct city *pcity, const void *data)
Definition cityrepdata.h:34
const char * title2
Definition cityrepdata.h:31
const char * explanation
Definition cityrepdata.h:32
const char * title1
Definition cityrepdata.h:30
Definition city.h:309
bool did_sell
Definition city.h:367
int id
Definition city.h:315
struct worklist worklist
Definition city.h:387
struct universal production
Definition city.h:382
int buy_cost
Definition city.h:449
struct tile * tile
Definition city.h:311
struct city::@17::@20 client
struct connection conn
Definition client_main.h:96
bool center_when_popup_city
Definition options.h:154
struct player * playing
Definition connection.h:156
GtkWidget * action_area
Definition gui_stuff.h:72
GtkWidget * vbox
Definition gui_stuff.h:71
Definition climisc.h:82
struct universal item
Definition climisc.h:83
struct city_list * cities
Definition player.h:281
int gold
Definition cityrep.c:69
int count
Definition cityrep.c:68
const struct impr_type * target
Definition cityrep.c:70
enum universals_n kind
Definition fc_types.h:758
universals_u value
Definition fc_types.h:757
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
bool is_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
Definition terrain.c:600
#define tile_continent(_tile)
Definition tile.h:91
const struct impr_type * building
Definition fc_types.h:598
void worklist_init(struct worklist *pwl)
Definition worklist.c:38
int worklist_length(const struct worklist *pwl)
Definition worklist.c:57