[gnome-games/no-games-sound] libgames-support: Remove games-sound.c and call canberra directly from the games



commit 4aff21b7fb2c37ad05a43071cfc1f76c20af99d6
Author: Robert Ancell <robert ancell canonical com>
Date:   Sat Dec 31 19:13:23 2011 +1100

    libgames-support: Remove games-sound.c and call canberra directly from the games

 Makefile.am                                 |    6 +-
 configure.ac                                |   31 +---
 gnect/src/Makefile.am                       |    3 +
 gnect/src/main.c                            |   35 +++-
 gnect/src/prefs.c                           |    3 -
 gnibbles/src/Makefile.am                    |    5 +
 gnibbles/src/boni.c                         |    6 +-
 gnibbles/src/gnibbles.c                     |    8 +-
 gnibbles/src/properties.c                   |    4 +-
 gnibbles/src/sound.c                        |   55 +++++
 gnibbles/src/sound.h                        |   27 +++
 gnibbles/src/worm.c                         |   16 +-
 gnobots2/src/Makefile.am                    |    3 +
 gnobots2/src/properties.c                   |    3 -
 gnobots2/src/sound.c                        |   28 ++-
 iagno/src/Makefile.am                       |    9 +-
 iagno/src/config.vapi                       |    1 +
 iagno/src/iagno.vala                        |   10 +-
 libgames-support/GnomeGamesSupport-1.0.vapi |   19 +--
 libgames-support/Makefile.am                |    7 -
 libgames-support/games-sound.c              |  285 ---------------------------
 libgames-support/games-sound.h              |   45 -----
 22 files changed, 174 insertions(+), 435 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index b50f9c4..ad4e931 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,10 +1,6 @@
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
-SUBDIRS = libgames-support $(gamelist) po
-
-if ENABLE_SOUND
-SUBDIRS += sounds
-endif
+SUBDIRS = libgames-support $(gamelist) po sounds
 
 DIST_SUBDIRS = po sounds libgames-support $(allgames) $(staginggames)
 
diff --git a/configure.ac b/configure.ac
index 8cf1928..b3a7de9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,7 +115,6 @@ need_opengl=no
 need_glx=no
 need_python=no
 need_clutter=no
-want_sound=no
 require_cairo_1_10=no
 
 for game in $gamelist; do
@@ -140,10 +139,6 @@ for game in $gamelist; do
     *) ;;
   esac
   case $game in
-    gnect|gnibbles|gnobots2|quadrapassel|iagno) want_sound=yes ;;
-    *) ;;
-  esac
-  case $game in
     glchess) ;;
     *) need_rsvg=yes ;;
   esac
@@ -271,24 +266,6 @@ esac
 AC_MSG_RESULT([$os_win32])
 AM_CONDITIONAL([PLATFORM_WIN32_NATIVE],[test "$os_win32" = "yes"])
 
-# ********
-# Features
-# ********
-
-# *****
-# Sound
-# *****
-
-if test "$want_sound" = "yes"; then
-  AC_MSG_CHECKING([whether to enable sound support])
-  AC_ARG_ENABLE([sound],
-    [AS_HELP_STRING([--enable-sound],[Enable sound using libcanberra])],
-    [],[enable_sound=yes])
-  AC_MSG_RESULT([$enable_sound])
-else
-  enable_sound=no
-fi
-
 # ********************
 # Checks for libraries
 # ********************
@@ -469,15 +446,9 @@ AM_CONDITIONAL([WITH_GTHREAD],[test "$need_gthread" = "yes"])
 
 # libcanberra
 
