GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Aug 28, 2016 8:36 am

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Gtk2 combobox with 2 columns but only one visible
PostPosted: Wed Jan 23, 2013 2:37 pm 
Familiar Face

Joined: Fri Oct 26, 2012 10:49 am
Posts: 48
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
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,

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);

    /* 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 );


and later, to fill the combobox:
gtk_list_store_set(liststore,&toplevel,   0,reciconnameWithExtension,  1,pixbuf,-1);   // (1. Spalte Text, 2. Spalte icon und Endezeichen

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group