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);
172 GtkWidget *frame, *sw;
179 = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(pdialog->
store));
180 g_object_unref(pdialog->
store);
182 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(pdialog->
sort),
184 GTK_SORT_DESCENDING);
187 = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pdialog->
sort));
188 gtk_widget_set_halign(pdialog->
list, GTK_ALIGN_CENTER);
189 g_object_unref(pdialog->
sort);
193 GtkCellRenderer *renderer;
194 GtkTreeViewColumn *col;
199 switch (pcol->
type) {
201 renderer = gtk_cell_renderer_pixbuf_new();
202 col = gtk_tree_view_column_new_with_attributes(
_(pcol->
title), renderer,
206 renderer = gtk_cell_renderer_text_new();
207 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
209 col = gtk_tree_view_column_new_with_attributes(
_(pcol->
title), renderer,
214 gtk_tree_view_column_set_sort_column_id(col, i);
217 renderer = gtk_cell_renderer_text_new();
218 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
220 col = gtk_tree_view_column_new_with_attributes(
_(pcol->
title), renderer,
225 gtk_tree_view_column_set_sort_column_id(col, i);
226 g_object_set(renderer,
"xalign", 1.0, NULL);
227 gtk_tree_view_column_set_alignment(col, 1.0);
237 gtk_tree_view_append_column(GTK_TREE_VIEW(pdialog->
list), col);
241 gtk_widget_set_hexpand(GTK_WIDGET(pdialog->
list),
TRUE);
242 gtk_widget_set_vexpand(GTK_WIDGET(pdialog->
list),
TRUE);
244 sw = gtk_scrolled_window_new(NULL, NULL);
245 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
246 GTK_POLICY_AUTOMATIC,
247 GTK_POLICY_AUTOMATIC);
248 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
250 gtk_container_add(GTK_CONTAINER(sw), pdialog->
list);
252 frame = gtk_frame_new(
_(
"Citizens"));
253 gtk_container_add(GTK_CONTAINER(frame), sw);
255 pdialog->
shell = frame;
286 if (pdialog->pcity ==
pcity) {
301 if (pdialog == NULL) {
305 gtk_tree_store_clear(pdialog->
store);
309 gtk_tree_store_append(pdialog->
store, &iter, NULL);
322 int style = PANGO_STYLE_NORMAL, weight = PANGO_WEIGHT_NORMAL;
327 switch (pcol->
type) {
330 gtk_tree_store_set(store, it, k, pcol->
func(pcity, pslot), -1);
334 if (pixbuf != NULL) {
335 gtk_tree_store_set(store, it, k, pixbuf, -1);
336 g_object_unref(pixbuf);
349 weight = PANGO_WEIGHT_BOLD;
350 style = PANGO_STYLE_NORMAL;
353 gtk_tree_store_set(store, it,
366 if (pdialog == NULL) {
370 gtk_widget_hide(pdialog->
shell);
374 gtk_widget_destroy(pdialog->
shell);
389 gtk_widget_show_all(pdialog->
shell);
392 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,...)