-if test "$enable_sound" = "yes"; then
-  PKG_CHECK_MODULES([CANBERRA_GTK],[libcanberra-gtk3 >= $LIBCANBERRA_GTK_REQUIRED],[],
+PKG_CHECK_MODULES([CANBERRA_GTK],[libcanberra-gtk3 >= $LIBCANBERRA_GTK_REQUIRED],[],
     [AC_MSG_ERROR([Sound support was requested, but libcanberra-gtk not found.])])
 
-  AC_DEFINE([ENABLE_SOUND],[1],[Define if sound support is enabled])
-fi
-
-AM_CONDITIONAL([ENABLE_SOUND],[test "$enable_sound" = "yes"])
-
 # *****************
 # Extra build tools
 # *****************
diff --git a/gnect/src/Makefile.am b/gnect/src/Makefile.am
index 92a16fc..8bc36d5 100644
--- a/gnect/src/Makefile.am
+++ b/gnect/src/Makefile.am
@@ -28,12 +28,15 @@ gnect_CPPFLAGS = \
 	$(AM_CPPFLAGS)
 
 gnect_CFLAGS = \
+	-DSOUND_DIRECTORY=\"$(pkgdatadir)/sounds\" \
 	$(GTK_CFLAGS) \
+	$(CANBERRA_GTK_CFLAGS) \
 	$(AM_CFLAGS)
 
 gnect_LDADD = \
 	$(top_builddir)/libgames-support/libgames-support.la \
 	$(GTK_LIBS) \
+	$(CANBERRA_GTK_LIBS) \
 	$(INTLLIBS) \
 	-lz
 
diff --git a/gnect/src/main.c b/gnect/src/main.c
index cef6e15..382a25f 100644
--- a/gnect/src/main.c
+++ b/gnect/src/main.c
@@ -27,12 +27,12 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#include <canberra-gtk.h>
 
 #include <libgames-support/games-conf.h>
 #include <libgames-support/games-gridframe.h>
 #include <libgames-support/games-help.h>
 #include <libgames-support/games-runtime.h>
-#include <libgames-support/games-sound.h>
 #include <libgames-support/games-stock.h>
 #include <libgames-support/games-fullscreen-action.h>
 
@@ -448,29 +448,46 @@ game_free (void)
 static void
 play_sound (SoundID id)
 {
- /* if (!p.do_sound)
-    return;*/
+ const gchar *name = NULL;
+
+ if (!p.do_sound)
+    return;
 
   switch (id) {
   case SOUND_DROP:
-    games_sound_play ("slide");
+    name = "slide";
     break;
   case SOUND_I_WIN:
-    games_sound_play ("reverse");
+    name = "reverse";
     break;
   case SOUND_YOU_WIN:
-    games_sound_play ("bonus");
+    name = "bonus";
     break;
   case SOUND_PLAYER_WIN:
-    games_sound_play ("bonus");
+    name = "bonus";
     break;
   case SOUND_DRAWN_GAME:
-    games_sound_play ("reverse");
+    name = "reverse";
     break;
   case SOUND_COLUMN_FULL:
-    games_sound_play ("bad");
+    name = "bad";
     break;
   }
+
+  if (name)
+  {
+    gchar *filename, *path;
+
+    filename = g_strdup_printf ("%s.ogg", name);
+    path = g_build_filename (SOUND_DIRECTORY, filename, NULL);
+    g_free (filename);
+
+    ca_gtk_play_for_widget (drawarea,
+                            0,
+                            CA_PROP_MEDIA_NAME, name,
+                            CA_PROP_MEDIA_FILENAME, path, NULL);
+    g_free (path);
+  }
 }
 
 
diff --git a/gnect/src/prefs.c b/gnect/src/prefs.c
index e35f248..8d2b85f 100644
--- a/gnect/src/prefs.c
+++ b/gnect/src/prefs.c
@@ -33,7 +33,6 @@
 #include <libgames-support/games-conf.h>
 #include <libgames-support/games-frame.h>
 #include <libgames-support/games-controls.h>
-#include <libgames-support/games-sound.h>
 
 #include "main.h"
 #include "theme.h"
@@ -141,7 +140,6 @@ conf_value_changed_cb (GamesConf *conf,
     p.do_sound = games_conf_get_boolean (NULL, KEY_DO_SOUND, NULL);
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_sound),
                                   p.do_sound);
