[Sugar-devel] Limiting Object Chooser to specified MIME types

Bert Freudenberg bert at freudenbergs.de
Fri May 8 11:56:25 EDT 2009


On 08.05.2009, at 17:41, Tomeu Vizoso wrote:

> On Fri, May 8, 2009 at 17:35, Bert Freudenberg  
> <bert at freudenbergs.de> wrote:
>> On 08.05.2009, at 17:03, James Simmons wrote:
>>
>>> Aleksey,
>>>
>>> I was interested in your comment about wrapping Object Chooser for
>>> backward compatibility.  Currently both of my Activities use Object
>>> Chooser, but don't make any attempt to limit what Journal entries
>>> can be chosen.  I would like to limit Read Etexts to the MIME types
>>> text/plain and application/zip, and View Slides to just application/
>>> zip.  In Sayamindu's code he is using mime.GENERIC_TYPE_IMAGE.
>>> There does not seem to be anything comparable that would select what
>>> I want selected.  I'm looking at the code for sugar.mime here:
>>>
>>> http://api.sugarlabs.org/sugar.mime-pysrc.html
>>>
>>> I'm wondering if I could make my own filter in my own Activities
>>> that would limit the Object Chooser to just plain text and Zip
>>> files.  I would of course follow your suggestion for backward
>>> compatibility.
>>>
>>> James Simmons
>>
>> This was discussed several times, last I think in this thread:
>>
>> http://lists.sugarlabs.org/archive/sugar-devel/2008-October/009118.html
>>
>> IMHO it would be quite a bit more useful than the restricted  
>> interface
>> we have now. You could build such a chooser yourself using the
>> datastore.find(query) function. But adding a similar "query"  
>> parameter
>> to the object chooser was deemed too powerful, possibly unsupportable
>> once the datastore was rewrittten. Maybe a list of mime types would  
>> be
>> acceptable to add, though?
>
> A bigger problem than the DS support is the UI. You currently can only
> pass programatically a generic type such as Image instead of
> individual mime types because the UI has only a way to change the
> generic type.
>
> Ideas?


Let the activity define more filters, similar to TEXT, AUDIO etc.  
filters that are there now. The activity provides a localized title  
for each entry, and an icon name (or possibly the activity icon would  
be used, or an icon meaning "custom filter"). The first custom filter  
should be selected by default and appear on top of the list, next to  
the generic filters. Something like this, an array of 3-tuples, using  
Python notation (D-Bus signature 'a(ssas)'):

[
  (
    'Localized filter name one',
    'first-icon-name',
    ['first/mime-type', 'second/mime-type']
  ),
  (
   'Localized filter name two',
   'second-icon-name',
   ['some/mime-type', 'other/mime-type']
  )
]



- Bert -




More information about the Sugar-devel mailing list