end
-def autoscroll_if_needed(img)
- xpos_left = img.window.position[0]
- xpos_right = img.window.position[0] + img.window.size[0]
- current_minx_visible = $imagesline_sw.hadjustment.value
- current_maxx_visible = $imagesline_sw.hadjustment.value + $imagesline_sw.hadjustment.page_size
-# puts "xpos left: #{xpos_left}"
-# puts "xpos right: #{xpos_right}"
-# puts "current minx visible: #{current_minx_visible}"
-# puts "current maxx visible: #{current_maxx_visible}"
- if xpos_left < current_minx_visible
- puts 'scroll_upper(scrolledwindow, ypos_top)'
- elsif xpos_right > current_maxx_visible
- puts 'scroll_lower(scrolledwindow, ypos_bottom)'
- end
-end
-
def check_memory_free_cache_if_needed
GC.start
mem = get_mem
}
end
+def autoscroll_if_needed(button)
+ xpos_left = button.event_window.position[0]
+ xpos_right = button.event_window.position[0] + button.event_window.size[0]
+ hadj = $imagesline_sw.hadjustment
+ current_minx_visible = hadj.value
+ current_maxx_visible = hadj.value + hadj.page_size
+ if xpos_left < current_minx_visible
+ #- autoscroll left
+ newval = hadj.value -
+ ((hadj.value - xpos_left - 1) / hadj.step_increment + 1) * hadj.step_increment
+ hadj.value = newval
+ button.queue_draw #- TOREMOVE: the visual focus is displayed incorrectly
+ elsif xpos_right > current_maxx_visible
+ #- autoscroll right
+ newval = hadj.value +
+ ((xpos_right - (hadj.value + hadj.page_size) - 1) / hadj.step_increment + 1) * hadj.step_increment
+ if newval > hadj.upper - hadj.page_size
+ newval = hadj.upper - hadj.page_size
+ end
+ hadj.value = newval
+ button.queue_draw #- TOREMOVE: the visual focus is displayed incorrectly
+ end
+end
+
def show_entries
e = Thread.new {
t1 = Time.now
entry.pixbuf_thumbnail
gtk_thread_protect(proc { |i|
entry = $allentries[i]
- entry.button = Gtk::Button.new.set_image(img = Gtk::Image.new(entry.pixbuf_thumbnail)).show_all
+ entry.button = Gtk::Button.new.set_image(img = Gtk::Image.new(entry.pixbuf_thumbnail))
tooltips.set_tip(entry.button, File.basename(entry.path).gsub(/\.[^.]+$/, ''), nil)
- $imagesline.pack_start(entry.button, false, false)
+ $imagesline.pack_start(entry.button.show_all, false, false)
entry.button.signal_connect('clicked') { $mainview.set_shown_entry(i) }
- entry.button.signal_connect('focus-in-event') { entry.button.clicked; autoscroll_if_needed(img) }
+ entry.button.signal_connect('focus-in-event') { entry.button.clicked; autoscroll_if_needed(entry.button) }
if i == 0
entry.button.grab_focus
end
end
Dir.entries(dir).each { |file|
type = entry2type(file)
- if type
-#&& $allentries.size < 8
+ if type && $allentries.size < 5
$allentries << Entry.new(File.join(dir, file), type)
end
}