handle enhance in toolbar as well
authorgc <gc>
Tue, 12 Apr 2005 21:03:06 +0000 (21:03 +0000)
committergc <gc>
Tue, 12 Apr 2005 21:03:06 +0000 (21:03 +0000)
bin/booh-gui

index 6b707340f9137cb800eaadd0fa7dcd436964852b..d9d3cac9a7d6bd5ce2177f5783f71c418c098248 100755 (executable)
@@ -125,17 +125,28 @@ def write_config
     ios.close
 end
 
-def set_mousecursor(widget, what)
-    if widget.window
-        widget.window.set_cursor(Gdk::Cursor.new(what))
+def set_mousecursor(what, *widget)
+    if widget[0] && widget[0].window
+        widget[0].window.set_cursor(Gdk::Cursor.new(what))
     end
+    if $main_window.window
+        $main_window.window.set_cursor(Gdk::Cursor.new(what))
+    end
+    $current_cursor = what
 end
-def set_mousecursor_wait(widget)
-    set_mousecursor(widget, Gdk::Cursor::WATCH)
+def set_mousecursor_wait(*widget)
+    set_mousecursor(Gdk::Cursor::WATCH, *widget)
     Gtk.main_iteration while Gtk.events_pending?
 end
-def set_mousecursor_normal(widget)
-    set_mousecursor(widget, Gdk::Cursor::LEFT_PTR)
+def set_mousecursor_normal(*widget)
+    set_mousecursor(Gdk::Cursor::LEFT_PTR, *widget)
+end
+def push_mousecursor_wait(*widget)
+    $save_cursor = $current_cursor
+    set_mousecursor_wait(*widget)
+end
+def pop_mousecursor(*widget)
+    set_mousecursor($save_cursor || Gdk::Cursor::LEFT_PTR, *widget)
 end
 
 def current_dest_dir
@@ -171,9 +182,9 @@ def view_element(filename)
                 dest_img = alternatives[-1]
             end
         else
-            set_mousecursor_wait($main_window)
+            push_mousecursor_wait
             gen_thumbnails_element(from_utf8("#{$current_path}/#{filename}"), $xmldir, false, [ { 'filename' => dest_img, 'size' => $default_size['fullscreen'] } ])
-            set_mousecursor_normal($main_window)
+            pop_mousecursor
             if !File.exists?(dest_img)
                 msg 2, _("Could not generate fullscreen thumbnail!")
                 return
@@ -271,7 +282,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
     frame1 = Gtk::Frame.new
     gen_real_thumbnail = Proc.new {
         Thread.new {
-            set_mousecursor_wait(frame1)
+            push_mousecursor_wait
             gen_thumbnails_element(from_utf8("#{$current_path}/#{filename}"), $xmldir, false, [ { 'filename' => thumbnail_img, 'size' => $default_size['thumbnails'] } ])
             img.set(thumbnail_img)
             $rotated_pixbufs[thumbnail_img] = { :orig => img.pixbuf, :pixbuf => img.pixbuf, :angle_to_orig => 0 }
@@ -279,7 +290,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
                 #- cleanup temp for videos
                 system("rm -f #{current_dest_dir}/screenshot.jpg00000*")
             end
-            set_mousecursor_normal(frame1)
+            pop_mousecursor
         }
     }
 
