bla
This commit is contained in:
@@ -11,6 +11,8 @@ import gi
|
|||||||
gi.require_version("Gtk", "4.0")
|
gi.require_version("Gtk", "4.0")
|
||||||
from gi.repository import Gtk, GLib, GObject
|
from gi.repository import Gtk, GLib, GObject
|
||||||
|
|
||||||
|
from cht.config import TRANSCRIBE_MIN_CHUNK_S, TRANSCRIBE_LINES_PER_GROUP
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -19,6 +21,8 @@ class TranscriptPanel(Gtk.Box):
|
|||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
"selection-changed": (GObject.SignalFlags.RUN_FIRST, None, ()),
|
"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):
|
def __init__(self, **kwargs):
|
||||||
@@ -29,11 +33,36 @@ class TranscriptPanel(Gtk.Box):
|
|||||||
self._order: list[str] = []
|
self._order: list[str] = []
|
||||||
self._selected: list[str] = []
|
self._selected: list[str] = []
|
||||||
|
|
||||||
label = Gtk.Label(label="Transcript")
|
# Header with sliders
|
||||||
label.add_css_class("heading")
|
header = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
|
||||||
label.set_margin_top(4)
|
header.set_margin_top(4)
|
||||||
label.set_margin_bottom(4)
|
header.set_margin_bottom(4)
|
||||||
self.append(label)
|
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 = Gtk.ListBox()
|
||||||
self._list.set_selection_mode(Gtk.SelectionMode.NONE)
|
self._list.set_selection_mode(Gtk.SelectionMode.NONE)
|
||||||
@@ -199,3 +228,18 @@ class TranscriptPanel(Gtk.Box):
|
|||||||
elif y + h > val + page:
|
elif y + h > val + page:
|
||||||
adj.set_value(y + h - page)
|
adj.set_value(y + h - page)
|
||||||
return False
|
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)
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ class ChtWindow(Adw.ApplicationWindow):
|
|||||||
# Cross-panel exclusion: selecting frame clears transcript and vice versa
|
# Cross-panel exclusion: selecting frame clears transcript and vice versa
|
||||||
self._frames_panel.connect("selection-changed", self._on_frame_selection_changed)
|
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("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")
|
log.info("Window initialized")
|
||||||
GLib.idle_add(self._check_agent_auth)
|
GLib.idle_add(self._check_agent_auth)
|
||||||
@@ -124,6 +126,14 @@ class ChtWindow(Adw.ApplicationWindow):
|
|||||||
if self._stream_mgr:
|
if self._stream_mgr:
|
||||||
self._stream_mgr.scene_threshold = val
|
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 --
|
# -- Session loading --
|
||||||
|
|
||||||
def _on_load_session_clicked(self, button):
|
def _on_load_session_clicked(self, button):
|
||||||
|
|||||||
Reference in New Issue
Block a user