allow to merge only new subalbums
authorgc <gc>
Sun, 8 May 2005 18:54:24 +0000 (18:54 +0000)
committergc <gc>
Sun, 8 May 2005 18:54:24 +0000 (18:54 +0000)
bin/booh
bin/booh-backend

index f2962996ceec4e7d2b93b7dd01c380fa8cce1cf1..cacc8071a3399f8b908cc91a98c513c7a9ee59ae 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -1324,7 +1324,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 = $generate.sensitive = $properties.sensitive = true
+    $save.sensitive = $save_as.sensitive = $merge.sensitive = $merge_subalbums.sensitive = $generate.sensitive = $properties.sensitive = true
     return nil
 end
 
@@ -1706,6 +1706,15 @@ def merge
                           { :closure_after => proc { open_file($filename) } })
 end
 
+def merge_subalbums
+    save_current_file
+
+    perform_in_background("booh-backend --merge-config-newdirs '#{$filename}' --for-gui " +
+                              "--verbose-level #{$verbose_level} #{additional_booh_options}",
+                          utf8(_("Please wait while scanning source directory...")),
+                          { :closure_after => proc { open_file($filename) } })
+end
+
 def save_as_do
     fc = Gtk::FileChooserDialog.new(utf8(_("Select a new filename to store this album's properties")),
                                     nil,
@@ -1782,10 +1791,13 @@ def create_menu_and_toolbar
     filesubmenu.append($save     = Gtk::ImageMenuItem.new(Gtk::Stock::SAVE).set_sensitive(false))
     filesubmenu.append($save_as  = Gtk::ImageMenuItem.new(Gtk::Stock::SAVE_AS).set_sensitive(false))
     filesubmenu.append(            Gtk::SeparatorMenuItem.new)
-    filesubmenu.append($merge    = Gtk::ImageMenuItem.new(utf8(_("Merge new images/videos"))).set_sensitive(false))
-    $merge.image = Gtk::Image.new("#{$FPATH}/images/stock-reset-16.png")
     tooltips = Gtk::Tooltips.new
-    tooltips.set_tip($merge, utf8(_("Take into account new/removed images/videos in the source directory")), nil)
+    filesubmenu.append($merge_subalbums = Gtk::ImageMenuItem.new(utf8(_("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))
+    $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 images/videos in existing subalbums in the source directory")), nil)
     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)
@@ -1802,6 +1814,7 @@ def create_menu_and_toolbar
     $save.signal_connect('activate') { save_current_file }
     $save_as.signal_connect('activate') { save_as_do }
     $merge.signal_connect('activate') { merge }
+    $merge_subalbums.signal_connect('activate') { merge_subalbums }
     $generate.signal_connect('activate') {
         save_current_file
         perform_in_background("booh-backend --config '#{$filename}' --verbose-level #{$verbose_level} #{additional_booh_options}",
index d012de32b5e514064985fea03f82fc096cc6a767..4120e0ea8b3f9ef91e04596d29542f73dde1314f 100755 (executable)
@@ -46,6 +46,7 @@ $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") ],
     [ '--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)") ],
@@ -135,6 +136,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-newdirs'
+                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_newdirs'
+                else
+                    die _('Config file does not exist or is unreadable.')
+                end
             when '--use-config'
                 arg = File.expand_path(arg)
                 if File.readable?(arg)
@@ -376,14 +388,16 @@ def walk_source_dir
         end
 
         #- place xml document on proper node if exists, else create
+        newly_created_dir = false
         xmldir = $xmldoc.elements["//dir[@path='#{utf8(dir)}']"]
         if $mode == 'use_config' || $mode == 'use_config_changetheme'
             if !xmldir
                 next
             end
         else
-            if $mode == 'gen_config' || ($mode == 'merge_config' && !xmldir)
+            if $mode == 'gen_config' || (($mode == 'merge_config' || $mode == 'merge_config_newdirs') && !xmldir)
                 #- add the <dir..> element if necessary
+                newly_created_dir = true
                 parent = File.dirname(dir)
                 xmldir = $xmldoc.elements["//dir[@path='#{utf8(parent)}']"]
                 if !xmldir
@@ -395,7 +409,7 @@ def walk_source_dir
 
         #- read images/videos entries from config or from directories depending on mode
         entries = []
-        if $mode == 'use_config' || $mode == 'use_config_changetheme'
+        if $mode == 'use_config' || $mode == 'use_config_changetheme' || ($mode == 'merge_config_newdirs' && !newly_created_dir)
             msg 2, _("Handling %s from config list...") % dir
             xmldir.elements.each { |element|
                 if %w(image video).include?(element.name)