correctly handle completely removed subalbums
authorgc <gc>
Sun, 8 May 2005 17:50:20 +0000 (17:50 +0000)
committergc <gc>
Sun, 8 May 2005 17:50:20 +0000 (17:50 +0000)
bin/booh

index a24de9c65b4913f9b93ef28c3a9c6ae4f4e1aeef..416bf2a2f32e2f39b86d89e38b0fd3b283cffae5 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -595,6 +595,8 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
             
             perform_delete.call
 
+            puts "delete performed, after is #{after}"
+
             if !after
                 if $xmldir.elements['dir']
                     $xmldir.delete_attribute('thumbnails-caption')
@@ -602,6 +604,8 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
                 else
                     $xmldir.remove
                 end
+                puts "saving changes"
+                save_changes
                 populate_subalbums_treeview
             else
                 save_undo(_("delete"),
@@ -930,17 +934,21 @@ def save_changes
     #- remove and reinsert elements to reflect new ordering
     save_attributes = {}
     save_types = {}
+    cpt = 0
     $xmldir.elements.each { |element|
         if element.name == 'image' || element.name == 'video'
             save_types[element.attributes['filename']] = element.name
             save_attributes[element.attributes['filename']] = element.attributes
             element.remove
+            cpt += 1
         end
     }
+    puts "save_changes: #{$xmldir.name}:#{from_utf8($xmldir.attributes['path'])} old, #{cpt} elements"
     $autotable.current_order.each { |path|
         chld = $xmldir.add_element save_types[path], save_attributes[path]
         chld.add_attribute('caption', $name2widgets[File.basename(path)][:textview].buffer.text)
     }
+    puts "save_changes: new, #{$autotable.current_order.size} elements"
 end
 
 def change_dir