slot.append(slot.content)
return slot
- self.gallery.set_min_children_per_line(self.per_row)
- self.gallery.set_max_children_per_line(self.per_row)
self.gallery.bind_model(self.gallery_selection, init_gallery_slot)
if sort:
self.gallery_store.sort(sorter)
to_select.activate()
self.update_gallery_view()
- def update_gallery_view(self):
+ def update_gallery_view(self, refocus=False):
"""Load/unload gallery's file images based on viewport visibility."""
+ self.gallery.set_min_children_per_line(self.per_row)
+ self.gallery.set_max_children_per_line(self.per_row)
viewport = self.gallery.get_parent().get_parent()
vp_height = viewport.get_height()
vp_width = viewport.get_width()
- vp_top = viewport.get_vadjustment().get_value()
+ vp_scroll = viewport.get_vadjustment()
+ vp_top = vp_scroll.get_value()
vp_bottom = vp_top + vp_height
margin = 6
max_slot_width = vp_width / self.per_row - margin
slot.content = Gtk.Label(label='?')
slot.append(slot.content)
slot.content.set_size_request(slot_size, slot_size)
+ if refocus:
+ for c in self.gallery.get_selected_children():
+ for i in range(self.gallery_store_filtered.get_n_items()):
+ if c == self.gallery.get_child_at_index(i):
+ slot = self.gallery.get_child_at_index(i).props.child
+ slot_top = (i // self.per_row) * (slot_size + margin)
+ slot_bottom = slot_top + slot_size
+ if slot_top < vp_top:
+ vp_scroll.set_value(slot_top)
+ elif slot_bottom > vp_bottom:
+ vp_scroll.set_value(slot_bottom - vp_height)
+ vp_scroll.emit('value-changed')
# # DEBUG: mere statistics
# from datetime import datetime
# n_imgs, n_buttons, n_others = 0, 0, 0
def toggle_side_box(self):
"""Toggle window sidebox visible/invisible."""
self.side_box.props.visible = not self.side_box.get_visible()
- self.update_gallery(self.gallery_selection.props.selected_item,
- sort=False)
+ self.update_gallery_view()
def reset_include_dirs(self, button):
"""By button's .active, in-/exclude directories from gallery view."""
"""Change by increment how many items max to display in gallery row."""
if self.per_row + increment > 0:
self.per_row += increment
- self.update_gallery(self.gallery_selection.props.selected_item,
- sort=False)
+ self.update_gallery_view(refocus=True)
def reset_recurse(self, button):
"""By button's .active, de-/activate recursion on image collection."""