video: reset button icon to inactive after video processing

In current state after video is processed and saved button has
video-recording icon, that is confusing.

The change handles exit code of movie.sh script and depending on that
notifies UI to set video-inactive icon. video-recording icon is set,
when the user press button to activate video recording.
This commit is contained in:
Andrey Skvortsov
2025-03-30 00:14:47 +03:00
committed by Martijn Braam
parent 4cbd8c2df7
commit 6a7d2ec85e
3 changed files with 28 additions and 8 deletions

View File

@@ -1008,13 +1008,11 @@ flash_button_clicked(GtkWidget *button, gpointer user_data)
}
void
notify_movie_progress(void)
notify_movie_record_ready(void)
{
if (!movie_start) {
// Recording started
gtk_button_set_icon_name(GTK_BUTTON(movie),
"video-recording-symbolic");
}
movie_start = 0;
gtk_button_set_icon_name(GTK_BUTTON(movie),
"video-inactive-symbolic");
}
void

View File

@@ -38,7 +38,7 @@ int remap(int value, int input_min, int input_max, int output_min, int output_ma
bool check_window_active();
void notify_movie_progress(void);
void notify_movie_record_ready(void);
void notify_movie_message(gchar *msg);
void notify_auto_status(gchar *msg);

View File

@@ -837,7 +837,6 @@ static void on_read_complete(GObject *source_object, GAsyncResult *res, gpointer
// End of file reached, close the stream
g_input_stream_close(stream, NULL, NULL);
g_object_unref(stream);
notify_movie_progress();
return;
}
if (bytes_read < 0) {
@@ -868,6 +867,27 @@ static void on_read_complete(GObject *source_object, GAsyncResult *res, gpointer
on_read_complete, NULL);
}
static void
spawn_movie_finished(GSubprocess *proc, GAsyncResult *res, gpointer data)
{
int exit_status;
g_subprocess_wait_finish(proc, res, NULL);
if (g_subprocess_get_if_exited (proc)) {
exit_status = g_subprocess_get_exit_status (proc);
if (movie_recording) {
// stop recording, when recording failed to start
if (exit_status) {
movie_recording = 0;
notify_movie_record_ready();
}
} else {
// finished video processing
notify_movie_record_ready();
}
}
}
static void
spawn_movie(char *cmd)
{
@@ -910,6 +930,8 @@ spawn_movie(char *cmd)
// Read the output of the subprocess asynchronously
g_input_stream_read_async(stdout_stream, stdout_buf, sizeof(stdout_buf), G_PRIORITY_DEFAULT, NULL,
on_read_complete, NULL);
g_subprocess_wait_async(proc, NULL, (GAsyncReadyCallback)spawn_movie_finished, NULL);
}