23#include <gdk/gdkkeysyms.h>
67#define CITIZENS_DLG_COL_STYLE (0 + num_citizens_cols)
68#define CITIZENS_DLG_COL_WEIGHT (1 + num_citizens_cols)
69#define CITIZENS_DLG_COL_ID (2 + num_citizens_cols)
82#define SPECLIST_TAG dialog
83#define SPECLIST_TYPE struct citizens_dialog
86#define dialog_list_iterate(dialoglist, pdialog) \
87 TYPED_LIST_ITERATE(struct citizens_dialog, dialoglist, pdialog)
88#define dialog_list_iterate_end LIST_ITERATE_END
109 if (nationality == 0) {
134 model_types[i] = GDK_TYPE_PIXBUF;
137 model_types[i] = GDK_TYPE_PIXBUF;
140 model_types[i] = G_TYPE_BOOLEAN;
144 model_types[i] = G_TYPE_STRING;
149 model_types[i++] = G_TYPE_INT;
150 model_types[i++] = G_TYPE_INT;
151 model_types[i++] = G_TYPE_INT;
153 store = gtk_tree_store_newv(i, model_types);
171 GtkWidget *frame, *sw;
178 = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(pdialog->
store));
179 g_object_unref(pdialog->
store);
181 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(pdialog->
sort),
183 GTK_SORT_DESCENDING);
186 = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pdialog->
sort));
187 gtk_widget_set_halign(pdialog->
list, GTK_ALIGN_CENTER);
188 g_object_unref(pdialog->
sort);
192 GtkCellRenderer *renderer;
193 GtkTreeViewColumn *col;
198 switch (pcol->
type) {
200 renderer = gtk_cell_renderer_pixbuf_new();
201 col = gtk_tree_view_column_new_with_attributes(
_(pcol->
title), renderer,
205 renderer = gtk_cell_renderer_text_new();
206 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
208 col = gtk_tree_view_column_new_with_attributes(
_(pcol->
title), renderer,
213 gtk_tree_view_column_set_sort_column_id(col, i);
216 renderer = gtk_cell_renderer_text_new();
217 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
219 col = gtk_tree_view_column_new_with_attributes(
_(pcol->
title), renderer,
224 gtk_tree_view_column_set_sort_column_id(col, i);
225 g_object_set(renderer,
"xalign", 1.0, NULL);
226 gtk_tree_view_column_set_alignment(col, 1.0);
236 gtk_tree_view_append_column(GTK_TREE_VIEW(pdialog->
list), col);
240 gtk_widget_set_hexpand(GTK_WIDGET(pdialog->
list),
TRUE);
241 gtk_widget_set_vexpand(GTK_WIDGET(pdialog->
list),
TRUE);
243 sw = gtk_scrolled_window_new();
244 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
245 GTK_POLICY_AUTOMATIC,
246 GTK_POLICY_AUTOMATIC);
247 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw),
FALSE);
248 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), pdialog->
list);
250 frame = gtk_frame_new(
_(
"Citizens"));
251 gtk_frame_set_child(GTK_FRAME(frame), sw);
253 pdialog->
shell = frame;
284 if (pdialog->pcity ==
pcity) {
299 if (pdialog == NULL) {
303 gtk_tree_store_clear(pdialog->
store);
307 gtk_tree_store_append(pdialog->
store, &iter, NULL);
320 int style = PANGO_STYLE_NORMAL, weight = PANGO_WEIGHT_NORMAL;
325 switch (pcol->
type) {
328 gtk_tree_store_set(store, it, k, pcol->
func(pcity, pslot), -1);
332 if (pixbuf != NULL) {
333 gtk_tree_store_set(store, it, k, pixbuf, -1);
334 g_object_unref(pixbuf);
347 weight = PANGO_WEIGHT_BOLD;
348 style = PANGO_STYLE_NORMAL;
351 gtk_tree_store_set(store, it,
365 if (pdialog == NULL) {
369 gtk_widget_hide(pdialog->
shell);
373 gtk_box_remove(GTK_BOX(gtk_widget_get_parent(pdialog->
shell)),
389 gtk_widget_show(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,...)