@@ -485,12 +496,14 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
     evtbox.signal_connect('button-press-event') { |w, event|
         retval = true
         if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 1
-            if $delete.active?
-                delete.call
-            elsif $r90.active?
+            if $r90.active?
                 rotate_and_cleanup.call(90)
             elsif $r270.active?
                 rotate_and_cleanup.call(270)
+            elsif $enhance.active?
+                enhance_and_cleanup.call
+            elsif $delete.active?
+                delete.call
             else
                 textview.grab_focus
             end
@@ -827,9 +840,10 @@ def change_dir
             if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 1
                 if $r90.active?
                     rotate_and_cleanup.call(90)
-                end
-                if $r270.active?
+                elif $r270.active?
                     rotate_and_cleanup.call(270)
+                elsif $enhance.active?
+                    enhance_and_cleanup.call
                 end
             end
             if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 3
@@ -1016,9 +1030,9 @@ def open_file_popup
     ok = false
     while !ok
         if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
-            set_mousecursor_wait(fc)
+            push_mousecursor_wait(fc)
             msg = open_file(fc.filename)
-            set_mousecursor_normal(fc)
+            pop_mousecursor(fc)
             if msg
                 show_popup(fc, msg)
                 ok = false
@@ -1076,9 +1090,9 @@ def create_menu_and_toolbar
             $config['last-opens'].reverse.each { |e|
                 lastopens.attach(item = Gtk::ImageMenuItem.new(e), 0, 1, j, j + 1)
                 item.signal_connect('activate') {
-                    set_mousecursor_wait($main_window)
+                    push_mousecursor_wait
                     msg = open_file(e)
-                    set_mousecursor_normal($main_window)
+                    pop_mousecursor
                     if msg
                         show_popup($main_window, msg)
                     end
@@ -1098,6 +1112,9 @@ def create_menu_and_toolbar
     tb.insert(-1, $r270 = Gtk::ToggleToolButton.new)
     $r270.icon_widget = Gtk::Image.new("#{$FPATH}/images/stock-rotate-270-16.png")
     $r270.label = utf8(_("Rotate"))
+    tb.insert(-1, $enhance = Gtk::ToggleToolButton.new)
+    $enhance.icon_widget = Gtk::Image.new("#{$FPATH}/images/stock-channels-16.png")
+    $enhance.label = utf8(_("Enhance"))
     tb.insert(-1, $delete = Gtk::ToggleToolButton.new(Gtk::Stock::DELETE))
     $delete.label = utf8(_("Delete"))  #- to avoid missing gtk2 l10n catalogs
     tb.insert(-1, nothing = Gtk::ToolButton.new('').set_sensitive(false))
@@ -1143,16 +1160,15 @@ Click the <span foreground=\"darkblue\">None</span> icon when you're finished wi
 
     $r90.signal_connect('toggled') {
         if $r90.active?
-            set_mousecursor($autotable, Gdk::Cursor::SB_RIGHT_ARROW)
-            set_mousecursor($subalbums, Gdk::Cursor::SB_RIGHT_ARROW)
+            set_mousecursor(Gdk::Cursor::SB_RIGHT_ARROW)
             one_click_explain_try.call
             $r270.active = false
+            $enhance.active = false
             $delete.active = false
             nothing.sensitive = true
         else
-            if !$r270.active? && !$delete.active?
-                set_mousecursor_normal($autotable)
-                set_mousecursor_normal($subalbums)
+            if !$r270.active? && !$enhance.active? && !$delete.active?
+                set_mousecursor_normal
                 nothing.sensitive = false
             else
                 nothing.sensitive = true
@@ -1161,16 +1177,32 @@ Click the <span foreground=\"darkblue\">None</span> icon when you're finished wi
     }
     $r270.signal_connect('toggled') {
         if $r270.active?
-            set_mousecursor($autotable, Gdk::Cursor::SB_LEFT_ARROW)
-            set_mousecursor($subalbums, Gdk::Cursor::SB_LEFT_ARROW)
+            set_mousecursor(Gdk::Cursor::SB_LEFT_ARROW)
+            one_click_explain_try.call
+            $r90.active = false
+            $enhance.active = false
+            $delete.active = false
+            nothing.sensitive = true
+        else
+            if !$r90.active? && !$enhance.active? && !$delete.active?
+                set_mousecursor_normal
+                nothing.sensitive = false
+            else
+                nothing.sensitive = true
+            end
+        end
+    }
+    $enhance.signal_connect('toggled') {
+        if $enhance.active?
+            set_mousecursor(Gdk::Cursor::SPRAYCAN)
             one_click_explain_try.call
             $r90.active = false
+            $r270.active = false
             $delete.active = false
             nothing.sensitive = true
         else
-            if !$r90.active? && !$delete.active?
-                set_mousecursor_normal($autotable)
-                set_mousecursor_normal($subalbums)
+            if !$r90.active? && !$r270.active? && !$delete.active?
+                set_mousecursor_normal
                 nothing.sensitive = false
             else
                 nothing.sensitive = true
@@ -1179,15 +1211,15 @@ Click the <span foreground=\"darkblue\">None</span> icon when you're finished wi
     }
     $delete.signal_connect('toggled') {
         if $delete.active?
-            set_mousecursor($autotable, Gdk::Cursor::PIRATE)
+            set_mousecursor(Gdk::Cursor::PIRATE)
             one_click_explain_try.call
             $r90.active = false
             $r270.active = false
+            $enhance.active = false
             nothing.sensitive = true
         else
-            if !$r90.active? && !$r270.active?
-                set_mousecursor_normal($autotable)
-                set_mousecursor_normal($subalbums)
+            if !$r90.active? && !$r270.active? && !$enhance.active?
+                set_mousecursor_normal
                 nothing.sensitive = false
             else
                 nothing.sensitive = true
@@ -1195,9 +1227,8 @@ Click the <span foreground=\"darkblue\">None</span> icon when you're finished wi
         end
     }
     nothing.signal_connect('clicked') {
-        $r90.active = $r270.active = $delete.active = false
-        set_mousecursor_normal($autotable)
-        set_mousecursor_normal($subalbums)
+        $r90.active = $r270.active = $enhance.active = $delete.active = false
+        set_mousecursor_normal
     }
 
     return [ mb, tb ]
@@ -1216,7 +1247,7 @@ def create_main_window
     $albums_tv.append_column(column)
     $albums_tv.set_headers_visible(false)
     $albums_tv.selection.signal_connect('changed') { |w|
-        set_mousecursor_wait($main_window)
+        push_mousecursor_wait
         save_changes
        iter = w.selected
         if !iter
@@ -1225,7 +1256,7 @@ def create_main_window
             $current_path = $albums_ts.get_value(iter, 1)
             change_dir
         end
-        set_mousecursor_normal($main_window)
+        pop_mousecursor
     }
     $albums_ts = Gtk::TreeStore.new(String, String)
     $albums_tv.set_model($albums_ts)