Updated imgs thumbnail scrolling logic

This commit is contained in:
itdominator 2023-04-23 23:35:23 -05:00
parent a8f423e8b8
commit 049bf2e408
4 changed files with 37 additions and 9 deletions

View File

@ -25,9 +25,37 @@ class ImageListScroll(Gtk.ScrolledWindow):
self.set_vexpand(True) self.set_vexpand(True)
def _setup_signals(self): def _setup_signals(self):
... self.connect("edge-reached", self._handle_edge_reached)
self.connect("edge-overshot", self._handle_edge_reached)
def _load_widgets(self): def _load_widgets(self):
viewport = Gtk.Viewport() self.add(ImageList())
viewport.add(ImageList())
self.add(viewport) def _handle_edge_reached(self, widget, edge):
img_list = widget.get_children()[0].get_children()[0]
children = img_list.get_children()
start, end = None, None
size = len(children)
for i, child in enumerate(children):
if start in (None, "") and child.is_visible():
start = i
if end in (None, "") and not start in (None, "") and not \
child.is_visible():
end = (i - 1)
break
if not end:
end = size - 1
if edge == Gtk.PositionType.TOP:
if start >= 1 and not end in (None, ""):
start -= 1
children[end].hide()
children[start].show()
if edge == Gtk.PositionType.BOTTOM:
if not end in (None, "") and not (end + 1) == size:
end += 1
children[start].hide()
children[end].show()

View File

@ -37,9 +37,7 @@ class ImageViewScroll(Gtk.ScrolledWindow):
self._set_up_dnd() self._set_up_dnd()
def _load_widgets(self): def _load_widgets(self):
viewport = Gtk.Viewport() self.add(ImageView())
viewport.add(ImageView())
self.add(viewport)
def _subscribe_to_events(self): def _subscribe_to_events(self):
event_system.subscribe("do_filter_open", self._do_filter_open) event_system.subscribe("do_filter_open", self._do_filter_open)

View File

@ -5,6 +5,7 @@ import gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
gi.require_version('GdkPixbuf', '2.0') gi.require_version('GdkPixbuf', '2.0')
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import GdkPixbuf from gi.repository import GdkPixbuf
try: try:

View File

@ -10,12 +10,13 @@ from gi.repository import Gtk
from ..widgets.image import Image from ..widgets.image import Image
class ImageList(Gtk.Box): class ImageList(Gtk.Box):
def __init__(self): def __init__(self):
super(ImageList, self).__init__() super(ImageList, self).__init__()
self.path = None self.path = None
self.img_list = None self.img_list = None
self._setup_styling() self._setup_styling()
self._setup_signals() self._setup_signals()