add "merge new subalbums" long needed
authorgc <gc>
Sun, 18 Sep 2005 22:49:43 +0000 (22:49 +0000)
committergc <gc>
Sun, 18 Sep 2005 22:49:43 +0000 (22:49 +0000)
bin/booh
bin/booh-backend

index 1fb669159a279c396445325a1e7cc76b5095afb2..05c6058a9d765e4e903e0541649d4ac1363b978b 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -1090,7 +1090,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
                 end
             end
             if event.keyval == Gdk::Keyval::GDK_Delete && control_pressed
-                delete.call
+                delete.call(false)
             end
             if event.keyval == Gdk::Keyval::GDK_Return && control_pressed
                 view_element(filename, { :delete => delete })
@@ -1122,7 +1122,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
                 elsif $enhance.active?
                     enhance_and_cleanup.call
                 elsif $delete.active?
-                    delete.call
+                    delete.call(false)
                 else
                     textview.grab_focus
                     $config['nogestures'] or $gesture_press = { :filename => filename, :x => event.x, :y => event.y }
@@ -1178,7 +1178,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
                 done = true
             elsif (($gesture_press[:y]-y)/($gesture_press[:x]-x)).abs > 2 && y-$gesture_press[:y] > 5
                 msg 3, "gesture delete: click-drag right button to the bottom"
-                delete.call
+                delete.call(false)
                 $statusbar.push(0, utf8(_("Mouse gesture: delete.")))
                 done = true
             end
index 617f34391994e5675a539cd48ae162c1467e37e0..8dbd5aa27252cff5e80bb694eb8392c9bb60c1ce 100755 (executable)
@@ -45,7 +45,8 @@ $options = [
     [ '--config-skel',   '-k', GetoptLong::REQUIRED_ARGUMENT, _("Filename where the script will output a config skeleton") ],
     [ '--merge-config',  '-M', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, where to merge new images/videos from --source, and change theme info") ],
     [ '--merge-config-onedir',  '-O', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, for merging the subdir specified with --dir") ],
-    [ '--dir',           '-D', GetoptLong::REQUIRED_ARGUMENT, _("Directory for merge with --merge-config-onedir") ],
+    [ '--merge-config-subdirs', '-U', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, for merging the new subdirs down the subdir specified with --dir") ],
+    [ '--dir',           '-D', GetoptLong::REQUIRED_ARGUMENT, _("Directory for merge with --merge-config-onedir or --merge-config-subdirs") ],
     [ '--use-config',    '-u', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, where to change theme info") ],
     [ '--force',         '-f', GetoptLong::NO_ARGUMENT,       _("Force generation of album even if the GUI marked some directories as already generated") ],
 
@@ -155,6 +156,17 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
                 else
                     die _('Config file does not exist or is unreadable.')
                 end
+            when '--merge-config-subdirs'
+                arg = File.expand_path(arg)
+                if File.readable?(arg)
+                    msg 2, _("Merge config notice: backuping current config file to %s.backup") % arg
+                    $xmldoc = REXML::Document.new File.new(arg)
+                    File.rename(arg, "#{arg}.backup")
+                    $config_writeto = arg
+                    $mode = 'merge_config_subdirs'
+                else
+                    die _('Config file does not exist or is unreadable.')
+                end
             when '--dir'
                 arg = File.expand_path(arg)
                 if !File.readable?(arg)
@@ -222,7 +234,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
     end
 
     if $mode == 'merge_config_onedir' && !$onedir
-        die _("Missing --dir for --merge_config_onedir")
+        die _("Missing --dir for --merge-config-onedir")
+    end
+    if $mode == 'merge_config_subdirs' && !$onedir
+        die _("Missing --dir for --merge-config-subdirs")
     end
 
     if !$source
@@ -537,10 +552,18 @@ def walk_source_dir
     #- preprocess the path->dir, rexml is very slow with that; we seem to improve speed by 7%
     optxpath = {}
     $xmldoc.elements.each('//dir') { |elem|
+        puts "setting up path: #{elem.attributes['path']}"
         optxpath[elem.attributes['path']] = elem
     }
 
-    examined_dirs = $mode == 'merge_config_onedir' ? [ $onedir ] : `find '#{$source}' -type d -follow`.sort
+    examined_dirs = nil
+    if $mode == 'merge_config_onedir'
+        examined_dirs = [ $onedir ]
+    elsif $mode == 'merge_config_subdirs'
+        examined_dirs = `find '#{$onedir}' -type d -follow`.sort.collect { |v| v.chomp }.delete_if { |v| optxpath.has_key?(utf8(v)) }
+    else
+        examined_dirs = `find '#{$source}' -type d -follow`.sort
+    end
     info("directories: #{examined_dirs.length}, sizes: #{$images_size.length}")
 
     examined_dirs.each { |dir|
@@ -562,7 +585,7 @@ def walk_source_dir
                 next
             end
         else
-            if $mode == 'gen_config' || ($mode == 'merge_config' && !xmldir)
+            if $mode == 'gen_config' || (($mode == 'merge_config' || $mode == 'merge_config_subdirs') && !xmldir)
                 #- add the <dir..> element if necessary
                 parent = File.dirname(dir)
                 xmldir = $xmldoc.elements["//dir[@path='#{utf8(parent)}']"]