4 // Copyright (C) 2005 Novell, Inc.
5 // Copyright (C) 2003, Mariano Cano P�rez <mariano.cano@hispalinux.es>
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 using System
.Runtime
.InteropServices
;
32 namespace Beagle
.Util
{
34 public class GnomeFu
{
36 private static Gtk
.IconTheme icon_theme
= null;
38 // FIXME: When gtk-sharp 2.5 is a requirement
39 // use Gnome.Vfs.MimeApplication stuff instead
40 [DllImport("libgnomevfs-2")]
41 static extern IntPtr
gnome_vfs_mime_get_default_application(string mime_type
);
45 Gnome
.Vfs
.Vfs
.Initialize ();
48 public static string GetMimeIconPath (string mimetype
)
50 if (icon_theme
== null)
51 icon_theme
= Gtk
.IconTheme
.Default
;
53 Gnome
.IconLookupResultFlags result
;
55 // FIXME when ximian bug #76540 is fixed
56 // change "new Gnome.Vfs.FileInfo (IntPtr.Zero)" to "null"
57 string icon_name
= Gnome
.Icon
.Lookup (icon_theme
, null, null, null, new Gnome
.Vfs
.FileInfo (IntPtr
.Zero
), mimetype
, (Gnome
.IconLookupFlags
) 0, out result
);
58 if (icon_name
== null)
61 Gtk
.IconInfo icon_info
= icon_theme
.LookupIcon (icon_name
, 48, 0);
62 if (icon_info
== null)
65 return icon_info
.Filename
;
68 public static VFSMimeApplication
GetDefaultAction(string mime_type
)
70 IntPtr ptr
= gnome_vfs_mime_get_default_application(mime_type
);
71 VFSMimeApplication ret
= VFSMimeApplication
.New(ptr
);
75 public enum VFSMimeApplicationArgumentType
82 [StructLayout(LayoutKind
.Sequential
)]
83 public struct VFSMimeApplication
87 public string command
;
88 public bool can_open_multiple_files
;
89 public VFSMimeApplicationArgumentType expects_uris
;
90 //public List supported_uri_schemes;
91 private IntPtr supported_uri_schemes
;
92 public bool requires_terminal
;
94 public IntPtr reserved1
;
95 public IntPtr reserved2
;
97 public static VFSMimeApplication Zero
= new VFSMimeApplication ();
99 public static VFSMimeApplication
New (IntPtr raw
)
101 if(raw
== IntPtr
.Zero
)
102 return VFSMimeApplication
.Zero
;
103 VFSMimeApplication self
= new VFSMimeApplication();
104 self
= (VFSMimeApplication
) Marshal
.PtrToStructure (raw
, self
.GetType ());
108 //Fixme: Create the supported uri schemes struct
109 public List SupportedUriSchemes
{
110 get { return new List (supported_uri_schemes); }
113 public static bool operator == (VFSMimeApplication a
, VFSMimeApplication b
)
118 public static bool operator != (VFSMimeApplication a
, VFSMimeApplication b
)
120 return ! a
.Equals (b
);
123 public override bool Equals (object o
)
125 //if (!(o is GnomeVFSMimeApplication))
127 return base.Equals(o
) ;
130 public override int GetHashCode ()
132 return base.GetHashCode ();