On Sat, 2006-08-19 at 17:22 +0200, Daniel Pekelharing wrote: > Hi all, > > I have for the first had the need of a GtkComboBox in my app... > > I am a little confused about how to use it. > > I have: > > GtkWidget *box; > GtkTreeList *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
This GtkTreeList thing is a typo, right? > ... fill in the list store ... > > box = gtk_combo_box_new_with_model(list); >... > > However the combo box remains empty.. ? May be the cell renderers ? > The documentation mentions that GtkComboBox uses the same cell rendering > setup as GtkTreeView, but I can find no functions that allow one to set > rendering attributes.. It implements GtkCellLayout. > Obviously I'm just missing something obvious somewhere ... > > Any ideas / clues? Check this out: // save as "test.c", compile with: // gcc test.c -o test `pkg-config --cflags --libs gtk+-2.0` // run with ./test #include <gtk/gtk.h> int main(int argc, char **argv) { GtkWidget *dialog, *dialog_vbox; GtkWidget *combo; GtkListStore *store; GtkTreeIter iter; GtkCellRenderer *text_renderer; gtk_init (&argc, &argv); dialog = gtk_dialog_new(); dialog_vbox = GTK_DIALOG (dialog)->vbox; gtk_widget_show (dialog_vbox); store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL(store)); gtk_widget_show (combo); gtk_box_pack_start (GTK_BOX (dialog_vbox), combo, TRUE, TRUE, 0); text_renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(combo), text_renderer, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(combo), text_renderer, "text", 0); text_renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_end (GTK_CELL_LAYOUT(combo), text_renderer, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(combo), text_renderer, "text", 1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, "Hi", 1, 0, -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, "Hi one", 1, 1, -1); g_signal_connect_swapped ( dialog, "response", gtk_main_quit, NULL ); gtk_widget_show (dialog); gtk_main (); return 0; } -- Iago Rubio _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list