Re: remove_dir() and notifies



On 9 Jan 2001, Havoc Pennington wrote:

Thanks for the quick reply,

> There isn't any notification of directory removal (or addition, for
> that matter) at the moment. My suggestion for now would be to just
> only display directories in the UI if they contain entries, I guess.

This seems fairly trivial on the surface, but is actually quite hard to
implement.  For various reasons, each path node contains a flag indicating
whether it has been fully read or not.  Unexpanded branches are displayed
with a `+' in the UI, and expanded with a `-':

 - /
   - apps
     + nautilus
   + extra

So, in this instance, the root node has been expanded, as has apps, but
nautilus and extra have not.  Now, suppose extra was empty - to verify it,
I would have to ensure that there were neither keys nor branches in it, or
that each branch was empty.  That means I need to fully read the tree,
which I was hoping to avoid (a very large tree over a nonlocal network may
take some time to read).

It is less nontrivial to flush a path when a key is deleted, since you can
assume any branches a node has are nonempty, and thus avoid recursion.
(You would have to backtrack the whole way up the tree, but the depth of
the tree is extremely insignificant compared to the breadth).

> Need to think about whether and how to add notification of directory
> removal - I'm not sure one really cares about empty directories one
> way or the other in GConf. They aren't hurting or helping anything by
> existing. So having UIs just ignore them seems like it might be
> simpler than complicating the notification mechanism.

You are right in that a notification isn't necessary, but they do take up
time and space to no purpose, which may not be significant, but itches my
effciency bone anyway. ;)

> Addition of directories already works this way, directories just
> magically appear if you use a key that's inside them. So having them
> magically disappear when there are no keys inside them seems sensible.

My UI takes care of this by adding an unexpanded branch if one was
missing.

> Perhaps rather than having UIs ignore them, we could actually ensure
> that they are gone (don't appear in all_dirs listings) once they are
> empty. When a key is deleted, a UI could then just rescan the
> directory the key was inside to see if it's gone.

It would be far simpler to remove unnecessary paths in the engine when
keys are removed than to try and mask it, for the same reasons it is
nontrivial for an application to test emptiness.

I have only just checked out the gconf source from CVS, so when I find
some time, I may look through to see how complicated it is to do just
that.

If you're interested, you can see a screenshot of the work in progress at
http://users.bigpond.net.au/mlm/gconfsole/gconfsole.png

-- 
bje





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