Index: src/ImageFile.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/ImageFile.cs,v
retrieving revision 1.32
diff -u -p -r1.32 ImageFile.cs
--- src/ImageFile.cs	22 Mar 2006 21:24:02 -0000	1.32
+++ src/ImageFile.cs	12 Jun 2006 11:49:52 -0000
@@ -11,7 +11,7 @@ namespace FSpot {
 	public class ImageFile {
 		protected Uri uri;
 
-		static System.Collections.Hashtable name_table;
+		static System.Collections.Hashtable mime_table;
 
 		public ImageFile (string path) 
 		{
@@ -42,26 +42,31 @@ namespace FSpot {
 
 		static ImageFile ()
 		{
-			name_table = new System.Collections.Hashtable ();
-			name_table [".svg"] = typeof (FSpot.Svg.SvgFile);
-			name_table [".gif"] = typeof (ImageFile);
-			name_table [".jpeg"] = typeof (JpegFile);
-			name_table [".jpg"] = typeof (JpegFile);
-			name_table [".png"] = typeof (FSpot.Png.PngFile);
-			name_table [".cr2"] = typeof (FSpot.Tiff.Cr2File);
-			name_table [".nef"] = typeof (FSpot.Tiff.NefFile);
-			name_table [".pef"] = typeof (FSpot.Tiff.NefFile);
-			name_table [".raw"] = typeof (FSpot.Tiff.NefFile);
-			name_table [".tiff"] = typeof (FSpot.Tiff.TiffFile);
-			name_table [".tif"] = typeof (FSpot.Tiff.TiffFile);
-			name_table [".orf"] =  typeof (FSpot.Tiff.NefFile);
-			name_table [".srf"] = typeof (FSpot.Tiff.NefFile);
-			name_table [".dng"] = typeof (FSpot.Tiff.DngFile);
-			name_table [".crw"] = typeof (FSpot.Ciff.CiffFile);
-			name_table [".ppm"] = typeof (FSpot.Pnm.PnmFile);
-			name_table [".mrw"] = typeof (FSpot.Mrw.MrwFile);
-			name_table [".raf"] = typeof (FSpot.Raf.RafFile);
-			name_table [".x3f"] = typeof (FSpot.X3f.X3fFile);
+//			name_table = new System.Collections.Hashtable ();
+//			name_table [".svg"] = typeof (FSpot.Svg.SvgFile);
+//			name_table [".gif"] = typeof (ImageFile);
+//			name_table [".jpeg"] = typeof (JpegFile);
+//			name_table [".jpg"] = typeof (JpegFile);
+//			name_table [".png"] = typeof (FSpot.Png.PngFile);
+//			name_table [".cr2"] = typeof (FSpot.Tiff.Cr2File);
+//			name_table [".nef"] = typeof (FSpot.Tiff.NefFile);
+//			name_table [".pef"] = typeof (FSpot.Tiff.NefFile);
+//			name_table [".raw"] = typeof (FSpot.Tiff.NefFile);
+//			name_table [".tiff"] = typeof (FSpot.Tiff.TiffFile);
+//			name_table [".tif"] = typeof (FSpot.Tiff.TiffFile);
+//			name_table [".orf"] =  typeof (FSpot.Tiff.NefFile);
+//			name_table [".srf"] = typeof (FSpot.Tiff.NefFile);
+//			name_table [".dng"] = typeof (FSpot.Tiff.DngFile);
+//			name_table [".crw"] = typeof (FSpot.Ciff.CiffFile);
+//			name_table [".ppm"] = typeof (FSpot.Pnm.PnmFile);
+//			name_table [".mrw"] = typeof (FSpot.Mrw.MrwFile);
+//			name_table [".raf"] = typeof (FSpot.Raf.RafFile);
+//			name_table [".x3f"] = typeof (FSpot.X3f.X3fFile);
+			
+			mime_table = new System.Collections.Hashtable();
+			mime_table ["image/gif"] = typeof (ImageFile);
+			mime_table ["image/jpeg"] = typeof (JpegFile);
+			mime_table ["image/png"] = typeof (FSpot.Png.PngFile);
 		}
 
 		public Uri Uri {
@@ -147,6 +152,13 @@ namespace FSpot {
 			}
 		}
 
+		private static System.Type TypeOf (Uri uri)
+		{
+			Gnome.Vfs.Uri g_uri = new Gnome.Vfs.Uri(uri.ToString());
+			Gnome.Vfs.FileInfo info = new Gnome.Vfs.FileInfo(g_uri, Gnome.Vfs.FileInfoOptions.GetMimeType);
+			return (System.Type) mime_table [info.MimeType];
+		}
+
 		public static bool HasLoader (string path)
 		{
 			return HasLoader (UriList.PathToFileUri (path));
@@ -154,9 +166,7 @@ namespace FSpot {
 		
 		public static bool HasLoader (Uri uri)
 		{
-			string path = uri.AbsolutePath;
-			string extension = System.IO.Path.GetExtension (path).ToLower ();
-			System.Type t = (System.Type) name_table [extension];
+			System.Type t = TypeOf (uri);
 			
 			return (t != null);
 		}
@@ -168,9 +178,7 @@ namespace FSpot {
 
 		public static ImageFile Create (Uri uri)
 		{
-			string path = uri.AbsolutePath;
-			string extension = System.IO.Path.GetExtension (path).ToLower ();
-			System.Type t = (System.Type) name_table [extension];
+			System.Type t = TypeOf (uri);
 			ImageFile img;
 
 			if (t != null)
