handle undo in changedir for captionfile for subalbums
[booh] / bin / booh
index a278275e24e7a7cdbdd71a61a6cce7833aee0fde..1d78874d1c31b5584cb59bbfefb2aac171b9d342 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -1021,14 +1021,40 @@ def change_dir
                 end
             }
             if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
+                $modified = true
+                old_file = captionfile
+                old_rotate = xmldir.attributes["#{infotype}-rotate"]
+                old_color_swap = xmldir.attributes["#{infotype}-color-swap"]
+                old_enhance = xmldir.attributes["#{infotype}-enhance"]
+                old_frame_offset = xmldir.attributes["#{infotype}-frame-offset"]
+
+                new_file = fc.filename
                 msg 3, "new captionfile is: #{fc.filename}"
-                $subalbums_edits[xmldir.attributes['path']][:captionfile] = captionfile = fc.filename
-                $rotated_pixbufs.delete(thumbnail_file)
-                xmldir.delete_attribute("#{infotype}-rotate")
-                xmldir.delete_attribute("#{infotype}-color-swap")
-                xmldir.delete_attribute("#{infotype}-enhance")
-                xmldir.delete_attribute("#{infotype}-frame-offset")
-                my_gen_real_thumbnail.call
+                perform_changefile = Proc.new {
+                    $subalbums_edits[xmldir.attributes['path']][:captionfile] = captionfile = new_file
+                    $rotated_pixbufs.delete(thumbnail_file)
+                    xmldir.delete_attribute("#{infotype}-rotate")
+                    xmldir.delete_attribute("#{infotype}-color-swap")
+                    xmldir.delete_attribute("#{infotype}-enhance")
+                    xmldir.delete_attribute("#{infotype}-frame-offset")
+                    my_gen_real_thumbnail.call
+                }
+                perform_changefile.call
+
+                save_undo(_("change caption file for sub-album"),
+                          Proc.new {
+                              $subalbums_edits[xmldir.attributes['path']][:captionfile] = captionfile = old_file
+                              xmldir.add_attribute("#{infotype}-rotate", old_rotate)
+                              xmldir.add_attribute("#{infotype}-color-swap", old_color_swap)
+                              xmldir.add_attribute("#{infotype}-enhance", old_enhance)
+                              xmldir.add_attribute("#{infotype}-frame-offset", old_frame_offset)
+                              my_gen_real_thumbnail.call
+                              $notebook.set_page(0)
+                              Proc.new {
+                                  perform_changefile.call
+                                  $notebook.set_page(0)
+                              }
+                          })
             end
             fc.destroy
         }