Feature #946 ยป 0035-gtk4x-Implement-bind-create-for-tech-list-item-facto.patch
client/gui-gtk-5.0/inteldlg.c | ||
---|---|---|
G_DEFINE_TYPE(FcWonderRow, fc_wonder_row, G_TYPE_OBJECT)
|
||
#define TECH_ROW_NAME 0
|
||
#define TECH_ROW_KNOWN 1
|
||
/**********************************************************************//**
|
||
Initialization method for FcTechRow class
|
||
**************************************************************************/
|
||
... | ... | |
intel_wonder_destroy_callback(NULL, pdialog);
|
||
}
|
||
/**********************************************************************//**
|
||
Tech table cell bind function
|
||
**************************************************************************/
|
||
static void tech_factory_bind(GtkSignalListItemFactory *self,
|
||
GtkListItem *list_item,
|
||
gpointer user_data)
|
||
{
|
||
FcTechRow *row;
|
||
row = gtk_list_item_get_item(list_item);
|
||
if (GPOINTER_TO_INT(user_data) == TECH_ROW_KNOWN) {
|
||
gtk_check_button_set_active(GTK_CHECK_BUTTON(gtk_list_item_get_child(list_item)),
|
||
row->known);
|
||
} else {
|
||
gtk_label_set_text(GTK_LABEL(gtk_list_item_get_child(list_item)),
|
||
row->name);
|
||
}
|
||
}
|
||
/**********************************************************************//**
|
||
Tech table cell setup function
|
||
**************************************************************************/
|
||
static void tech_factory_setup(GtkSignalListItemFactory *self,
|
||
GtkListItem *list_item,
|
||
gpointer user_data)
|
||
{
|
||
if (GPOINTER_TO_INT(user_data) == TECH_ROW_KNOWN) {
|
||
gtk_list_item_set_child(list_item, gtk_check_button_new());
|
||
} else {
|
||
gtk_list_item_set_child(list_item, gtk_label_new(""));
|
||
}
|
||
}
|
||
/**********************************************************************//**
|
||
Create new intelligence dialog between client user and player
|
||
given as parameter.
|
||
... | ... | |
GtkWidget *shell, *notebook, *label, *sw, *view, *table;
|
||
GtkCellRenderer *rend;
|
||
GtkTreeViewColumn *col;
|
||
GtkListItemFactory *factory;
|
||
int i;
|
||
pdialog = fc_malloc(sizeof(*pdialog));
|
||
... | ... | |
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(pdialog->techs),
|
||
1, GTK_SORT_ASCENDING);
|
||
factory = gtk_signal_list_item_factory_new();
|
||
g_signal_connect(factory, "bind", G_CALLBACK(tech_factory_bind),
|
||
GINT_TO_POINTER(TECH_ROW_NAME));
|
||
g_signal_connect(factory, "setup", G_CALLBACK(tech_factory_setup),
|
||
GINT_TO_POINTER(TECH_ROW_NAME));
|
||
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pdialog->techs));
|
||
gtk_widget_set_margin_bottom(view, 6);
|
||
gtk_widget_set_margin_end(view, 6);
|