From 721f943da914be2a6ee8838acdb0e72a7c7aafd4 Mon Sep 17 00:00:00 2001 From: Martijn Braam Date: Fri, 26 Mar 2021 22:47:00 +0100 Subject: [PATCH] Trigger capture with spacebar --- main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/main.c b/main.c index ebbb700..eb52c00 100644 --- a/main.c +++ b/main.c @@ -420,6 +420,12 @@ on_shutter_clicked(GtkWidget *widget, gpointer user_data) mp_io_pipeline_capture(); } +void +on_capture_shortcut(void) +{ + on_shutter_clicked(NULL, NULL); +} + static bool check_point_inside_bounds(int x, int y, int *bounds_x, int *bounds_y) { @@ -760,6 +766,17 @@ main(int argc, char *argv[]) gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_USER); + GClosure* capture_shortcut = g_cclosure_new(on_capture_shortcut, 0, 0); + + GtkAccelGroup* accel_group = gtk_accel_group_new(); + gtk_accel_group_connect(accel_group, + GDK_KEY_space, + 0, + 0, + capture_shortcut); + + gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); + mp_io_pipeline_start(); camera = mp_get_camera_config(0);