Use libfeedback to emit shutter sound (MR 24)
This makes it simpler to notice that a picture was taken
This commit is contained in:
@@ -2,6 +2,7 @@ project('megapixels', 'c', version: '1.5.2')
|
|||||||
|
|
||||||
gnome = import('gnome')
|
gnome = import('gnome')
|
||||||
gtkdep = dependency('gtk4')
|
gtkdep = dependency('gtk4')
|
||||||
|
libfeedback = dependency('libfeedback-0.0')
|
||||||
tiff = dependency('libtiff-4')
|
tiff = dependency('libtiff-4')
|
||||||
zbar = dependency('zbar')
|
zbar = dependency('zbar')
|
||||||
threads = dependency('threads')
|
threads = dependency('threads')
|
||||||
@@ -50,7 +51,7 @@ executable('megapixels',
|
|||||||
'src/zbar_pipeline.c',
|
'src/zbar_pipeline.c',
|
||||||
resources,
|
resources,
|
||||||
include_directories: 'src/',
|
include_directories: 'src/',
|
||||||
dependencies: [gtkdep, libm, tiff, zbar, threads, epoxy],
|
dependencies: [gtkdep, libfeedback, libm, tiff, zbar, threads, epoxy],
|
||||||
install: true,
|
install: true,
|
||||||
link_args: '-Wl,-ldl')
|
link_args: '-Wl,-ldl')
|
||||||
|
|
||||||
|
26
src/main.c
26
src/main.c
@@ -10,6 +10,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#define LIBFEEDBACK_USE_UNSTABLE_API
|
||||||
|
#include <libfeedback.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <linux/kdev_t.h>
|
#include <linux/kdev_t.h>
|
||||||
#include <linux/media.h>
|
#include <linux/media.h>
|
||||||
@@ -32,6 +34,8 @@
|
|||||||
RENDERDOC_API_1_1_2 *rdoc_api = NULL;
|
RENDERDOC_API_1_1_2 *rdoc_api = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define APP_ID "org.postmarketos.Megapixels"
|
||||||
|
|
||||||
enum user_control { USER_CONTROL_ISO, USER_CONTROL_SHUTTER };
|
enum user_control { USER_CONTROL_ISO, USER_CONTROL_SHUTTER };
|
||||||
|
|
||||||
static bool camera_is_initialized = false;
|
static bool camera_is_initialized = false;
|
||||||
@@ -75,6 +79,7 @@ GtkWidget *scanned_codes;
|
|||||||
GtkWidget *preview_top_box;
|
GtkWidget *preview_top_box;
|
||||||
GtkWidget *preview_bottom_box;
|
GtkWidget *preview_bottom_box;
|
||||||
GtkWidget *flash_button;
|
GtkWidget *flash_button;
|
||||||
|
LfbEvent *capture_event;
|
||||||
|
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
|
|
||||||
@@ -516,6 +521,9 @@ run_capture_action(GSimpleAction *action, GVariant *param, gpointer user_data)
|
|||||||
{
|
{
|
||||||
gtk_spinner_start(GTK_SPINNER(process_spinner));
|
gtk_spinner_start(GTK_SPINNER(process_spinner));
|
||||||
gtk_stack_set_visible_child(GTK_STACK(open_last_stack), process_spinner);
|
gtk_stack_set_visible_child(GTK_STACK(open_last_stack), process_spinner);
|
||||||
|
if (capture_event)
|
||||||
|
lfb_event_trigger_feedback_async(capture_event, NULL, NULL, NULL);
|
||||||
|
|
||||||
mp_io_pipeline_capture();
|
mp_io_pipeline_capture();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,7 +984,6 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
"gtk-application-prefer-dark-theme",
|
"gtk-application-prefer-dark-theme",
|
||||||
TRUE,
|
TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
GdkDisplay *display = gdk_display_get_default();
|
GdkDisplay *display = gdk_display_get_default();
|
||||||
GtkIconTheme *icon_theme = gtk_icon_theme_get_for_display(display);
|
GtkIconTheme *icon_theme = gtk_icon_theme_get_for_display(display);
|
||||||
gtk_icon_theme_add_resource_path(icon_theme, "/org/postmarketos/Megapixels");
|
gtk_icon_theme_add_resource_path(icon_theme, "/org/postmarketos/Megapixels");
|
||||||
@@ -1108,6 +1115,17 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
gtk_widget_show(window);
|
gtk_widget_show(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
startup(GApplication *app, gpointer data)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) err = NULL;
|
||||||
|
|
||||||
|
if (lfb_init(APP_ID, &err))
|
||||||
|
capture_event = lfb_event_new("camera-shutter");
|
||||||
|
else
|
||||||
|
g_warning("Failed to init libfeedback: %s", err->message);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shutdown(GApplication *app, gpointer data)
|
shutdown(GApplication *app, gpointer data)
|
||||||
{
|
{
|
||||||
@@ -1115,6 +1133,9 @@ shutdown(GApplication *app, gpointer data)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mp_io_pipeline_stop();
|
mp_io_pipeline_stop();
|
||||||
mp_flash_gtk_clean();
|
mp_flash_gtk_clean();
|
||||||
|
|
||||||
|
g_clear_object(&capture_event);
|
||||||
|
lfb_uninit();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1141,8 +1162,9 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
setenv("LC_NUMERIC", "C", 1);
|
setenv("LC_NUMERIC", "C", 1);
|
||||||
|
|
||||||
GtkApplication *app = gtk_application_new("org.postmarketos.Megapixels", 0);
|
GtkApplication *app = gtk_application_new(APP_ID, 0);
|
||||||
|
|
||||||
|
g_signal_connect(app, "startup", G_CALLBACK(startup), NULL);
|
||||||
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
|
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
|
||||||
g_signal_connect(app, "shutdown", G_CALLBACK(shutdown), NULL);
|
g_signal_connect(app, "shutdown", G_CALLBACK(shutdown), NULL);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user