display undo/redo actions in statusbar
authorgc <gc>
Tue, 12 Apr 2005 21:45:53 +0000 (21:45 +0000)
committergc <gc>
Tue, 12 Apr 2005 21:45:53 +0000 (21:45 +0000)
bin/booh-gui
lib/booh/UndoHandler.rb
po/Makefile

index d9d3cac..276efaf 100755 (executable)
@@ -159,8 +159,8 @@ def build_full_dest_filename(filename)
     return current_dest_dir + '/' + make_dest_filename(from_utf8(filename))
 end
 
-def save_undo(closure, *params)
-    UndoHandler.save_undo(closure, [ *params ])
+def save_undo(name, closure, *params)
+    UndoHandler.save_undo(name, closure, [ *params ])
     $undo_tb.sensitive = $undo_mb.sensitive = true
 end
 
@@ -232,7 +232,8 @@ def create_editzone(scrolledwindow, pagenum)
     }
     textview.signal_connect('key-release-event') { |w, event|
         if candidate_undo_text && candidate_undo_text != textview.buffer.text
-            save_undo(Proc.new { |text|
+            save_undo(_("text edit"),
+                      Proc.new { |text|
                           save_text = textview.buffer.text
                           textview.buffer.text = text
                           textview.grab_focus
@@ -339,7 +340,8 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
 
         cleanup_all_thumbnails.call
 
-        save_undo(Proc.new { |angle|
+        save_undo(angle == 90 ? _("rotate clockwise") : angle == -90 ? _("rotate counter-clockwise") : _("flip upside-down"),
+                  Proc.new { |angle|
                       perform_rotate_and_cleanup.call(angle)
                       $notebook.set_page(1)
                       Proc.new {
@@ -364,7 +366,8 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
         cleanup_all_thumbnails.call
         perform_color_swap_and_cleanup.call
 
-        save_undo(Proc.new {
+        save_undo(_("color swap"),
+                  Proc.new {
                       perform_color_swap_and_cleanup.call
                       $notebook.set_page(1)
                       Proc.new {
@@ -390,7 +393,8 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
         perform_enhance_and_cleanup.call
 
         #- remove out of sync images
-        save_undo(Proc.new {
+        save_undo(_("enhance"),
+                  Proc.new {
                       perform_enhance_and_cleanup.call
                       $notebook.set_page(1)
                       Proc.new {
@@ -412,7 +416,8 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
             end
         }
 
-        save_undo(Proc.new { |pos|
+        save_undo(_("delete"),
+                  Proc.new { |pos|
                       autotable.reinsert(pos, vbox, filename)
                       $notebook.set_page(1)
                       Proc.new {
@@ -499,7 +504,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
             if $r90.active?
                 rotate_and_cleanup.call(90)
             elsif $r270.active?
-                rotate_and_cleanup.call(270)
+                rotate_and_cleanup.call(-90)
             elsif $enhance.active?
                 enhance_and_cleanup.call
             elsif $delete.active?
@@ -515,7 +520,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
             r90.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-90-16.png")
             r90.signal_connect('activate') { rotate_and_cleanup.call(90) }
             r270.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-270-16.png")
-            r270.signal_connect('activate') { rotate_and_cleanup.call(270) }
+            r270.signal_connect('activate') { rotate_and_cleanup.call(-90) }
             if type == 'video'
                 menu.append(             Gtk::SeparatorMenuItem.new)
                 menu.append(color_swap = Gtk::ImageMenuItem.new(utf8(_("Red/blue color swap"))))
@@ -573,7 +578,8 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
                 from, to = selection_data.data.to_i, autotable.get_current_number(vbox)
                 if from != to
                     autotable.move(from, to)
-                    save_undo(Proc.new { |from, to|
+                    save_undo(_("reorder"),
+                              Proc.new { |from, to|
                                   if to > from
                                       autotable.move(to - 1, from)
                                   else
@@ -782,7 +788,8 @@ def change_dir
             perform_rotate_and_cleanup.call(angle)
             system("rm -f '#{thumbnail_file}'")
 
-            save_undo(Proc.new { |angle|
+            save_undo(angle == 90 ? _("rotate clockwise") : angle == -90 ? _("rotate counter-clockwise") : _("flip upside-down"),
+                      Proc.new { |angle|
                           perform_rotate_and_cleanup.call(angle)
                           $notebook.set_page(0)
                           Proc.new {
@@ -803,7 +810,8 @@ def change_dir
             }
             perform_color_swap_and_cleanup.call
 
-            save_undo(Proc.new {
+            save_undo(_("color swap"),
+                      Proc.new {
                           perform_color_swap_and_cleanup.call
                           $notebook.set_page(0)
                           Proc.new {
@@ -826,7 +834,8 @@ def change_dir
             perform_enhance_and_cleanup.call
             
             #- remove out of sync images
-            save_undo(Proc.new {
+            save_undo(_("enhance"),
+                      Proc.new {
                           perform_enhance_and_cleanup.call
                           $notebook.set_page(1)
                           Proc.new {
@@ -840,8 +849,8 @@ def change_dir
             if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 1
                 if $r90.active?
                     rotate_and_cleanup.call(90)
-                elif $r270.active?
-                    rotate_and_cleanup.call(270)
+                elsif $r270.active?
+                    rotate_and_cleanup.call(-90)
                 elsif $enhance.active?
                     enhance_and_cleanup.call
                 end
@@ -857,7 +866,7 @@ def change_dir
                 r90.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-90-16.png")
                 r90.signal_connect('activate') { rotate_and_cleanup.call(90) }
                 r270.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-270-16.png")
-                r270.signal_connect('activate') { rotate_and_cleanup.call(270) }
+                r270.signal_connect('activate') { rotate_and_cleanup.call(-90) }
                 if entry2type(captionfile) == 'video'
                     menu.append(             Gtk::SeparatorMenuItem.new)
                     menu.append(color_swap = Gtk::ImageMenuItem.new(utf8(_("Red/blue color swap"))))
@@ -1128,13 +1137,13 @@ def create_menu_and_toolbar
 
     perform_undo = Proc.new {
         $redo_tb.sensitive = $redo_mb.sensitive = true
-        if not more_undoes = UndoHandler.undo
+        if not more_undoes = UndoHandler.undo($statusbar)
             $undo_tb.sensitive = $undo_mb.sensitive = false
         end
     }
     perform_redo = Proc.new {
         $undo_tb.sensitive = $undo_mb.sensitive = true
-        if not more_redoes = UndoHandler.redo
+        if not more_redoes = UndoHandler.redo($statusbar)
             $redo_tb.sensitive = $redo_mb.sensitive = false
         end
     }
index 2a165b2..a2dbf40 100644 (file)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+require 'gettext'
+include GetText
+bindtextdomain("booh")
+
 module UndoHandler
 
     @undo_actions = []
@@ -26,20 +30,24 @@ module UndoHandler
 
     module_function
 
-    def save_undo(closure, params)
-        @undo_actions << { :closure => closure, :params => params }
+    def save_undo(name, closure, params)
+        @undo_actions << { :name => name, :closure => closure, :params => params }
     end
 
-    def undo
+    def undo(statusbar)
         todo = @undo_actions.pop
         redo_closure = todo[:closure].call(*todo[:params])
-        @redo_actions << { :redo => redo_closure, :undo => todo }
+        statusbar.pop(0)
+        statusbar.push(0, utf8(_("Undo %s.") % todo[:name]))
+        @redo_actions << { :name => todo[:name], :redo => redo_closure, :undo => todo }
         return !@undo_actions.empty?
     end
 
-    def redo
+    def redo(statusbar)
         redo_item = @redo_actions.pop
         redo_item[:redo].call
+        statusbar.pop(0)
+        statusbar.push(0, utf8(_("Redo %s.") % redo_item[:name]))
         @undo_actions << redo_item[:undo]
         return !@redo_actions.empty?
     end
index 10d489d..64c4313 100644 (file)
@@ -2,7 +2,7 @@
 PGOAL = booh
 
 # ruby files to search translatable strings in
-RB_FILES = ../bin/booh ../lib/booh/html-merges.rb ../bin/booh-gui ../lib/booh/booh-lib.rb
+RB_FILES = ../bin/booh ../lib/booh/html-merges.rb ../bin/booh-gui ../lib/booh/booh-lib.rb ../lib/booh/UndoHandler.rb
 
 POFILES = $(wildcard *.po)