Re: Gtk2::FileFilter by mime type

On Fri, 2009-11-27 at 10:48 -0800, Zettai Muri wrote:
From: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
I've checked the C implementation of GtkFileFilter and mime types rules are processed with  
g_content_type_is_a[1] which has different implementations for Unix/Linux and Windows.

In Linux g_content_type_is_a behaves as you expect so 'text/png' is considered a 'text/*'. I haven't tried 
with a GtkFileFilter yet.

Are you running your program in Linux/Unix or in Windows?


Thank you for this, yep that's my problem I'm running the program under Windows.  If I wanted to be able to 
run it under both Linux & Windows would I be better off using add_pattern("*.mp3") etc. to detect different 
file formats?

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') {
  else {

or, since add_mime_type() is ignored on Windows:

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

Is there a recommended way to overcome these differences between different OSes?

not always; gtk+ will try (through GLib) to do the things in a portable
way but different features on respective systems have to be accounted
for by the application developer.


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