very nice
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user