Hello!
Is it possible to hide one of the column of a combobox?
I would like to show only the icon but I would like to save the value of the first one.
The code
Code:
gtk_tree_view_column_set_visible(col, FALSE);
seems to have no effect.
It would be good if someone could say me what is wrong,
Thanks!
MBoerner
Code:
static void set_up_cbo_reciconname(GtkWidget *combo)
{
GtkTreeViewColumn *col;
GtkWidget *view;
GtkListStore *liststore;
GtkCellLayout *layout;
GtkCellRenderer *renderer;
/* Create a new GtkListStore with 1 string column and 1 pixbuf column... */
liststore = gtk_list_store_new( 2, G_TYPE_STRING, GDK_TYPE_PIXBUF );
rech_local.recipeIconModel = fill_cboRecIcon_model (liststore);
/* ...and set it as the combo box's model */
gtk_combo_box_set_model(GTK_COMBO_BOX(combo), GTK_TREE_MODEL(liststore));
layout = GTK_CELL_LAYOUT(combo);
/* text cell */
view = gtk_tree_view_new();
col = gtk_tree_view_column_new();
gtk_tree_view_column_set_min_width (col,100);
gtk_tree_view_column_set_visible(col, FALSE); // (seems to have no effect)
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(layout, renderer,FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo),renderer,"text",COL_RECICONNAME,NULL);
/* icon cell */
view = gtk_tree_view_new();
col = gtk_tree_view_column_new();
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
renderer = gtk_cell_renderer_pixbuf_new();
gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(combo), renderer, FALSE );
gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(combo), renderer, "pixbuf", COL_RECICON, NULL );
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)),GTK_SELECTION_NONE);
}
and later, to fill the combobox:
Code:
gtk_list_store_append(liststore,&toplevel);
gtk_list_store_set(liststore,&toplevel, 0,reciconnameWithExtension, 1,pixbuf,-1); // (1. Spalte Text, 2. Spalte icon und Endezeichen