GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Dec 20, 2014 12:59 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: My text is not display in the treeview
PostPosted: Tue Dec 15, 2009 6:19 pm 
Offline
GTK+ Guru

Joined: Sun Apr 06, 2008 6:43 pm
Posts: 288
Location: Fortress of solitude
Here is my TreeView creation:
Code:
void crear_lista(struct MisWidgets * pmw)
{
   GtkWidget *scroll = gtk_scrolled_window_new(FALSE, FALSE);
   GtkTreeViewColumn *columna1 = gtk_tree_view_column_new_with_attributes("Estado", gtk_cell_renderer_pixbuf_new(), "pixbuf", 0, NULL);
   GtkTreeViewColumn *columna2 = gtk_tree_view_column_new_with_attributes("Lista de carátulas", gtk_cell_renderer_text_new(), "text", 0, NULL);
   GtkListStore * lista = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
   pmw->Lista = gtk_tree_view_new_with_model(GTK_TREE_MODEL(lista));
   g_object_unref(lista);
   gtk_tree_view_append_column(GTK_TREE_VIEW(pmw->Lista), columna1);
   gtk_tree_view_append_column(GTK_TREE_VIEW(pmw->Lista), columna2);
   gtk_container_add(GTK_CONTAINER(scroll), pmw->Lista);
   gtk_box_pack_start_defaults(GTK_BOX(pmw->Contenedor), scroll);
}

How I add items on the tree:
Code:
void append_item(GtkWidget *lista, const gchar * label)
{
   GdkPixbuf *pixbuf;
   GtkWidget *cellview;
   GtkListStore *store;
   GtkTreeIter  iter;
   store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(lista)));
   cellview = gtk_cell_view_new ();
   pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_BUTTON, NULL);
   gtk_list_store_append(store, &iter);
   gtk_list_store_set(store, &iter, 0, pixbuf, 1, label, -1);
   gtk_widget_destroy (cellview);
   g_object_unref( G_OBJECT( pixbuf ) );
}

When I add strings in the treeview, the image shows correctly, but the strings don't, I get the following error on terminal:
Quote:
GLib-GObject-WARNING **: unable to set property `text' of type `gchararray' from value of type `GdkPixbuf'

Any ideas?

_________________
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 15, 2009 6:26 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello.

When you create you second tree view column, you should pass 1 as "text" property column, not 0 like you do right now.

Tadej


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 15, 2009 7:17 pm 
Offline
GTK+ Guru

Joined: Sun Apr 06, 2008 6:43 pm
Posts: 288
Location: Fortress of solitude
Thanks :)

_________________
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


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