gnome-session r4558 - trunk/gnome-session



Author: hadess
Date: Mon Feb 11 12:16:51 2008
New Revision: 4558
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4558&view=rev

Log:
2008-02-11  Bastien Nocera  <hadess hadess net>

	reviewed by: Vincent Untz <vuntz gnome org>

	* Makefile.am:
	* gsm-sound.c: (get_filename_from_string),
	(get_filename_for_sound_from_keyfile), (get_filename_for_sound),
	(play_sound_event): Don't use libgnome's triggers to play the
	login sound, as gnome-settings-daemon hasn't loaded the
	samples in esound when we want to play that file, so referencing
	it by sample name won't work (Helps: #466458)



Modified:
   trunk/gnome-session/ChangeLog
   trunk/gnome-session/Makefile.am
   trunk/gnome-session/gsm-sound.c

Modified: trunk/gnome-session/Makefile.am
==============================================================================
--- trunk/gnome-session/Makefile.am	(original)
+++ trunk/gnome-session/Makefile.am	Mon Feb 11 12:16:51 2008
@@ -16,12 +16,12 @@
 	-DDEFAULTDIR="\"$(defaultdir)\""		\
 	-DESD_SERVER="\"$(ESD_SERVER)\""		\
 	-DAT_SPI_REGISTRYD_DIR="\"$(AT_SPI_REGISTRYD_DIR)\""	\
-	-DTIME_UTILITY="\"$(TIME_UTILITY)\""
+	-DTIME_UTILITY="\"$(TIME_UTILITY)\""		\
+	-DSYSCONFDIR=\""$(sysconfdir)"\"
 
 # Used by the GNOME_PROGRAM_STANDARD_PROPERTIES macros
 STANDARD_PROPERTIES_CFLAGS =                                    \
 	-DPREFIX=\""$(prefix)"\"                                \
-	-DSYSCONFDIR=\""$(sysconfdir)"\"                        \
 	-DLIBDIR=\""$(libdir)"\"                                \
 	-DDATADIR=\""$(datadir)"\"                              \
 	$(NULL)

Modified: trunk/gnome-session/gsm-sound.c
==============================================================================
--- trunk/gnome-session/gsm-sound.c	(original)
+++ trunk/gnome-session/gsm-sound.c	Mon Feb 11 12:16:51 2008
@@ -9,8 +9,7 @@
 #endif
 #include "util.h"
 
-#include <libgnome/gnome-sound.h>
-#include <libgnome/gnome-triggers.h>
+#include <libgnome/libgnome.h>
 
 #define ENABLE_SOUND_KEY        "/desktop/gnome/sound/enable_esd"
 #define ENABLE_EVENT_SOUNDS_KEY "/desktop/gnome/sound/event_sounds"
@@ -138,10 +137,81 @@
 #endif
 }
 
+static char *
+get_filename_from_string (const char *string)
+{
+  if (string[0] != '/')
+    {
+      return gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_SOUND, string,
+					TRUE, NULL);
+    }
+
+  return g_strdup (string);
+}
+
+static char *
+get_filename_for_sound_from_keyfile (const char *name, const char *soundlist_file)
+{
+  GKeyFile *keyfile;
+  char *sound;
+
+  keyfile = g_key_file_new ();
+
+  if (g_key_file_load_from_file (keyfile, soundlist_file, G_KEY_FILE_NONE, NULL) == FALSE)
+    {
+      g_key_file_free (keyfile);
+      return NULL;
+    }
+
+  sound = g_key_file_get_string (keyfile, name, "file", NULL);
+  g_key_file_free (keyfile);
+  if (sound != NULL)
+    {
+      char *res;
+
+      res = get_filename_from_string (sound);
+      if (res != NULL)
+        {
+          g_free (sound);
+	  return res;
+	}
+    }
+  g_free (sound);
+
+  return NULL;
+}
+
+static char *
+get_filename_for_sound (const char *name)
+{
+  char *soundlist, *sound;
+
+  /* Try to load the user configuration first */
+  soundlist = g_build_filename (g_get_home_dir(), ".gnome2", "sound",
+				"events", "gnome-2.soundlist", NULL);
+  sound = get_filename_for_sound_from_keyfile (name, soundlist);
+  g_free (soundlist);
+  if (sound != NULL)
+    return sound;
+
+  soundlist = g_build_filename (SYSCONFDIR, "sound", "events", "gnome-2.soundlist", NULL);
+  sound = get_filename_for_sound_from_keyfile (name, soundlist);
+  g_free (soundlist);
+
+  return sound;
+}
+
 static void
 play_sound_event (const char *name)
 {
-  gnome_triggers_do (NULL, NULL, "gnome-2", name, NULL);
+  char *sound;
+
+  sound = get_filename_for_sound (name);
+  if (sound != NULL)
+    {
+      gnome_sound_play (sound);
+      g_free (sound);
+    }
 }
 
 void 



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