RE: How to force the visibility of a GTK2 treeview row expander
- From: "Rastatter, Ken (OH32)" <Ken Rastatter Honeywell com>
- To: "'gtk-app-devel-list gnome org'" <gtk-app-devel-list gnome org>
- Subject: RE: How to force the visibility of a GTK2 treeview row expander
- Date: Fri, 30 May 2003 09:54:25 -0700
Sam wrote on 29 May 2003 18:18:13 +0200
I have a GTK2 treeview (tree store) row that has no children and I'd
like to have it's expander visible anyway.
Is there a way to do this or will I have to add a dummy node?
Nope, you have to add a dummy child node.
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(). This creates a
child
node, albeit an empty one.
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; // "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, 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
Honeywell Sensotec
2080 Arlingate Lane, Columbus, Ohio, 43228-4112 USA
Home Page: http://www.sensotec.com
"These opinions are mine and not necessarily those of Honeywell."
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]