Re: Gtk2::FileFilter by mime type
- From: Emmanuele Bassi <ebassi gmail com>
- To: gtk-perl-list gnome org
- Subject: Re: Gtk2::FileFilter by mime type
- Date: Fri, 27 Nov 2009 23:18:20 +0000
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?
[1] http://library.gnome.org/devel/gio/stable/gio-GContentType.html
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') {
$filter->add_pattern('*.mp3');
}
else {
$filter->add_mime_type('audio/mp3');
}
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';
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.
ciao,
Emmanuele.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]