24#include <gdk/gdkkeysyms.h>
68#define CITIZENS_DLG_COL_STYLE (0 + num_citizens_cols)
69#define CITIZENS_DLG_COL_WEIGHT (1 + num_citizens_cols)
70#define CITIZENS_DLG_COL_ID (2 + num_citizens_cols)
83#define SPECLIST_TAG dialog
84#define SPECLIST_TYPE struct citizens_dialog
87#define dialog_list_iterate(dialoglist, pdialog) \
88 TYPED_LIST_ITERATE(struct citizens_dialog, dialoglist, pdialog)
89#define dialog_list_iterate_end LIST_ITERATE_END
110 if (nationality == 0) {
135 model_types[i] = GDK_TYPE_PIXBUF;
138 model_types[i] = GDK_TYPE_PIXBUF;
141 model_types[i] = G_TYPE_BOOLEAN;
145 model_types[i] = G_TYPE_STRING;
150 model_types[i++] = G_TYPE_INT;
151 model_types[i++] = G_TYPE_INT;
152 model_types[i++] = G_TYPE_INT;
154 store = gtk_tree_store_newv(i, model_types);
173 GtkWidget *frame, *sw;
180 = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(pdialog->
store));
181 g_object_unref(pdialog->
store);
183 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(pdialog->
sort),
185 GTK_SORT_DESCENDING);
188 = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pdialog->
sort));
189 gtk_widget_set_halign(pdialog->
list, GTK_ALIGN_CENTER);
190 g_object_unref(pdialog->
sort);
194 GtkCellRenderer *renderer;
195 GtkTreeViewColumn *col;
200 switch (pcol->
type) {
202 renderer = gtk_cell_renderer_pixbuf_new();
203 col = gtk_tree_view_column_new_with_attributes(
_(pcol->
title), renderer,
207 renderer = gtk_cell_renderer_text_new();
208 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
210 col = gtk_tree_view_column_new_with_attributes(
_(pcol->
title), renderer,
215 gtk_tree_view_column_set_sort_column_id(col, i);
218 renderer = gtk_cell_renderer_text_new();
219 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
221 col = gtk_tree_view_column_new_with_attributes(
_(pcol->
title), renderer,
226 gtk_tree_view_column_set_sort_column_id(col, i);
227 g_object_set(renderer,
"xalign", 1.0, NULL);
228 gtk_tree_view_column_set_alignment(col, 1.0);
238 gtk_tree_view_append_column(GTK_TREE_VIEW(pdialog->
list), col);
242 gtk_widget_set_hexpand(GTK_WIDGET(pdialog->
list),
TRUE);
243 gtk_widget_set_vexpand(GTK_WIDGET(pdialog->
list),
TRUE);
245 sw = gtk_scrolled_window_new(NULL, NULL);
246 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
247 GTK_POLICY_AUTOMATIC,
248 GTK_POLICY_AUTOMATIC);
249 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
251 gtk_container_add(GTK_CONTAINER(sw), pdialog->
list);
253 frame = gtk_frame_new(
_(
"Citizens"));
254 gtk_container_add(GTK_CONTAINER(frame), sw);
256 pdialog->
shell = frame;
287 if (pdialog->pcity ==
pcity) {
302 if (pdialog == NULL) {
306 gtk_tree_store_clear(pdialog->
store);
310 gtk_tree_store_append(pdialog->
store, &iter, NULL);
323 int style = PANGO_STYLE_NORMAL, weight = PANGO_WEIGHT_NORMAL;
329 switch (pcol->
type) {
332 gtk_tree_store_set(store, it, k, pcol->
func(pcity, pslot), -1);
336 if (pixbuf != NULL) {
337 gtk_tree_store_set(store, it, k, pixbuf, -1);
338 g_object_unref(pixbuf);
351 weight = PANGO_WEIGHT_BOLD;
352 style = PANGO_STYLE_NORMAL;
355 gtk_tree_store_set(store, it,
369 if (pdialog == NULL) {
373 gtk_widget_hide(pdialog->
shell);
377 gtk_widget_destroy(pdialog->
shell);
392 gtk_widget_show_all(pdialog->
shell);
395 return pdialog->
shell;
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
#define citizens_iterate_end
#define citizens_iterate(_pcity, _pslot, _nationality)
#define city_owner(_pcity_)
#define CITIZENS_DLG_COL_STYLE
void citizens_dialog_init(void)
static const char * col_citizens(const struct city *pcity, const struct player_slot *pslot)
GtkWidget * citizens_dialog_display(const struct city *pcity)
static struct citizens_column citizens_cols[]
void citizens_dialog_refresh(const struct city *pcity)
#define dialog_list_iterate_end
static struct citizens_dialog * citizens_dialog_create(const struct city *pcity)
#define CITIZENS_DLG_COL_ID
static const int num_citizens_cols
#define CITIZENS_DLG_COL_WEIGHT
#define dialog_list_iterate(dialoglist, pdialog)
void citizens_dialog_close(const struct city *pcity)
static struct dialog_list * dialog_list
static GtkTreeStore * citizens_dialog_store_new(void)
static int citizens_dialog_default_sort_column(void)
static const char * col_nation(const struct city *pcity, const struct player_slot *pslot)
static struct citizens_dialog * citizens_dialog_get(const struct city *pcity)
static void citizens_dialog_row(GtkTreeStore *store, GtkTreeIter *it, const struct city *pcity, const struct player_slot *pslot)
void citizens_dialog_done(void)
GdkPixbuf * get_flag(const struct nation_type *nation)
#define fc_assert(condition)
const char * nation_adjective_for_player(const struct player *pplayer)
struct nation_type * nation_of_player(const struct player *pplayer)
int player_slot_index(const struct player_slot *pslot)
struct player * player_slot_get_player(const struct player_slot *pslot)
const char *(* func)(const struct city *, const struct player_slot *)
enum player_dlg_column_type type
const struct city * pcity
int fc_snprintf(char *str, size_t n, const char *format,...)