From db52579ffcec6f7b5f80c74f26e8c7764a267377 Mon Sep 17 00:00:00 2001 From: gc Date: Mon, 26 Dec 2005 15:33:35 +0000 Subject: [PATCH] allow to remove a subalbum directly in the treeview, suggested by JC --- bin/booh | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/bin/booh b/bin/booh index 5937758..38ca520 100755 --- 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 -- 2.30.4