[f-spot/rubenv-gsoc-2009: 39/86] Remove ImageFile.HasLoader in favor of ImageLoader.IsAvailable



commit b960d766066b0430ad992000aad401409764d21c
Author: Ruben Vermeersch <ruben savanne be>
Date:   Wed Jul 29 20:02:09 2009 +0200

    Remove ImageFile.HasLoader in favor of ImageLoader.IsAvailable

 src/FileImportBackend.cs   |    3 ++-
 src/Imaging/ImageFile.cs   |   11 -----------
 src/Loaders/ImageLoader.cs |   13 +++++++++++++
 src/UriCollection.cs       |    8 +++++---
 4 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/src/FileImportBackend.cs b/src/FileImportBackend.cs
index 93446e2..e06c010 100644
--- a/src/FileImportBackend.cs
+++ b/src/FileImportBackend.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
 using System;
 using FSpot;
 using FSpot.Utils;
+using FSpot.Loaders;
 using FSpot.Xmp;
 using FSpot.UI.Dialog;
 using System.IO;
@@ -80,7 +81,7 @@ public class FileImportBackend : ImportBackend {
 		foreach (Uri uri in base_paths) {
 			var enumerator = new RecursiveFileEnumerator (uri, recurse, true);
 			foreach (var file in enumerator) {
-				if (FSpot.ImageFile.HasLoader (file.Uri))
+				if (ImageLoader.IsAvailable (file.Uri))
 					import_info.Add (new ImportInfo (file.Uri));
 			}
 		}	
diff --git a/src/Imaging/ImageFile.cs b/src/Imaging/ImageFile.cs
index 49358f1..b2154ba 100644
--- a/src/Imaging/ImageFile.cs
+++ b/src/Imaging/ImageFile.cs
@@ -188,17 +188,6 @@ namespace FSpot {
 			}
 		}
 
-		[Obsolete ("use HasLoader (System.Uri) instead")]
-		public static bool HasLoader (string path)
-		{
-			return HasLoader (UriUtils.PathToFileUri (path));
-		}
-		
-		public static bool HasLoader (Uri uri)
-		{
-			return GetLoaderType (uri) != null;
-		}
-
 		static Type GetLoaderType (Uri uri)
 		{
 			string path = uri.AbsolutePath;
diff --git a/src/Loaders/ImageLoader.cs b/src/Loaders/ImageLoader.cs
index 1d524fc..bf44d61 100644
--- a/src/Loaders/ImageLoader.cs
+++ b/src/Loaders/ImageLoader.cs
@@ -88,5 +88,18 @@ namespace FSpot.Loaders {
 
 			return loader;
 		}
+
+		[Obsolete ("Use Uri instead, this will deprecate soon")]
+		public static bool IsAvailable (string path)
+		{
+			return IsAvailable (UriUtils.PathToFileUri (path));
+		}
+
+		public static bool IsAvailable (Uri uri)
+		{
+			string path = uri.AbsolutePath;
+			string extension = System.IO.Path.GetExtension (path).ToLower ();
+			return name_table.ContainsKey (extension);
+		}
 	}
 }
diff --git a/src/UriCollection.cs b/src/UriCollection.cs
index 6f6a4b3..1b6a46d 100644
--- a/src/UriCollection.cs
+++ b/src/UriCollection.cs
@@ -19,6 +19,8 @@ using System.Xml;
 
 using GLib;
 
+using FSpot.Loaders;
+
 namespace FSpot {
 	public class UriCollection : PhotoList {
 		public UriCollection () : base (new IBrowsableItem [0])
@@ -37,7 +39,7 @@ namespace FSpot {
 
 		public void Add (Uri uri)
 		{
-			if (FSpot.ImageFile.HasLoader (uri)) {
+			if (ImageLoader.IsAvailable (uri)) {
 				//Console.WriteLine ("using image loader {0}", uri.ToString ());
 				Add (new FileBrowsableItem (uri));
 			} else {
@@ -129,7 +131,7 @@ namespace FSpot {
 				foreach (GLib.FileInfo info in file.EnumerateChildrenFinish (res)) {
 					Uri i = file.GetChild (info.Name).Uri;
 					FSpot.Utils.Log.Debug ("testing uri = {0}", i);
-					if (FSpot.ImageFile.HasLoader (i))
+					if (ImageLoader.IsAvailable (i))
 						items.Add (new FileBrowsableItem (i));
 				}
 				Gtk.Application.Invoke (items, System.EventArgs.Empty, delegate (object sender, EventArgs args) {
@@ -142,7 +144,7 @@ namespace FSpot {
 		{
 			List<IBrowsableItem> items = new List<IBrowsableItem> ();
 			foreach (var f in files) {
-				if (FSpot.ImageFile.HasLoader (f.FullName)) {
+				if (ImageLoader.IsAvailable (f.FullName)) {
 					Console.WriteLine (f.FullName);
 					items.Add (new FileBrowsableItem (f.FullName));
 				}



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