[gnome-utils] Play shutter sound effect through libcanberra



commit 8cdf904d9b913f7a16a9a044a68e1268da0ae532
Author: William Jon McCann <jmccann redhat com>
Date:   Sun Aug 23 19:57:38 2009 -0400

    Play shutter sound effect through libcanberra
    
    Fixes http://bugzilla.gnome.org/show_bug.cgi?id=592372

 configure.ac                        |    5 ++++
 gnome-screenshot/Makefile.am        |    2 +
 gnome-screenshot/gnome-screenshot.c |   42 +++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 09ae01c..1eeb14b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,6 +74,7 @@ GTK_REQUIRED=2.17.2
 GIO_UNIX_REQUIRED=2.18.0
 LIBPANEL_APPLET_REQUIRED=2.13.4
 LIBGTOP_REQUIRED=2.12.0
+LIBCANBERRA_GTK_REQUIRED=0.4
 
 # common checks
 PKG_CHECK_MODULES(GNOME_UTILS, glib-2.0 >= $GLIB_REQUIRED dnl
@@ -150,6 +151,10 @@ PKG_CHECK_MODULES(LIBGTOP, libgtop-2.0 >= $LIBGTOP_REQUIRED)
 AC_SUBST(LIBGTOP_CFLAGS)
 AC_SUBST(LIBGTOP_LIBS)
 
+PKG_CHECK_MODULES(LIBCANBERRA_GTK, libcanberra-gtk >= $LIBCANBERRA_GTK_REQUIRED)
+AC_SUBST(LIBCANBERRA_GTK_CFLAGS)
+AC_SUBST(LIBCANBERRA_GTK_LIBS)
+
 dnl ***************************************************************
 dnl Other miscellaneous checks 
 dnl ***************************************************************
diff --git a/gnome-screenshot/Makefile.am b/gnome-screenshot/Makefile.am
index 6e775db..f9c671d 100644
--- a/gnome-screenshot/Makefile.am
+++ b/gnome-screenshot/Makefile.am
@@ -6,6 +6,7 @@ INCLUDES =							\
 	-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"	\
 	-DUIDIR=\""$(uidir)"\"					\
 	$(GNOME_UTILS_CFLAGS)					\
+	$(LIBCANBERRA_GTK_CFLAGS)				\
 	$(GTHREAD_CFLAGS)					\
 	$(NULL)
 
@@ -32,6 +33,7 @@ gnome_screenshot_LDFLAGS = -export-dynamic
 gnome_screenshot_LDADD =		\
 	$(XSHAPE_LIBS)			\
 	$(GNOME_UTILS_LIBS)		\
+	$(LIBCANBERRA_GTK_LIBS)		\
 	$(GTHREAD_LIBS)			\
 	$(NULL)
 
diff --git a/gnome-screenshot/gnome-screenshot.c b/gnome-screenshot/gnome-screenshot.c
index 64ffc04..fe12c70 100644
--- a/gnome-screenshot/gnome-screenshot.c
+++ b/gnome-screenshot/gnome-screenshot.c
@@ -40,6 +40,7 @@
 #include <gio/gio.h>
 #include <pwd.h>
 #include <X11/Xutil.h>
+#include <canberra-gtk.h>
 
 #include "screenshot-shadow.h"
 #include "screenshot-utils.h"
@@ -773,6 +774,45 @@ run_dialog (ScreenshotDialog *dialog)
 }
 
 static void
+play_sound_effect (GdkWindow *window)
+{
+  ca_context *c;
+  ca_proplist *p = NULL;
+  int res;
+
+  c = ca_gtk_context_get ();
+
+  res = ca_proplist_create (&p);
+  if (res < 0)
+    goto done;
+
+  res = ca_proplist_sets (p, CA_PROP_EVENT_ID, "screen-capture");
+  if (res < 0)
+    goto done;
+
+  res = ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION, _("Screenshot taken"));
+  if (res < 0)
+    goto done;
+
+  if (window != NULL)
+    {
+      res = ca_proplist_setf (p,
+                              CA_PROP_WINDOW_X11_XID,
+                              "%lu",
+                              (unsigned long) GDK_WINDOW_XID (window));
+      if (res < 0)
+        goto done;
+    }
+
+  ca_context_play_full (c, 0, p, NULL, NULL);
+
+ done:
+  if (p != NULL)
+    ca_proplist_destroy (p);
+
+}
+
+static void
 finish_prepare_screenshot (char *initial_uri, GdkWindow *window, GdkRectangle *rectangle)
 {  
   ScreenshotDialog *dialog;
@@ -809,6 +849,8 @@ finish_prepare_screenshot (char *initial_uri, GdkWindow *window, GdkRectangle *r
       exit (1);
     }
 
+  play_sound_effect (window);
+
   dialog = screenshot_dialog_new (screenshot, initial_uri, take_window_shot);
   g_free (initial_uri);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]