diff --git a/demos/gtk-demo/listview_minesweeper.c b/demos/gtk-demo/listview_minesweeper.c index f7f77d6231..662ba06553 100644 --- a/demos/gtk-demo/listview_minesweeper.c +++ b/demos/gtk-demo/listview_minesweeper.c @@ -8,6 +8,7 @@ * to implement rather different interaction behavior to a typical list. */ +#include "config.h" #include #include @@ -375,6 +376,23 @@ sweeper_game_init (SweeperGame *self) sweeper_game_new_game (self, 8, 8, 10); } +static void +celebrate (gboolean win) +{ + char *path; + GtkMediaStream *stream; + + if (win) + path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "complete.oga", NULL); + else + path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "suspend-error.oga", NULL); + stream = gtk_media_file_new_for_filename (path); + gtk_media_stream_set_volume (stream, 1.0); + gtk_media_stream_play (stream); + g_signal_connect (stream, "notify::ended", G_CALLBACK (g_object_unref), NULL); + g_free (path); +} + static void sweeper_game_end (SweeperGame *self, gboolean win) @@ -383,7 +401,9 @@ sweeper_game_end (SweeperGame *self, { self->playing = FALSE; g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_PLAYING]); + celebrate (win); } + if (self->win != win) { self->win = win; diff --git a/demos/gtk-demo/peg_solitaire.c b/demos/gtk-demo/peg_solitaire.c index 0f5761408c..2006aab736 100644 --- a/demos/gtk-demo/peg_solitaire.c +++ b/demos/gtk-demo/peg_solitaire.c @@ -119,12 +119,6 @@ solitaire_peg_new (void) /*** Helper for finding a win ***/ -static void -ended (GObject *object) -{ - g_object_unref (object); -} - static void celebrate (gboolean win) { @@ -134,12 +128,12 @@ celebrate (gboolean win) if (win) path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "complete.oga", NULL); else - path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "dialog-error.oga", NULL); + path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "suspend-error.oga", NULL); stream = gtk_media_file_new_for_filename (path); gtk_media_stream_set_volume (stream, 1.0); gtk_media_stream_play (stream); - g_signal_connect (stream, "notify::ended", G_CALLBACK (ended), NULL); + g_signal_connect (stream, "notify::ended", G_CALLBACK (g_object_unref), NULL); g_free (path); } diff --git a/demos/gtk-demo/sliding_puzzle.c b/demos/gtk-demo/sliding_puzzle.c index 592fe0fde2..0e4c08a00f 100644 --- a/demos/gtk-demo/sliding_puzzle.c +++ b/demos/gtk-demo/sliding_puzzle.c @@ -40,7 +40,7 @@ celebrate (gboolean win) if (win) path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "complete.oga", NULL); else - path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "dialog-error.oga", NULL); + path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "suspend-error.oga", NULL); stream = gtk_media_file_new_for_filename (path); gtk_media_stream_set_volume (stream, 1.0); gtk_media_stream_play (stream);