[f-spot/taglib-metadata: 7/20] Pull date handling out of Imaging.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/taglib-metadata: 7/20] Pull date handling out of Imaging.
- Date: Sat, 26 Jun 2010 19:36:40 +0000 (UTC)
commit 0f1758a6491dade8b97bed15132a25c4fe6412d8
Author: Ruben Vermeersch <ruben savanne be>
Date: Sat Jun 12 13:52:49 2010 +0200
Pull date handling out of Imaging.
Also move PhotoStore creating to a model that uses IBrowsableItem.
src/FileBrowsableItem.cs | 17 +++++++++++++----
src/Imaging/Ciff.cs | 14 --------------
src/Imaging/ImageFile.cs | 9 ---------
src/Imaging/JpegFile.cs | 7 -------
src/Imaging/MrwFile.cs | 12 ------------
src/Imaging/PngFile.cs | 15 ---------------
src/Imaging/Tiff.cs | 25 -------------------------
7 files changed, 13 insertions(+), 86 deletions(-)
---
diff --git a/src/FileBrowsableItem.cs b/src/FileBrowsableItem.cs
index f4aa3dc..be92366 100644
--- a/src/FileBrowsableItem.cs
+++ b/src/FileBrowsableItem.cs
@@ -16,6 +16,7 @@ using System.Xml;
using Hyena;
using FSpot.Utils;
+using Mono.Unix.Native;
namespace FSpot {
public class FileBrowsableItem : IBrowsableItem
@@ -34,10 +35,11 @@ namespace FSpot {
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;
}
@@ -56,6 +58,13 @@ namespace FSpot {
}
}
+ 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 IBrowsableItemVersion DefaultVersion { get; private set; }
private string description;
diff --git a/src/Imaging/Ciff.cs b/src/Imaging/Ciff.cs
index 66425f6..97994ba 100644
--- a/src/Imaging/Ciff.cs
+++ b/src/Imaging/Ciff.cs
@@ -432,20 +432,6 @@ namespace FSpot.Ciff {
return orientation;
}
- public override System.DateTime Date {
- get {
- ImageDirectory props = Root.ReadDirectory (Tag.ImageProps);
- byte [] date = props.ReadEntry (Tag.TimeStamp);
-
- if (date == null) {
- Log.Debug ("NO DATE");
- return base.Date;
- }
-
- return new CaptureTime (date, little).LocalTime;
- }
- }
-
public override System.IO.Stream PixbufStream ()
{
byte [] data = GetEmbeddedJpeg ();
diff --git a/src/Imaging/ImageFile.cs b/src/Imaging/ImageFile.cs
index dab045a..1e8ee4d 100644
--- a/src/Imaging/ImageFile.cs
+++ b/src/Imaging/ImageFile.cs
@@ -166,15 +166,6 @@ namespace FSpot {
return null;
}
- public virtual System.DateTime Date
- {
- get {
- GFileInfo info = GLib.FileFactory.NewForUri (uri).QueryInfo ("time::modified", GLib.FileQueryInfoFlags.None, null);
- DateTime create = NativeConvert.ToDateTime ((long)info.GetAttributeULong ("time::modified"));
- return create;
- }
- }
-
public static bool HasLoader (SafeUri uri)
{
return GetLoaderType (uri) != null;
diff --git a/src/Imaging/JpegFile.cs b/src/Imaging/JpegFile.cs
index b187e8d..5a7d8e6 100644
--- a/src/Imaging/JpegFile.cs
+++ b/src/Imaging/JpegFile.cs
@@ -183,12 +183,5 @@ namespace FSpot {
metadata_file.ImageTag.DateTime = time;
}
- public override System.DateTime Date {
- get {
- var date = metadata_file.ImageTag.DateTime;
- return date.HasValue ? date.Value : base.Date;
- }
- }
-
}
}
diff --git a/src/Imaging/MrwFile.cs b/src/Imaging/MrwFile.cs
index df334aa..edc71d5 100644
--- a/src/Imaging/MrwFile.cs
+++ b/src/Imaging/MrwFile.cs
@@ -192,18 +192,6 @@ namespace FSpot.Mrw {
}
}
- public override System.DateTime Date
- {
- get {
- DirectoryEntry e = this.Header.Directory.Lookup (TagId.DateTime);
-
- if (e != null)
- return DirectoryEntry.DateTimeFromString (e.StringValue);
- else
- return base.Date;
- }
- }
-
public void Select (SemWeb.StatementSink sink)
{
this.Header.Select (sink);
diff --git a/src/Imaging/PngFile.cs b/src/Imaging/PngFile.cs
index cc64eec..be87c09 100644
--- a/src/Imaging/PngFile.cs
+++ b/src/Imaging/PngFile.cs
@@ -1375,20 +1375,5 @@ namespace FSpot.Png {
}
Header.Insert (itext);
}
-
- public override System.DateTime Date {
- get {
- // FIXME: we should first try parsing the
- // LookupText ("Creation Time") as a valid date
-
- foreach (Chunk chunk in Chunks) {
- TimeChunk time = chunk as TimeChunk;
- if (time != null)
- return time.Time;
- }
- return base.Date;
- }
- }
-
}
}
diff --git a/src/Imaging/Tiff.cs b/src/Imaging/Tiff.cs
index 13b2769..e7df951 100644
--- a/src/Imaging/Tiff.cs
+++ b/src/Imaging/Tiff.cs
@@ -2035,31 +2035,6 @@ namespace FSpot.Tiff {
Header.SelectDirectory (Header.Directory, sink);
}
- public override System.DateTime Date {
- get {
- SubdirectoryEntry sub = (SubdirectoryEntry) this.Header.Directory.Lookup (TagId.ExifIfdPointer);
- DirectoryEntry e;
-
- try {
- if (sub != null) {
- e = sub.Directory [0].Lookup (TagId.DateTimeOriginal);
-
- if (e != null)
- return DirectoryEntry.DateTimeFromString (e.StringValue);
- }
-
- e = this.Header.Directory.Lookup (TagId.DateTime);
-
- if (e != null)
- return DirectoryEntry.DateTimeFromString (e.StringValue);
- else
- return base.Date;
- } catch (Exception) {
- return base.Date;
- }
- }
- }
-
public override PixbufOrientation GetOrientation ()
{
ShortEntry e = (ShortEntry)(this.Header.Directory.Lookup (TagId.Orientation));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]