[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Google
  Web www.spinics.net

Re: GtkTreeModel



On Sun, 2003-08-31 at 13:27, Christer Palm wrote:
> Hi!
> 
> A question for all you GtkTreeModel wizards out there;
> 
> I have implemented a custom GtkTreeModel to model a directory tree. For 
> obvious performance reasons, I need to delay the scanning of a 
> subdirectory until the user actually expands it. Thus, all directories 
> will initially be assumed to contain subdirectories (i.e. my 
> gtk_tree_model_iter_has_child() implementation speculatively returns true).
> 
> The tricky part is what happens if the user tries to expand a 
> subdirectory which doesn't happen to contain any subdirectories. Just 
> like the Windoze explorer (cough) directory view, I want the expander 
> for that directory to "magically" disappear when the user tries to 
> expand it.

Use gtktreestore model. Add a dummy for non expanded directories. That
makes the expander appear. When the user expands, if nothing is in
there, collapse the node and remove the dummy. Since there will be no
children, the expander disappears. But what would you do if some other
process or whatever creates a file in that directory? You will not be
able to expand it, unless you are constantly monitoring the contents.

Edscott
> 
> However, just having the model change its mind turns out to be a very 
> bad idea. I get messages like:
> 
> (DirectoryTreeTest:30175): Gtk-CRITICAL **: file gtktreeview.c: line 
> 3243 (gtk_tree_view_bin_expose): assertion `has_child' failed.
> There is a disparity between the internal view of the GtkTreeView,
> and the GtkTreeModel.  This generally means that the model has changed
> without letting the view know.  Any display from now on is likely to
> be incorrect.
> 
> all over the place...
> 
> How can I "let the view know" that the model has changed, and is it safe 
>   to do it from within the GtkTreeModel implementation?
> 
> Cheers,
> --
> Christer Palm
> 
> _______________________________________________
> 
> gtk-list@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[GIMP Users]     [Yosemite News]    [Yosemite Photos]    [Gimp's Home]     [Steve's Art]

Add to Google Powered by Linux