[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    Re: Has anyone been able to force TreeView expander with no children?
From:       "Daniel B. Thurman" <dant () cdkkt ! com>
Date:       2009-10-15 14:44:56
Message-ID: 4AD73568.4070100 () cdkkt ! com
[Download RAW message or body]

On 10/14/2009 11:56 PM, Lars Wirzenius wrote:
> ke, 2009-10-14 kello 18:52 -0700, Daniel B. Thurman kirjoitti:
>   
>> I have a FileViewer application that I am working on
>> and so far I have not been able to force expanders
>> on TreeView when there are only "top-level"
>> directories/files populated in the TreeStore.
>>     
> As I understand it, the expander will only be shown for tree rows that
> have children. You want to show them always, so that you don't have to
> scan an entire directory tree to figure out which have children and
> which don't.
>
> Would one of the following approaches work for you?
>
> a) Add dummy items to nodes. When a node is expanded, and it has a dummy
> node, scan for subdirectories and replace the dummy node with real ones.
> This means even nodes without subdirectories will have an expander,
> which might be awkward for the user.
>
> b) Initially, add top level items and their immediate subdirectories.
> When a node is expanded the first time, scan its subdirectories'
> subdirectories and add those. That was confusing, let me show an
> example. Initially, have this (> means closed expander, v means open):
>
>         > aaa
>         > bbb
>           ccc
>
> Here, you've scanned aaa and bbb and ccc for subdirectories. You know
> ccc doesn't have any, so it gets no children and no expander. aaa and
> bbb have children, so they get them and expanders.
>
> When aaa is expanded the first time, you scan aaa/* for subdirectories,
> and add them to their parent nodes (i.e., to children of aaa), before
> letting the aaa node be expanded on screen. In other words:
>
>         v aaa
>             aaa-1
>           > aaa-2
>             aaa-3
>         > bbb
>           ccc
>         
> Here, you scanned aaa-1, aaa-2, and aaa-3 for children, and found that
> aaa-2 has them.
>
> You can use a hidden column to keep track of which nodes have been
> expanded (= scanned).
>
> c) Do the scan in the background, modifying the tree when you find
> things. You can either let the scan go through the entire filesystem
> this way, or scan directories that are shown (a bit like in option b,
> but scanning is done in the background, not just when the node is about
> to be expanded).
>
>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>   
Yes,  I have already implemented (b) as you suggested.

In reading the documentation, it was not clear at first, that
setting the boolean=True does not make expanders appear
when there are no children.  This makes sense.

I still have some other issues to deal with:

(1) I am trying to find the "expander-open" event for the
      connect method. I think it is something like:

      self.treeview.connect('expander-open', self.on_expander_open)

      Do you know of a link/reference listing GTK events for the
      connect() method so that I can look them up?

(2) I note that for some reason when I open an expander, the
     the icon/text next gets "right justified".

     The expected behavior is:

        v aaa
            aaa-1
          > aaa-2
              bbb-1
            > bbb-2
            aaa-3
        > bbb
          ccc

       But I get:

        v     aaa
              aaa-1
          >   aaa-2
              bbb-1
            > bbb-2
              aaa-3
        >     bbb
              ccc

      So, every time one opens a sub-expander, the icon/text
      cell keeps shifting further to the right. So how can I
      correct this?

Thank you for replying,
and kind regards!

Dan


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic