[f-spot/taglib-metadata: 6/9] Slightly decouple from ImageFile.



commit fcb8ca6bb2073658a8f9a4f399bd67551f5999fe
Author: Ruben Vermeersch <ruben savanne be>
Date:   Sat Jun 12 00:47:56 2010 +0200

    Slightly decouple from ImageFile.

 src/Import/FileImportSource.cs |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/Import/FileImportSource.cs b/src/Import/FileImportSource.cs
index f7edeca..2bc051d 100644
--- a/src/Import/FileImportSource.cs
+++ b/src/Import/FileImportSource.cs
@@ -4,6 +4,7 @@ using System.Threading;
 using System.Collections.Generic;
 using FSpot.Utils;
 using Gtk;
+using Mono.Unix.Native;
 
 namespace FSpot.Import
 {
@@ -154,10 +155,11 @@ namespace FSpot.Import
 			if (metadata_parsed)
 				return;
 
-			using (var img = ImageFile.Create (DefaultVersion.Uri)) {
-				time = img.Date;
-				description = img.Description;
-			}
+            var res = new GIOTagLibFileAbstraction () { Uri = DefaultVersion.Uri };
+            var metadata_file = TagLib.File.Create (res) as TagLib.Image.File;
+            var date = metadata_file.ImageTag.DateTime;
+            time = date.HasValue ? date.Value : CreateDate;
+            description = metadata_file.ImageTag.Comment;
 
 			metadata_parsed = true;
 		}
@@ -181,6 +183,13 @@ namespace FSpot.Import
 			}
 		}
 
+        private DateTime CreateDate {
+            get {
+                var info = GLib.FileFactory.NewForUri (DefaultVersion.Uri).QueryInfo ("time::created", GLib.FileQueryInfoFlags.None, null);
+                return NativeConvert.ToDateTime ((long)info.GetAttributeULong ("time::created"));
+            }
+        }
+
         public Tag [] Tags { get { throw new NotImplementedException (); } }
         public string Name { get { throw new NotImplementedException (); } }
         public uint Rating { get { return 0; } }



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