Re: More Recent files questions



On Mon, 2006-07-24 at 11:41 -0500, Jonathon Jongsma wrote:
> Hello GTK+ developers
> 
> This is a question I had while working on some gtkmm documentation for
> the new recent files stuff in GTK+ 2.10.  Can anybody enlighten me on
> the question below?

Sure.

> [Also, the GtkRecentFilterInfo type is a bit confusing to me in
> general.  It feels more like an internal implementation detail rather
> than an external API, but maybe I just don't understand it very well
> -- the documentation is still pretty sparse.  Any help would be
> appreciated]

GtkRecentFilter works like GtkFileFilter (okay: it's a rip-off of
GtkFileFilter); both are a bit of black magic that escapes from beneath
the implementations of GtkRecentChooser and GtkFileChooser.  The only
difference is that you can actually write your own GtkRecentChooser
implementation, while you can't do the same with GtkFileChooser; so, if
you want to create your own widget for showing the recently used
documents, and you want to add filtering support to it, then you'll have
to deal with GtkRecentFilter API.

> > >  There's a RecentFilter
> > > member function in GTK+ that's not wrapped:
> > > gtk_recent_filter_filter().  The GTK+ documentation says that this
> > > function is only really used in the implementation of GtkRecentChooser
> > > and friends, so I assume that this is why the function was not
> > > wrapped.
> > >
> > > However, I'm thinking of a situation where you get a list of
> > > recently-used items from RecentManager::get_items() and you want to
> > > filter these (i.e. without going through the default chooser widgets).
> > >  Wouldn't Gtk::RecentFilter::filter() be useful in this case?

Yes and no.

Most of the time, filtering the list of GtkRecentInfo objects that the
recent manager returns can be done with g_list_foreach() and a custom
filter function; when I first wrote the GtkRecentManager API I had hooks
for filtering and sorting in place, but then I removed them because they
had little to do with the manager itself (the manager does not change
the way the list is shown - that is the task of the GtkRecentChooser
implementations) and because the GList API is enough for all the special
needs of custom sorting and filtering.

Obviously, using GtkRecentFilter is possible, because the API and the
object are both already there; but then you'll have to care about the
reference count of the RecentFilter object (it's a GtkObject so you can
add it to the RecentChooser implementation and let it handle the filter
lifetime for you) and you'll still have to write your own custom
filtering function, checking against what the filter object contains.

There's not much to be gained.

> > > The only problem is that I'm not sure if the underlying GTK+ machinery
> > > works well for this case (maybe it wasn't intended to) because
> > > gtk_recent_filter_filter() takes a GtkRecentFilterInfo object, and I'm
> > > not sure how you would go about converting a GtkRecentInfo object (the
> > > type returned from get_items()) to a GtkRecentFilterInfo object
> > > without a bunch of tedious copying between the two.

Exactly: you have to copy the stuff from the RecentInfo to the
RecentFilterInfo and then check the needed flags; that's how it's done
inside the GtkRecentChooser implementations available inside GTK.

> > > Is this a valid use-case?

Valid, it's indeed valid.  Whether it's worth it, I'll leave it to
you. ;-)

Ciao,
 Emmanuele.

-- 
Emmanuele Bassi,  E: ebassi gmail com
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net




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