From: Thomas L. <ta...@ec...> - 2002-08-17 19:40:20
|
Hi everyone, As you may have noticed, I've been quietly removing calls to the collection_* functions over the last few months and replacing them with view_* calls. I got rid of the last of the old-style calls today. Hurrah! If you're feeling confused about all this... read on... FilerWindow no longer has a 'collection' attribute. Instead, it has a View, which can be any object implementing the View interface. Currently, the only object which does this is ViewCollection, which is the only part of the code that uses the Collection API. The View interface is documented in view_iface.c. Whereas a Collection doesn't know anything about files (it's just a grid of rectangular items), the View API knows all about files. A View also scrolls (so a ViewCollection is actually a Collection inside a ViewPort, although that isn't where the View part of the name comes from, confusingly ;-). You can't use integers to index into Views. Instead, you use ViewIters. These work a bit like other iterators in Gtk+-2.0. You can use a ViewIter to get each DirItem in a View in turn, in various ways (only selected; backwards; from the cursor, etc). For example, this code prints out all the selected items in a filer window: ViewIter iter; DirItem *item; view_get_iter(filer_window->view, &iter, VIEW_ITER_SELECTED); while ((item = iter.next(&iter))) g_print("Item '%s' is selected.\n", item->leafname); OK, so what's the point? 1) Introduces many exciting new bugs. 2) Slower. 3) More complicated. Apart from that, I think it makes the code a bit neater. It also makes it much easier to switch to a different widget for laying out files. Or, to have very different types of View and switch between them (eg, a collection and a list). Possibly. Anyway, watch out for bugs -- especially off-by-ones, as I've changed the semantics of ViewIters several times recently and confused myself a bit... -- Thomas Leonard http://rox.sourceforge.net ta...@ec... ta...@us... GPG: 9242 9807 C985 3C07 44A6 8B9A AE07 8280 59A5 3CC1 |