From 7af6bf13edaa904e9d22a2ba05af5d2583635816 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Thu, 18 Aug 2011 11:18:27 +0900 Subject: [PATCH] Support feedback sounds. --- README | 2 +- configure.ac | 20 ++++++++++++++++++++ eek/Makefile.am | 4 ++-- eek/eek-gtk-keyboard.c | 23 ++++++++++++++++++++--- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/README b/README index ebbc9952..659ca4a5 100644 --- a/README +++ b/README @@ -8,7 +8,7 @@ tools to implement desktop virtual keyboards. ** Dependencies REQUIRED: GLib2, GTK, PangoCairo, libxklavier, libcroco -OPTIONAL: libXtst, at-spi2-core, IBus, Clutter, Clutter-Gtk, Python, Vala, gobject-introspection +OPTIONAL: libXtst, at-spi2-core, IBus, Clutter, Clutter-Gtk, Python, Vala, gobject-introspection, libcanberra ** Build from git repo diff --git a/configure.ac b/configure.ac index 01008db3..128f648c 100644 --- a/configure.ac +++ b/configure.ac @@ -288,6 +288,23 @@ if test x$enable_clutter = xyes; then fi AM_CONDITIONAL(ENABLE_CLUTTER_GTK, [test x$enable_clutter_gtk = xyes]) +dnl libcanberra +AC_MSG_CHECKING([whether you enable libcanberra]) +AC_ARG_ENABLE(libcanberra, + AS_HELP_STRING([--enable-libcanberra=no/yes], + [Enable clutter user interface default=no]), + enable_libcanberra=$enableval, + enable_libcanberra=yes) + +if test x$enable_libcanberra = xyes; then + PKG_CHECK_MODULES([LIBCANBERRA], [libcanberra-gtk3], , enable_libcanberra=no) + if test x$enable_libcanberra = xyes; then + AC_DEFINE([HAVE_LIBCANBERRA], [1], [Define if libcanberra is found]) + fi +fi +AM_CONDITIONAL(ENABLE_LIBCANBERRA, [test x$enable_libcanberra = xyes]) +AC_MSG_RESULT($enable_libcanberra) + GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) dnl define GETTEXT_* variables @@ -343,7 +360,10 @@ Build options: Build Clutter UI $enable_clutter Build Vala binding $enable_vala Build Python binding $enable_python + Sound support $enable_libcanberra Build document $enable_gtk_doc Focus listeners $focus_listeners Keystroke listeners $keystroke_listeners ]) + + diff --git a/eek/Makefile.am b/eek/Makefile.am index c1bd4af0..6ab5e4bf 100644 --- a/eek/Makefile.am +++ b/eek/Makefile.am @@ -130,8 +130,8 @@ libeek_gtk_sources = \ $(srcdir)/eek-gtk-renderer.c libeek_gtk_la_SOURCES = $(libeek_gtk_sources) -libeek_gtk_la_CFLAGS = -DEEK_COMPILATION=1 $(GTK_CFLAGS) -libeek_gtk_la_LIBADD = libeek.la $(GTK_LIBS) +libeek_gtk_la_CFLAGS = -DEEK_COMPILATION=1 $(GTK_CFLAGS) $(LIBCANBERRA_CFLAGS) +libeek_gtk_la_LIBADD = libeek.la $(GTK_LIBS) $(LIBCANBERRA_LIBS) libeek_xkb_public_headers = \ $(srcdir)/eek-xkb-layout.h \ diff --git a/eek/eek-gtk-keyboard.c b/eek/eek-gtk-keyboard.c index 58badc2e..c4df9a37 100644 --- a/eek/eek-gtk-keyboard.c +++ b/eek/eek-gtk-keyboard.c @@ -27,6 +27,10 @@ #include "config.h" #endif /* HAVE_CONFIG_H */ +#ifdef HAVE_LIBCANBERRA +#include +#endif + #include #include "eek-gtk-keyboard.h" @@ -370,9 +374,6 @@ eek_gtk_keyboard_init (EekGtkKeyboard *self) EekGtkKeyboardPrivate *priv; priv = self->priv = EEK_GTK_KEYBOARD_GET_PRIVATE(self); - priv->renderer = NULL; - priv->keyboard = NULL; - priv->dragged_key = NULL; } /** @@ -487,6 +488,14 @@ on_key_pressed (EekKeyboard *keyboard, return; render_pressed_key (widget, key); + +#if HAVE_LIBCANBERRA + ca_gtk_play_for_widget (widget, 0, + CA_PROP_EVENT_ID, "button-pressed", + CA_PROP_EVENT_DESCRIPTION, "virtual key pressed", + CA_PROP_APPLICATION_ID, "org.fedorahosted.Eekboard", + NULL); +#endif } static void @@ -502,6 +511,14 @@ on_key_released (EekKeyboard *keyboard, return; render_released_key (widget, key); + +#if HAVE_LIBCANBERRA + ca_gtk_play_for_widget (widget, 0, + CA_PROP_EVENT_ID, "button-released", + CA_PROP_EVENT_DESCRIPTION, "virtual key pressed", + CA_PROP_APPLICATION_ID, "org.fedorahosted.Eekboard", + NULL); +#endif } static void