Re: gtk_tree_view
- From: Ken Rastatter <krastatter sensotec com>
- To: gtk-app-devel-list gnome org
- Subject: Re: gtk_tree_view
- Date: Wed, 12 Mar 2003 13:15:43 -0500
Markus Lausser wrote:
1. Do i have to add a dummy child node if i want the parent node have
a expander to click on?
AFAIK, yes.
2. If yes, how do i insert a dummy node in the tree_model
For a parent node to have a expand/collapse handle, I create a child
node using gtk_tree_store_append() and then don't follow with a call
to gtk_tree_store_set().
and prevent the tree_view to expand it immediately?
This empty child node is easy to detect in a "row_expand" signal
callback. This is how I do it:
void
on_treeview1_row_expanded (GtkTreeView *treeview,
GtkTreeIter *arg1,
GtkTreePath *arg2,
gpointer user_data)
{
extern GtkTreeStore *treestore;
GtkTreeIter child_iter;
gchar *name; // assume "name" is the file/directory name of G_TYPE_STRING
// See if this row has ever had a name gtk_tree_store_set()'ed to it.
// If not, it is empty. Therefore, read the directory contents
gtk_tree_model_get(GTK_TREE_MODEL(treestore), arg1,
NAME_COLUMN, &name, -1);
if (!name)
{
g_print("Read this directory's contents here.");
// Replace the blank child with the first directory entry
// You may be tempted to remove the blank child node and then append a
// new one. Don't. If you remove the blank child node GTK gets
// confused and won't expand the parent row.
gtk_tree_model_iter_children(GTK_TREE_MODEL(treestore),
&child_iter, arg1);
gtk_tree_store_set (treestore, &child_iter,
NAME_COLUMN, first_entry_name,
-1);
// Append all of the other directory entries
gtk_tree_store_append(treestore, &child_iter, arg1);
gtk_tree_store_set (treestore, &child_iter,
NAME_COLUMN, second_entry_name,
-1);
}
return;
}
I hope this helps.
--
Ken Rastatter, Design Engineer
Sensotec, Inc.
2080 Arlingate Lane, Columbus, Ohio, 43228-4112 USA
Voice: (614)850-5000 Fax: (614)850-6041 Toll Free: 1-800-848-6564
Home Page: http://www.sensotec.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]