GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 30, 2014 11:55 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: regarding treeview
PostPosted: Tue May 15, 2007 12:25 pm 
Offline
GTK+ Geek

Joined: Fri Oct 06, 2006 6:37 am
Posts: 57
iam adding items to the treeview in the startup of my application.
for (j=0;j<rec;j++) {
textNames[0] =buddies[j];
pixbuf = gdk_pixbuf_new_from_file("/usr/local/share/globe7/pixmaps/offline.bmp", &error);
gtk_list_store_append (store1, &iter);
gtk_list_store_set (store1, &iter,0,pixbuf,
1,textNames[0],
-1);
}
gtk_widget_show(treeview);
but My problem is items r not visble until we click on the treeview amd sometimes scrollbar also not visible.
y this problem occur and how can i fix this bug
thank u
sree


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 3:51 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Use gtk_widget_show_all (treeview). Also, you do not need to load a new version of the same pixbuf every single time. You can load one version and add it. You see, GdkPixbuf is not like widgets because it can be used multiple places. Every time you add it, its reference count will be incremented. Therefore, just create one version, add it to all rows, and then call gdk_pixbuf_unref() on it so that the object is destroyed when the tree view is destroyed.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 11:40 am 
Offline
GTK+ Geek

Joined: Fri Oct 06, 2006 6:37 am
Posts: 57
thanks for ur valuable reply.
still my problem is not solved.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 12:19 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Can you show more code around this such as how you create the tree view columns?

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 17, 2007 11:01 am 
Offline
GTK+ Geek

Joined: Fri Oct 06, 2006 6:37 am
Posts: 57
// creation of treeview
store1 = gtk_tree_store_new (2, GDK_TYPE_PIXBUF,G_TYPE_STRING);

GtkTreeViewColumn *col;

treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store1));


gtk_tree_view_set_rules_hint(treeview,TRUE);
col = gtk_tree_view_column_new();
gtk_tree_view_column_set_title(col, "items");


renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(col, renderer, FALSE);
gtk_tree_view_column_set_attributes(col, renderer,
"pixbuf", 0,
NULL);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(col, renderer,FALSE);
gtk_tree_view_column_set_attributes(col, renderer,
"text", 1,
NULL);

g_object_set(renderer,"weight","PANG0_WEIGHT_BOLD","weight-set",TRUE,NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), col);
gtk_widget_show(treeeview);
//end
another problem is iam geeting space before pixbuf.
so i want to remove the space between pixbuf and thw wall of the treeview
thank u
sree


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 8:08 am 
Offline

Joined: Tue Jun 05, 2007 7:54 am
Posts: 4
Hello,

I have tried your code and make it working by replacing

gtk_list_store_append (store1, &iter);
gtk_list_store_set (store1, &iter,0,pixbuf,

by:

gtk_tree_store_append (store1, &iter, NULL);
gtk_tree_store_set (store1, &iter,0,pixbuf,


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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