Ticket #2400 (new enhancement)

Opened 3 years ago

Object Chooser API awkward / too limited

Reported by: sascha_silbe Owned by: alsroot
Priority: Unspecified by Maintainer Milestone: 1.0
Component: journal Version: Git as of bugdate
Severity: Major Keywords:
Cc: Distribution/OS:
Bug Status: New

Description

The  Object Chooser API is rather awkward to work with if one wants to let the user select a specific kind of object from the Journal. what_filter takes a single string which is either the bundle ID of an activity or the name of a  generic MIME type collection (e.g. 'Audio'). There is no way to select objects
1. that are not part of a predefined collection (e.g. a TIFF image as TIFF is not yet part of the 'Image' collection) or
2. have a specific MIME type (e.g. only Ogg Vorbis audio files, but no MP3s).

From an API point of view, passing a query dictionary like we do in  sugar.datastore.datastore.find() would be a good way to approach this. I'm not sure about the UI part, though: Currently we use the what_filter to preselect the  "What" combo box. Some parts of a query dictionary translate more or less easily into the existing filters while others have no UI equivalent at all.

A compromise might be supporting only specific filters, but with a clean API. E.g.  one of the mockups explains:

The object chooser supports some extra parameters from activities, including lists of filters and mime-types. The filter list specifies presets for the controls in the toolbar, for instance allowing an "insert image" button to automatically filter for all entries of type "image". A boolean for each specified filter determines whether or not the preset is locked, or remains adjustable by the child. The mime-type list specifies the formats which the activity can support. Items which do not match on this list and therefore cannot be selected are rendered with gray text, and do not receive a highlight on rollover.

Note: See TracTickets for help on using tickets.