 |
GTK+ Forums Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
|
|
|
| Author |
Message |
|
|
cnu_sree GTK+ Geek
Joined: 06 Oct 2006 Posts: 57
|
Posted: Tue May 15, 2007 12:25 pm Post subject: regarding treeview |
|
|
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 |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Tue May 15, 2007 3:51 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
cnu_sree GTK+ Geek
Joined: 06 Oct 2006 Posts: 57
|
Posted: Wed May 16, 2007 11:40 am Post subject: |
|
|
thanks for ur valuable reply.
still my problem is not solved. |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Wed May 16, 2007 12:19 pm Post subject: |
|
|
| Can you show more code around this such as how you create the tree view columns? |
|
| Back to top |
|
 |
cnu_sree GTK+ Geek
Joined: 06 Oct 2006 Posts: 57
|
Posted: Thu May 17, 2007 11:01 am Post subject: |
|
|
// 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 |
|
| Back to top |
|
 |
gdw
Joined: 05 Jun 2007 Posts: 4
|
Posted: Tue Jun 05, 2007 8:08 am Post subject: |
|
|
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, |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group CodeBB 1.0 Beta 2
|