[recipes] Add a sound



commit 18c84340c855be155b1d1f245ea9c49432236dce
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jul 14 18:01:16 2017 -0400

    Add a sound
    
    Play a 'ta da' sound when opening the welcome dialog.
    Sound recorded by Mike Koenig, http://soundbible.com/1003-Ta-Da.html

 data/meson.build     |    1 +
 data/sounds/tada.wav |  Bin 0 -> 291276 bytes
 src/gr-window.c      |   28 ++++++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 00fb0a8..478d65a 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -31,6 +31,7 @@ install_data(   'images/american.png',
                 install_dir: join_paths([pkgdatadir,'images']))
 
 install_data('sounds/complete.oga',
+             'sounds/tada.wav',
              install_dir: join_paths([pkgdatadir,'sounds']))
 
 install_data('chefs.db',
diff --git a/data/sounds/tada.wav b/data/sounds/tada.wav
new file mode 100644
index 0000000..3bb129b
Binary files /dev/null and b/data/sounds/tada.wav differ
diff --git a/src/gr-window.c b/src/gr-window.c
index cb97462..368ca9b 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -48,6 +48,10 @@
 #include "gr-appdata.h"
 #include "gr-settings.h"
 
+#ifdef ENABLE_CANBERRA
+#include <canberra.h>
+#endif
+
 
 struct _GrWindow
 {
@@ -1520,6 +1524,29 @@ should_show_surprise (void)
         return FALSE;
 }
 
+static void
+play_tada_sound (GtkWindow *win)
+{
+#ifdef ENABLE_CANBERRA
+        g_autofree char *path;
+        ca_context *c;
+
+        ca_context_create (&c);
+        g_object_set_data_full (G_OBJECT (win), "ca-context", c, (GDestroyNotify) ca_context_destroy);
+        ca_context_change_props (c,
+                                 CA_PROP_APPLICATION_NAME, _("GNOME Recipes"),
+                                 CA_PROP_APPLICATION_ID, "org.gnome.Recipes",
+                                 CA_PROP_APPLICATION_ICON_NAME, "org.gnome.Recipes",
+                                 NULL);
+        path = g_build_filename (get_pkg_data_dir (), "sounds", "tada.wav", NULL);
+        ca_context_play (c, 0,
+                         CA_PROP_MEDIA_ROLE, "alert",
+                         CA_PROP_MEDIA_FILENAME, path,
+                         CA_PROP_MEDIA_NAME, _("GNOME turns 20 !"),
+                         NULL);
+#endif
+}
+
 void
 gr_window_show_surprise (GrWindow *window)
 {
@@ -1536,6 +1563,7 @@ gr_window_show_surprise (GrWindow *window)
         g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), dialog);
         gtk_window_set_transient_for (dialog, GTK_WINDOW (window));
         gr_window_present_dialog (window, dialog);
+        play_tada_sound (dialog);
 }
 
 void


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