end
def set_mousecursor(widget, what)
- if !widget.window
- widget.realize
+ if widget.window
+ widget.window.set_cursor(Gdk::Cursor.new(what))
end
- widget.window.set_cursor(Gdk::Cursor.new(what))
end
def set_mousecursor_wait(widget)
set_mousecursor(widget, Gdk::Cursor::WATCH)
def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
img = nil
+ frame1 = Gtk::Frame.new
gen_real_thumbnail = Proc.new {
Thread.new {
+ set_mousecursor_wait(frame1)
gen_thumbnails_element(from_utf8("#{$current_path}/#{filename}"), $xmldir, false, [ { 'filename' => thumbnail_img, 'size' => $default_size['thumbnails'] } ])
img.set(thumbnail_img)
$rotated_pixbufs[thumbnail_img] = { :orig => img.pixbuf, :pixbuf => img.pixbuf, :angle_to_orig => 0 }
#- cleanup temp for videos
system("rm -f #{current_dest_dir}/screenshot.jpg00000*")
end
+ set_mousecursor_normal(frame1)
}
}
- frame1 = Gtk::Frame.new
#- generate the thumbnail if missing (if image was rotated but booh was not relaunched)
if !$rotated_pixbufs[thumbnail_img] && !File.exists?(thumbnail_img)
frame1.add(img = Gtk::Image.new)
#- to be able to find widgets by name
$name2widgets[filename] = { :textview => textview }
+ cleanup_all_thumbnails = Proc.new {
+ #- remove out of sync images
+ dest_img_base = build_full_dest_filename(filename).sub(/\.[^\.]+$/, '')
+ for sizeobj in $images_size
+ system("rm -f #{dest_img_base}-#{sizeobj['fullscreen']}.jpg #{dest_img_base}-#{sizeobj['thumbnails']}.jpg")
+ end
+
+ }
+
rotate_and_cleanup = Proc.new { |angle|
perform_rotate_and_cleanup = Proc.new { |angle|
rotate(angle, thumbnail_img, img, $xmldir.elements["[@filename='#{filename}']"], '', $default_thumbnails[:x], $default_thumbnails[:y])
}
perform_rotate_and_cleanup.call(angle)
- #- remove out of sync images
- dest_img_base = build_full_dest_filename(filename).sub(/\.[^\.]+$/, '')
- for sizeobj in $images_size
- system("rm -f #{dest_img_base}-#{sizeobj['fullscreen']}.jpg #{dest_img_base}-#{sizeobj['thumbnails']}.jpg")
- end
+ cleanup_all_thumbnails.call
save_undo(Proc.new { |angle|
perform_rotate_and_cleanup.call(angle)
system("rm -f '#{thumbnail_img}'")
gen_real_thumbnail.call
}
- perform_color_swap_and_cleanup.call
- #- remove out of sync images
- dest_img_base = build_full_dest_filename(filename).sub(/\.[^\.]+$/, '')
- for sizeobj in $images_size
- system("rm -f #{dest_img_base}-#{sizeobj['thumbnails']}.jpg")
- end
+ cleanup_all_thumbnails.call
+ perform_color_swap_and_cleanup.call
save_undo(Proc.new {
perform_color_swap_and_cleanup.call
})
}
+ enhance_and_cleanup = Proc.new {
+ perform_enhance_and_cleanup = Proc.new {
+ xmlelem = $xmldir.elements["[@filename='#{filename}']"]
+ if xmlelem.attributes['enhance']
+ xmlelem.delete_attribute('enhance')
+ else
+ xmlelem.add_attribute('enhance', '1')
+ end
+ system("rm -f '#{thumbnail_img}'")
+ gen_real_thumbnail.call
+ }
+
+ cleanup_all_thumbnails.call
+ perform_enhance_and_cleanup.call
+
+ #- remove out of sync images
+ save_undo(Proc.new {
+ perform_enhance_and_cleanup.call
+ $notebook.set_page(1)
+ Proc.new {
+ perform_enhance_and_cleanup
+ $notebook.set_page(1)
+ }
+ })
+ }
+
delete = Proc.new {
perform_delete = Proc.new {
after = autotable.get_next_widget(vbox)
flip.signal_connect('activate') { rotate_and_cleanup.call(180) }
end
menu.append( Gtk::SeparatorMenuItem.new)
+ menu.append(enhance = Gtk::ImageMenuItem.new(utf8($xmldir.elements["[@filename='#{filename}']"].attributes['enhance'] ? _("Original contrast") :
+ _("Enhance constrast"))))
+ enhance.image = Gtk::Image.new("#{$FPATH}/images/stock-channels-16.png")
+ enhance.signal_connect('activate') { enhance_and_cleanup.call }
+ menu.append( Gtk::SeparatorMenuItem.new)
menu.append(delete_item = Gtk::ImageMenuItem.new(Gtk::Stock::DELETE))
delete_item.signal_connect('activate') { delete.call }
menu.show_all
$xmldir = $xmldoc.elements["//dir[@path='#{$current_path}']"]
$subalbums_edits = {}
- find_infotype = Proc.new { |xmldir|
- xmldir == $xmldir ? 'thumbnails' : find_subalbum_info_type(xmldir)
- }
-
add_subalbum = Proc.new { |xmldir|
if xmldir == $xmldir
thumbnail_file = "#{current_dest_dir}/thumbnails-thumbnail.jpg"
caption = xmldir.attributes['thumbnails-caption']
captionfile, dummy = find_subalbum_caption_info(xmldir)
+ infotype = 'thumbnails'
else
thumbnail_file = "#{current_dest_dir}/thumbnails-#{from_utf8(File.basename(xmldir.attributes['path']))}.jpg"
captionfile, caption = find_subalbum_caption_info(xmldir)
+ infotype = find_subalbum_info_type(xmldir)
end
msg 3, "add subdir: #{xmldir.attributes['path']} with file: #{thumbnail_file}"
hbox = Gtk::HBox.new
Thread.new {
system("rm -f '#{thumbnail_file}'")
gen_thumbnails_subdir(from_utf8(captionfile), xmldir, false,
- [ { 'filename' => thumbnail_file, 'size' => $albums_thumbnail_size } ], find_infotype.call(xmldir))
+ [ { 'filename' => thumbnail_file, 'size' => $albums_thumbnail_size } ], infotype)
img.set(thumbnail_file)
$rotated_pixbufs[thumbnail_file] = { :orig => img.pixbuf, :pixbuf => img.pixbuf, :angle_to_orig => 0 }
if entry2type(captionfile) == 'video'
msg 3, "new captionfile is: #{fc.filename}"
$subalbums_edits[xmldir.attributes['path']][:captionfile] = captionfile = utf8(fc.filename)
$rotated_pixbufs.delete(thumbnail_file)
- infotype = find_infotype.call(xmldir)
xmldir.delete_attribute("#{infotype}-rotate")
xmldir.delete_attribute("#{infotype}-color-swap")
+ xmldir.delete_attribute("#{infotype}-enhance")
gen_real_thumbnail.call
end
fc.destroy
rotate_and_cleanup = Proc.new { |angle|
perform_rotate_and_cleanup = Proc.new { |angle|
- rotate(angle, thumbnail_file, img, xmldir, find_infotype.call(xmldir) + '-',
+ rotate(angle, thumbnail_file, img, xmldir, "#{infotype}-",
$default_albums_thumbnails[:x], $default_albums_thumbnails[:y])
}
perform_rotate_and_cleanup.call(angle)
color_swap_and_cleanup = Proc.new {
perform_color_swap_and_cleanup = Proc.new {
- infotype = find_infotype.call(xmldir)
if xmldir.attributes["#{infotype}-color-swap"]
xmldir.delete_attribute("#{infotype}-color-swap")
else
})
}
+ enhance_and_cleanup = Proc.new {
+ perform_enhance_and_cleanup = Proc.new {
+ if xmldir.attributes["#{infotype}-enhance"]
+ xmldir.delete_attribute("#{infotype}-enhance")
+ else
+ xmldir.add_attribute("#{infotype}-enhance", '1')
+ end
+ gen_real_thumbnail.call
+ }
+
+ perform_enhance_and_cleanup.call
+
+ #- remove out of sync images
+ save_undo(Proc.new {
+ perform_enhance_and_cleanup.call
+ $notebook.set_page(1)
+ Proc.new {
+ perform_enhance_and_cleanup
+ $notebook.set_page(1)
+ }
+ })
+ }
+
evtbox.signal_connect('button-press-event') { |w, event|
if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 1
if $r90.active?
flip.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-180-16.png")
flip.signal_connect('activate') { rotate_and_cleanup.call(180) }
end
+ menu.append( Gtk::SeparatorMenuItem.new)
+ menu.append(enhance = Gtk::ImageMenuItem.new(utf8(xmldir.attributes["#{infotype}-enhance"] ? _("Original contrast") :
+ _("Enhance constrast"))))
+ enhance.image = Gtk::Image.new("#{$FPATH}/images/stock-channels-16.png")
+ enhance.signal_connect('activate') { enhance_and_cleanup.call }
menu.show_all
menu.popup(nil, nil, event.button, event.time)
end