From 68c640e3ab7946b85396829f504a61a184cb1629 Mon Sep 17 00:00:00 2001 From: buenosairesam Date: Fri, 3 Apr 2026 04:41:59 -0300 Subject: [PATCH] bla --- cht/ui/transcript_panel.py | 54 ++++++++++++++++++++++++++++++++++---- cht/window.py | 10 +++++++ 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/cht/ui/transcript_panel.py b/cht/ui/transcript_panel.py index 7ca3cf6..d451019 100644 --- a/cht/ui/transcript_panel.py +++ b/cht/ui/transcript_panel.py @@ -11,6 +11,8 @@ import gi gi.require_version("Gtk", "4.0") from gi.repository import Gtk, GLib, GObject +from cht.config import TRANSCRIBE_MIN_CHUNK_S, TRANSCRIBE_LINES_PER_GROUP + log = logging.getLogger(__name__) @@ -19,6 +21,8 @@ class TranscriptPanel(Gtk.Box): __gsignals__ = { "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,)), } def __init__(self, **kwargs): @@ -29,11 +33,36 @@ class TranscriptPanel(Gtk.Box): self._order: list[str] = [] self._selected: list[str] = [] - label = Gtk.Label(label="Transcript") - label.add_css_class("heading") - label.set_margin_top(4) - label.set_margin_bottom(4) - self.append(label) + # Header with sliders + header = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8) + header.set_margin_top(4) + header.set_margin_bottom(4) + header.set_margin_start(8) + header.set_margin_end(8) + + self._header_label = Gtk.Label( + label=f"Transcript (chunk: {TRANSCRIBE_MIN_CHUNK_S}s, group: {TRANSCRIBE_LINES_PER_GROUP})" + ) + self._header_label.add_css_class("heading") + header.append(self._header_label) + + chunk_scale = Gtk.Scale.new_with_range(Gtk.Orientation.HORIZONTAL, 2, 15, 1) + chunk_scale.set_value(TRANSCRIBE_MIN_CHUNK_S) + chunk_scale.set_hexpand(True) + chunk_scale.set_draw_value(False) + chunk_scale.connect("value-changed", self._on_chunk_changed) + header.append(chunk_scale) + + group_scale = Gtk.Scale.new_with_range(Gtk.Orientation.HORIZONTAL, 1, 10, 1) + group_scale.set_value(TRANSCRIBE_LINES_PER_GROUP) + group_scale.set_hexpand(True) + group_scale.set_draw_value(False) + group_scale.connect("value-changed", self._on_group_changed) + header.append(group_scale) + + self._chunk_val = TRANSCRIBE_MIN_CHUNK_S + self._group_val = TRANSCRIBE_LINES_PER_GROUP + self.append(header) self._list = Gtk.ListBox() self._list.set_selection_mode(Gtk.SelectionMode.NONE) @@ -199,3 +228,18 @@ class TranscriptPanel(Gtk.Box): elif y + h > val + page: adj.set_value(y + h - page) return False + + def _update_header(self): + self._header_label.set_label( + f"Transcript (chunk: {self._chunk_val}s, group: {self._group_val})" + ) + + def _on_chunk_changed(self, scale): + self._chunk_val = int(scale.get_value()) + self._update_header() + self.emit("min-chunk-changed", float(self._chunk_val)) + + def _on_group_changed(self, scale): + self._group_val = int(scale.get_value()) + self._update_header() + self.emit("lines-per-group-changed", self._group_val) diff --git a/cht/window.py b/cht/window.py index d10c224..821db88 100644 --- a/cht/window.py +++ b/cht/window.py @@ -91,6 +91,8 @@ class ChtWindow(Adw.ApplicationWindow): # Cross-panel exclusion: selecting frame clears transcript and vice versa self._frames_panel.connect("selection-changed", self._on_frame_selection_changed) self._transcript_panel.connect("selection-changed", self._on_transcript_selection_changed) + self._transcript_panel.connect("min-chunk-changed", self._on_min_chunk_changed) + self._transcript_panel.connect("lines-per-group-changed", self._on_lines_per_group_changed) log.info("Window initialized") GLib.idle_add(self._check_agent_auth) @@ -124,6 +126,14 @@ class ChtWindow(Adw.ApplicationWindow): if self._stream_mgr: self._stream_mgr.scene_threshold = val + def _on_min_chunk_changed(self, panel, val): + import cht.config + cht.config.TRANSCRIBE_MIN_CHUNK_S = val + + def _on_lines_per_group_changed(self, panel, val): + import cht.config + cht.config.TRANSCRIBE_LINES_PER_GROUP = val + # -- Session loading -- def _on_load_session_clicked(self, button):