119 lines
2.4 KiB
Diff
119 lines
2.4 KiB
Diff
|
--- gnome-session/gsm-sound.c
|
||
|
+++ gnome-session/gsm-sound.c
|
||
|
@@ -11,6 +11,8 @@
|
||
|
|
||
|
#include <libgnome/gnome-sound.h>
|
||
|
#include <libgnome/gnome-triggers.h>
|
||
|
+#include <libgnome/gnome-util.h>
|
||
|
+#include <libgnome/gnome-config.h>
|
||
|
|
||
|
#define ENABLE_SOUND_KEY "/desktop/gnome/sound/enable_esd"
|
||
|
#define ENABLE_EVENT_SOUNDS_KEY "/desktop/gnome/sound/event_sounds"
|
||
|
@@ -70,7 +72,7 @@
|
||
|
static void
|
||
|
start_esd (void)
|
||
|
{
|
||
|
- gchar *argv[] = {ESD_SERVER, "-nobeeps", NULL};
|
||
|
+ gchar *argv[] = {ESD_SERVER, "-terminate", "-nobeeps", NULL};
|
||
|
GError *err = NULL;
|
||
|
time_t starttime;
|
||
|
|
||
|
@@ -94,6 +96,81 @@
|
||
|
}
|
||
|
}
|
||
|
|
||
|
+
|
||
|
+static gboolean
|
||
|
+load_login_sample_from (const char *file,
|
||
|
+ gboolean *isset)
|
||
|
+{
|
||
|
+ char *key;
|
||
|
+ char *sample_file;
|
||
|
+ int sample_id;
|
||
|
+
|
||
|
+ if (!file)
|
||
|
+ return FALSE;
|
||
|
+
|
||
|
+ key = g_strconcat ("=", file, "=login/file", NULL);
|
||
|
+ sample_file = gnome_config_get_string (key);
|
||
|
+ g_free (key);
|
||
|
+
|
||
|
+ if (sample_file && isset)
|
||
|
+ *isset = TRUE;
|
||
|
+ else if (isset)
|
||
|
+ *isset = FALSE;
|
||
|
+
|
||
|
+ if (sample_file && *sample_file && *sample_file != '/')
|
||
|
+ {
|
||
|
+ char *tmp_sample_file;
|
||
|
+ tmp_sample_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_SOUND, sample_file, TRUE, NULL);
|
||
|
+ g_free (sample_file);
|
||
|
+ sample_file = tmp_sample_file;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (!(sample_file && *sample_file))
|
||
|
+ {
|
||
|
+ g_free (sample_file);
|
||
|
+ return FALSE;
|
||
|
+ }
|
||
|
+
|
||
|
+ sample_id = esd_sample_getid (gnome_sound_connection_get (), "gnome-2/login");
|
||
|
+ if (sample_id >= 0)
|
||
|
+ esd_sample_free (gnome_sound_connection_get (), sample_id);
|
||
|
+
|
||
|
+ sample_id = gnome_sound_sample_load ("gnome-2/login", sample_file);
|
||
|
+
|
||
|
+ if (sample_id < 0)
|
||
|
+ {
|
||
|
+ g_warning ("Couldn't load sound file %s\n", sample_file);
|
||
|
+ return FALSE;
|
||
|
+ }
|
||
|
+
|
||
|
+ g_free (sample_file);
|
||
|
+
|
||
|
+ return TRUE;
|
||
|
+}
|
||
|
+
|
||
|
+#define SOUND_EVENT_FILE "sound/events/gnome-2.soundlist"
|
||
|
+ static gboolean
|
||
|
+load_login_sample (void)
|
||
|
+{
|
||
|
+ char *s;
|
||
|
+ gboolean loaded;
|
||
|
+ gboolean isset;
|
||
|
+
|
||
|
+ s = gnome_util_home_file (SOUND_EVENT_FILE);
|
||
|
+ loaded = load_login_sample_from (s, &isset);
|
||
|
+ g_free (s);
|
||
|
+
|
||
|
+ if (isset)
|
||
|
+ return loaded;
|
||
|
+
|
||
|
+ s = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_CONFIG, SOUND_EVENT_FILE, TRUE, NULL);
|
||
|
+ loaded = load_login_sample_from (s, NULL);
|
||
|
+ g_free (s);
|
||
|
+
|
||
|
+ return loaded;
|
||
|
+}
|
||
|
+
|
||
|
+
|
||
|
static void
|
||
|
stop_esd (void)
|
||
|
{
|
||
|
@@ -127,7 +204,7 @@
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
|
- return TRUE;
|
||
|
+ return load_login_sample();
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
@@ -159,6 +236,4 @@
|
||
|
{
|
||
|
if (sound_events_enabled ())
|
||
|
play_sound_event ("logout");
|
||
|
-
|
||
|
- sound_shutdown ();
|
||
|
}
|