Project

General

Profile

Feature #980 ยป 0043-gtk4x-Implement-bind-create-for-citydlg-prod-list-it.patch

Marko Lindqvist, 10/18/2024 09:12 PM

View differences:

client/gui-gtk-5.0/citydlg.c
G_DEFINE_TYPE(FcProdRow, fc_prod_row, G_TYPE_OBJECT)
#define PROD_ROW_PIXBUF 0
#define PROD_ROW_NAME 1
/**********************************************************************//**
Initialization method for FcImprRow class
**************************************************************************/
......
return view;
}
/**********************************************************************//**
Prod table cell bind function
**************************************************************************/
static void prod_factory_bind(GtkSignalListItemFactory *self,
GtkListItem *list_item,
gpointer user_data)
{
FcProdRow *row;
GtkWidget *child = gtk_list_item_get_child(list_item);
row = gtk_list_item_get_item(list_item);
switch (GPOINTER_TO_INT(user_data)) {
case PROD_ROW_PIXBUF:
gtk_image_set_from_pixbuf(GTK_IMAGE(child), row->sprite);
break;
case PROD_ROW_NAME:
{
gtk_label_set_text(GTK_LABEL(child), row->name);
if (row->useless) {
PangoAttrList *attributes;
PangoAttribute *attr;
attributes = pango_attr_list_new();
attr = pango_attr_strikethrough_new(TRUE);
pango_attr_list_insert(attributes, attr);
gtk_label_set_attributes(GTK_LABEL(child), attributes);
}
}
break;
}
}
/**********************************************************************//**
Prod table cell setup function
**************************************************************************/
static void prod_factory_setup(GtkSignalListItemFactory *self,
GtkListItem *list_item,
gpointer user_data)
{
switch (GPOINTER_TO_INT(user_data)) {
case PROD_ROW_PIXBUF:
gtk_list_item_set_child(list_item, gtk_image_new());
break;
case PROD_ROW_NAME:
gtk_list_item_set_child(list_item, gtk_label_new(""));
break;
}
}
/***********************************************************************//**
**** Overview page ****
+- GtkWidget *page ------------------------------------------+
......
gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
if (!low_citydlg) {
GtkListItemFactory *factory;
GtkWidget *middle;
GtkWidget *vbox;
GtkWidget *hbox;
......
G_TYPE_INT, G_TYPE_BOOLEAN);
pdialog->overview.change_production_store = production_store;
factory = gtk_signal_list_item_factory_new();
g_signal_connect(factory, "bind", G_CALLBACK(prod_factory_bind),
GINT_TO_POINTER(PROD_ROW_PIXBUF));
g_signal_connect(factory, "setup", G_CALLBACK(prod_factory_setup),
GINT_TO_POINTER(PROD_ROW_PIXBUF));
bar = gtk_progress_bar_new();
gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(bar), TRUE);
pdialog->overview.production_bar = bar;
    (1-1/1)