f-spot r3552 - in trunk: . src
- From: sdelcroix svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r3552 - in trunk: . src
- Date: Wed, 16 Jan 2008 16:44:39 +0000 (GMT)
Author: sdelcroix
Date: Wed Jan 16 16:44:39 2008
New Revision: 3552
URL: http://svn.gnome.org/viewvc/f-spot?rev=3552&view=rev
Log:
2008-01-16 Stephane Delcroix <sdelcroix novell com>
* src/main.cs: minor fixes.
* src/PhotoVersion.cs:
* src/PhotoStore.cs:
* src/Makefile.am: the PhotoVersion class deserve its own file too.
* src/IBrowsableItem.cs:
* src/TagStore.cs: moved the tests to Tests
Added:
trunk/src/PhotoVersion.cs
Modified:
trunk/ChangeLog
trunk/src/IBrowsableItem.cs
trunk/src/Makefile.am
trunk/src/PhotoStore.cs
trunk/src/PhotoVersionCommands.cs
trunk/src/TagStore.cs
trunk/src/main.cs
Modified: trunk/src/IBrowsableItem.cs
==============================================================================
--- trunk/src/IBrowsableItem.cs (original)
+++ trunk/src/IBrowsableItem.cs Wed Jan 16 16:44:39 2008
@@ -1,7 +1,3 @@
-#if ENABLE_NUNIT
-using NUnit.Framework;
-#endif
-
namespace FSpot {
public delegate void IBrowsableCollectionChangedHandler (IBrowsableCollection collection);
public delegate void IBrowsableCollectionItemsChangedHandler (IBrowsableCollection collection, BrowsableArgs args);
@@ -239,83 +235,5 @@
SetIndex (0);
}
-#if ENABLE_NUNIT
- [TestFixture]
- public class Tests
- {
- BrowsablePointer item;
- UriCollection collection;
- bool changed;
-
- public Tests ()
- {
- Gnome.Vfs.Vfs.Initialize ();
-
- collection = new FSpot.UriCollection ();
- item = new BrowsablePointer (collection, 0);
- item.Changed += delegate {
- changed = true;
- };
- }
-
- [Test]
- public void ChangeNotification ()
- {
- collection.Clear ();
- item.Index = 0;
-
- collection.Add (new System.Uri ("file:///blah.jpg"));
- Assert.IsTrue (item.IsValid);
- Assert.IsTrue (changed);
-
- changed = false;
- collection.Add (new System.Uri ("file:///test.png"));
- Assert.IsFalse (changed);
-
- collection.MarkChanged (0);
- Assert.IsTrue (changed);
-
- changed = false;
- item.MoveNext ();
- Assert.IsTrue (changed);
- Assert.AreEqual (item.Index, 1);
-
- changed = false;
- collection.Add (new System.Uri ("file:///bill.png"));
- Assert.IsFalse (changed);
- }
-
- [Test]
- public void Motion ()
- {
- collection.Clear ();
- item.Index = 0;
-
- collection.Add (new System.Uri ("file:///fake.png"));
- collection.Add (new System.Uri ("file:///mynameisedd.jpg"));
- Assert.AreEqual (item.Index, 0);
-
- changed = false;
- item.MoveNext ();
- Assert.IsTrue (changed);
-
- Assert.AreEqual (item.Index, 1);
- item.MoveNext ();
- Assert.AreEqual (item.Index, 1);
- item.MoveNext (true);
- Assert.AreEqual (item.Index, 0);
-
- changed = false;
- item.MovePrevious (true);
- Assert.IsTrue (changed);
-
- Assert.AreEqual (item.Index, 1);
- item.MovePrevious ();
- Assert.AreEqual (item.Index, 0);
- item.MovePrevious ();
- Assert.AreEqual (item.Index, 0);
- }
- }
-#endif
}
}
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Jan 16 16:44:39 2008
@@ -163,6 +163,7 @@
$(srcdir)/PhotoQuery.cs \
$(srcdir)/PhotoStore.cs \
$(srcdir)/PhotoTagMenu.cs \
+ $(srcdir)/PhotoVersion.cs \
$(srcdir)/PhotoVersionCommands.cs \
$(srcdir)/PhotoVersionMenu.cs \
$(srcdir)/PhotoView.cs \
Modified: trunk/src/PhotoStore.cs
==============================================================================
--- trunk/src/PhotoStore.cs (original)
+++ trunk/src/PhotoStore.cs Wed Jan 16 16:44:39 2008
@@ -2,9 +2,9 @@
* PhotoStore.cs
*
* Author(s):
- Ettore Perazzoli <ettore perazzoli org>
- Larry Ewing <lewing gnome org>
- Stephane Delcroix <stephane delcroix org>
+ * Ettore Perazzoli <ettore perazzoli org>
+ * Larry Ewing <lewing gnome org>
+ * Stephane Delcroix <stephane delcroix org>
*
* This is free software. See COPYING for details.
*/
@@ -35,70 +35,6 @@
}
}
-public class PhotoVersion : FSpot.IBrowsableItem
-{
- Photo photo;
- uint version_id;
- System.Uri uri;
- string name;
- bool is_protected;
-
- public System.DateTime Time {
- get { return photo.Time; }
- }
-
- public Tag [] Tags {
- get { return photo.Tags; }
- }
-
- public System.Uri DefaultVersionUri {
- get { return uri; }
- }
-
- public string Description {
- get { return photo.Description; }
- }
-
- public string Name {
- get { return name; }
- set { name = value; }
- }
-
- public Photo Photo {
- get { return photo; }
- }
-
- public System.Uri Uri {
- get { return uri; }
- set {
- if (value == null)
- throw new System.ArgumentNullException ("uri");
- uri = value;
- }
- }
-
- public uint VersionId {
- get { return version_id; }
- }
-
- public bool IsProtected {
- get { return is_protected; }
- }
-
- public uint Rating {
- get { return photo.Rating; }
- }
-
- public PhotoVersion (Photo photo, uint version_id, System.Uri uri, string name, bool is_protected)
- {
- this.photo = photo;
- this.version_id = version_id;
- this.uri = uri;
- this.name = name;
- this.is_protected = is_protected;
- }
-}
-
public class Photo : DbItem, IComparable, FSpot.IBrowsableItem {
// IComparable
public int CompareTo (object obj) {
@@ -1260,7 +1196,7 @@
query_builder.Append (condition.SqlClause ());
where_added = true;
}
- query_builder.Append("ORDER BY time");
+ query_builder.Append(" ORDER BY time ");
return Query (query_builder.ToString ());
}
@@ -1428,118 +1364,4 @@
Console.WriteLine ("Query: {0}", query_builder.ToString());
return Query (query_builder.ToString ());
}
-
-#if TEST_PHOTO_STORE
- static void Dump (Photo photo)
- {
- // Console.WriteLine ("\t[{0}] {1}", photo.Id, photo.Path);
- Console.WriteLine ("\t{0}", photo.Time.ToLocalTime ());
-
- if (photo.Description != String.Empty)
- Console.WriteLine ("\t{0}", photo.Description);
- else
- Console.WriteLine ("\t(no description)");
-
- Console.WriteLine ("\tTags:");
-
- if (photo.Tags.Count == 0) {
- Console.WriteLine ("\t\t(no tags)");
- } else {
- foreach (Tag t in photo.Tags)
- Console.WriteLine ("\t\t{0}", t.Name);
- }
-
- Console.WriteLine ("\tVersions:");
-
- foreach (uint id in photo.VersionIds)
- Console.WriteLine ("\t\t[{0}] {1}", id, photo.GetVersionName (id));
- }
-
- static void Dump (ArrayList photos)
- {
- foreach (Photo p in photos)
- Dump (p);
- }
-
- static void DumpAll (Db db)
- {
- Console.WriteLine ("\n*** All pictures");
- Dump (db.Photos.Query (null));
- }
-
- static void DumpForTags (Db db, ArrayList tags)
- {
- Console.Write ("\n*** Pictures for tags: ");
- foreach (Tag t in tags)
- Console.Write ("{0} ", t.Name);
- Console.WriteLine ();
-
- Dump (db.Photos.Query (tags));
- }
-
- static void Main (string [] args)
- {
- Program program = new Program ("PhotoStoreTest", "0.0", Modules.UI, args);
-
- const string path = "/tmp/PhotoStoreTest.db";
-
- try {
- File.Delete (path);
- } catch {}
-
- Db db = new Db (path, true);
-
- Tag portraits_tag = db.Tags.CreateTag (null, "Portraits");
- Tag landscapes_tag = db.Tags.CreateTag (null, "Landscapes");
- Tag favorites_tag = db.Tags.CreateTag (null, "Street");
-
- uint portraits_tag_id = portraits_tag.Id;
- uint landscapes_tag_id = landscapes_tag.Id;
- uint favorites_tag_id = favorites_tag.Id;
-
- Pixbuf unused_thumbnail;
-
- Photo ny_landscape = db.Photos.Create (DateTime.Now.ToUniversalTime (), 1, "/home/ettore/Photos/ny_landscape.jpg",
- out unused_thumbnail);
- ny_landscape.Description = "Pretty NY skyline";
- ny_landscape.AddTag (landscapes_tag);
- ny_landscape.AddTag (favorites_tag);
- db.Photos.Commit (ny_landscape);
-
- Photo me_in_sf = db.Photos.Create (DateTime.Now.ToUniversalTime (), 2, "/home/ettore/Photos/me_in_sf.jpg",
- out unused_thumbnail);
- me_in_sf.AddTag (landscapes_tag);
- me_in_sf.AddTag (portraits_tag);
- me_in_sf.AddTag (favorites_tag);
- db.Photos.Commit (me_in_sf);
-
- me_in_sf.RemoveTag (favorites_tag);
- me_in_sf.Description = "Myself and the SF skyline";
- me_in_sf.CreateVersion ("cropped", Photo.OriginalVersionId);
- me_in_sf.CreateVersion ("UM-ed", Photo.OriginalVersionId);
- db.Photos.Commit (me_in_sf);
-
- Photo macro_shot = db.Photos.Create (DateTime.Now.ToUniversalTime (), 2, "/home/ettore/Photos/macro_shot.jpg",
- out unused_thumbnail);
- db.Dispose ();
-
- db = new Db (path, false);
-
- DumpAll (db);
-
- portraits_tag = db.Tags.Get (portraits_tag_id) as Tag;
- landscapes_tag = db.Tags.Get (landscapes_tag_id) as Tag;
- favorites_tag = db.Tags.Get (favorites_tag_id) as Tag;
-
- ArrayList query_tags = new ArrayList ();
- query_tags.Add (portraits_tag);
- query_tags.Add (landscapes_tag);
- DumpForTags (db, query_tags);
-
- query_tags.Clear ();
- query_tags.Add (favorites_tag);
- DumpForTags (db, query_tags);
- }
-
-#endif
}
Added: trunk/src/PhotoVersion.cs
==============================================================================
--- (empty file)
+++ trunk/src/PhotoVersion.cs Wed Jan 16 16:44:39 2008
@@ -0,0 +1,77 @@
+/*
+ * PhotoStore.cs
+ *
+ * Author(s):
+ * Ettore Perazzoli <ettore perazzoli org>
+ * Larry Ewing <lewing gnome org>
+ * Stephane Delcroix <stephane delcroix org>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+namespace FSpot
+{
+ public class PhotoVersion : FSpot.IBrowsableItem
+ {
+ Photo photo;
+ uint version_id;
+ System.Uri uri;
+ string name;
+ bool is_protected;
+
+ public System.DateTime Time {
+ get { return photo.Time; }
+ }
+
+ public Tag [] Tags {
+ get { return photo.Tags; }
+ }
+
+ public System.Uri DefaultVersionUri {
+ get { return uri; }
+ }
+
+ public string Description {
+ get { return photo.Description; }
+ }
+
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public Photo Photo {
+ get { return photo; }
+ }
+
+ public System.Uri Uri {
+ get { return uri; }
+ set {
+ if (value == null)
+ throw new System.ArgumentNullException ("uri");
+ uri = value;
+ }
+ }
+
+ public uint VersionId {
+ get { return version_id; }
+ }
+
+ public bool IsProtected {
+ get { return is_protected; }
+ }
+
+ public uint Rating {
+ get { return photo.Rating; }
+ }
+
+ public PhotoVersion (Photo photo, uint version_id, System.Uri uri, string name, bool is_protected)
+ {
+ this.photo = photo;
+ this.version_id = version_id;
+ this.uri = uri;
+ this.name = name;
+ this.is_protected = is_protected;
+ }
+ }
+}
Modified: trunk/src/PhotoVersionCommands.cs
==============================================================================
--- trunk/src/PhotoVersionCommands.cs (original)
+++ trunk/src/PhotoVersionCommands.cs Wed Jan 16 16:44:39 2008
@@ -2,6 +2,7 @@
using Glade;
using System;
using Mono.Unix;
+using FSpot;
public class PhotoVersionCommands {
Modified: trunk/src/TagStore.cs
==============================================================================
--- trunk/src/TagStore.cs (original)
+++ trunk/src/TagStore.cs Wed Jan 16 16:44:39 2008
@@ -568,64 +568,4 @@
}
}
}
-
-
-
-#if TEST_TAG_STORE
-
- private static void Dump (Category category, int indent)
- {
- foreach (Tag tag in category.Children) {
- for (int i = 0; i < indent; i ++)
- Console.Write ("\t");
-
- Console.Write (tag.Name);
- if (tag is Category)
- Console.Write (" (category)");
- Console.Write ("\n");
-
- if (tag is Category)
- Dump (tag as Category, indent + 1);
- }
- }
-
- static void Main (string [] args)
- {
- Program program = new Program ("TagStoreTest", "0.0", Modules.UI, args);
-
- const string path = "/tmp/TagStoreTest.db";
-
- try {
- File.Delete (path);
- } catch {}
-
- Db db = new Db (path, true);
-
- Category people_category = db.Tags.CreateCategory (null, "People");
- Tag anna_tag = db.Tags.CreateTag (people_category, "Anna");
- Tag ettore_tag = db.Tags.CreateTag (people_category, "Ettore");
- Tag miggy_tag = db.Tags.CreateTag (people_category, "Miggy");
- miggy_tag.SortPriority = -1;
- db.Tags.Commit (miggy_tag);
-
- Category places_category = db.Tags.CreateCategory (null, "Places");
- Tag milan_tag = db.Tags.CreateTag (places_category, "Milan");
- Tag boston_tag = db.Tags.CreateTag (places_category, "Boston");
-
- Category exotic_category = db.Tags.CreateCategory (places_category, "Exotic");
- Tag bengalore_tag = db.Tags.CreateTag (exotic_category, "Bengalore");
- Tag manila_tag = db.Tags.CreateTag (exotic_category, "Manila");
- Tag tokyo_tag = db.Tags.CreateTag (exotic_category, "Tokyo");
-
- tokyo_tag.Category = places_category;
- tokyo_tag.Name = "Paris";
- db.Tags.Commit (tokyo_tag);
-
- db.Dispose ();
-
- db = new Db (path, false);
- Dump (db.Tags.RootCategory, 0);
- }
-
-#endif
}
Modified: trunk/src/main.cs
==============================================================================
--- trunk/src/main.cs (original)
+++ trunk/src/main.cs Wed Jan 16 16:44:39 2008
@@ -42,7 +42,6 @@
bool view = false;
bool slideshow = false;
string import_uri = null;
- string view_uri = null;
for (int i = 0; i < args.Length && !shutdown; i++) {
switch (args [i]) {
@@ -104,7 +103,6 @@
default:
Help ();
return 1;
- break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]