let merge new/removed images/videos only in one specified directory (in current direc...
authorgc <gc>
Mon, 16 May 2005 21:30:52 +0000 (21:30 +0000)
committergc <gc>
Mon, 16 May 2005 21:30:52 +0000 (21:30 +0000)
bin/booh
bin/booh-backend

index d42b71b5197abc37ddfed247881731ceaaefd621..de57cba5bef91fcdffc4a6c0562be4827d598971 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -1510,7 +1510,7 @@ def open_file(filename)
     if $config['last-opens'][-1] != utf8(filename)
         $config['last-opens'] << utf8(filename)
     end
-    $save.sensitive = $save_as.sensitive = $merge.sensitive = $merge_subalbums.sensitive = $generate.sensitive = $properties.sensitive = true
+    $save.sensitive = $save_as.sensitive = $merge_current.sensitive = $merge.sensitive = $merge_subalbums.sensitive = $generate.sensitive = $properties.sensitive = true
     return nil
 end
 
@@ -1878,6 +1878,20 @@ def properties
     end
 end
 
+def merge_current
+    save_current_file
+
+    sel = $albums_tv.selection.selected_rows
+
+    perform_in_background("booh-backend --merge-config-onedir '#{$filename}' --dir '#{from_utf8($current_path)}' --for-gui " +
+                              "--verbose-level #{$verbose_level} #{additional_booh_options}",
+                          utf8(_("Please wait while scanning source directory...")),
+                          { :closure_after => proc {
+                                  open_file($filename)
+                                  $albums_tv.selection.select_path(sel[0])
+                              } })
+end
+
 def merge
     save_current_file
 
@@ -1985,12 +1999,16 @@ def create_menu_and_toolbar
     filesubmenu.append($save_as  = Gtk::ImageMenuItem.new(Gtk::Stock::SAVE_AS).set_sensitive(false))
     filesubmenu.append(            Gtk::SeparatorMenuItem.new)
     tooltips = Gtk::Tooltips.new
-    filesubmenu.append($merge_subalbums = Gtk::ImageMenuItem.new(utf8(_("Merge new subalbums"))).set_sensitive(false))
+    filesubmenu.append($merge_current = Gtk::ImageMenuItem.new(utf8(_("Merge new/removed images/videos in current subalbum"))).set_sensitive(false))
+    $merge_current.image = Gtk::Image.new("#{$FPATH}/images/stock-reset-16.png")
+    tooltips.set_tip($merge_current, utf8(_("Take into account new/removed images/videos in currently viewed subalbum")), nil)
+    filesubmenu.append($merge_subalbums = Gtk::ImageMenuItem.new(utf8(_("Scan source directory to merge new subalbums"))).set_sensitive(false))
     $merge_subalbums.image = Gtk::Image.new("#{$FPATH}/images/stock-reset-16.png")
-    tooltips.set_tip($merge_subalbums, utf8(_("Take into account new/removed subalbums (subdirectories) in the source directory")), nil)
-    filesubmenu.append($merge    = Gtk::ImageMenuItem.new(utf8(_("Merge new subalbums and new/removed images/videos"))).set_sensitive(false))
+    tooltips.set_tip($merge_subalbums, utf8(_("Take into account new/removed subalbums (subdirectories) in the source directory (but don't touch existing subalbums)")), nil)
+    filesubmenu.append($merge    = Gtk::ImageMenuItem.new(utf8(_("Scan source directory to merge new subalbums and new/removed images/videos"))).set_sensitive(false))
     $merge.image = Gtk::Image.new("#{$FPATH}/images/stock-reset-16.png")
-    tooltips.set_tip($merge, utf8(_("Take into account new/removed subalbums (subdirectories) and new/removed images/videos in existing subalbums in the source directory")), nil)
+    tooltips.set_tip($merge, utf8(_("Take into account new/removed subalbums (subdirectories) and new/removed images/videos in existing subalbums")), nil)
+    filesubmenu.append(            Gtk::SeparatorMenuItem.new)
     filesubmenu.append($generate = Gtk::ImageMenuItem.new(utf8(_("Generate web-album"))).set_sensitive(false))
     $generate.image = Gtk::Image.new("#{$FPATH}/images/stock-web-16.png")
     tooltips.set_tip($generate, utf8(_("(Re)generate web-album from latest changes into the destination directory")), nil)
@@ -2006,6 +2024,7 @@ def create_menu_and_toolbar
     open.signal_connect('activate') { open_file_popup }
     $save.signal_connect('activate') { save_current_file }
     $save_as.signal_connect('activate') { save_as_do }
+    $merge_current.signal_connect('activate') { merge_current }
     $merge.signal_connect('activate') { merge }
     $merge_subalbums.signal_connect('activate') { merge_subalbums }
     $generate.signal_connect('activate') {
index f079e098a377750a67f0cc370584cfbd5b3b7708..a5e1a08ae962b46f4941ac3e0ca88f8559afcbf9 100755 (executable)
@@ -46,7 +46,9 @@ $options = [
     [ '--config',        '-C', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing images and videos within directories with captions") ],
     [ '--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-newdirs',  '-N', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, where to merge new subdirs from --source") ],
+    [ '--merge-config-newdirs', '-N', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, where to merge new subdirs from --source") ],
+    [ '--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") ],
     [ '--use-config',    '-u', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, where to change theme info") ],
 
     [ '--sizes',         '-S', GetoptLong::REQUIRED_ARGUMENT, _("Specify the list of images sizes to use instead of all specified in the theme (this is a comma-separated list)") ],
@@ -147,6 +149,24 @@ 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-onedir'
+                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_onedir'
+                else
+                    die _('Config file does not exist or is unreadable.')
+                end
+            when '--dir'
+                arg = File.expand_path(arg)
+                if !File.readable?(arg)
+                    die _('Specified directory to merge with --dir is not readable')
+                else
+                    $onedir = arg
+                end
             when '--use-config'
                 arg = File.expand_path(arg)
                 if File.readable?(arg)
@@ -187,6 +207,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
         $limit_sizes ||= $xmldoc.root.attributes['limit-sizes']
     end
 
+    if $mode == 'merge_config_onedir' && !$onedir
+        die _("Missing --dir for --merge_config_onedir")
+    end
+
     if !$source
         die _("Missing --source or --config parameter.")
     end
@@ -460,7 +484,9 @@ def walk_source_dir
         optxpath[elem.attributes['path']] = elem
     }
 
-    `find '#{$source}' -type d`.sort.each { |dir|
+    examined_dirs = $mode == 'merge_config_onedir' ? [ $onedir ] : `find '#{$source}' -type d`.sort
+
+    examined_dirs.each { |dir|
         dir.chomp!
         if File.basename(dir) =~ /^\./
             msg 1, _("Ignoring directory %s, begins with a dot (indicating a hidden directory)") % dir
@@ -770,7 +796,7 @@ def walk_source_dir
     #- second pass to create index.html files
     msg 3, _("\trescanning directories to generate all `index.html' files...")
 
-    `find '#{$source}' -type d`.each { |dir|
+    examined_dirs.each { |dir|
         dir.chomp!
         xmldir = optxpath[utf8(dir)]
         if !xmldir