[f-spot: 3/16] Added confirmation to the reparenting command.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot: 3/16] Added confirmation to the reparenting command.
- Date: Tue, 25 May 2010 12:48:25 +0000 (UTC)
commit 3231d149e9e05af6046f606c4ca6f382f5b4e166
Author: Anton Keks <anton azib net>
Date: Mon Jul 20 22:51:25 2009 +0300
Added confirmation to the reparenting command.
This prevents accidental reparenting when it is enabled globally.
src/PhotoVersionCommands.cs | 63 +++++++++++++++++++++++++++++-------------
1 files changed, 43 insertions(+), 20 deletions(-)
---
diff --git a/src/PhotoVersionCommands.cs b/src/PhotoVersionCommands.cs
index fd7e759..370b503 100644
--- a/src/PhotoVersionCommands.cs
+++ b/src/PhotoVersionCommands.cs
@@ -198,7 +198,7 @@ public class PhotoVersionCommands
{
string ok_caption = Catalog.GetString ("De_tach");
string msg = String.Format (Catalog.GetString ("Really detach version \"{0}\" from \"{1}\"?"), photo.DefaultVersion.Name, photo.Name.Replace("_", "__"));
- string desc = Catalog.GetString ("This makes the verion appear as a separate photo in the library.");
+ string desc = Catalog.GetString ("This makes the verion appear as a separate photo in the library. To undo, drag the new photo back to its parent.");
try {
if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation(parent_window, DialogFlags.DestroyWithParent,
MessageType.Warning, msg, desc, ok_caption)) {
@@ -231,28 +231,51 @@ public class PhotoVersionCommands
public class Reparent {
public bool Execute (PhotoStore store, Photo [] photos, Photo new_parent, Gtk.Window parent_window)
{
- foreach (Photo photo in photos) {
- new_parent.AddTag (photo.Tags);
- foreach (uint version_id in photo.VersionIds) {
- try {
- new_parent.DefaultVersionId = new_parent.CreateReparentedVersion (photo.GetVersion (version_id) as PhotoVersion);
- store.Commit (new_parent);
- } catch (Exception e) {
- Log.DebugException (e);
- }
- }
- uint [] version_ids = photo.VersionIds;
- Array.Reverse (version_ids);
- foreach (uint version_id in version_ids) {
- try {
- photo.DeleteVersion (version_id, true, true);
- } catch (Exception e) {
- Log.DebugException (e);
+ string ok_caption = Catalog.GetString ("Re_parent");
+ string msg = String.Format (Catalog.GetPluralString ("Really reparent selected photo as version of {1}?",
+ "Really reparent {0} selected photos as versions of {1}?", photos.Length),
+ photos.Length, new_parent.Name.Replace ("_", "__"));
+ string desc = Catalog.GetString ("The tags will be merged with the new parent.");
+
+ try {
+ if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation(parent_window, DialogFlags.DestroyWithParent,
+ MessageType.Warning, msg, desc, ok_caption)) {
+ foreach (Photo photo in photos) {
+ new_parent.AddTag (photo.Tags);
+ foreach (uint version_id in photo.VersionIds) {
+ try {
+ new_parent.DefaultVersionId = new_parent.CreateReparentedVersion (photo.GetVersion (version_id) as PhotoVersion);
+ store.Commit (new_parent);
+ } catch (Exception e) {
+ Log.DebugException (e);
+ }
+ }
+ uint [] version_ids = photo.VersionIds;
+ Array.Reverse (version_ids);
+ foreach (uint version_id in version_ids) {
+ try {
+ photo.DeleteVersion (version_id, true, true);
+ } catch (Exception e) {
+ Log.DebugException (e);
+ }
+ }
+ App.Instance.Database.Photos.Remove (photo);
}
+ return true;
}
- App.Instance.Database.Photos.Remove (photo);
}
- return true;
+ catch (Exception e) {
+ Log.DebugException (e);
+ msg = Catalog.GetString ("Could not reparent photos");
+ desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to reparent to \"{1}\""),
+ e.Message, new_parent.Name);
+ HigMessageDialog md = new HigMessageDialog (parent_window, DialogFlags.DestroyWithParent,
+ Gtk.MessageType.Error, ButtonsType.Ok, msg, desc);
+ md.Run ();
+ md.Destroy ();
+ }
+
+ return false;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]