scrub optimization
This commit is contained in:
@@ -23,6 +23,7 @@ class TranscriptPanel(Gtk.Box):
|
||||
"selection-changed": (GObject.SignalFlags.RUN_FIRST, None, ()),
|
||||
"min-chunk-changed": (GObject.SignalFlags.RUN_FIRST, None, (float,)),
|
||||
"lines-per-group-changed": (GObject.SignalFlags.RUN_FIRST, None, (int,)),
|
||||
"seek-requested": (GObject.SignalFlags.RUN_FIRST, None, (float,)),
|
||||
}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
@@ -30,6 +31,7 @@ class TranscriptPanel(Gtk.Box):
|
||||
|
||||
self._rows: dict[str, Gtk.ListBoxRow] = {}
|
||||
self._texts: dict[str, str] = {}
|
||||
self._timestamps: dict[str, float] = {}
|
||||
self._order: list[str] = []
|
||||
self._selected: list[str] = []
|
||||
|
||||
@@ -176,6 +178,7 @@ class TranscriptPanel(Gtk.Box):
|
||||
self._selected.clear()
|
||||
self._rows.clear()
|
||||
self._texts.clear()
|
||||
self._timestamps.clear()
|
||||
self._order.clear()
|
||||
while child := self._list.get_first_child():
|
||||
self._list.remove(child)
|
||||
@@ -186,6 +189,10 @@ class TranscriptPanel(Gtk.Box):
|
||||
seg_id = getattr(row, "_seg_id", None)
|
||||
if seg_id:
|
||||
self.select(seg_id)
|
||||
# Double-activation (Enter key on focused row) → seek
|
||||
ts = self._timestamps.get(seg_id)
|
||||
if ts is not None:
|
||||
self.emit("seek-requested", ts)
|
||||
|
||||
def _make_row(self, seg):
|
||||
m1, s1 = divmod(int(seg.start), 60)
|
||||
@@ -208,6 +215,7 @@ class TranscriptPanel(Gtk.Box):
|
||||
self._list.append(row)
|
||||
self._rows[seg.id] = row
|
||||
self._texts[seg.id] = seg.text
|
||||
self._timestamps[seg.id] = seg.start
|
||||
self._order.append(seg.id)
|
||||
|
||||
def _clear_visual(self):
|
||||
|
||||
Reference in New Issue
Block a user