-    games_sound_enable (p.do_sound);
   } else if (strcmp (key, KEY_MOVE_LEFT) == 0) {
     p.keypress[MOVE_LEFT] = games_conf_get_keyval_with_default (NULL, KEY_MOVE_LEFT, DEFAULT_KEY_LEFT);
   } else if (strcmp (key, KEY_MOVE_RIGHT) == 0) {
@@ -236,7 +234,6 @@ prefs_init (void)
   p.level[PLAYER1] = sane_player_level (p.level[PLAYER1]);
   p.level[PLAYER2] = sane_player_level (p.level[PLAYER2]);
   p.theme_id = sane_theme_id (p.theme_id);
-  games_sound_enable (p.do_sound);
 }
 
 
diff --git a/gnibbles/src/Makefile.am b/gnibbles/src/Makefile.am
index dd4e4e0..fc8c58a 100644
--- a/gnibbles/src/Makefile.am
+++ b/gnibbles/src/Makefile.am
@@ -21,6 +21,8 @@ gnibbles_SOURCES = \
 	main.h \
 	board.c \
 	board.h \
+	sound.c \
+	sound.h \
 	worm.c \
 	worm.h
 
@@ -29,7 +31,9 @@ gnibbles_CPPFLAGS = \
 	$(AM_CPPFLAGS)
 
 gnibbles_CFLAGS = \
+	-DSOUND_DIRECTORY=\"$(pkgdatadir)/sounds\" \
 	$(GTK_CFLAGS) \
+	$(CANBERRA_GTK_CFLAGS) \
 	$(CLUTTER_GTK_CFLAGS) \
 	$(CLUTTER_CFLAGS) \
 	$(AM_CFLAGS)
@@ -37,6 +41,7 @@ gnibbles_CFLAGS = \
 gnibbles_LDADD = \
 	$(top_builddir)/libgames-support/libgames-support.la \
 	$(GTK_LIBS) \
+	$(CANBERRA_GTK_LIBS) \
 	$(CLUTTER_GTK_LIBS) \
 	$(CLUTTER_LIBS) \
 	$(INTLLIBS)
diff --git a/gnibbles/src/boni.c b/gnibbles/src/boni.c
index 676ab21..4d2b9f0 100644
--- a/gnibbles/src/boni.c
+++ b/gnibbles/src/boni.c
@@ -24,7 +24,6 @@
 
 #include <gtk/gtk.h>
 
-#include <libgames-support/games-sound.h>
 #include <clutter-gtk/clutter-gtk.h>
 
 #include "gnibbles.h"
@@ -33,6 +32,7 @@
 #include "boni.h"
 #include "board.h"
 #include "properties.h"
+#include "sound.h"
 
 extern GnibblesBoard *board;
 extern GnibblesProperties *properties;
@@ -85,7 +85,7 @@ gnibbles_boni_add_bonus (GnibblesBoni * boni, gint t_x, gint t_y,
 
   boni->numbonuses++;
   if (t_type != BONUSREGULAR)
-    games_sound_play ("appear");
+    play_sound ("appear");
 }
 
 void
@@ -105,7 +105,7 @@ gnibbles_boni_add_bonus_final (GnibblesBoni * boni, gint t_x, gint t_y,
   gnibbles_bonus_draw (boni->bonuses[boni->numbonuses]);
   boni->numbonuses++;
   if (t_type != BONUSREGULAR)
-    games_sound_play ("appear");
+    play_sound ("appear");
 }
 
 int
diff --git a/gnibbles/src/gnibbles.c b/gnibbles/src/gnibbles.c
index 57a6830..24f100c 100644
--- a/gnibbles/src/gnibbles.c
+++ b/gnibbles/src/gnibbles.c
@@ -33,7 +33,6 @@
 #include <libgames-support/games-runtime.h>
 #include <libgames-support/games-scores-dialog.h>
 #include <libgames-support/games-scores.h>
-#include <libgames-support/games-sound.h>
 
 #include "main.h"
 #include "gnibbles.h"
@@ -43,6 +42,7 @@
 #include "properties.h"
 #include "scoreboard.h"
 #include "board.h"
+#include "sound.h"
 #include "worm.h"
 
 GnibblesWorm *worms[NUMWORMS];
