]> git.scottworley.com Git - srec/blobdiff - srec.py
Factor out begin_monitoring_file_size()
[srec] / srec.py
diff --git a/srec.py b/srec.py
index 944cc5cccd387587d86466a2389383023c5bf230..64f2d07e89d4c98c1e93d06892cdc89a035da929 100644 (file)
--- a/srec.py
+++ b/srec.py
@@ -74,13 +74,7 @@ def summarize_size(n: int) -> str:
     return str(n)
 
 
-def on_start_recording(_: Gtk.Button, stack: Gtk.Stack) -> None:
-    global recording  # pylint: disable=global-statement
-    assert recording is None
-
-    filename = make_filename()
-    size_display = find_size_display(stack)
-
+def begin_monitoring_file_size(size_display: Gtk.Label, filename: str) -> None:
     def update_size_display() -> Any:
         try:
             size = summarize_size(os.stat(filename).st_size)
@@ -90,6 +84,14 @@ def on_start_recording(_: Gtk.Button, stack: Gtk.Stack) -> None:
         return GLib.SOURCE_REMOVE if recording is None else GLib.SOURCE_CONTINUE
     GLib.timeout_add_seconds(1, update_size_display)
 
+
+def on_start_recording(_: Gtk.Button, stack: Gtk.Stack) -> None:
+    global recording  # pylint: disable=global-statement
+    assert recording is None
+
+    filename = make_filename()
+    begin_monitoring_file_size(find_size_display(stack), filename)
+
     recording = Stream.start(
         ['ffmpeg', '-framerate', '25'] + video_source(stack) +
         ['-f', 'pulse', '-ac', '2', '-i', 'default', filename])