Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-gtk-3.0/cityrep.c Source File

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
67 struct 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
73 enum city_operation_type {
74 CO_CHANGE, CO_LAST, CO_NEXT, CO_FIRST, CO_NEXT_TO_LAST, CO_SELL, CO_NONE
75};
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
98 static struct gui_dialog *city_dialog_shell = NULL;
99
100enum {
101 CITY_CENTER = 1, CITY_POPUP, CITY_BUY
102};
103
104 static GtkWidget *city_view;
105 static GtkTreeSelection *city_selection;
106 static 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
118 static GtkWidget *city_center_command;
119 static GtkWidget *city_popup_command;
120 static GtkWidget *city_buy_command;
121 static GtkWidget *city_production_command;
122 static GtkWidget *city_governor_command;
123 static GtkWidget *city_sell_command;
124 static GtkWidget *city_total_buy_cost_label;
125
126 static GtkWidget *change_improvements_item;
127 static GtkWidget *change_units_item;
128 static GtkWidget *change_wonders_item;
129
130 static GtkWidget *last_improvements_item;
131 static GtkWidget *last_units_item;
132 static GtkWidget *last_wonders_item;
133
134 static GtkWidget *first_improvements_item;
135 static GtkWidget *first_units_item;
136 static GtkWidget *first_wonders_item;
137
138 static GtkWidget *next_improvements_item;
139 static GtkWidget *next_units_item;
140 static GtkWidget *next_wonders_item;
141
142 static GtkWidget *next_to_last_improvements_item;
143 static GtkWidget *next_to_last_units_item;
144 static GtkWidget *next_to_last_wonders_item;
145
146 static GtkWidget *select_island_item;
147
148 static GtkWidget *select_bunit_item;
149 static GtkWidget *select_bimprovement_item;
150 static GtkWidget *select_bwonder_item;
151
152 static GtkWidget *select_supported_item;
153 static GtkWidget *select_present_item;
154 static GtkWidget *select_built_improvements_item;
155 static GtkWidget *select_built_wonders_item;
156
157 static GtkWidget *select_improvements_item;
158 static GtkWidget *select_units_item;
159 static GtkWidget *select_wonders_item;
160 static GtkWidget *select_cma_item;
161
162 static int city_dialog_shell_is_modal;
163
164 bool select_menu_cached;
165
166/************************************************************************/
169 static 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/************************************************************************/
188 static 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/************************************************************************/
207 static 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/************************************************************************/
226 static 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
234 && client_has_player()
235 && city_owner(pcity) != client_player())
236 ? NULL : pcity);
237}
238
239/************************************************************************/
242 static 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/************************************************************************/
262 static void city_model_fill(GtkListStore *store,
263 GtkTreeSelection *selection, GHashTable *select)
264{
265 GtkTreeIter iter;
266
267 if (client_has_player()) {
268 city_list_iterate(client_player()->cities, pcity) {
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 }
275 } city_list_iterate_end;
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 }
285 } cities_iterate_end;
286 }
287}
288
289/************************************************************************/
292 void city_report_dialog_popup(bool raise)
293{
294 if (!city_dialog_shell) {
295 city_dialog_shell_is_modal = FALSE;
296
297 create_city_report_dialog(FALSE);
298
299 select_menu_cached = FALSE;
300 }
301
302 gui_dialog_present(city_dialog_shell);
303 hilite_cities_from_canvas();
304 if (raise) {
305 gui_dialog_raise(city_dialog_shell);
306 }
307}
308
309/************************************************************************/
312 void city_report_dialog_popdown(void)
313{
314 if (city_dialog_shell) {
315 gui_dialog_destroy(city_dialog_shell);
316 }
317}
318
319/************************************************************************/
322 static void append_impr_or_unit_to_menu_item(GtkMenuItem *parent_item,
323 bool append_units,
324 bool append_wonders,
325 enum city_operation_type
326 city_operation,
327 TestCityFunc test_func,
328 GCallback callback,
329 int size)
330{
331 GtkWidget *menu;
332 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
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
360 if (!itree_is_selected(city_selection, &it)
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/************************************************************************/
456 static 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/************************************************************************/
472 static 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/************************************************************************/
493 static 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/************************************************************************/
513 static 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/************************************************************************/
532 static 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/************************************************************************/
548 static 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);
559 city_sell_improvement(pcity, improvement_number(sd->target));
560 }
561}
562
563/************************************************************************/
567 static 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)) {
585 itree_select(city_selection, &it);
586 }
587 }
588 } else {
589 GtkTreeSelectionForeachFunc foreach_func;
590
591 connection_do_buffer(&client.conn);
592 switch (city_operation) {
593 case CO_LAST:
594 gtk_tree_selection_selected_foreach(city_selection,
595 worklist_last_impr_or_unit_iterate,
596 GINT_TO_POINTER(cid_encode(target)));
597 break;
598 case CO_CHANGE:
599 gtk_tree_selection_selected_foreach(city_selection,
600 impr_or_unit_iterate,
601 GINT_TO_POINTER(cid_encode(target)));
602 break;
603 case CO_FIRST:
604 gtk_tree_selection_selected_foreach(city_selection,
605 worklist_first_impr_or_unit_iterate,
606 GINT_TO_POINTER(cid_encode(target)));
607 break;
608 case CO_NEXT:
609 gtk_tree_selection_selected_foreach(city_selection,
610 worklist_next_impr_or_unit_iterate,
611 GINT_TO_POINTER(cid_encode(target)));
612 break;
613 case CO_NEXT_TO_LAST:
614 foreach_func = worklist_next_to_last_impr_or_unit_iterate;
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 }
667 connection_do_unbuffer(&client.conn);
668 }
669}
670
671/************************************************************************/
674 static 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 {
684 cma_put_city_under_agent(pcity, cmafec_preset_get_parameter(idx));
685 }
686 refresh_city_dialog(pcity);
687 }
688}
689
690/************************************************************************/
694 static 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,
730 cmafec_preset_get_parameter(idx))) {
731 select = TRUE;
732 }
733 }
734
735 if (select) {
736 itree_select(city_selection, &it);
737 }
738 }
739 } else {
740 gtk_tree_selection_selected_foreach(city_selection,
741 cma_iterate, GINT_TO_POINTER(idx));
742 }
743}
744
745/************************************************************************/
751 static 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
763 if (!can_client_issue_orders()) {
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;
789 city_list_iterate(client.conn.playing->cities, pcity) {
790 if (!cma_is_city_under_agent(pcity, NULL)) {
791 found = 1;
792 break;
793 }
794 } city_list_iterate_end;
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;
808 city_list_iterate(client.conn.playing->cities, pcity) {
809 if (cma_is_city_under_agent(pcity, &parameter)
810 && cmafec_preset_get_index_of_parameter(&parameter) == -1) {
811 found = 1;
812 break;
813 }
814 } city_list_iterate_end;
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;
829 city_list_iterate(client.conn.playing->cities, pcity) {
830 if (cma_is_city_under_agent(pcity, &parameter)
831 && cm_are_parameter_equal(&parameter,
832 cmafec_preset_get_parameter(i))) {
833 found = 1;
834 break;
835 }
836 } city_list_iterate_end;
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/************************************************************************/
857 static 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/************************************************************************/
875 static void append_worklist_callback(GtkMenuItem *menuitem, gpointer data)
876{
877 struct global_worklist *pgwl =
878 global_worklist_by_id(GPOINTER_TO_INT(data));
879
880 fc_assert_ret(city_selection != NULL);
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,
888 append_worklist_foreach,
889 (gpointer) global_worklist_get(pgwl));
890}
891
892/************************************************************************/
896 static 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/************************************************************************/
913 static void set_worklist_callback(GtkMenuItem *menuitem, gpointer data)
914{
915 struct global_worklist *pgwl =
916 global_worklist_by_id(GPOINTER_TO_INT(data));
917
918 fc_assert_ret(city_selection != NULL);
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,
928 set_worklist_foreach,
929 (gpointer) global_worklist_get(pgwl));
930}
931
932/************************************************************************/
936 static 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
960 if (!can_client_issue_orders()) {
961 return;
962 }
963
964 gtk_container_forall(GTK_CONTAINER(menu),
965 (GtkCallback) gtk_widget_destroy, NULL);
966
967 global_worklists_iterate(pgwl) {
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++;
973 } global_worklists_iterate_end;
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/************************************************************************/
986 static void city_report_update_views(void)
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/************************************************************************/
1010 static void toggle_view(GtkCheckMenuItem *item, gpointer data)
1011{
1012 struct city_report_spec *spec = data;
1013
1014 spec->show ^= 1;
1015 city_report_update_views();
1016}
1017
1018/************************************************************************/
1021 static 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/************************************************************************/
1040 static 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"));
1054 city_production_command = item;
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);
1062 create_change_menu(item);
1063
1064 item = gtk_menu_item_new_with_mnemonic(_("Add _First"));
1065 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1066 create_first_menu(item);
1067
1068 item = gtk_menu_item_new_with_mnemonic(_("Add _Next"));
1069 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1070 create_next_menu(item);
1071
1072 item = gtk_menu_item_new_with_mnemonic(_("Add _2nd Last"));
1073 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1074 create_next_to_last_menu(item);
1075
1076 item = gtk_menu_item_new_with_mnemonic(_("Add _Last"));
1077 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1078 create_last_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",
1086 set_worklist_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",
1092 append_worklist_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"));
1101 city_governor_command = item;
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);
1107 city_sell_command = item;
1108 create_sell_menu(item);
1109
1110 item = gtk_menu_item_new_with_mnemonic(_("_Select"));
1111 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
1112 create_select_menu(item);
1113
1114 item = gtk_menu_item_new_with_mnemonic(_("_Display"));
1115 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
1116 update_view_menu(item);
1117 return vbox;
1118}
1119
1120/************************************************************************/
1123 static gint cityrep_sort_func(GtkTreeModel *model, GtkTreeIter *a,
1124 GtkTreeIter *b, gpointer data)
1125{
1126 gint col = GPOINTER_TO_INT(data);
1127 const gchar *str1, *str2;
1128
1129 gtk_tree_model_get(model, a, col, &str1, -1);
1130 gtk_tree_model_get(model, b, col, &str2, -1);
1131
1132 return cityrepfield_compare(str1, str2);
1133}
1134
1135/************************************************************************/
1138 static void create_city_report_dialog(bool make_modal)
1139{
1140 static char **titles;
1141 static char (*buf)[128];
1142 struct city_report_spec *spec;
1143 GtkWidget *w, *sw, *menubar;
1144 int i;
1145
1146 gui_dialog_new(&city_dialog_shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
1147 gui_dialog_set_title(city_dialog_shell, _("Cities"));
1148
1149 gui_dialog_set_default_size(city_dialog_shell, -1, 420);
1150
1151 gui_dialog_response_set_callback(city_dialog_shell,
1152 city_command_callback);
1153
1154 /* menubar */
1155 menubar = create_city_report_menubar();
1156 gui_dialog_add_widget(city_dialog_shell, menubar);
1157
1158 /* buttons */
1159 city_total_buy_cost_label = gtk_label_new(NULL);
1160 gtk_widget_set_hexpand(city_total_buy_cost_label, TRUE);
1161 gtk_label_set_ellipsize(GTK_LABEL(city_total_buy_cost_label),
1162 PANGO_ELLIPSIZE_START);
1163 gtk_container_add(GTK_CONTAINER(city_dialog_shell->action_area),
1164 city_total_buy_cost_label);
1165
1166 w = gui_dialog_add_stockbutton(city_dialog_shell, GTK_STOCK_EXECUTE,
1167 _("_Buy"), CITY_BUY);
1168 city_buy_command = w;
1169
1170 w = gui_dialog_add_stockbutton(city_dialog_shell, GTK_STOCK_ZOOM_IN,
1171 _("_Inspect"), CITY_POPUP);
1172 city_popup_command = w;
1173
1174 w = gui_dialog_add_stockbutton(city_dialog_shell, GTK_STOCK_ZOOM_FIT,
1175 _("Cen_ter"), CITY_CENTER);
1176 city_center_command = w;
1177
1178 gui_dialog_set_default_response(city_dialog_shell,
1179 GTK_RESPONSE_CLOSE);
1180
1181 /* tree view */
1182 buf = fc_realloc(buf, NUM_CREPORT_COLS * sizeof(buf[0]));
1183 titles = fc_realloc(titles, NUM_CREPORT_COLS * sizeof(titles[0]));
1184 for (i = 0; i < NUM_CREPORT_COLS; i++) {
1185 titles[i] = buf[i];
1186 }
1187 get_city_table_header(titles, sizeof(buf[0]));
1188
1189 city_model = city_report_dialog_store_new();
1190
1191 city_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(city_model));
1192 gtk_widget_set_hexpand(city_view, TRUE);
1193 gtk_widget_set_vexpand(city_view, TRUE);
1194 g_object_unref(city_model);
1195 gtk_widget_set_name(city_view, "small_font");
1196 g_signal_connect(city_view, "row_activated",
1197 G_CALLBACK(city_activated_callback), NULL);
1198 city_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(city_view));
1199 gtk_tree_selection_set_mode(city_selection, GTK_SELECTION_MULTIPLE);
1200 g_signal_connect(city_selection, "changed",
1201 G_CALLBACK(city_selection_changed_callback), NULL);
1202
1203 for (i = 0, spec = city_report_specs; i < NUM_CREPORT_COLS; i++, spec++) {
1204 GtkWidget *header;
1205 GtkCellRenderer *renderer;
1206 GtkTreeViewColumn *col;
1207
1208 renderer = gtk_cell_renderer_text_new();
1209 col = gtk_tree_view_column_new_with_attributes(NULL, renderer,
1210 "text", i, NULL);
1211 header = gtk_label_new(titles[i]);
1212 gtk_widget_set_tooltip_text(header, spec->explanation);
1213 gtk_widget_show(header);
1214 gtk_tree_view_column_set_widget(col, header);
1215 gtk_tree_view_column_set_visible(col, spec->show);
1216 gtk_tree_view_column_set_sort_column_id(col, i);
1217 gtk_tree_view_column_set_reorderable(col, TRUE);
1218 g_object_set_data(G_OBJECT(col), "city_report_spec", spec);
1219 gtk_tree_view_append_column(GTK_TREE_VIEW(city_view), col);
1220 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(city_model), i,
1221 cityrep_sort_func, GINT_TO_POINTER(i),
1222 NULL);
1223 }
1224
1225 sw = gtk_scrolled_window_new(NULL, NULL);
1226 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1227 GTK_SHADOW_ETCHED_IN);
1228 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1229 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1230 gtk_container_add(GTK_CONTAINER(sw), city_view);
1231
1232 gtk_container_add(GTK_CONTAINER(city_dialog_shell->vbox), sw);
1233
1234 city_model_fill(city_model, NULL, NULL);
1235 gui_dialog_show_all(city_dialog_shell);
1236
1237 city_selection_changed_callback(city_selection);
1238}
1239
1240/************************************************************************/
1243 static void city_select_all_callback(GtkMenuItem *item, gpointer data)
1244{
1245 gtk_tree_selection_select_all(city_selection);
1246}
1247
1248/************************************************************************/
1251 static void city_unselect_all_callback(GtkMenuItem *item, gpointer data)
1252{
1253 gtk_tree_selection_unselect_all(city_selection);
1254}
1255
1256/************************************************************************/
1259 static void city_invert_selection_callback(GtkMenuItem *item, gpointer data)
1260{
1261 ITree it;
1262 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
1263
1264 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1265 if (itree_is_selected(city_selection, &it)) {
1266 itree_unselect(city_selection, &it);
1267 } else {
1268 itree_select(city_selection, &it);
1269 }
1270 }
1271}
1272
1273/************************************************************************/
1276 static void city_select_coastal_callback(GtkMenuItem *item, gpointer data)
1277{
1278 ITree it;
1279 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
1280
1281 gtk_tree_selection_unselect_all(city_selection);
1282
1283 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1284 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
1285
1286 if (pcity != NULL
1287 && is_terrain_class_near_tile(&(wld.map), pcity->tile, TC_OCEAN)) {
1288 itree_select(city_selection, &it);
1289 }
1290 }
1291}
1292
1293/************************************************************************/
1296 static void same_island_iterate(GtkTreeModel *model, GtkTreePath *path,
1297 GtkTreeIter *iter, gpointer data)
1298{
1299 struct city *selected_pcity = city_model_get(model, iter);
1300 ITree it;
1301
1302 if (NULL == selected_pcity) {
1303 return;
1304 }
1305
1306 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1307 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
1308
1309 if (NULL != pcity
1310 && (tile_continent(pcity->tile)
1311 == tile_continent(selected_pcity->tile))) {
1312 itree_select(city_selection, &it);
1313 }
1314 }
1315}
1316
1317/************************************************************************/
1320 static void city_select_same_island_callback(GtkMenuItem *item, gpointer data)
1321{
1322 gtk_tree_selection_selected_foreach(city_selection,same_island_iterate,NULL);
1323}
1324
1325/************************************************************************/
1328 static void city_select_building_callback(GtkMenuItem *item, gpointer data)
1329{
1330 enum production_class_type which = GPOINTER_TO_INT(data);
1331 ITree it;
1332 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
1333
1334 gtk_tree_selection_unselect_all(city_selection);
1335
1336 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1337 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
1338
1339 if (NULL != pcity
1340 && ((which == PCT_UNIT && VUT_UTYPE == pcity->production.kind)
1341 || (which == PCT_NORMAL_IMPROVEMENT
1342 && VUT_IMPROVEMENT == pcity->production.kind
1343 && !is_wonder(pcity->production.value.building))
1344 || (which == PCT_WONDER
1345 && VUT_IMPROVEMENT == pcity->production.kind
1346 && is_wonder(pcity->production.value.building)))) {
1347 itree_select(city_selection, &it);
1348 }
1349 }
1350}
1351
1352/************************************************************************/
1355 static void buy_iterate(GtkTreeModel *model, GtkTreePath *path,
1356 GtkTreeIter *iter, gpointer data)
1357{
1358 struct city *pcity = city_model_get(model, iter);
1359
1360 if (NULL != pcity) {
1361 cityrep_buy(pcity);
1362 }
1363}
1364
1365/************************************************************************/
1368 static void center_iterate(GtkTreeModel *model, GtkTreePath *path,
1369 GtkTreeIter *iter, gpointer data)
1370{
1371 struct city *pcity = city_model_get(model, iter);
1372
1373 if (NULL != pcity) {
1374 center_tile_mapcanvas(pcity->tile);
1375 }
1376}
1377
1378/************************************************************************/
1381 static void popup_iterate(GtkTreeModel *model, GtkTreePath *path,
1382 GtkTreeIter *iter, gpointer data)
1383{
1384 struct city *pcity = city_model_get(model, iter);
1385
1386 if (NULL != pcity) {
1387 if (gui_options.center_when_popup_city) {
1388 center_tile_mapcanvas(pcity->tile);
1389 }
1390 popup_city_dialog(pcity);
1391 }
1392}
1393
1394/************************************************************************/
1397 static void city_command_callback(struct gui_dialog *dlg, int response,
1398 gpointer data)
1399{
1400 switch (response) {
1401 case CITY_CENTER:
1402 if (1 == gtk_tree_selection_count_selected_rows(city_selection)) {
1403 /* Center to city doesn't make sense if many city are selected. */
1404 gtk_tree_selection_selected_foreach(city_selection, center_iterate,
1405 NULL);
1406 }
1407 break;
1408 case CITY_POPUP:
1409 gtk_tree_selection_selected_foreach(city_selection, popup_iterate, NULL);
1410 break;
1411 case CITY_BUY:
1412 gtk_tree_selection_selected_foreach(city_selection, buy_iterate, NULL);
1413 break;
1414 default:
1415 gui_dialog_destroy(dlg);
1416 break;
1417 }
1418}
1419
1420/************************************************************************/
1423 static void city_activated_callback(GtkTreeView *view, GtkTreePath *path,
1424 GtkTreeViewColumn *col, gpointer data)
1425{
1426 GtkTreeModel *model;
1427 GtkTreeIter iter;
1428 GdkWindow *win;
1429 GdkDeviceManager *manager;
1430 GdkModifierType mask;
1431
1432 model = gtk_tree_view_get_model(view);
1433
1434 if (!gtk_tree_model_get_iter(model, &iter, path)) {
1435 return;
1436 }
1437
1438 win = gdk_get_default_root_window();
1439 manager = gdk_display_get_device_manager(gdk_window_get_display(win));
1440
1441 gdk_window_get_device_position(win,
1442 gdk_device_manager_get_client_pointer(manager),
1443 NULL, NULL, &mask);
1444
1445 if (!(mask & GDK_CONTROL_MASK)) {
1446 popup_iterate(model, path, &iter, NULL);
1447 } else {
1448 center_iterate(model, path, &iter, NULL);
1449 }
1450}
1451
1452/************************************************************************/
1455 void real_city_report_dialog_update(void *unused)
1456{
1457 GHashTable *selected;
1458 ITree iter;
1459 gint city_id;
1460
1461 if (NULL == city_dialog_shell) {
1462 return;
1463 }
1464
1465 /* Save the selection. */
1466 selected = g_hash_table_new(NULL, NULL);
1467 for (itree_begin(GTK_TREE_MODEL(city_model), &iter);
1468 !itree_end(&iter); itree_next(&iter)) {
1469 if (itree_is_selected(city_selection, &iter)) {
1470 itree_get(&iter, CRD_COL_CITY_ID, &city_id, -1);
1471 g_hash_table_insert(selected, GINT_TO_POINTER(city_id), NULL);
1472 }
1473 }
1474
1475 /* Update and restore the selection. */
1476 gtk_list_store_clear(city_model);
1477 city_model_fill(city_model, city_selection, selected);
1478 g_hash_table_destroy(selected);
1479
1480 if (gtk_widget_get_sensitive(city_governor_command)) {
1481 append_cma_to_menu_item(GTK_MENU_ITEM(city_governor_command), TRUE);
1482 }
1483
1484 select_menu_cached = FALSE;
1485}
1486
1487/************************************************************************/
1490 void real_city_report_update_city(struct city *pcity)
1491{
1492 GtkTreeIter iter;
1493
1494 if (NULL == city_dialog_shell) {
1495 return;
1496 }
1497
1498 if (!city_model_find(GTK_TREE_MODEL(city_model), &iter, pcity)) {
1499 gtk_list_store_prepend(city_model, &iter);
1500 }
1501 city_model_set(city_model, &iter, pcity);
1502
1503 update_total_buy_cost();
1504}
1505
1506/************************************************************************/
1509 static void create_change_menu(GtkWidget *item)
1510{
1511 GtkWidget *menu;
1512
1513 menu = gtk_menu_new();
1514 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1515 g_signal_connect(menu, "show", G_CALLBACK(popup_change_menu), NULL);
1516
1517 change_units_item = gtk_menu_item_new_with_label(_("Units"));
1518 gtk_menu_shell_append(GTK_MENU_SHELL(menu), change_units_item);
1519 change_improvements_item = gtk_menu_item_new_with_label(_("Improvements"));
1520 gtk_menu_shell_append(GTK_MENU_SHELL(menu), change_improvements_item);
1521 change_wonders_item = gtk_menu_item_new_with_label(_("Wonders"));
1522 gtk_menu_shell_append(GTK_MENU_SHELL(menu), change_wonders_item);
1523}
1524
1525/************************************************************************/
1528 static void create_last_menu(GtkWidget *item)
1529{
1530 GtkWidget *menu;
1531
1532 menu = gtk_menu_new();
1533 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1534 g_signal_connect(menu, "show", G_CALLBACK(popup_last_menu), NULL);
1535
1536 last_units_item = gtk_menu_item_new_with_label(_("Units"));
1537 gtk_menu_shell_append(GTK_MENU_SHELL(menu), last_units_item);
1538 last_improvements_item = gtk_menu_item_new_with_label(_("Improvements"));
1539 gtk_menu_shell_append(GTK_MENU_SHELL(menu), last_improvements_item);
1540 last_wonders_item = gtk_menu_item_new_with_label(_("Wonders"));
1541 gtk_menu_shell_append(GTK_MENU_SHELL(menu), last_wonders_item);
1542}
1543
1544/************************************************************************/
1547 static void create_first_menu(GtkWidget *item)
1548{
1549 GtkWidget *menu;
1550
1551 menu = gtk_menu_new();
1552 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1553 g_signal_connect(menu, "show", G_CALLBACK(popup_first_menu), NULL);
1554
1555 first_units_item = gtk_menu_item_new_with_label(_("Units"));
1556 gtk_menu_shell_append(GTK_MENU_SHELL(menu), first_units_item);
1557 first_improvements_item = gtk_menu_item_new_with_label(_("Improvements"));
1558 gtk_menu_shell_append(GTK_MENU_SHELL(menu), first_improvements_item);
1559 first_wonders_item = gtk_menu_item_new_with_label(_("Wonders"));
1560 gtk_menu_shell_append(GTK_MENU_SHELL(menu), first_wonders_item);
1561}
1562
1563/************************************************************************/
1566 static void create_next_menu(GtkWidget *item)
1567{
1568 GtkWidget *menu;
1569
1570 menu = gtk_menu_new();
1571 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1572 g_signal_connect(menu, "show", G_CALLBACK(popup_next_menu), NULL);
1573
1574 next_units_item = gtk_menu_item_new_with_label(_("Units"));
1575 gtk_menu_shell_append(GTK_MENU_SHELL(menu), next_units_item);
1576 next_improvements_item = gtk_menu_item_new_with_label(_("Improvements"));
1577 gtk_menu_shell_append(GTK_MENU_SHELL(menu), next_improvements_item);
1578 next_wonders_item = gtk_menu_item_new_with_label(_("Wonders"));
1579 gtk_menu_shell_append(GTK_MENU_SHELL(menu), next_wonders_item);
1580}
1581
1582/************************************************************************/
1585 static void create_next_to_last_menu(GtkWidget *parent_item)
1586{
1587 GtkWidget *menu, *item;
1588
1589 menu = gtk_menu_new();
1590 gtk_menu_item_set_submenu(GTK_MENU_ITEM(parent_item), menu);
1591 g_signal_connect(menu, "show",
1592 G_CALLBACK(popup_next_to_last_menu), NULL);
1593
1594 item = gtk_menu_item_new_with_label(_("Units"));
1595 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1596 next_to_last_units_item = item;
1597
1598 item = gtk_menu_item_new_with_label(_("Improvements"));
1599 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1600 next_to_last_improvements_item = item;
1601
1602 item = gtk_menu_item_new_with_label(_("Wonders"));
1603 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1604 next_to_last_wonders_item = item;
1605}
1606
1607/************************************************************************/
1610 static void create_sell_menu(GtkWidget *item)
1611{
1612 GtkWidget *menu;
1613
1614 menu = gtk_menu_new();
1615 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1616}
1617
1618/************************************************************************/
1621 static void popup_change_menu(GtkMenuShell *menu, gpointer data)
1622{
1623 int n;
1624
1625 n = gtk_tree_selection_count_selected_rows(city_selection);
1626
1627 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(change_improvements_item),
1628 FALSE, FALSE, CO_CHANGE,
1629 can_city_build_now,
1630 G_CALLBACK(select_impr_or_unit_callback), n);
1631 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(change_units_item),
1632 TRUE, FALSE, CO_CHANGE,
1633 can_city_build_now,
1634 G_CALLBACK(select_impr_or_unit_callback), n);
1635 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(change_wonders_item),
1636 FALSE, TRUE, CO_CHANGE,
1637 can_city_build_now,
1638 G_CALLBACK(select_impr_or_unit_callback), n);
1639}
1640
1641/************************************************************************/
1644 static void popup_last_menu(GtkMenuShell *menu, gpointer data)
1645{
1646 int n;
1647
1648 n = gtk_tree_selection_count_selected_rows(city_selection);
1649
1650 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(last_improvements_item),
1651 FALSE, FALSE, CO_LAST,
1652 can_city_build_now,
1653 G_CALLBACK(select_impr_or_unit_callback), n);
1654 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(last_units_item),
1655 TRUE, FALSE, CO_LAST,
1656 can_city_build_now,
1657 G_CALLBACK(select_impr_or_unit_callback), n);
1658 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(last_wonders_item),
1659 FALSE, TRUE, CO_LAST,
1660 can_city_build_now,
1661 G_CALLBACK(select_impr_or_unit_callback), n);
1662}
1663
1664/************************************************************************/
1667 static void popup_first_menu(GtkMenuShell *menu, gpointer data)
1668{
1669 int n;
1670
1671 n = gtk_tree_selection_count_selected_rows(city_selection);
1672
1673 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(first_improvements_item),
1674 FALSE, FALSE, CO_FIRST,
1675 can_city_build_now,
1676 G_CALLBACK(select_impr_or_unit_callback), n);
1677 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(first_units_item),
1678 TRUE, FALSE, CO_FIRST,
1679 can_city_build_now,
1680 G_CALLBACK(select_impr_or_unit_callback), n);
1681 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(first_wonders_item),
1682 FALSE, TRUE, CO_FIRST,
1683 can_city_build_now,
1684 G_CALLBACK(select_impr_or_unit_callback), n);
1685}
1686
1687/************************************************************************/
1690 static void popup_next_menu(GtkMenuShell *menu, gpointer data)
1691{
1692 int n;
1693
1694 n = gtk_tree_selection_count_selected_rows(city_selection);
1695
1696 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(next_improvements_item),
1697 FALSE, FALSE, CO_NEXT,
1698 can_city_build_now,
1699 G_CALLBACK(select_impr_or_unit_callback), n);
1700 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(next_units_item),
1701 TRUE, FALSE, CO_NEXT,
1702 can_city_build_now,
1703 G_CALLBACK(select_impr_or_unit_callback), n);
1704 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(next_wonders_item),
1705 FALSE, TRUE, CO_NEXT,
1706 can_city_build_now,
1707 G_CALLBACK(select_impr_or_unit_callback), n);
1708}
1709
1710/************************************************************************/
1713 static void popup_next_to_last_menu(GtkMenuShell *menu, gpointer data)
1714{
1715 GtkWidget *item;
1716 GCallback callback;
1717 int n;
1718
1719 fc_assert_ret(city_selection != NULL);
1720
1721 n = gtk_tree_selection_count_selected_rows(city_selection);
1722 callback = G_CALLBACK(select_impr_or_unit_callback);
1723
1724 item = next_to_last_improvements_item;
1725 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(item),
1726 FALSE, FALSE, CO_NEXT_TO_LAST,
1727 can_city_build_now,
1728 callback, n);
1729 item = next_to_last_units_item;
1730 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(item),
1731 TRUE, FALSE, CO_NEXT_TO_LAST,
1732 can_city_build_now,
1733 callback, n);
1734 item = next_to_last_wonders_item;
1735 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(item),
1736 FALSE, TRUE, CO_NEXT_TO_LAST,
1737 can_city_build_now,
1738 callback, n);
1739}
1740
1741/************************************************************************/
1744 static void recreate_sell_menu(void)
1745{
1746 int n;
1747 GList *children;
1748 GtkWidget *menu;
1749
1750 n = gtk_tree_selection_count_selected_rows(city_selection);
1751 menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(city_sell_command));
1752 gtk_menu_popdown(GTK_MENU(menu));
1753
1754 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(city_sell_command),
1755 FALSE, FALSE, CO_SELL,
1756 can_city_sell_universal,
1757 G_CALLBACK(select_impr_or_unit_callback),
1758 n);
1759
1760 menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(city_sell_command));
1761 children = gtk_container_get_children(GTK_CONTAINER(menu));
1762
1763 n = g_list_length(children);
1764 gtk_widget_set_sensitive(city_sell_command, n > 0);
1765 g_list_free(children);
1766}
1767
1768/************************************************************************/
1771 static void create_select_menu(GtkWidget *item)
1772{
1773 GtkWidget *menu;
1774
1775 menu = gtk_menu_new();
1776 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1777 g_signal_connect(menu, "show", G_CALLBACK(popup_select_menu), NULL);
1778
1779 item = gtk_menu_item_new_with_label(_("All Cities"));
1780 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1781 g_signal_connect(item, "activate",
1782 G_CALLBACK(city_select_all_callback), NULL);
1783
1784 item = gtk_menu_item_new_with_label(_("No Cities"));
1785 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1786 g_signal_connect(item, "activate",
1787 G_CALLBACK(city_unselect_all_callback), NULL);
1788
1789 item = gtk_menu_item_new_with_label(_("Invert Selection"));
1790 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1791 g_signal_connect(item, "activate",
1792 G_CALLBACK(city_invert_selection_callback), NULL);
1793
1794
1795 item = gtk_separator_menu_item_new();
1796 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1797
1798
1799 item = gtk_menu_item_new_with_label(_("Building Units"));
1800 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1801 g_signal_connect(item, "activate",
1802 G_CALLBACK(city_select_building_callback),
1803 GINT_TO_POINTER(PCT_UNIT));
1804
1805 item = gtk_menu_item_new_with_label( _("Building Improvements"));
1806 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1807 g_signal_connect(item, "activate",
1808 G_CALLBACK(city_select_building_callback),
1809 GINT_TO_POINTER(PCT_NORMAL_IMPROVEMENT));
1810
1811 item = gtk_menu_item_new_with_label(_("Building Wonders"));
1812 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1813 g_signal_connect(item, "activate",
1814 G_CALLBACK(city_select_building_callback),
1815 GINT_TO_POINTER(PCT_WONDER));
1816
1817
1818 item = gtk_separator_menu_item_new();
1819 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1820
1821
1822 select_bunit_item =
1823 gtk_menu_item_new_with_label(_("Building Unit"));
1824 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_bunit_item);
1825
1826 select_bimprovement_item =
1827 gtk_menu_item_new_with_label( _("Building Improvement"));
1828 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_bimprovement_item);
1829
1830 select_bwonder_item =
1831 gtk_menu_item_new_with_label(_("Building Wonder"));
1832 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_bwonder_item);
1833
1834
1835 item = gtk_separator_menu_item_new();
1836 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1837
1838
1839 item = gtk_menu_item_new_with_label(_("Coastal Cities"));
1840 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1841 g_signal_connect(item, "activate",
1842 G_CALLBACK(city_select_coastal_callback), NULL);
1843
1844 select_island_item = gtk_menu_item_new_with_label(_("Same Island"));
1845 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_island_item);
1846 g_signal_connect(select_island_item, "activate",
1847 G_CALLBACK(city_select_same_island_callback), NULL);
1848
1849
1850 item = gtk_separator_menu_item_new();
1851 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1852
1853
1854 select_supported_item = gtk_menu_item_new_with_label(_("Supported Units"));
1855 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_supported_item);
1856
1857 select_present_item = gtk_menu_item_new_with_label(_("Units Present"));
1858 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_present_item);
1859
1860 select_built_improvements_item =
1861 gtk_menu_item_new_with_label(_("Improvements in City"));
1862 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_built_improvements_item);
1863
1864 select_built_wonders_item =
1865 gtk_menu_item_new_with_label(_("Wonders in City"));
1866 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_built_wonders_item);
1867
1868
1869 item = gtk_separator_menu_item_new();
1870 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1871
1872
1873 select_units_item =
1874 gtk_menu_item_new_with_label(_("Available Units"));
1875 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_units_item);
1876 select_improvements_item =
1877 gtk_menu_item_new_with_label(_("Available Improvements"));
1878 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_improvements_item);
1879 select_wonders_item =
1880 gtk_menu_item_new_with_label(_("Available Wonders"));
1881 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_wonders_item);
1882 select_cma_item =
1883 gtk_menu_item_new_with_label(_("Citizen Governor"));
1884 gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_cma_item);
1885}
1886
1887/************************************************************************/
1890 static bool city_building_impr_or_unit(const struct city *pcity,
1891 const struct universal *target)
1892{
1893 return are_universals_equal(&pcity->production, target);
1894}
1895
1896/************************************************************************/
1899 static void popup_select_menu(GtkMenuShell *menu, gpointer data)
1900{
1901 int n;
1902
1903 if (select_menu_cached)
1904 return;
1905
1906 n = gtk_tree_selection_count_selected_rows(city_selection);
1907 gtk_widget_set_sensitive(select_island_item, (n > 0));
1908
1909 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_bunit_item),
1910 TRUE, FALSE, CO_NONE,
1911 city_building_impr_or_unit,
1912 G_CALLBACK(select_impr_or_unit_callback), -1);
1913 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_bimprovement_item),
1914 FALSE, FALSE, CO_NONE,
1915 city_building_impr_or_unit,
1916 G_CALLBACK(select_impr_or_unit_callback), -1);
1917 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_bwonder_item),
1918 FALSE, TRUE, CO_NONE,
1919 city_building_impr_or_unit,
1920 G_CALLBACK(select_impr_or_unit_callback), -1);
1921
1922 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_supported_item),
1923 TRUE, FALSE, CO_NONE,
1924 city_unit_supported,
1925 G_CALLBACK(select_impr_or_unit_callback), -1);
1926 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_present_item),
1927 TRUE, FALSE, CO_NONE,
1928 city_unit_present,
1929 G_CALLBACK(select_impr_or_unit_callback), -1);
1930 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_built_improvements_item),
1931 FALSE, FALSE, CO_NONE,
1932 city_building_present,
1933 G_CALLBACK(select_impr_or_unit_callback), -1);
1934 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_built_wonders_item),
1935 FALSE, TRUE, CO_NONE,
1936 city_building_present,
1937 G_CALLBACK(select_impr_or_unit_callback), -1);
1938
1939 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_improvements_item),
1940 FALSE, FALSE, CO_NONE,
1941 can_city_build_now,
1942 G_CALLBACK(select_impr_or_unit_callback), -1);
1943 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_units_item),
1944 TRUE, FALSE, CO_NONE,
1945 can_city_build_now,
1946 G_CALLBACK(select_impr_or_unit_callback), -1);
1947 append_impr_or_unit_to_menu_item(GTK_MENU_ITEM(select_wonders_item),
1948 FALSE, TRUE, CO_NONE,
1949 can_city_build_now,
1950 G_CALLBACK(select_impr_or_unit_callback), -1);
1951 append_cma_to_menu_item(GTK_MENU_ITEM(select_cma_item), FALSE);
1952
1953 select_menu_cached = TRUE;
1954}
1955
1956/************************************************************************/
1960 static void update_total_buy_cost(void)
1961{
1962 GtkWidget *label, *view;
1963 GList *rows, *p;
1964 GtkTreeModel *model;
1965 GtkTreeSelection *sel;
1966 GtkTreePath *path;
1967 GtkTreeIter iter;
1968 struct city *pcity;
1969 int total = 0;
1970
1971 view = city_view;
1972 label = city_total_buy_cost_label;
1973
1974 if (!view || !label) {
1975 return;
1976 }
1977
1978 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1979 rows = gtk_tree_selection_get_selected_rows(sel, &model);
1980
1981 for (p = rows; p != NULL; p = p->next) {
1982 path = p->data;
1983 if (gtk_tree_model_get_iter(model, &iter, path)) {
1984 if ((pcity = city_model_get(model, &iter))) {
1985 total += pcity->client.buy_cost;
1986 }
1987 }
1988 gtk_tree_path_free(path);
1989 }
1990 g_list_free(rows);
1991
1992 if (total > 0) {
1993 gchar *buf = g_strdup_printf(_("Total Buy Cost: %d"), total);
1994
1995 gtk_label_set_text(GTK_LABEL(label), buf);
1996 g_free(buf);
1997 } else {
1998 gtk_label_set_text(GTK_LABEL(label), NULL);
1999 }
2000}
2001
2002/************************************************************************/
2006 static void city_selection_changed_callback(GtkTreeSelection *selection)
2007{
2008 int n;
2009 bool obs_may, plr_may;
2010
2011 n = gtk_tree_selection_count_selected_rows(selection);
2012 obs_may = n > 0;
2013 plr_may = obs_may && can_client_issue_orders();
2014
2015 gtk_widget_set_sensitive(city_production_command, plr_may);
2016 gtk_widget_set_sensitive(city_governor_command, plr_may);
2017 gtk_widget_set_sensitive(city_center_command, obs_may);
2018 gtk_widget_set_sensitive(city_popup_command, obs_may);
2019 gtk_widget_set_sensitive(city_buy_command, plr_may);
2020 if (plr_may) {
2021 recreate_sell_menu();
2022 } else {
2023 gtk_widget_set_sensitive(city_sell_command, FALSE);
2024 }
2025
2026 update_total_buy_cost();
2027}
2028
2029/************************************************************************/
2032 static void clear_worklist_foreach_func(GtkTreeModel *model,
2033 GtkTreePath *path,
2034 GtkTreeIter *iter,
2035 gpointer data)
2036{
2037 struct city *pcity = city_model_get(model, iter);
2038
2039 if (NULL != pcity) {
2040 struct worklist empty;
2041
2042 worklist_init(&empty);
2043 city_set_worklist(pcity, &empty);
2044 }
2045}
2046
2047/************************************************************************/
2050 static void city_clear_worklist_callback(GtkMenuItem *item, gpointer data)
2051{
2052 struct connection *pconn = &client.conn;
2053
2054 fc_assert_ret(city_selection != NULL);
2055
2056 connection_do_buffer(pconn);
2057 gtk_tree_selection_selected_foreach(city_selection,
2058 clear_worklist_foreach_func, NULL);
2059 connection_do_unbuffer(pconn);
2060}
2061
2062/************************************************************************/
2067 void hilite_cities_from_canvas(void)
2068{
2069 ITree it;
2070 GtkTreeModel *model;
2071
2072 if (!city_dialog_shell) {
2073 return;
2074 }
2075
2076 model = GTK_TREE_MODEL(city_model);
2077
2078 gtk_tree_selection_unselect_all(city_selection);
2079
2080 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
2081 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
2082
2083 if (NULL != pcity && is_city_hilited(pcity)) {
2084 itree_select(city_selection, &it);
2085 }
2086 }
2087}
2088
2089/************************************************************************/
2092 void toggle_city_hilite(struct city *pcity, bool on_off)
2093{
2094 GtkTreeIter iter;
2095
2096 if (NULL == city_dialog_shell) {
2097 return;
2098 }
2099
2100 if (city_model_find(GTK_TREE_MODEL(city_model), &iter, pcity)) {
2101 if (on_off) {
2102 gtk_tree_selection_select_iter(city_selection, &iter);
2103 } else {
2104 gtk_tree_selection_unselect_iter(city_selection, &iter);
2105 }
2106 }
2107}
n
#define n
Definition astring.c:77
can_city_build_now
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Definition city.c:989
city_has_building
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1212
city.h
cities_iterate_end
#define cities_iterate_end
Definition city.h:497
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:488
cities_iterate
#define cities_iterate(pcity)
Definition city.h:492
city_owner
#define city_owner(_pcity_)
Definition city.h:543
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:490
production_class_type
production_class_type
Definition city.h:38
PCT_UNIT
@ PCT_UNIT
Definition city.h:39
PCT_NORMAL_IMPROVEMENT
@ PCT_NORMAL_IMPROVEMENT
Definition city.h:40
PCT_WONDER
@ PCT_WONDER
Definition city.h:41
get_city_dialog_production_row
void get_city_dialog_production_row(char *buf[], size_t column_size, struct universal *target, struct city *pcity)
Definition citydlg_common.c:364
city_set_worklist
int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
Definition citydlg_common.c:1273
city_queue_insert
bool city_queue_insert(struct city *pcity, int position, struct universal *item)
Definition citydlg_common.c:1384
city_queue_insert_worklist
bool city_queue_insert_worklist(struct city *pcity, int position, const struct worklist *worklist)
Definition citydlg_common.c:1412
city_set_queue
bool city_set_queue(struct city *pcity, const struct worklist *pqueue)
Definition citydlg_common.c:1459
city_change_production
int city_change_production(struct city *pcity, struct universal *target)
Definition citydlg_common.c:1261
city_sell_improvement
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
Definition citydlg_common.c:1517
citydlg_common.h
popup_city_dialog
void popup_city_dialog(struct city *pcity)
Definition update_queue.c:623
refresh_city_dialog
void refresh_city_dialog(struct city *pcity)
Definition update_queue.c:632
can_city_sell_universal
bool can_city_sell_universal(const struct city *pcity, const struct universal *target)
Definition cityrepdata.c:1104
city_report_specs
struct city_report_spec * city_report_specs
Definition cityrepdata.c:798
cityrepfield_compare
int cityrepfield_compare(const char *str1, const char *str2)
Definition cityrepdata.c:1077
cityrepdata.h
NUM_CREPORT_COLS
#define NUM_CREPORT_COLS
Definition cityrepdata.h:25
city_model
Definition cityrep.h:103
client
struct civclient client
Definition client_main.c:149
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1265
client_has_player
bool client_has_player(void)
Definition client_main.c:1365
client_main.h
client_player
#define client_player()
Definition client_main.h:106
city_unit_supported
bool city_unit_supported(const struct city *pcity, const struct universal *target)
Definition climisc.c:537
cityrep_buy
void cityrep_buy(struct city *pcity)
Definition climisc.c:1137
name_and_sort_items
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:633
cid_encode
cid cid_encode(struct universal target)
Definition climisc.c:475
city_building_present
bool city_building_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:575
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:518
city_unit_present
bool city_unit_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:556
collect_production_targets
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:683
climisc.h
MAX_NUM_PRODUCTION_TARGETS
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:87
TestCityFunc
bool(* TestCityFunc)(const struct city *, const struct universal *)
Definition climisc.h:85
cm_are_parameter_equal
bool cm_are_parameter_equal(const struct cm_parameter *const p1, const struct cm_parameter *const p2)
Definition cm.c:2136
cma_is_city_under_agent
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:550
cma_put_city_under_agent
void cma_put_city_under_agent(struct city *pcity, const struct cm_parameter *const parameter)
Definition cma_core.c:522
cma_release_city
void cma_release_city(struct city *pcity)
Definition cma_core.c:540
cmafec_preset_get_descr
char * cmafec_preset_get_descr(int idx)
Definition cma_fec.c:169
cmafec_preset_get_parameter
const struct cm_parameter * cmafec_preset_get_parameter(int idx)
Definition cma_fec.c:182
cmafec_preset_get_index_of_parameter
int cmafec_preset_get_index_of_parameter(const struct cm_parameter *const parameter)
Definition cma_fec.c:196
cmafec_preset_num
int cmafec_preset_num(void)
Definition cma_fec.c:213
cma_fec.h
connection_do_buffer
void connection_do_buffer(struct connection *pc)
Definition connection.c:323
connection_do_unbuffer
void connection_do_unbuffer(struct connection *pc)
Definition connection.c:335
id
int int id
Definition editgui_g.h:28
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
wld
struct world wld
Definition game.c:58
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:102
game.h
global_worklist_by_id
struct global_worklist * global_worklist_by_id(int id)
Definition global_worklist.c:298
global_worklist_name
const char * global_worklist_name(const struct global_worklist *pgwl)
Definition global_worklist.c:323
global_worklist_id
int global_worklist_id(const struct global_worklist *pgwl)
Definition global_worklist.c:288
global_worklist_get
const struct worklist * global_worklist_get(const struct global_worklist *pgwl)
Definition global_worklist.c:276
global_worklist.h
global_worklists_iterate
#define global_worklists_iterate(pgwl)
Definition global_worklist.h:65
global_worklists_iterate_end
#define global_worklists_iterate_end
Definition global_worklist.h:68
append_worklist_foreach
static void append_worklist_foreach(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:857
select_wonders_item
static GtkWidget * select_wonders_item
Definition cityrep.c:159
create_city_report_dialog
static void create_city_report_dialog(bool make_modal)
Definition cityrep.c:1138
next_to_last_wonders_item
static GtkWidget * next_to_last_wonders_item
Definition cityrep.c:144
city_governor_command
static GtkWidget * city_governor_command
Definition cityrep.c:122
city_invert_selection_callback
static void city_invert_selection_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1259
city_popup_command
static GtkWidget * city_popup_command
Definition cityrep.c:119
select_cma_item
static GtkWidget * select_cma_item
Definition cityrep.c:160
worklist_next_impr_or_unit_iterate
static void worklist_next_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:513
last_wonders_item
static GtkWidget * last_wonders_item
Definition cityrep.c:132
create_first_menu
static void create_first_menu(GtkWidget *item)
Definition cityrep.c:1547
create_next_to_last_menu
static void create_next_to_last_menu(GtkWidget *item)
Definition cityrep.c:1585
city_total_buy_cost_label
static GtkWidget * city_total_buy_cost_label
Definition cityrep.c:124
city_buy_command
static GtkWidget * city_buy_command
Definition cityrep.c:120
update_total_buy_cost
static void update_total_buy_cost(void)
Definition cityrep.c:1960
change_units_item
static GtkWidget * change_units_item
Definition cityrep.c:127
real_city_report_dialog_update
void real_city_report_dialog_update(void *unused)
Definition cityrep.c:1455
CRD_COL_CITY_ID
#define CRD_COL_CITY_ID
Definition cityrep.c:107
last_units_item
static GtkWidget * last_units_item
Definition cityrep.c:131
popup_next_to_last_menu
static void popup_next_to_last_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1713
real_city_report_update_city
void real_city_report_update_city(struct city *pcity)
Definition cityrep.c:1490
create_next_menu
static void create_next_menu(GtkWidget *item)
Definition cityrep.c:1566
city_select_building_callback
static void city_select_building_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1328
popup_iterate
static void popup_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1381
create_select_menu
static void create_select_menu(GtkWidget *item)
Definition cityrep.c:1771
city_activated_callback
static void city_activated_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition cityrep.c:1423
select_impr_or_unit_callback
static void select_impr_or_unit_callback(GtkWidget *wdg, gpointer data)
Definition cityrep.c:567
impr_or_unit_iterate
static void impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:456
select_improvements_item
static GtkWidget * select_improvements_item
Definition cityrep.c:157
city_model_fill
static void city_model_fill(GtkListStore *store, GtkTreeSelection *selection, GHashTable *select)
Definition cityrep.c:262
center_iterate
static void center_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1368
CITY_POPUP
@ CITY_POPUP
Definition cityrep.c:101
CITY_CENTER
@ CITY_CENTER
Definition cityrep.c:101
CITY_BUY
@ CITY_BUY
Definition cityrep.c:101
toggle_city_hilite
void toggle_city_hilite(struct city *pcity, bool on_off)
Definition cityrep.c:2092
city_building_impr_or_unit
static bool city_building_impr_or_unit(const struct city *pcity, const struct universal *target)
Definition cityrep.c:1890
select_supported_item
static GtkWidget * select_supported_item
Definition cityrep.c:152
select_bimprovement_item
static GtkWidget * select_bimprovement_item
Definition cityrep.c:149
CMA_NONE
#define CMA_NONE
Definition cityrep.c:64
select_units_item
static GtkWidget * select_units_item
Definition cityrep.c:158
select_island_item
static GtkWidget * select_island_item
Definition cityrep.c:146
cityrep_sort_func
static gint cityrep_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data)
Definition cityrep.c:1123
change_improvements_item
static GtkWidget * change_improvements_item
Definition cityrep.c:126
city_model_get
static struct city * city_model_get(GtkTreeModel *model, GtkTreeIter *iter)
Definition cityrep.c:226
append_impr_or_unit_to_menu_item
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
city_select_coastal_callback
static void city_select_coastal_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1276
production_menu_shown
static void production_menu_shown(GtkWidget *widget, gpointer data)
Definition cityrep.c:936
popup_select_menu
static void popup_select_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1899
popup_first_menu
static void popup_first_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1667
city_command_callback
static void city_command_callback(struct gui_dialog *dlg, int response, gpointer data)
Definition cityrep.c:1397
city_model_set
static void city_model_set(GtkListStore *store, GtkTreeIter *iter, struct city *pcity)
Definition cityrep.c:207
last_improvements_item
static GtkWidget * last_improvements_item
Definition cityrep.c:130
city_clear_worklist_callback
static void city_clear_worklist_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:2050
city_model
static GtkListStore * city_model
Definition cityrep.c:106
clear_worklist_foreach_func
static void clear_worklist_foreach_func(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:2032
city_sell_command
static GtkWidget * city_sell_command
Definition cityrep.c:123
append_cma_to_menu_item
static void append_cma_to_menu_item(GtkMenuItem *parent_item, bool change_cma)
Definition cityrep.c:751
select_bwonder_item
static GtkWidget * select_bwonder_item
Definition cityrep.c:150
NEG_VAL
#define NEG_VAL(x)
Definition cityrep.c:61
city_select_all_callback
static void city_select_all_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1243
CMA_CUSTOM
#define CMA_CUSTOM
Definition cityrep.c:65
popup_last_menu
static void popup_last_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1644
sell_impr_iterate
static void sell_impr_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:548
city_selection
static GtkTreeSelection * city_selection
Definition cityrep.c:105
create_last_menu
static void create_last_menu(GtkWidget *item)
Definition cityrep.c:1528
same_island_iterate
static void same_island_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1296
change_wonders_item
static GtkWidget * change_wonders_item
Definition cityrep.c:128
first_improvements_item
static GtkWidget * first_improvements_item
Definition cityrep.c:134
city_select_same_island_callback
static void city_select_same_island_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1320
select_built_wonders_item
static GtkWidget * select_built_wonders_item
Definition cityrep.c:155
set_worklist_callback
static void set_worklist_callback(GtkMenuItem *menuitem, gpointer data)
Definition cityrep.c:913
city_selection_changed_callback
static void city_selection_changed_callback(GtkTreeSelection *selection)
Definition cityrep.c:2006
city_model_find
static gboolean city_model_find(GtkTreeModel *model, GtkTreeIter *iter, const struct city *pcity)
Definition cityrep.c:242
worklist_next_to_last_impr_or_unit_iterate
static void worklist_next_to_last_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:532
next_to_last_units_item
static GtkWidget * next_to_last_units_item
Definition cityrep.c:143
next_to_last_improvements_item
static GtkWidget * next_to_last_improvements_item
Definition cityrep.c:142
city_production_command
static GtkWidget * city_production_command
Definition cityrep.c:121
city_report_dialog_store_new
static GtkListStore * city_report_dialog_store_new(void)
Definition cityrep.c:188
city_dialog_shell_is_modal
static int city_dialog_shell_is_modal
Definition cityrep.c:162
create_city_report_menubar
static GtkWidget * create_city_report_menubar(void)
Definition cityrep.c:1040
city_report_update_views
static void city_report_update_views(void)
Definition cityrep.c:986
get_city_table_header
static void get_city_table_header(char **text, int n)
Definition cityrep.c:169
select_bunit_item
static GtkWidget * select_bunit_item
Definition cityrep.c:148
hilite_cities_from_canvas
void hilite_cities_from_canvas(void)
Definition cityrep.c:2067
city_report_dialog_popdown
void city_report_dialog_popdown(void)
Definition cityrep.c:312
create_sell_menu
static void create_sell_menu(GtkWidget *item)
Definition cityrep.c:1610
city_report_dialog_popup
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
city_view
static GtkWidget * city_view
Definition cityrep.c:104
select_present_item
static GtkWidget * select_present_item
Definition cityrep.c:153
update_view_menu
static void update_view_menu(GtkWidget *show_item)
Definition cityrep.c:1021
select_built_improvements_item
static GtkWidget * select_built_improvements_item
Definition cityrep.c:154
city_dialog_shell
static struct gui_dialog * city_dialog_shell
Definition cityrep.c:98
worklist_first_impr_or_unit_iterate
static void worklist_first_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:493
next_improvements_item
static GtkWidget * next_improvements_item
Definition cityrep.c:138
popup_change_menu
static void popup_change_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1621
cma_iterate
static void cma_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:674
set_worklist_foreach
static void set_worklist_foreach(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:896
toggle_view
static void toggle_view(GtkCheckMenuItem *item, gpointer data)
Definition cityrep.c:1010
append_worklist_callback
static void append_worklist_callback(GtkMenuItem *menuitem, gpointer data)
Definition cityrep.c:875
city_unselect_all_callback
static void city_unselect_all_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1251
popup_next_menu
static void popup_next_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1690
worklist_last_impr_or_unit_iterate
static void worklist_last_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:472
next_wonders_item
static GtkWidget * next_wonders_item
Definition cityrep.c:140
first_units_item
static GtkWidget * first_units_item
Definition cityrep.c:135
next_units_item
static GtkWidget * next_units_item
Definition cityrep.c:139
first_wonders_item
static GtkWidget * first_wonders_item
Definition cityrep.c:136
city_center_command
static GtkWidget * city_center_command
Definition cityrep.c:118
buy_iterate
static void buy_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1355
select_menu_cached
bool select_menu_cached
Definition cityrep.c:164
city_operation_type
city_operation_type
Definition cityrep.c:73
CO_SELL
@ CO_SELL
Definition cityrep.c:74
CO_NEXT_TO_LAST
@ CO_NEXT_TO_LAST
Definition cityrep.c:74
CO_NEXT
@ CO_NEXT
Definition cityrep.c:74
CO_CHANGE
@ CO_CHANGE
Definition cityrep.c:74
CO_FIRST
@ CO_FIRST
Definition cityrep.c:74
CO_LAST
@ CO_LAST
Definition cityrep.c:74
CO_NONE
@ CO_NONE
Definition cityrep.c:74
recreate_sell_menu
static void recreate_sell_menu(void)
Definition cityrep.c:1744
create_change_menu
static void create_change_menu(GtkWidget *item)
Definition cityrep.c:1509
select_cma_callback
static void select_cma_callback(GtkWidget *w, gpointer data)
Definition cityrep.c:694
top_notebook
GtkWidget * top_notebook
Definition gui_main.c:128
gui_dialog_destroy
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:951
gui_dialog_present
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:834
gui_dialog_set_default_response
void gui_dialog_set_default_response(struct gui_dialog *dlg, int response)
Definition gui_stuff.c:733
itree_get
void itree_get(ITree *it,...)
Definition gui_stuff.c:158
gui_dialog_raise
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:864
gui_dialog_new
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:504
gui_dialog_add_widget
GtkWidget * gui_dialog_add_widget(struct gui_dialog *dlg, GtkWidget *widget)
Definition gui_stuff.c:721
gui_dialog_response_set_callback
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:985
itree_begin
void itree_begin(GtkTreeModel *model, ITree *it)
Definition gui_stuff.c:121
itree_unselect
void itree_unselect(GtkTreeSelection *selection, ITree *it)
Definition gui_stuff.c:200
gui_dialog_add_stockbutton
GtkWidget * gui_dialog_add_stockbutton(struct gui_dialog *dlg, const char *stock, const char *text, int response)
Definition gui_stuff.c:690
gui_dialog_show_all
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:794
itree_select
void itree_select(GtkTreeSelection *selection, ITree *it)
Definition gui_stuff.c:192
gui_dialog_set_title
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:932
gui_dialog_set_default_size
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:916
itree_next
void itree_next(ITree *it)
Definition gui_stuff.c:138
itree_is_selected
gboolean itree_is_selected(GtkTreeSelection *selection, ITree *it)
Definition gui_stuff.c:184
gtk_aux_menu_bar_new
GtkWidget * gtk_aux_menu_bar_new(void)
Definition gui_stuff.c:249
itree_end
gboolean itree_end(ITree *it)
Definition gui_stuff.c:130
TREE_ITER_PTR
#define TREE_ITER_PTR(x)
Definition gui_stuff.h:37
gui_stuff.h
chatline.h
citydlg.h
cityrep.h
gui_main.h
mapctrl.h
mapview.h
optiondlg.h
repodlgs.h
impr_sell_gold
int impr_sell_gold(const struct impr_type *pimprove)
Definition improvement.c:332
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:182
is_wonder
bool is_wonder(const struct impr_type *pimprove)
Definition improvement.c:341
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:241
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_action
#define fc_assert_action(condition, action)
Definition log.h:187
is_city_hilited
bool is_city_hilited(struct city *pcity)
Definition mapctrl_common.c:302
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1222
mapview_common.h
fc_realloc
#define fc_realloc(ptr, sz)
Definition mem.h:36
gui_options
struct client_options gui_options
Definition options.c:71
options.h
packets.h
cities
struct city_list * cities
Definition packhand.c:117
are_universals_equal
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Definition requirements.c:5278
shared.h
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
size
size_t size
Definition specvec.h:72
ITree
Definition gui_stuff.h:31
callback
Definition gui_main.c:2187
city_report_spec
Definition cityrepdata.h:27
city_report_spec::func
const char *(* func)(const struct city *pcity, const void *data)
Definition cityrepdata.h:34
city_report_spec::width
int width
Definition cityrepdata.h:29
city_report_spec::title2
const char * title2
Definition cityrepdata.h:31
city_report_spec::data
void * data
Definition cityrepdata.h:33
city_report_spec::show
bool show
Definition cityrepdata.h:28
city_report_spec::explanation
const char * explanation
Definition cityrepdata.h:32
city_report_spec::title1
const char * title1
Definition cityrepdata.h:30
city
Definition city.h:309
city::did_sell
bool did_sell
Definition city.h:367
city::id
int id
Definition city.h:315
city::worklist
struct worklist worklist
Definition city.h:387
city::production
struct universal production
Definition city.h:382
city::buy_cost
int buy_cost
Definition city.h:449
city::tile
struct tile * tile
Definition city.h:311
city::client
struct city::@17::@20 client
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::center_when_popup_city
bool center_when_popup_city
Definition options.h:154
cm_parameter
Definition cm.h:40
connection
Definition connection.h:141
connection::playing
struct player * playing
Definition connection.h:156
global_worklist
Definition global_worklist.c:49
gui_dialog
Definition gui_stuff.h:69
gui_dialog::action_area
GtkWidget * action_area
Definition gui_stuff.h:72
gui_dialog::vbox
GtkWidget * vbox
Definition gui_stuff.h:71
impr_type
Definition improvement.h:68
item
Definition climisc.h:80
item::item
struct universal item
Definition climisc.h:81
player::cities
struct city_list * cities
Definition player.h:281
sell_data
Definition cityrep.c:67
sell_data::gold
int gold
Definition cityrep.c:69
sell_data::count
int count
Definition cityrep.c:68
sell_data::target
const struct impr_type * target
Definition cityrep.c:70
test_func
Definition mapgen.c:679
universal
Definition fc_types.h:756
universal::kind
enum universals_n kind
Definition fc_types.h:758
universal::value
universals_u value
Definition fc_types.h:757
view
Definition mapview_common.h:36
widget
Definition widget.h:112
worklist
Definition worklist.h:28
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
is_terrain_class_near_tile
bool is_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
Definition terrain.c:600
tile_continent
#define tile_continent(_tile)
Definition tile.h:91
universals_u::building
const struct impr_type * building
Definition fc_types.h:598
unit.h
worklist_init
void worklist_init(struct worklist *pwl)
Definition worklist.c:38
worklist_length
int worklist_length(const struct worklist *pwl)
Definition worklist.c:57