@@ -285,14 +285,14 @@ gnibbles_move_worms (void)
       if (!gnibbles_worm_lose_life (worms[i])) {
         /* One of the worms lost one life, but the round continues. */
         gnibbles_worm_reset (worms[i]);
-        games_sound_play ("crash");
+        play_sound ("crash");
       }
     }
   }
 
   if (status & GAMEOVER) {
-    games_sound_play ("crash");
-    games_sound_play ("gameover");
+    play_sound ("crash");
+    play_sound ("gameover");
     return GAMEOVER;
   }
 
diff --git a/gnibbles/src/properties.c b/gnibbles/src/properties.c
index 41f1adb..f9d1712 100644
--- a/gnibbles/src/properties.c
+++ b/gnibbles/src/properties.c
@@ -26,12 +26,12 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 
-#include <libgames-support/games-sound.h>
 #include <libgames-support/games-scores.h>
 #include <libgames-support/games-conf.h>
 
 #include "properties.h"
 #include "main.h"
+#include "sound.h"
 
 #define MAX_SPEED 4
 
@@ -120,7 +120,7 @@ gnibbles_properties_update (GnibblesProperties * tmp)
     tmp->startlevel = MAXLEVEL;
 
   tmp->sound = games_conf_get_boolean (KEY_PREFERENCES_GROUP, KEY_SOUND, NULL);
-  games_sound_enable (tmp->sound);
+  sound_enable (tmp->sound);
 
   tmp->tilesize = games_conf_get_integer (KEY_PREFERENCES_GROUP,
                                           KEY_TILE_SIZE, NULL);
