This commit is contained in:
2026-04-03 04:41:59 -03:00
parent b6a98f1fb7
commit 68c640e3ab
2 changed files with 59 additions and 5 deletions

View File

@@ -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)