w.show_all
end
-def create_editzone(scrolledwindow, pagenum)
+def create_editzone(scrolledwindow, pagenum, image)
frame = Gtk::Frame.new
frame.add(textview = Gtk::TextView.new.set_wrap_mode(Gtk::TextTag::WRAP_WORD))
frame.set_shadow_type(Gtk::SHADOW_IN)
}, candidate_undo_text)
candidate_undo_text = nil
end
+
+ if ![Gdk::Keyval::GDK_Page_Up, Gdk::Keyval::GDK_Page_Down, Gdk::Keyval::GDK_Up, Gdk::Keyval::GDK_Down].include?(event.keyval)
+ #- autoscroll if cursor or image is not visible
+ ypos_top = (image && image.window) ? image.window.position[1] : textview.window.position[1]
+ ypos_bottom = max(textview.window.position[1] + textview.window.size[1], image && image.window ? image.window.position[1] + image.window.size[1] : -1)
+ current_miny_visible = scrolledwindow.vadjustment.value
+ current_maxy_visible = scrolledwindow.vadjustment.value + scrolledwindow.vadjustment.page_size
+ if ypos_top < current_miny_visible
+ newval = scrolledwindow.vadjustment.value -
+ ((current_miny_visible - ypos_top - 1) / scrolledwindow.vadjustment.step_increment + 1) * scrolledwindow.vadjustment.step_increment
+ if newval < scrolledwindow.vadjustment.lower
+ newval = scrolledwindow.vadjustment.lower
+ end
+ scrolledwindow.vadjustment.value = newval
+ elsif ypos_bottom > current_maxy_visible
+ newval = scrolledwindow.vadjustment.value +
+ ((ypos_bottom - current_maxy_visible - 1) / scrolledwindow.vadjustment.step_increment + 1) * scrolledwindow.vadjustment.step_increment
+ if newval > scrolledwindow.vadjustment.upper - scrolledwindow.vadjustment.page_size
+ newval = scrolledwindow.vadjustment.upper - scrolledwindow.vadjustment.page_size
+ end
+ scrolledwindow.vadjustment.value = newval
+ end
+ end
false #- propagate
}
tipname = from_utf8(File.basename(filename).gsub(/\.[^\.]+$/, ''))
tooltips.set_tip(evtbox, utf8(type == 'video' ? (_("%s (video - %s KB)") % [tipname, commify(file_size(from_utf8("#{$current_path}/#{filename}"))/1024)]) : tipname), nil)
- frame2, textview = create_editzone($autotable_sw, 1)
+ frame2, textview = create_editzone($autotable_sw, 1, img)
textview.buffer.text = utf8(caption)
textview.set_justification(Gtk::Justification::CENTER)
$gesture_press = nil
}
- frame, textview = create_editzone($subalbums_sw, 0)
+ frame, textview = create_editzone($subalbums_sw, 0, img)
textview.buffer.text = caption
$subalbums.attach(Gtk::Alignment.new(0, 0.5, 0.5, 0).add(frame),
1, 2, current_y_sub_albums, current_y_sub_albums + 1, Gtk::FILL, Gtk::FILL, 2, 2)
if $xmldir.elements['dir']
#- title edition
- frame, $subalbums_title = create_editzone($subalbums_sw, 0)
+ frame, $subalbums_title = create_editzone($subalbums_sw, 0, nil)
$subalbums_title.buffer.text = $xmldir.attributes['subdirs-caption']
$subalbums_title.set_justification(Gtk::Justification::CENTER)
$subalbums_vb.pack_start(Gtk::Alignment.new(0.5, 0.5, 0.5, 0).add(frame), false, false)