51
public VersionNameRequest (RequestType request_type, Photo photo, Gtk.Window parent_window) : base ("version_name_dialog")
51
public VersionNameRequest (RequestType request_type, Photo photo, Gtk.Window parent_window) : base ("version_name_dialog.ui", "version_name_dialog")
53
53
this.request_type = request_type;
54
54
this.photo = photo;
56
56
switch (request_type) {
57
57
case RequestType.Create:
58
this.Dialog.Title = Catalog.GetString ("Create New Version");
58
this.Title = Catalog.GetString ("Create New Version");
59
59
prompt_label.Text = Catalog.GetString ("Name:");
62
62
case RequestType.Rename:
63
this.Dialog.Title = Catalog.GetString ("Rename Version");
63
this.Title = Catalog.GetString ("Rename Version");
64
64
prompt_label.Text = Catalog.GetString ("New name:");
65
65
version_name_entry.Text = photo.GetVersion (photo.DefaultVersionId).Name;
66
66
version_name_entry.SelectRegion (0, -1);
130
120
public class Delete {
131
121
public bool Execute (PhotoStore store, Photo photo, Gtk.Window parent_window)
134
Dialog dialog = new Dialog ();
135
dialog.BorderWidth = 6;
136
dialog.TransientFor = parent_window;
137
dialog.HasSeparator = false;
138
dialog.Title = Catalog.GetString ("Really Delete?");
139
dialog.AddButton (Catalog.GetString ("Cancel"), (int) ResponseType.Cancel);
140
dialog.AddButton (Catalog.GetString ("Delete"), (int) ResponseType.Ok);
141
dialog.DefaultResponse = ResponseType.Ok;
143
string version_name = photo.GetVersion (photo.DefaultVersionId).Name;
144
Label label = new Label (String.Format (Catalog.GetString ("Really delete version \"{0}\"?"), version_name));
146
dialog.VBox.PackStart (label, false, true, 6);;
148
if (dialog.Run () == (int) ResponseType.Ok) {
123
string ok_caption = Catalog.GetString ("Delete");
124
string msg = String.Format (Catalog.GetString ("Really delete version \"{0}\"?"), photo.DefaultVersion.Name);
125
string desc = Catalog.GetString ("This removes the version and deletes the corresponding file from disk.");
127
if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation(parent_window, DialogFlags.DestroyWithParent,
128
MessageType.Warning, msg, desc, ok_caption)) {
150
129
photo.DeleteVersion (photo.DefaultVersionId);
151
130
store.Commit (photo);
152
} catch (Exception e) {
153
Log.DebugException (e);
154
string msg = Catalog.GetString ("Could not delete a version");
155
string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to delete version \"{1}\""),
156
e.Message, photo.Name);
158
HigMessageDialog md = new HigMessageDialog (parent_window, DialogFlags.DestroyWithParent,
159
Gtk.MessageType.Error, ButtonsType.Ok,
164
dialog.Destroy (); // Delete confirmation window.
133
} catch (Exception e) {
134
HandleException ("Could not delete a version", e, parent_window);
178
140
// Renaming a version.
180
142
public class Rename {
193
155
photo.RenameVersion (photo.DefaultVersionId, new_name);
194
156
store.Commit (photo);
195
158
} catch (Exception e) {
196
string msg = Catalog.GetString ("Could not rename a version");
197
string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to rename version to \"{1}\""),
198
e.Message, new_name);
200
HigMessageDialog md = new HigMessageDialog (parent_window, DialogFlags.DestroyWithParent,
201
Gtk.MessageType.Error, ButtonsType.Ok,
159
HandleException ("Could not rename a version", e, parent_window);
165
// Detaching a version (making it a separate photo).
167
public class Detach {
168
public bool Execute (PhotoStore store, Photo photo, Gtk.Window parent_window)
170
string ok_caption = Catalog.GetString ("De_tach");
171
string msg = String.Format (Catalog.GetString ("Really detach version \"{0}\" from \"{1}\"?"), photo.DefaultVersion.Name, photo.Name.Replace("_", "__"));
172
string desc = Catalog.GetString ("This makes the version appear as a separate photo in the library. To undo, drag the new photo back to its parent.");
174
if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation(parent_window, DialogFlags.DestroyWithParent,
175
MessageType.Warning, msg, desc, ok_caption)) {
176
Photo new_photo = store.CreateFrom (photo, photo.RollId);
177
new_photo.CopyAttributesFrom (photo);
178
photo.DeleteVersion (photo.DefaultVersionId, false, true);
179
store.Commit (new Photo[] {new_photo, photo});
182
} catch (Exception e) {
183
HandleException ("Could not detach a version", e, parent_window);
213
189
// Reparenting a photo as version of another one
214
191
public class Reparent {
215
192
public bool Execute (PhotoStore store, Photo [] photos, Photo new_parent, Gtk.Window parent_window)
217
foreach (Photo photo in photos) {
218
new_parent.AddTag (photo.Tags);
219
foreach (uint version_id in photo.VersionIds) {
221
new_parent.DefaultVersionId = new_parent.CreateReparentedVersion (photo.GetVersion (version_id) as PhotoVersion);
222
store.Commit (new_parent);
223
} catch (Exception e) {
224
Log.DebugException (e);
227
uint [] version_ids = photo.VersionIds;
228
Array.Reverse (version_ids);
229
foreach (uint version_id in version_ids) {
231
photo.DeleteVersion (version_id, true, true);
232
} catch (Exception e) {
233
Log.DebugException (e);
236
MainWindow.Toplevel.Database.Photos.Remove (photo);
194
string ok_caption = Catalog.GetString ("Re_parent");
195
string msg = String.Format (Catalog.GetPluralString ("Really reparent \"{0}\" as version of \"{1}\"?",
196
"Really reparent {2} photos as versions of \"{1}\"?", photos.Length),
197
new_parent.Name.Replace ("_", "__"), photos[0].Name.Replace ("_", "__"), photos.Length);
198
string desc = Catalog.GetString ("This makes the photos appear as a single one in the library. The versions can be detached using the Photo menu.");
201
if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation(parent_window, DialogFlags.DestroyWithParent,
202
MessageType.Warning, msg, desc, ok_caption)) {
203
uint highest_rating = new_parent.Rating;
204
string new_description = new_parent.Description;
205
foreach (Photo photo in photos) {
206
highest_rating = Math.Max(photo.Rating, highest_rating);
207
if (string.IsNullOrEmpty(new_description))
208
new_description = photo.Description;
209
new_parent.AddTag (photo.Tags);
211
foreach (uint version_id in photo.VersionIds) {
212
new_parent.DefaultVersionId = new_parent.CreateReparentedVersion (photo.GetVersion (version_id) as PhotoVersion);
213
store.Commit (new_parent);
215
uint [] version_ids = photo.VersionIds;
216
Array.Reverse (version_ids);
217
foreach (uint version_id in version_ids) {
218
photo.DeleteVersion (version_id, true, true);
220
store.Remove (photo);
222
new_parent.Rating = highest_rating;
223
new_parent.Description = new_description;
224
store.Commit (new_parent);
228
catch (Exception e) {
229
HandleException ("Could not reparent photos", e, parent_window);
235
private static void HandleException (string msg, Exception e, Gtk.Window parent_window) {
236
Log.DebugException (e);
237
msg = Catalog.GetString (msg);
238
string desc = String.Format (Catalog.GetString ("Received exception \"{0}\"."), e.Message);
239
HigMessageDialog md = new HigMessageDialog (parent_window, DialogFlags.DestroyWithParent,
240
Gtk.MessageType.Error, ButtonsType.Ok, msg, desc);