allow to remove a thumbnail from its fullsize view
authorgc <gc>
Sun, 22 May 2005 17:34:42 +0000 (17:34 +0000)
committergc <gc>
Sun, 22 May 2005 17:34:42 +0000 (17:34 +0000)
bin/booh

index 7a4a14290c60436f96484c23fb1e6cfec3931097..e7ab0a915766222bafbf417680d5a450304964b2 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -175,7 +175,7 @@ def save_undo(name, closure, *params)
     $undo_tb.sensitive = $undo_mb.sensitive = true
 end
 
-def view_element(filename)
+def view_element(filename, closures)
     if entry2type(filename) == 'video'
         cmd = from_utf8($config['video-viewer']).gsub('%f', "'#{from_utf8($current_path + '/' + filename)}'")
         msg 2, cmd
@@ -205,7 +205,18 @@ def view_element(filename)
         end
     end
     evt = Gtk::EventBox.new.add(Gtk::Alignment.new(0.5, 0.5, 0, 0).add(Gtk::Frame.new.add(Gtk::Image.new(dest_img)).set_shadow_type(Gtk::SHADOW_ETCHED_OUT)))
-
+    evt.signal_connect('button-press-event') { |this, event|
+        if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 3
+            menu = Gtk::Menu.new
+            menu.append(delete_item  = Gtk::ImageMenuItem.new(Gtk::Stock::DELETE))
+            delete_item.signal_connect('activate') {
+                w.destroy
+                closures[:delete].call
+            }
+            menu.show_all
+            menu.popup(nil, nil, event.button, event.time)
+        end
+    }
     tooltips = Gtk::Tooltips.new
     tooltips.set_tip(evt, File.basename(filename).gsub(/\.jpg/, ''), nil)
 
@@ -864,7 +875,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
                 delete.call
             end
             if event.keyval == Gdk::Keyval::GDK_Return && control_pressed
-                view_element(filename)
+                view_element(filename, { :delete => delete })
                 propagate = false
             end
         end
@@ -897,7 +908,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
                                    :frame_offset => change_frame_offset_and_cleanup, :delete => delete, :whitebalance => whitebalance_and_cleanup })
         end
         if event.event_type == Gdk::Event::BUTTON2_PRESS && event.button == 1
-            view_element(filename)
+            view_element(filename, { :delete => delete })
         else
             retval = false  #- propagate
         end