diff --git a/gnibbles/src/sound.c b/gnibbles/src/sound.c
new file mode 100644
index 0000000..40d2886
--- /dev/null
+++ b/gnibbles/src/sound.c
@@ -0,0 +1,55 @@
+/*
+ *   Gnome Nibbles: Gnome Worm Game
+ *   Written by Sean MacIsaac <sjm acm org>, Ian Peters <itp gnu org>,
+ *              Guillaume Beland <guillaume beland gmail com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <config.h>
+
+#include <gdk/gdk.h>
+#include <canberra-gtk.h>
+
+#include "sound.h"
+
+extern GtkWidget *clutter_widget;
+
+static gboolean enabled = TRUE;
+
+void
+sound_enable (gboolean enable)
+{
+  enabled = enable;
+}
+
+void
+play_sound (const gchar *name)
+{
+  gchar *filename, *path;
+
+  if (!enabled)
+    return;
+
+  filename = g_strdup_printf ("%s.ogg", name);
+  path = g_build_filename (SOUND_DIRECTORY, filename, NULL);
+  g_free (filename);
+
+  ca_gtk_play_for_widget (clutter_widget,
+                          0,
+                          CA_PROP_MEDIA_NAME, name,
+                          CA_PROP_MEDIA_FILENAME, path, NULL);
+  g_free (path);
+}
diff --git a/gnibbles/src/sound.h b/gnibbles/src/sound.h
new file mode 100644
index 0000000..42e49b2
--- /dev/null
+++ b/gnibbles/src/sound.h
@@ -0,0 +1,27 @@
+/*
+ *   Gnome Nibbles: Gnome Worm Game
+ *   Written by Sean MacIsaac <sjm acm org>, Ian Peters <itp gnu org>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _SOUND_H_
+#define _SOUND_H_
+
+void sound_enable (gboolean enable);
+
+void play_sound (const gchar *name);
+
+#endif
diff --git a/gnibbles/src/worm.c b/gnibbles/src/worm.c
index 274be2f..c4bdabf 100644
--- a/gnibbles/src/worm.c
+++ b/gnibbles/src/worm.c
@@ -28,7 +28,6 @@
 #include <stdlib.h>
 #include <math.h>
 
-#include <libgames-support/games-sound.h>
 #include <libgames-support/games-runtime.h>
 #include <clutter-gtk/clutter-gtk.h>
 
@@ -39,6 +38,7 @@
 #include "warpmanager.h"
 #include "properties.h"
 #include "board.h"
+#include "sound.h"
 
 #include "worm.h"
 
@@ -295,7 +295,7 @@ gnibbles_worm_grok_bonus (GnibblesWorm *worm)
 
   if (gnibbles_boni_fake (boni, worm->xhead, worm->yhead)) {
     g_timeout_add (1, (GSourceFunc) gnibbles_worm_reverse, worm);
-    games_sound_play ("reverse");
+    play_sound ("reverse");
     return;
   }
 
@@ -304,12 +304,12 @@ gnibbles_worm_grok_bonus (GnibblesWorm *worm)
       boni->numleft--;
       worm->change += (boni->numboni - boni->numleft) * GROWFACTOR;
       worm->score += (boni->numboni - boni->numleft) * current_level;
-      games_sound_play ("gobble");
+      play_sound ("gobble");
       break;
     case BONUSDOUBLE:
       worm->score += (worm->length + worm->change) * current_level;
       worm->change += worm->length + worm->change;
-      games_sound_play ("bonus");
+      play_sound ("bonus");
       break;
     case BONUSHALF:
       if (worm->length + worm->change > 2) {
@@ -318,19 +318,19 @@ gnibbles_worm_grok_bonus (GnibblesWorm *worm)
                                   (g_list_length (worm->list)
                                   + worm->change) / 2);
         worm->change -= (g_list_length (worm->list) + worm->change) / 2;
-        games_sound_play ("bonus");
+        play_sound ("bonus");
       }
       break;
     case BONUSLIFE:
       worm->lives += 1;
-      games_sound_play ("life");
+      play_sound ("life");
       break;
     case BONUSREVERSE:
       for (i = 0; i < properties->numworms; i++)
         if (worm != worms[i])
           g_timeout_add (1, (GSourceFunc)
                          gnibbles_worm_reverse, worms[i]);
-      games_sound_play ("reverse");
+      play_sound ("reverse");
       break;
   }
 }
@@ -374,7 +374,7 @@ gnibbles_worm_handle_bonus (GnibblesWorm *worm)
 
   if (board->walls[worm->xhead][worm->yhead] == WARPLETTER) {
     gnibbles_warpmanager_worm_change_pos (warpmanager, worm);
-    games_sound_play ("teleport");
+    play_sound ("teleport");
   }
 }
 
diff --git a/gnobots2/src/Makefile.am b/gnobots2/src/Makefile.am
index 5307d53..5bfb00c 100644
--- a/gnobots2/src/Makefile.am
+++ b/gnobots2/src/Makefile.am
@@ -39,12 +39,15 @@ gnobots2_CPPFLAGS = \
 	$(AM_CPPFLAGS)
 
 gnobots2_CFLAGS = \
+	-DSOUND_DIRECTORY=\"$(pkgdatadir)/sounds\" \
 	$(GTK_CFLAGS) \
+	$(CANBERRA_GTK_CFLAGS) \
 	$(AM_CFLAGS)
 
 gnobots2_LDADD = \
 	$(top_builddir)/libgames-support/libgames-support.la \
 	$(GTK_LIBS) \
+	$(CANBERRA_GTK_LIBS) \
 	$(INTLLIBS) \
 	-lm
 
diff --git a/gnobots2/src/properties.c b/gnobots2/src/properties.c
index 9bb5552..56a4611 100644
--- a/gnobots2/src/properties.c
+++ b/gnobots2/src/properties.c
@@ -33,7 +33,6 @@
 #include <libgames-support/games-scores.h>
 #include <libgames-support/games-scores-dialog.h>
 #include <libgames-support/games-conf.h>
-#include <libgames-support/games-sound.h>
 #include <libgames-support/games-runtime.h>
 
 #include "properties.h"
@@ -272,7 +271,6 @@ static void
 sound_cb (GtkWidget * widget, gpointer data)
 {
   properties.sound = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-  games_sound_enable (properties.sound);
   conf_set_enable_sound (properties.sound);
 }
 
@@ -638,7 +636,6 @@ load_properties (void)
   properties.show_toolbar = games_conf_get_boolean (KEY_PREFERENCES_GROUP,
                                                     KEY_SHOW_TOOLBAR, NULL);
 
-  games_sound_enable (properties.sound);
   set_game_graphics (properties.themename);
   set_game_config (properties.selected_config);
   keyboard_set (properties.keys);
diff --git a/gnobots2/src/sound.c b/gnobots2/src/sound.c
index d1743db..dfafeac 100644
--- a/gnobots2/src/sound.c
+++ b/gnobots2/src/sound.c
@@ -22,8 +22,7 @@
 #include <config.h>
 
 #include <gdk/gdk.h>
-
-#include <libgames-support/games-sound.h>
+#include <canberra-gtk.h>
 
 #include "gbdefs.h"
 #include "sound.h"
@@ -69,28 +68,43 @@ play_sound (gint sno)
   }
 
   if (properties_sound ()) {
+    gchar *name = NULL;
 
     switch (sno) {
     case SOUND_VICTORY:
-      games_sound_play ("victory");
+      name = "victory";
       break;
     case SOUND_DIE:
-      games_sound_play ("die");
+      name = "die";
       break;
     case SOUND_TELEPORT:
-      games_sound_play ("teleport");
+      name = "teleport";
       break;
     case SOUND_SPLAT:
-      games_sound_play ("splat");
+      name = "splat";
       break;
     case SOUND_BAD:
       gdk_beep ();
       break;
     case SOUND_YAHOO:
-      games_sound_play ("yahoo");
+      name = "yahoo";
       break;
     }
 
+    if (name)
+    {
+      gchar *filename, *path;
+
+      filename = g_strdup_printf ("%s.ogg", name);
+      path = g_build_filename (SOUND_DIRECTORY, filename, NULL);
+      g_free (filename);
+
+      ca_context_play (ca_gtk_context_get_for_screen (gdk_screen_get_default ()),
+                      0,
+                      CA_PROP_MEDIA_NAME, name,
+                      CA_PROP_MEDIA_FILENAME, path, NULL);
+      g_free (path);
+    }
   }
 
   return TRUE;
diff --git a/iagno/src/Makefile.am b/iagno/src/Makefile.am
index a5d890a..96cd049 100644
--- a/iagno/src/Makefile.am
+++ b/iagno/src/Makefile.am
@@ -12,17 +12,22 @@ iagno_CFLAGS = \
 	-DVERSION=\"$(VERSION)\" \
 	-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
 	-DDATA_DIRECTORY=\"$(datadir)/iagno\" \
-	$(GTK_CFLAGS)
+	-DSOUND_DIRECTORY=\"$(pkgdatadir)/sounds\" \
+	$(GTK_CFLAGS) \
+	$(CANBERRA_GTK_CFLAGS)
 
 iagno_VALAFLAGS = \
 	--pkg posix \
 	--pkg gtk+-3.0 \
+	--pkg libcanberra \
+	--pkg libcanberra-gtk \
 	--vapidir $(top_srcdir)/libgames-support \
 	--pkg GnomeGamesSupport-1.0
 
 iagno_LDADD = \
 	$(top_builddir)/libgames-support/libgames-support.la \
-	$(GTK_LIBS)
+	$(GTK_LIBS) \
+	$(CANBERRA_GTK_LIBS)
 
 if HAVE_GNOME
 iagno_CFLAGS += $(GNOME_CFLAGS)
diff --git a/iagno/src/config.vapi b/iagno/src/config.vapi
index c0c89fc..e90b1fe 100644
--- a/iagno/src/config.vapi
+++ b/iagno/src/config.vapi
@@ -1,3 +1,4 @@
 public const string VERSION;
 public const string GETTEXT_PACKAGE;
 public const string DATA_DIRECTORY;
+public const string SOUND_DIRECTORY;
diff --git a/iagno/src/iagno.vala b/iagno/src/iagno.vala
index a7017e1..e682fbe 100644
--- a/iagno/src/iagno.vala
+++ b/iagno/src/iagno.vala
@@ -146,8 +146,6 @@ public class Iagno : Gtk.Application
 
         statusbar_id = statusbar.get_context_id ("iagno");
 
-        GnomeGamesSupport.sound_enable (settings.get_boolean ("sound"));
-
         start_game ();
     }
 
@@ -337,7 +335,12 @@ public class Iagno : Gtk.Application
         if (game.n_light_tiles == game.n_dark_tiles)
             show_message (_("The game was a draw."));
 
-        GnomeGamesSupport.sound_play ("gameover");
+        if (settings.get_boolean ("sound"))
+        {
+            CanberraGtk.play_for_widget (view, 0,
+                                         Canberra.PROP_MEDIA_NAME, "gameover",
+                                         Canberra.PROP_MEDIA_FILENAME, Path.build_filename (SOUND_DIRECTORY, "gameover.ogg"));
+        }
     }
 
     private void player_move_cb (int x, int y)
@@ -404,7 +407,6 @@ public class Iagno : Gtk.Application
     {
         var play_sounds = widget.get_active ();
         settings.set_boolean ("sound", play_sounds);
-        GnomeGamesSupport.sound_enable (play_sounds);
     }
 
     private void grid_select (Gtk.ToggleButton widget)
diff --git a/libgames-support/GnomeGamesSupport-1.0.vapi b/libgames-support/GnomeGamesSupport-1.0.vapi
index b369bbb..e8524c5 100644
--- a/libgames-support/GnomeGamesSupport-1.0.vapi
+++ b/libgames-support/GnomeGamesSupport-1.0.vapi
@@ -92,24 +92,7 @@ namespace GnomeGamesSupport
     public static int runtime_get_gpl_version  ();
     [CCode (cheader_filename = "games-runtime.h")]
     public static bool runtime_is_system_prefix ();
-
-    [CCode (cheader_filename = "games-sound.h")]
-    bool sound_is_available ();
-    [CCode (cheader_filename = "games-sound.h")]
-    void sound_init (Gdk.Screen screen);
-    [CCode (cheader_filename = "games-sound.h")]
-    void sound_play (string sound_name);
-    [CCode (cheader_filename = "games-sound.h")]
-    void sound_play_for_screen (string sound_name, Gdk.Screen screen);
-    [CCode (cheader_filename = "games-sound.h")]
-    void sound_play_for_event (string sound_name, Gdk.Event event);
-    [CCode (cheader_filename = "games-sound.h")]
-    void sound_play_for_widget (string sound_name, Gtk.Widget widget);
-    [CCode (cheader_filename = "games-sound.h")]
-    void sound_enable (bool enabled);
-    [CCode (cheader_filename = "games-sound.h")]
-    bool sound_is_enabled ();
-    
+   
     [CCode (cheader_filename = "games-help.h")]
     public static void help_display (Gtk.Widget window, string doc_module, string? section);
     [CCode (cheader_filename = "games-help.h")]
diff --git a/libgames-support/Makefile.am b/libgames-support/Makefile.am
index d798478..6502177 100644
--- a/libgames-support/Makefile.am
+++ b/libgames-support/Makefile.am
@@ -21,8 +21,6 @@ libgames_support_la_SOURCES =		\
 	games-runtime.h			\
 	games-show.c			\
 	games-show.h			\
-	games-sound.c			\
-	games-sound.h			\
 	games-stock.c			\
 	games-stock.h
 
@@ -103,11 +101,6 @@ libgames_support_la_CFLAGS += $(RSVG_CFLAGS)
 libgames_support_la_LIBADD += $(RSVG_LIBS)
 endif
 
-if ENABLE_SOUND
-libgames_support_la_CFLAGS += $(CANBERRA_GTK_CFLAGS)
-libgames_support_la_LIBADD += $(CANBERRA_GTK_LIBS)
-endif
-
 gsettingsschema_in_files = org.gnome.Games.WindowState.gschema.xml.in
 gsettings_SCHEMAS = $(gsettingsschema_in_files:.gschema.xml.in=.gschema.xml)
 



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