very nice

This commit is contained in:
2026-04-03 07:18:42 -03:00
parent 84dc1405dc
commit 51c0bdd2da
8 changed files with 178 additions and 17 deletions

View File

@@ -173,6 +173,24 @@ class TranscriptPanel(Gtk.Box):
self._selected.clear()
self.emit("selection-changed")
def highlight_nearest(self, timestamp: float) -> None:
"""Scroll to and briefly highlight the transcript segment closest to *timestamp*."""
if not self._order:
return
best_id = None
best_dist = float("inf")
for sid, ts in self._timestamps.items():
d = abs(ts - timestamp)
if d < best_dist:
best_dist = d
best_id = sid
if not best_id or best_id not in self._rows:
return
row = self._rows[best_id]
row.add_css_class("frame-highlight")
self._scroll_to_row(row)
GLib.timeout_add(400, lambda: row.remove_css_class("frame-highlight") or False)
def clear(self):
"""Remove all items and reset state."""
self._selected.clear()