Re: gtk_tree_view



On Wed, Mar 12, 2003 at 04:28:38PM -0800, David M. Cook wrote:
On Wed, Mar 12, 2003 at 05:00:24PM +0100, Markus Lausser wrote:

I'd like to create a tree_view where the contents is created on demand
(dir browser). In terms: The childs of a node should only be created
when the node is expanded. Its known whether the node will have childs
before it is expanded. Now two questions:

1. Do i have to add a dummy child node if i want the parent node have
   a expander to click on?

Yes, this is how I would do it.  Just append a single empty child node.
AFAIK, the only other way to do it would be to implement your own TreeModel.

2. If yes, how do i insert a dummy node in the tree_model and prevent
   the tree_view to expand it immediately?

The treeview won't expand immediately.  Are you having a problem with this?

2) was a fault of mine. I did a gtk_tree_view_expand_row()...

It works all fine now, and like Ken said, the expand callback must not
remove the dummy node before inserting the sub folders, cause the node
itself would be collapsed in the expand callback again (dont know
whether also the collapse signal is triggered as i dont catch it).

Here's another question not really gtk related: I only insert the
dummy child node if the current node (representing a folder) has
subfolders. To check for subfolders i do not scan it (cause it
consumes to much time when there are many subfolders). Instead i check
(stat.st_nlink > 2). Works fine, but isnt really correct, is it?
stat.st_nlink represents the number of hard links to that directory,
right? So is there a safe way to check for subfolders with stat() ?

Markus.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]