Project

General

Profile

Feature #969 ยป 0040-gtk4x-Add-implemention-for-inteldlg-wonders-list-as-.patch

Marko Lindqvist, 10/16/2024 12:39 AM

View differences:

client/gui-gtk-5.0/inteldlg.c
struct player *pplayer;
GtkWidget *shell;
GtkListStore *wonders;
GtkListStore *wonders_depr;
GListStore *wonders;
GtkWidget *rule;
};
......
/**********************************************************************//**
FcWonderRow creation method
**************************************************************************/
#if 0
static FcWonderRow *fc_wonder_row_new(void)
{
FcWonderRow *result;
......
return result;
}
#endif
/**********************************************************************//**
Initialize intelligence dialogs
......
struct intel_wonder_dialog *pdialog;
GtkWidget *shell, *sw, *view;
GtkCellRenderer *rend;
GtkWidget *list;
GtkColumnViewColumn *column;
GtkListItemFactory *factory;
GtkSingleSelection *selection;
GtkWidget *box;
pdialog = fc_malloc(sizeof(*pdialog));
......
/* Columns: 0 - wonder name, 1 - location (city/unknown/lost),
* 2 - strikethrough (for lost or obsolete),
* 3 - font weight (great wonders in bold) */
pdialog->wonders = gtk_list_store_new(4, G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_BOOLEAN,
G_TYPE_INT);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(pdialog->wonders),
pdialog->wonders_depr = gtk_list_store_new(4, G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_BOOLEAN,
G_TYPE_INT);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(pdialog->wonders_depr),
3, GTK_SORT_DESCENDING);
pdialog->wonders = g_list_store_new(FC_TYPE_WONDER_ROW);
selection = gtk_single_selection_new(G_LIST_MODEL(pdialog->wonders));
list = gtk_column_view_new(GTK_SELECTION_MODEL(selection));
factory = gtk_signal_list_item_factory_new();
g_signal_connect(factory, "bind", G_CALLBACK(wonder_factory_bind),
GINT_TO_POINTER(WONDER_ROW_NAME));
g_signal_connect(factory, "setup", G_CALLBACK(wonder_factory_setup),
nullptr);
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pdialog->wonders));
column = gtk_column_view_column_new(_("Name"), factory);
gtk_column_view_append_column(GTK_COLUMN_VIEW(list), column);
factory = gtk_signal_list_item_factory_new();
g_signal_connect(factory, "bind", G_CALLBACK(wonder_factory_bind),
GINT_TO_POINTER(WONDER_ROW_CITY));
g_signal_connect(factory, "setup", G_CALLBACK(wonder_factory_setup),
nullptr);
column = gtk_column_view_column_new(_("City"), factory);
gtk_column_view_append_column(GTK_COLUMN_VIEW(list), column);
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pdialog->wonders_depr));
gtk_widget_set_margin_bottom(view, 6);
gtk_widget_set_margin_end(view, 6);
gtk_widget_set_margin_start(view, 6);
gtk_widget_set_margin_top(view, 6);
gtk_widget_set_hexpand(view, TRUE);
gtk_widget_set_vexpand(view, TRUE);
g_object_unref(pdialog->wonders);
g_object_unref(pdialog->wonders_depr);
gtk_widget_set_margin_start(view, 6);
gtk_widget_set_margin_end(view, 6);
gtk_widget_set_margin_top(view, 6);
......
gtk_label_set_text(GTK_LABEL(pdialog->rule), rule);
gtk_list_store_clear(pdialog->wonders);
gtk_list_store_clear(pdialog->wonders_depr);
improvement_iterate(impr) {
if (is_wonder(impr)) {
......
continue;
}
gtk_list_store_append(pdialog->wonders, &it);
gtk_list_store_set(pdialog->wonders, &it,
gtk_list_store_append(pdialog->wonders_depr, &it);
gtk_list_store_set(pdialog->wonders_depr, &it,
0, improvement_name_translation(impr),
1, cityname,
2, is_lost,
/* Font weight: great wonders in bold */
3, is_great_wonder(impr) ? 700 : 400,
-1);
FcWonderRow *row = fc_wonder_row_new();
row->name = improvement_name_translation(impr);
row->cityname = cityname;
row->is_lost = is_lost;
row->font_weight = is_great_wonder(impr) ? 700 : 400;
g_list_store_append(pdialog->wonders, row);
g_object_unref(row);
}
} improvement_iterate_end;
}
    (1-1/1)