scrub optimization

This commit is contained in:
2026-04-03 06:40:08 -03:00
parent 9dfa252727
commit 84dc1405dc
13 changed files with 813 additions and 68 deletions

View File

@@ -24,12 +24,14 @@ class FramesPanel(Gtk.Box):
"selection-changed": (GObject.SignalFlags.RUN_FIRST, None, ()),
"capture-requested": (GObject.SignalFlags.RUN_FIRST, None, ()),
"threshold-changed": (GObject.SignalFlags.RUN_FIRST, None, (float,)),
"seek-requested": (GObject.SignalFlags.RUN_FIRST, None, (float,)),
}
def __init__(self, **kwargs):
super().__init__(orientation=Gtk.Orientation.VERTICAL, spacing=0, **kwargs)
self._widgets: dict[str, Gtk.Box] = {}
self._timestamps: dict[str, float] = {}
self._order: list[str] = []
self._selected: str | None = None
@@ -105,10 +107,11 @@ class FramesPanel(Gtk.Box):
box.append(label)
gesture = Gtk.GestureClick()
gesture.connect("released", lambda g, n, x, y, fid=frame_id: self.select(fid))
gesture.connect("released", self._on_frame_click, frame_id)
box.add_controller(gesture)
self._widgets[frame_id] = box
self._timestamps[frame_id] = timestamp
self._order.append(frame_id)
self._strip.append(box)
@@ -117,6 +120,12 @@ class FramesPanel(Gtk.Box):
log.info("Thumbnail: %s at %.1fs", frame_id, timestamp)
def _on_frame_click(self, gesture, n_press, x, y, frame_id):
self.select(frame_id)
if n_press == 2:
ts = self._timestamps.get(frame_id, 0)
self.emit("seek-requested", ts)
def load_items(self, items: list[dict]):
"""Bulk load. Each dict has 'id', 'pixbuf', 'timestamp'."""
self.clear()
@@ -171,6 +180,7 @@ class FramesPanel(Gtk.Box):
"""Remove all items and reset state."""
self._selected = None
self._widgets.clear()
self._timestamps.clear()
self._order.clear()
while child := self._strip.get_first_child():
self._strip.remove(child)