dest_img = build_full_dest_filename(filename).sub(/\.[^\.]+$/, '') + "-#{$default_size['fullscreen']}.jpg"
#- typically this file won't exist in case of videos; try with the largest thumbnail around
if !File.exists?(dest_img)
- alternatives = Dir[build_full_dest_filename(filename).sub(/\.[^\.]+$/, '') + '-*'].sort
- if not alternatives.empty?
- dest_img = alternatives[-1]
+ if entry2type(filename) == 'video'
+ alternatives = Dir[build_full_dest_filename(filename).sub(/\.[^\.]+$/, '') + '-*'].sort
+ if not alternatives.empty?
+ dest_img = alternatives[-1]
+ end
else
- return
+ set_mousecursor_wait($main_window.window)
+ gen_thumbnails(from_utf8("#{$current_path}/#{filename}"), $xmldir, false, [ { 'filename' => dest_img, 'size' => $default_size['fullscreen'] } ])
+ set_mousecursor_normal($main_window.window)
+ if !File.exists?(dest_img)
+ msg 2, _("Could not generate fullscreen thumbnail!")
+ return
+ end
end
end
i = Gtk::Image.new(dest_img)
def add_thumbnail(autotable, name, type, filename, caption)
+ #- generate the thumbnail if missing (if image was rotated but booh was not relaunched)
+ if !$rotated_pixbufs[filename] && !File.exists?(filename)
+ gen_thumbnails(from_utf8("#{$current_path}/#{name}"), $xmldir, false, [ { 'filename' => filename, 'size' => $default_size['thumbnails'] } ])
+ end
frame1 = Gtk::Frame.new
frame1.add(img = Gtk::Image.new($rotated_pixbufs[filename] ? $rotated_pixbufs[filename][:pixbuf] : filename))
frame1.set_shadow_type(Gtk::SHADOW_ETCHED_OUT)
rotate = Proc.new { |angle|
#- update rotate attribute
- xmldir = $xmldoc.elements["//dir[@path='#{$current_path}']"]
- felem = xmldir.elements["[@filename='#{name}']"]
+ felem = $xmldir.elements["[@filename='#{name}']"]
felem.add_attribute('rotate', current_angle = ( felem.attributes['rotate'].to_i + angle ) % 360)
#- remove out of sync images
+ dest_img_base = build_full_dest_filename(name).sub(/\.[^\.]+$/, '')
+ for sizeobj in $images_size
+ system("rm -f #{dest_img_base}-#{sizeobj['fullscreen']}.jpg #{dest_img_base}-#{sizeobj['thumbnails']}.jpg")
+ end
if !$rotated_pixbufs[filename]
$rotated_pixbufs[filename] = { :orig => img.pixbuf, :angle_to_orig => angle % 360 }
- dest_img_base = build_full_dest_filename(name).sub(/\.[^\.]+$/, '')
- for sizeobj in $images_size
- system("rm -f #{dest_img_base}-#{sizeobj['fullscreen']}.jpg #{dest_img_base}-#{sizeobj['thumbnails']}.jpg")
- end
else
$rotated_pixbufs[filename][:angle_to_orig] = ( $rotated_pixbufs[filename][:angle_to_orig] + angle ) % 360
end
delete.call
end
if event.keyval == Gdk::Keyval::GDK_Return && control_pressed
- view_element(File.basename(name))
+ view_element(name)
propagate = false
end
end
end
textview.grab_focus
if event.event_type == Gdk::Event::BUTTON2_PRESS
- view_element(File.basename(name))
+ view_element(name)
else
retval = false #- propagate
end
#- remove and reinsert elements to reflect new ordering
save_attributes = {}
save_types = {}
- xmldir = $xmldoc.elements["//dir[@path='#{$current_path}']"]
- xmldir.elements.each { |element|
+ $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
end
}
$autotable.current_order.each { |path|
- chld = xmldir.add_element save_types[path], save_attributes[path]
+ chld = $xmldir.add_element save_types[path], save_attributes[path]
chld.add_attribute('caption', $name2widgets[File.basename(path)][:textview].buffer.text)
}
end
$vbox2textview = {}
$name2widgets = {}
- xmldir = $xmldoc.elements["//dir[@path='#{$current_path}']"]
- xmldir.elements.each { |element|
+ $xmldir = $xmldoc.elements["//dir[@path='#{$current_path}']"]
+ $xmldir.elements.each { |element|
if element.name == 'image' || element.name == 'video'
dest_img = build_full_dest_filename(element.attributes['filename']).sub(/\.[^\.]+$/, '') + "-#{$default_size['thumbnails']}.jpg"
msg 3, "dest_img: #{dest_img}"