limit_sizes = $xmldoc.root.attributes['limit-sizes']
optimizefor32 = !$xmldoc.root.attributes['optimize-for-32'].nil?
+ nperrow = $xmldoc.root.attributes['thumbnails-per-row']
$filename = filename
- select_theme(theme, limit_sizes, optimizefor32)
+ select_theme(theme, limit_sizes, optimizefor32, nperrow)
$default_size['thumbnails'] =~ /(.*)x(.*)/
$default_thumbnails = { :x => $1.to_i, :y => $2.to_i }
$albums_thumbnail_size =~ /(.*)x(.*)/
pack_start(sizes = Gtk::HBox.new, false, false, 0))
vb.add(optimize432 = Gtk::CheckButton.new(utf8(_("Optimize for 3/2 aspect ratio"))))
tooltips.set_tip(optimize432, utf8(_("Resize images with optimized sizes for 3/2 aspect ratio rather than 4/3 (typical aspect ratio of pictures from non digital cameras are 3/2 when pictures from digital cameras are 4/3)")), nil)
+ vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per row: "))), false, false, 0).
+ pack_start(nperrowradios = Gtk::HBox.new, false, false, 0))
src_nb_calculated_for = ''
src_nb_thread = nil
}
theme_sizes = []
+ nperrows = []
recreate_theme_config = proc {
theme_sizes.each { |e| sizes.remove(e[:widget]) }
theme_sizes = []
- select_theme(theme_button.label, 'all', optimize432.active?)
+ select_theme(theme_button.label, 'all', optimize432.active?, nil)
$images_size.each { |s|
sizes.add(cb = Gtk::CheckButton.new(sizename(s['name'])))
if !s['optional']
tooltips.set_tip(cb, utf8(_("Include original image in web-album")), nil)
theme_sizes << { :widget => cb, :value => 'original' }
sizes.show_all
+
+ nperrows.each { |e| nperrowradios.remove(e[:widget]) }
+ nperrow_group = nil
+ nperrows = []
+ $allowed_N_values.each { |n|
+ if nperrow_group
+ nperrowradios.add(rb = Gtk::RadioButton.new(nperrow_group, n.to_s, false))
+ else
+ nperrowradios.add(nperrow_group = rb = Gtk::RadioButton.new(n.to_s))
+ end
+ if $default_N == n
+ rb.active = true
+ end
+ nperrows << { :widget => rb, :value => n }
+ }
+ nperrowradios.show_all
}
recreate_theme_config.call
configskel = File.expand_path(from_utf8(conf.text))
theme = theme_button.label
sizes = theme_sizes.find_all { |e| e[:widget].active? }.collect { |e| e[:value] }.join(',')
+ nperrow = nperrows.find { |e| e[:widget].active? }[:value]
opt432 = optimize432.active?
if src_nb_thread
Thread.kill(src_nb_thread)
if ok
call_backend("booh-backend --source '#{srcdir}' --destination '#{destdir}' --config-skel '#{configskel}' --for-gui " +
- "--verbose-level #{$verbose_level} --theme #{theme} --sizes #{sizes} #{opt432 ? '--optimize-for-32' : ''} #{additional_booh_options}",
+ "--verbose-level #{$verbose_level} --theme #{theme} --sizes #{sizes} --thumbnails-per-row #{nperrow} " +
+ "#{opt432 ? '--optimize-for-32' : ''} #{additional_booh_options}",
utf8(_("Please wait while scanning source directory...")),
'full scan',
{ :closure_after => proc { open_file(configskel) } })
dest = $xmldoc.root.attributes['destination']
theme = $xmldoc.root.attributes['theme']
opt432 = !$xmldoc.root.attributes['optimize-for-32'].nil?
+ nperrow = $xmldoc.root.attributes['thumbnails-per-row']
limit_sizes = $xmldoc.root.attributes['limit-sizes']
if limit_sizes
limit_sizes = limit_sizes.split(/,/)
pack_start(sizes = Gtk::HBox.new, false, false, 0))
vb.add(optimize432 = Gtk::CheckButton.new(utf8(_("Optimize for 3/2 aspect ratio"))).set_active(opt432))
tooltips.set_tip(optimize432, utf8(_("Resize images with optimized sizes for 3/2 aspect ratio rather than 4/3 (typical aspect ratio of pictures from non digital cameras are 3/2 when pictures from digital cameras are 4/3)")), nil)
+ vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per row: "))), false, false, 0).
+ pack_start(nperrowradios = Gtk::HBox.new, false, false, 0))
theme_sizes = []
+ nperrows = []
recreate_theme_config = proc {
theme_sizes.each { |e| sizes.remove(e[:widget]) }
theme_sizes = []
- select_theme(theme_button.label, 'all', optimize432.active?)
+ select_theme(theme_button.label, 'all', optimize432.active?, nperrow)
+
$images_size.each { |s|
sizes.add(cb = Gtk::CheckButton.new(sizename(s['name'])))
if limit_sizes
end
theme_sizes << { :widget => cb, :value => 'original' }
sizes.show_all
+
+ nperrows.each { |e| nperrowradios.remove(e[:widget]) }
+ nperrow_group = nil
+ nperrows = []
+ $allowed_N_values.each { |n|
+ if nperrow_group
+ nperrowradios.add(rb = Gtk::RadioButton.new(nperrow_group, n.to_s, false))
+ else
+ nperrowradios.add(nperrow_group = rb = Gtk::RadioButton.new(n.to_s))
+ end
+ nperrowradios.add(Gtk::Label.new(' '))
+ if nperrow && n.to_s == nperrow || !nperrow && $default_N == n
+ rb.active = true
+ end
+ nperrows << { :widget => rb, :value => n.to_s }
+ }
+ nperrowradios.show_all
}
recreate_theme_config.call
theme_button.signal_connect('clicked') {
if newtheme = theme_choose(theme_button.label)
limit_sizes = nil
+ nperrow = nil
theme_button.label = newtheme
recreate_theme_config.call
end
save_theme = theme_button.label
save_limit_sizes = theme_sizes.find_all { |e| e[:widget].active? }.collect { |e| e[:value] }
save_opt432 = optimize432.active?
+ save_nperrow = nperrows.find { |e| e[:widget].active? }[:value]
dialog.destroy
- if ok && (save_theme != theme || save_limit_sizes != limit_sizes || save_opt432 != opt432)
+ if ok && (save_theme != theme || save_limit_sizes != limit_sizes || save_opt432 != opt432 || save_nperrow != nperrow)
$xmldoc.elements.each('//dir') { |elem|
elem.delete_attribute('already-generated')
}
save_current_file
call_backend("booh-backend --use-config '#{$filename}' --for-gui --verbose-level #{$verbose_level} " +
- "--theme #{theme} --sizes #{save_limit_sizes.join(',')} #{save_opt432 ? '--optimize-for-32' : ''} #{additional_booh_options}",
+ "--thumbnails-per-row #{save_nperrow} --theme #{theme} --sizes #{save_limit_sizes.join(',')} " +
+ "#{save_opt432 ? '--optimize-for-32' : ''} #{additional_booh_options}",
utf8(_("Please wait while scanning source directory...")),
'full scan',
- { :closure_after => proc { open_file($filename) } })
+ { :closure_after => proc {
+ open_file($filename)
+ $modified = true
+ } })
end
end
[ '--force', '-f', GetoptLong::NO_ARGUMENT, _("Force generation of album even if the GUI marked some directories as already generated") ],
[ '--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)") ],
+ [ '--thumbnails-per-row', '-T', GetoptLong::REQUIRED_ARGUMENT, _("Specify the amount of thumbnails per row in the thumbnails page (if applicable in theme)") ],
[ '--optimize-for-32', '-o', GetoptLong::NO_ARGUMENT, _("Resize images with optimized sizes for 3/2 aspect ratio rather than 4/3 (typical aspect ratio of pictures from non digital cameras are 3/2 when pictures from digital cameras are 4/3)") ],
[ '--empty-comments','-e', GetoptLong::NO_ARGUMENT, _("Prefer empty comments over filename when creating new albums") ],
when '--sizes'
$limit_sizes = arg
+ when '--thumbnails-per-row'
+ $N_per_row = arg
+
when '--optimize-for-32'
$optimize_for_32 = true
$dest = from_utf8($xmldoc.root.attributes['destination'])
$theme = $xmldoc.root.attributes['theme']
$limit_sizes ||= $xmldoc.root.attributes['limit-sizes']
- if $mode == 'use_config'
+ if $mode == 'use_config' || $mode =~ /^merge_config/
$optimize_for_32 = !$xmldoc.root.attributes['optimize-for-32'].nil?
+ $N_per_row = $xmldoc.root.attributes['thumbnails-per-row']
end
end
$theme = 'simple'
end
- select_theme($theme, $limit_sizes, $optimize_for_32)
+ select_theme($theme, $limit_sizes, $optimize_for_32, $N_per_row)
if !$xmldoc
additional_params = ''
if $optimize_for_32
additional_params += " optimize-for-32='true'"
end
+ if $N_per_row
+ additional_params += " thumbnails-per-row='#{$N_per_row}'"
+ end
$xmldoc = Document.new "<booh version='#{$VERSION}' source='#{utf8($source)}' destination='#{utf8($dest)}' theme='#{$theme}' #{additional_params}/>"
$xmldoc << XMLDecl.new(XMLDecl::DEFAULT_VERSION, $CURRENT_CHARSET)
$mode = 'gen_config'
else
$xmldoc.root.delete_attribute('optimize-for-32')
end
+ if $N_per_row
+ $xmldoc.root.add_attribute('thumbnails-per-row', $N_per_row)
+ else
+ $xmldoc.root.delete_attribute('thumbnails-per-row')
+ end
end
end
end
def discover_iterations(iterations, line)
- if line =~ /~~iterate(\d)_open(_max(\d+))?~~/
+ if line =~ /~~iterate(\d)_open(_max(\d+|N))?~~/
for iter in iterations.values
if iter['open']
iter['open'] = false
iter['close_wait'] = $1.to_i
end
end
- iterations[$1.to_i] = { 'open' => true, 'max' => $3, 'opening' => '', 'closing' => '' }
+ max = $3 == 'N' ? ($N_per_row || $default_N) : $3
+ iterations[$1.to_i] = { 'open' => true, 'max' => max, 'opening' => '', 'closing' => '' }
if $1.to_i == 1
line.sub!(/.*/, '~~thumbnails~~')
else