Re: GtkComboBox

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michael,

If I am not wrong, with tree model we can even display images and text
together as part of the menu items. This is the reason why I chose to
use tree model. If there was only text then you are correct. Thanks to
Neumann for pointing out what I was missing in the code.

-Pramod


On 5/31/05, Michael Ott <michael@xxxxxxxxxx> wrote:
> Hello Pramod!
> 
> > I was trying out GtkComboBox. I have Gtk-2.4. I have created a
> > GtkTreeModel and populated the corresponding GtkTreeStore. But when I
> > run the program, the entries are not shown. Why is this happening? I
> > am attaching the program here:
> >
> > GtkTreeStore *ts = gtk_tree_store_new(1,G_TYPE_STRING);
> >       GtkWidget *tv = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ts));
> >       GtkCellRenderer* cr = gtk_cell_renderer_text_new();
> >       GtkTreeViewColumn* tvc =
> > gtk_tree_view_column_new_with_attributes(NULL, cr, "text", 0, NULL);
> >       gtk_tree_view_append_column (GTK_TREE_VIEW(tv), tvc);
> >       gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tv), FALSE);
> >       GtkTreeSelection* TS = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
> >       gtk_tree_selection_set_mode(TS, GTK_SELECTION_BROWSE);
> >
> >       GtkTreeIter iter;
> >
> >       gtk_tree_store_insert(ts, &iter, NULL, 0);
> >       gtk_tree_store_set(ts, &iter, 0, "FIRST",-1);
> >
> >       gtk_tree_store_insert(ts, &iter, NULL, 0);
> >       gtk_tree_store_set(ts, &iter, 0,"SECOND",-1);
> >
> >       GtkWidget* combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ts));
> >       gtk_container_add(GTK_CONTAINER(dialog),combo);
> >       gtk_widget_show(combo);
> >
> > Can anyone please point out, why the entries are now show n in the combo box?
> Why so difficult. You can use gtk_combo_box_append_text and need no tree
> model
> 
> CU
> 
>   Michael
> 
> --
>            Michael Ott, e-mail: michael@xxxxxxxxxx, www.zolnott.de
> I am registered as user #275453 with the Linux Counter, http://counter.li.org.
> 
> 
>
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux