allow to remove a subalbum directly in the treeview, suggested by JC
authorgc <gc>
Mon, 26 Dec 2005 15:33:35 +0000 (15:33 +0000)
committergc <gc>
Mon, 26 Dec 2005 15:33:35 +0000 (15:33 +0000)
bin/booh

index 5937758e7fa0b081293ab5f5e1bd0a7eed3508f4..38ca520fa15f8d139ff3d80a1fade16993c71228 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -863,6 +863,32 @@ def popup_thumbnail_menu(event, optionals, fullpath, type, xmldir, attributes_pr
     menu.popup(nil, nil, event.button, event.time)
 end
 
+def delete_current_subalbum
+    $xmldir.elements.each { |e|
+        if e.name == 'image' || e.name == 'video'
+            e.add_attribute('deleted', 'true')
+        end
+    }
+    #- branch if we have a non deleted subalbum
+    if $xmldir.child_byname_notattr('dir', 'deleted')
+        $xmldir.delete_attribute('thumbnails-caption')
+        $xmldir.delete_attribute('thumbnails-captionfile')
+    else
+        $xmldir.add_attribute('deleted', 'true')
+        moveup = $xmldir
+        while moveup.parent.name == 'dir'
+            moveup = moveup.parent
+            if !moveup.child_byname_notattr('dir', 'deleted') && !moveup.child_byname_notattr('image', 'deleted') && !moveup.child_byname_notattr('video', 'deleted')
+                moveup.add_attribute('deleted', 'true')
+            else
+                break
+            end
+        end
+    end
+    save_changes('forced')
+    populate_subalbums_treeview
+end
+
 def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
 
     img = nil
@@ -1075,7 +1101,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
     }
 
     delete = Proc.new { |isacut|
-        if autotable.current_order.size > 1 || show_popup($main_window, utf8(_("Do you confirm this subalbum needs to be completely removed?")), { :okcancel => true })
+        if autotable.current_order.size > 1 || show_popup($main_window, utf8(_("Do you confirm this subalbum needs to be completely removed? This operation cannot be undone.")), { :okcancel => true })
             $modified = true
             after = nil
             perform_delete = Proc.new {
@@ -1098,23 +1124,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
             perform_delete.call
 
             if !after
-                if $xmldir.child_byname_notattr('dir', 'deleted')
-                    $xmldir.delete_attribute('thumbnails-caption')
-                    $xmldir.delete_attribute('thumbnails-captionfile')
-                else
-                    $xmldir.add_attribute('deleted', 'true')
-                    moveup = $xmldir
-                    while moveup.parent.name == 'dir'
-                        moveup = moveup.parent
-                        if !moveup.child_byname_notattr('dir', 'deleted') && !moveup.child_byname_notattr('image', 'deleted') && !moveup.child_byname_notattr('video', 'deleted')
-                            moveup.add_attribute('deleted', 'true')
-                        else
-                            break
-                        end
-                    end
-                end
-                save_changes('forced')
-                populate_subalbums_treeview
+                delete_current_subalbum
             else
                 save_undo(_("delete"),
                           Proc.new { |pos|
@@ -3814,6 +3824,13 @@ def create_main_window
             menu.append(passprotect = Gtk::ImageMenuItem.new(utf8(_("Password protect"))))
             passprotect.image = Gtk::Image.new("#{$FPATH}/images/galeon-secure.png")
             passprotect.signal_connect('activate') { ask_password_protect }
+            menu.append(Gtk::SeparatorMenuItem.new)
+            menu.append(delete = Gtk::ImageMenuItem.new(Gtk::Stock::DELETE))
+            delete.signal_connect('activate') {
+                if show_popup($main_window, utf8(_("Do you confirm this subalbum needs to be completely removed? This operation cannot be undone.")), { :okcancel => true })
+                    delete_current_subalbum
+                end
+            }
             menu.show_all
             menu.popup(nil, nil, event.button, event.time)
         end