[f-spot: 10/16] Try to derive reparented version name from its filename.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot: 10/16] Try to derive reparented version name from its filename.
- Date: Tue, 25 May 2010 12:49:01 +0000 (UTC)
commit 25b0a98f13f9476ec7e85ba42bdb2bfda9c0caf7
Author: Anton Keks <anton azib net>
Date: Mon Aug 3 19:45:04 2009 +0300
Try to derive reparented version name from its filename.
This preserves version names when detaching and reparenting again.
src/Core/Photo.cs | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/src/Core/Photo.cs b/src/Core/Photo.cs
index c460893..3a8c6a5 100644
--- a/src/Core/Photo.cs
+++ b/src/Core/Photo.cs
@@ -360,22 +360,24 @@ namespace FSpot
public uint CreateReparentedVersion (PhotoVersion version, bool is_protected)
{
- int num = 0;
- while (true) {
- num++;
+ // Try to derive version name from its filename
+ string filename = Uri.UnescapeDataString (Path.GetFileNameWithoutExtension (version.Uri.AbsolutePath));
+ string parent_filename = Path.GetFileNameWithoutExtension (Name);
+ string name = null;
+ if (filename.StartsWith (parent_filename))
+ name = filename.Substring (parent_filename.Length).Replace ("(", "").Replace (")", "").Replace ("_", " "). Trim();
+
+ for (int num = 1; name == null || VersionNameExists (name); num++) {
// Note for translators: Reparented is a picture becoming a version of another one
- string name = (num == 1) ? Catalog.GetString ("Reparented") : String.Format (Catalog.GetString( "Reparented ({0})"), num);
+ name = Catalog.GetString (num == 1 ? "Reparented" : "Reparented ({0})");
name = String.Format (name, num);
- if (VersionNameExists (name))
- continue;
-
- highest_version_id ++;
- versions [highest_version_id] = new PhotoVersion (this, highest_version_id, version.Uri, version.MD5Sum, name, is_protected);
+ }
+ highest_version_id ++;
+ versions [highest_version_id] = new PhotoVersion (this, highest_version_id, version.Uri, version.MD5Sum, name, is_protected);
- changes.AddVersion (highest_version_id);
+ changes.AddVersion (highest_version_id);
- return highest_version_id;
- }
+ return highest_version_id;
}
public uint CreateDefaultModifiedVersion (uint base_version_id, bool create_file)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]