end
end
+def change_frame_offset(xmldir, attributes_prefix, value)
+ xmldir.add_attribute("#{attributes_prefix}frame-offset", value)
+end
+
+def ask_new_frame_offset(xmldir, attributes_prefix)
+ value = xmldir.attributes["#{attributes_prefix}frame-offset"]
+
+ dialog = Gtk::Dialog.new(utf8(_("Change frame offset")),
+ $main_window,
+ Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT,
+ [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK],
+ [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL])
+
+ lbl = Gtk::Label.new
+ lbl.markup = utf8(
+_("Please specify the <b>frame offset</b> of the video, to take the thumbnail
+from. There are approximately 25 frames per second in a video.
+"))
+ dialog.vbox.add(lbl)
+ dialog.vbox.add(entry = Gtk::Entry.new.set_text(value))
+ entry.signal_connect('key-press-event') { |w, event|
+ if event.keyval == Gdk::Keyval::GDK_Return
+ dialog.response(Gtk::Dialog::RESPONSE_OK)
+ true
+ elsif event.keyval == Gdk::Keyval::GDK_Escape
+ dialog.response(Gtk::Dialog::RESPONSE_CANCEL)
+ true
+ else
+ false #- propagate if needed
+ end
+ }
+
+ dialog.window_position = Gtk::Window::POS_MOUSE
+ dialog.show_all
+
+ dialog.run { |response|
+ newval = entry.text
+ dialog.destroy
+ if response == Gtk::Dialog::RESPONSE_OK
+ msg 3, "changing frame offset top #{newval}"
+ return { :old => value, :new => newval }
+ else
+ return nil
+ end
+ }
+end
+
def gen_real_thumbnail(type, origfile, destfile, xmldir, size, img)
Thread.new {
push_mousecursor_wait
r270.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-270-16.png")
r270.signal_connect('activate') { closures[:rotate].call(-90) }
if type == 'video'
- menu.append( Gtk::SeparatorMenuItem.new)
- menu.append(color_swap = Gtk::ImageMenuItem.new(utf8(_("Red/blue color swap"))))
+ menu.append( Gtk::SeparatorMenuItem.new)
+ menu.append( color_swap = Gtk::ImageMenuItem.new(utf8(_("Red/blue color swap"))))
color_swap.image = Gtk::Image.new("#{$FPATH}/images/stock-color-triangle-16.png")
color_swap.signal_connect('activate') { closures[:color_swap].call }
- menu.append( flip = Gtk::ImageMenuItem.new(utf8(_("Flip upside-down"))))
+ menu.append( flip = Gtk::ImageMenuItem.new(utf8(_("Flip upside-down"))))
flip.image = Gtk::Image.new("#{$FPATH}/images/stock-rotate-180-16.png")
flip.signal_connect('activate') { closures[:rotate].call(180) }
+ menu.append(frame_offset = Gtk::ImageMenuItem.new(utf8(_("Specify frame offset"))))
+ frame_offset.image = Gtk::Image.new("#{$FPATH}/images/stock-video-16.png")
+ frame_offset.signal_connect('activate') { closures[:frame_offset].call }
end
menu.append( Gtk::SeparatorMenuItem.new)
menu.append(enhance = Gtk::ImageMenuItem.new(utf8(xmldir.attributes["#{attributes_prefix}enhance"] ? _("Original contrast") :
perform_color_swap_and_cleanup.call
$notebook.set_page(1)
Proc.new {
- perform_color_swap_and_cleanup
+ perform_color_swap_and_cleanup.call
$notebook.set_page(1)
}
})
}
+ change_frame_offset_and_cleanup = Proc.new {
+ if values = ask_new_frame_offset($xmldir.elements["[@filename='#{filename}']"], '')
+ perform_change_frame_offset_and_cleanup = Proc.new { |val|
+ change_frame_offset($xmldir.elements["[@filename='#{filename}']"], '', val)
+ my_gen_real_thumbnail.call
+ }
+ perform_change_frame_offset_and_cleanup.call(values[:new])
+
+ save_undo(_("specify frame offset"),
+ Proc.new {
+ perform_change_frame_offset_and_cleanup.call(values[:old])
+ $notebook.set_page(1)
+ Proc.new {
+ perform_change_frame_offset_and_cleanup.call(values[:new])
+ $notebook.set_page(1)
+ }
+ })
+ end
+ }
+
enhance_and_cleanup = Proc.new {
perform_enhance_and_cleanup = Proc.new {
enhance($xmldir.elements["[@filename='#{filename}']"], '')
perform_enhance_and_cleanup.call
$notebook.set_page(1)
Proc.new {
- perform_enhance_and_cleanup
+ perform_enhance_and_cleanup.call
$notebook.set_page(1)
}
})
end
if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 3
popup_thumbnail_menu(event, ['delete'], type, $xmldir.elements["[@filename='#{filename}']"], '',
- { :rotate => rotate_and_cleanup, :color_swap => color_swap_and_cleanup, :enhance => enhance_and_cleanup, :delete => delete })
+ { :rotate => rotate_and_cleanup, :color_swap => color_swap_and_cleanup, :enhance => enhance_and_cleanup,
+ :frame_offset => change_frame_offset_and_cleanup, :delete => delete })
end
if event.event_type == Gdk::Event::BUTTON2_PRESS && event.button == 1
view_element(filename)
perform_color_swap_and_cleanup.call
$notebook.set_page(0)
Proc.new {
- perform_color_swap_and_cleanup
+ perform_color_swap_and_cleanup.call
$notebook.set_page(0)
}
})
}
+ change_frame_offset_and_cleanup = Proc.new {
+ if values = ask_new_frame_offset(xmldir, "#{infotype}-")
+ perform_change_frame_offset_and_cleanup = Proc.new { |val|
+ change_frame_offset(xmldir, "#{infotype}-", val)
+ my_gen_real_thumbnail.call
+ }
+ perform_change_frame_offset_and_cleanup.call(values[:new])
+
+ save_undo(_("specify frame offset"),
+ Proc.new {
+ perform_change_frame_offset_and_cleanup.call(values[:old])
+ $notebook.set_page(0)
+ Proc.new {
+ perform_change_frame_offset_and_cleanup.call(values[:new])
+ $notebook.set_page(0)
+ }
+ })
+ end
+ }
+
enhance_and_cleanup = Proc.new {
perform_enhance_and_cleanup = Proc.new {
enhance(xmldir, "#{infotype}-")
save_undo(_("enhance"),
Proc.new {
perform_enhance_and_cleanup.call
- $notebook.set_page(1)
+ $notebook.set_page(0)
Proc.new {
- perform_enhance_and_cleanup
- $notebook.set_page(1)
+ perform_enhance_and_cleanup.call
+ $notebook.set_page(0)
}
})
}
end
if event.event_type == Gdk::Event::BUTTON_PRESS && event.button == 3
popup_thumbnail_menu(event, ['change_image'], entry2type(captionfile), xmldir, "#{infotype}-",
- { :change => change_image, :rotate => rotate_and_cleanup, :enhance => enhance_and_cleanup, :color_swap => color_swap_and_cleanup })
+ { :change => change_image, :rotate => rotate_and_cleanup, :enhance => enhance_and_cleanup,
+ :color_swap => color_swap_and_cleanup, :frame_offset => change_frame_offset_and_cleanup })
end
if event.event_type == Gdk::Event::BUTTON2_PRESS && event.button == 1
change_image.call