gtk-2.0
Hello!
I have a combobox that I made with a model, 2 columns, the first one contains text, the second one a icon.
I want to retrieve the text
I connected the change signal with cb_on_cboxChuck_changed()
My problem is to get the value of the text-cell of the active combobox items.
the function "gtk_combo_box_get_active_text" doesn't work, may be because there are two columns.
How could I get the value of the first column?
Thanks a lot for your help in advance
M.Boerner
callback of the changed signal
Code:
static gboolean cb_on_cboxChuck_changed(GtkComboBox *widget, gpointer user_data)
{
char *p_newChuckIcon;
p_newChuckIcon = gtk_combo_box_get_active_text(widget); //==> doesn't work
strcpy(recipe_editBuffer.header.chuck_type, p_newChuckIcon);
return FALSE;
}
code to connect the changed signal:
Code:
g_signal_connect(rech_local.widgets.cboxChucks, "changed", G_CALLBACK ( cb_on_cboxChuck_changed), NULL);
code to make the model of the combobox:
Code:
static void set_up_cbo_chuckname(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.recipeNrModel = fill_cboChuck_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_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_CHUCKNAME,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_CHUCKICON, NULL );
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)),GTK_SELECTION_NONE);
}
I filled the combo box with the following command:
Code:
gtk_list_store_set(liststore,&toplevel, 0, name, 1,pixbuf,-1);// 1 coulmn is a nam, the second one is a picture