Re: Gtk2::FileFilter by mime type





On Sat, Nov 28, 2009 at 12:18 AM, Emmanuele Bassi <ebassi gmail com> wrote:
you can add multiple rules to a filter, but in this case I'd check the
OS you're running on to decide what to use, e.g.:

Âif ($^O eq 'MSWin32') {
  Â$filter->add_pattern('*.mp3');
Â}
Âelse {
  Â$filter->add_mime_type('audio/mp3');
Â}

This is probably the best solution.
Â
or, since add_mime_type() is ignored on Windows:

Â# default to MIME type...
Â$filter->add_mime_type('audio/mp3');
Â# ... and add the extension matching on Windows
Â$filter->add_pattern('*.mp3') if $^O eq 'MSWin32';

From what I've seen mime-type rules are not ignored in windows[1] , instead they get stored and processed as if there was no difference [2] (but there's a difference). What happens later is that g_content_type_is_a will assumes that it's arguments are not mime-types under windows. In the case of Gtk2::FileFilter this results in no matches under windows as g_content_type_is_a is expecting extensions and gets mime-types which don't match. At the end this is not too intuitive as the documentation of gtk_file_chooser_add_mime_type doesn't warn us about this behaviour.

[1] http://git.gnome.org/cgit/gtk+/tree/gtk/gtkfilefilter.c#n217
[2] http://git.gnome.org/cgit/gtk+/tree/gtk/gtkfilefilter.c#n378
--
Emmanuel Rodriguez


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