Mercurial > pidgin.yaz
annotate src/gtksound.c @ 11076:75be3005640e
[gaim-migrate @ 13086]
I'd left off a null and it caused a crash. Also, I changed the
thing to use vargs, since it will need to use that in the future
anyway, I think.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 09 Jul 2005 20:00:07 +0000 |
parents | 50224ac8184d |
children | e25575a59f01 |
rev | line source |
---|---|
5684 | 1 /* |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10158
diff
changeset
|
2 * @file gtksound.h GTK+ Sound |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10158
diff
changeset
|
3 * @ingroup gtkui |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10158
diff
changeset
|
4 * |
5684 | 5 * gaim |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
5684 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5684 | 28 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
29 #ifdef _WIN32 |
5684 | 30 #include <windows.h> |
31 #include <mmsystem.h> | |
32 #endif | |
33 | |
34 #ifdef USE_AO | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
35 # include <ao/ao.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
36 # include <audiofile.h> |
5684 | 37 #endif /* USE_AO */ |
38 | |
39 #ifdef USE_NAS_AUDIO | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
40 # include <audio/audiolib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
41 # include <audio/soundlib.h> |
5684 | 42 #endif /* USE_NAS_AUDIO */ |
43 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
44 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
45 #include "notify.h" |
5684 | 46 #include "prefs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
47 #include "sound.h" |
7465 | 48 #include "util.h" |
5684 | 49 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
50 #include "gtksound.h" |
5684 | 51 |
52 struct gaim_sound_event { | |
53 char *label; | |
54 char *pref; | |
55 char *def; | |
56 }; | |
57 | |
10074 | 58 #define PLAY_SOUND_TIMEOUT 15000 |
5684 | 59 |
10320 | 60 static guint mute_login_sounds_timeout = 0; |
5684 | 61 static gboolean mute_login_sounds = FALSE; |
6199 | 62 static gboolean sound_initialized = FALSE; |
5684 | 63 |
64 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = { | |
10158 | 65 {N_("Buddy logs in"), "login", "login.wav"}, |
66 {N_("Buddy logs out"), "logout", "logout.wav"}, | |
5684 | 67 {N_("Message received"), "im_recv", "receive.wav"}, |
68 {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, | |
69 {N_("Message sent"), "send_im", "send.wav"}, | |
10158 | 70 {N_("Person enters chat"), "join_chat", "login.wav"}, |
71 {N_("Person leaves chat"), "left_chat", "logout.wav"}, | |
5684 | 72 {N_("You talk in chat"), "send_chat_msg", "send.wav"}, |
73 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, | |
74 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ | |
10158 | 75 {NULL, "pounce_default", "alert.wav"}, |
76 {N_("Someone says your name in chat"), "nick_said", "alert.wav"} | |
5684 | 77 }; |
78 | |
79 #ifdef USE_AO | |
80 static int ao_driver = -1; | |
81 #endif /* USE_AO */ | |
82 | |
10320 | 83 static gboolean |
84 mute_login_sounds_cb(gpointer data) | |
85 { | |
86 mute_login_sounds = FALSE; | |
87 mute_login_sounds_timeout = 0; | |
88 return FALSE; | |
89 } | |
90 | |
91 /* | |
92 * We mute sounds for the 10 seconds after you log in so that | |
93 * you don't get flooded with sounds when the blist shows all | |
94 * your buddies logging in. | |
95 */ | |
96 static void | |
97 account_signon_cb(GaimConnection *gc, gpointer data) | |
98 { | |
99 if (mute_login_sounds_timeout != 0) | |
100 g_source_remove(mute_login_sounds_timeout); | |
101 mute_login_sounds = TRUE; | |
102 mute_login_sounds_timeout = gaim_timeout_add(10000, mute_login_sounds_cb, NULL); | |
103 } | |
104 | |
10322 | 105 static void |
106 _pref_sound_method_changed(const char *name, GaimPrefType type, | |
107 gpointer val, gpointer data) { | |
108 if(type != GAIM_PREF_STRING || strcmp(name, "/gaim/gtk/sound/method")) | |
109 return; | |
110 | |
111 sound_initialized = TRUE; | |
112 | |
113 #ifdef USE_AO | |
114 ao_driver = -1; | |
115 | |
116 if(!strcmp(val, "esd")) | |
117 ao_driver = ao_driver_id("esd"); | |
118 else if(!strcmp(val, "arts")) | |
119 ao_driver = ao_driver_id("arts"); | |
120 else if(!strcmp(val, "automatic")) | |
121 ao_driver = ao_default_driver_id(); | |
122 | |
123 if(ao_driver != -1) { | |
124 ao_info *info = ao_driver_info(ao_driver); | |
125 gaim_debug_info("sound", | |
126 "Sound output driver loaded: %s\n", info->name); | |
127 } | |
128 #endif /* USE_AO */ | |
129 #ifdef USE_NAS | |
130 if (!strcmp(val, "nas")) | |
131 gaim_debug_info("sound", | |
132 "Sound output driver loaded: NAS output\n"); | |
133 #endif /* USE_NAS */ | |
134 } | |
135 | |
136 const char * | |
137 gaim_gtk_sound_get_event_option(GaimSoundEventID event) | |
138 { | |
139 if(event >= GAIM_NUM_SOUNDS) | |
140 return 0; | |
141 | |
142 return sounds[event].pref; | |
143 } | |
144 | |
145 char * | |
146 gaim_gtk_sound_get_event_label(GaimSoundEventID event) | |
147 { | |
148 if(event >= GAIM_NUM_SOUNDS) | |
149 return NULL; | |
150 | |
151 return sounds[event].label; | |
152 } | |
153 | |
154 void * | |
155 gaim_gtk_sound_get_handle() | |
156 { | |
157 static int handle; | |
158 | |
159 return &handle; | |
160 } | |
161 | |
162 static void | |
163 gaim_gtk_sound_init(void) | |
5684 | 164 { |
10320 | 165 void *gtk_sound_handle = gaim_gtk_sound_get_handle(); |
166 | |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10922
diff
changeset
|
167 gaim_debug_register_category("sound"); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10922
diff
changeset
|
168 |
10320 | 169 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
170 gtk_sound_handle, GAIM_CALLBACK(account_signon_cb), | |
171 NULL); | |
172 | |
5684 | 173 gaim_prefs_add_none("/gaim/gtk/sound"); |
174 gaim_prefs_add_none("/gaim/gtk/sound/enabled"); | |
175 gaim_prefs_add_none("/gaim/gtk/sound/file"); | |
176 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/login", TRUE); | |
177 gaim_prefs_add_string("/gaim/gtk/sound/file/login", ""); | |
178 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/logout", TRUE); | |
179 gaim_prefs_add_string("/gaim/gtk/sound/file/logout", ""); | |
180 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/im_recv", TRUE); | |
181 gaim_prefs_add_string("/gaim/gtk/sound/file/im_recv", ""); | |
182 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/first_im_recv", FALSE); | |
183 gaim_prefs_add_string("/gaim/gtk/sound/file/first_im_recv", ""); | |
184 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/send_im", TRUE); | |
185 gaim_prefs_add_string("/gaim/gtk/sound/file/send_im", ""); | |
186 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/join_chat", FALSE); | |
187 gaim_prefs_add_string("/gaim/gtk/sound/file/join_chat", ""); | |
188 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/left_chat", FALSE); | |
189 gaim_prefs_add_string("/gaim/gtk/sound/file/left_chat", ""); | |
190 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/send_chat_msg", FALSE); | |
191 gaim_prefs_add_string("/gaim/gtk/sound/file/send_chat_msg", ""); | |
192 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/chat_msg_recv", FALSE); | |
193 gaim_prefs_add_string("/gaim/gtk/sound/file/chat_msg_recv", ""); | |
194 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/nick_said", FALSE); | |
195 gaim_prefs_add_string("/gaim/gtk/sound/file/nick_said", ""); | |
7460
3973a09525b3
[gaim-migrate @ 8073]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
196 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/pounce_default", TRUE); |
3973a09525b3
[gaim-migrate @ 8073]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
197 gaim_prefs_add_string("/gaim/gtk/sound/file/pounce_default", ""); |
8633 | 198 gaim_prefs_add_bool("/gaim/gtk/sound/conv_focus", TRUE); |
10074 | 199 gaim_prefs_add_bool("/gaim/gtk/sound/mute", FALSE); |
5684 | 200 gaim_prefs_add_string("/gaim/gtk/sound/command", ""); |
201 gaim_prefs_add_string("/gaim/gtk/sound/method", "automatic"); | |
202 | |
203 #ifdef USE_AO | |
10322 | 204 gaim_debug_info("sound", "Initializing sound output drivers.\n"); |
5684 | 205 ao_initialize(); |
206 #endif /* USE_AO */ | |
207 | |
10087 | 208 gaim_prefs_connect_callback(gaim_gtk_sound_get_handle(), "/gaim/gtk/sound/method", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
209 _pref_sound_method_changed, NULL); |
5684 | 210 } |
211 | |
10322 | 212 static void |
213 gaim_gtk_sound_uninit(void) | |
5684 | 214 { |
215 #ifdef USE_AO | |
216 ao_shutdown(); | |
217 #endif | |
6199 | 218 sound_initialized = FALSE; |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10922
diff
changeset
|
219 |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10922
diff
changeset
|
220 gaim_debug_unregister_category("sound"); |
5684 | 221 } |
222 | |
10322 | 223 #ifdef USE_NAS_AUDIO |
224 static gboolean | |
225 play_file_nas(const char *filename) | |
226 { | |
227 AuServer *nas_serv; | |
228 gboolean ret = FALSE; | |
229 | |
230 if((nas_serv = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL))) { | |
231 ret = AuSoundPlaySynchronousFromFile(nas_serv, filename, 100); | |
232 AuCloseServer(nas_serv); | |
233 } | |
234 | |
235 return ret; | |
236 } | |
237 | |
238 #endif /* USE_NAS_AUDIO */ | |
239 | |
10074 | 240 #if defined(USE_NAS_AUDIO) || defined(USE_AO) |
10322 | 241 static gboolean |
242 expire_old_child(gpointer data) | |
10074 | 243 { |
244 int ret; | |
245 pid_t pid = GPOINTER_TO_INT(data); | |
246 | |
247 ret = waitpid(pid, NULL, WNOHANG | WUNTRACED); | |
248 | |
249 if(ret == 0) { | |
250 if(kill(pid, SIGKILL) < 0) | |
10322 | 251 gaim_debug_error("gtksound", "Killing process %d failed (%s)\n", |
252 pid, strerror(errno)); | |
10074 | 253 } |
254 | |
255 return FALSE; /* do not run again */ | |
256 } | |
257 #endif | |
258 | |
10322 | 259 static void |
260 gaim_gtk_sound_play_file(const char *filename) | |
5684 | 261 { |
262 const char *method; | |
263 #if defined(USE_NAS_AUDIO) || defined(USE_AO) | |
264 pid_t pid; | |
265 #ifdef USE_AO | |
266 AFfilehandle file; | |
267 #endif | |
268 #endif | |
269 | |
6199 | 270 if (!sound_initialized) |
271 gaim_prefs_trigger_callback("/gaim/gtk/sound/method"); | |
272 | |
10074 | 273 if (gaim_prefs_get_bool("/gaim/gtk/sound/mute")) |
5684 | 274 return; |
275 | |
276 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); | |
277 | |
10074 | 278 if (!strcmp(method, "none")) { |
279 return; | |
280 } else if (!strcmp(method, "beep")) { | |
5684 | 281 gdk_beep(); |
282 return; | |
283 } | |
284 | |
285 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
286 char *tmp = g_strdup_printf(_("Unable to play sound because the chosen file (%s) does not exist."), filename); | |
287 gaim_notify_error(NULL, NULL, tmp, NULL); | |
288 g_free(tmp); | |
289 return; | |
290 } | |
291 | |
292 #ifndef _WIN32 | |
293 if (!strcmp(method, "custom")) { | |
294 const char *sound_cmd; | |
295 char *command; | |
296 GError *error = NULL; | |
297 | |
298 sound_cmd = gaim_prefs_get_string("/gaim/gtk/sound/command"); | |
299 | |
300 if (!sound_cmd || *sound_cmd == '\0') { | |
301 gaim_notify_error(NULL, NULL, | |
302 _("Unable to play sound because the " | |
303 "'Command' sound method has been chosen, " | |
304 "but no command has been set."), NULL); | |
305 return; | |
306 } | |
307 | |
7464 | 308 if(strstr(sound_cmd, "%s")) |
309 command = gaim_strreplace(sound_cmd, "%s", filename); | |
310 else | |
311 command = g_strdup_printf("%s %s", sound_cmd, filename); | |
5684 | 312 |
313 if(!g_spawn_command_line_async(command, &error)) { | |
314 char *tmp = g_strdup_printf(_("Unable to play sound because the configured sound command could not be launched: %s"), error->message); | |
315 gaim_notify_error(NULL, NULL, tmp, NULL); | |
316 g_free(tmp); | |
317 g_error_free(error); | |
318 } | |
319 | |
320 g_free(command); | |
321 return; | |
322 } | |
323 #if defined(USE_NAS_AUDIO) || defined(USE_AO) | |
324 pid = fork(); | |
325 if (pid < 0) | |
326 return; | |
327 else if (pid == 0) { | |
328 #ifdef USE_NAS_AUDIO | |
329 if (!strcmp(method, "nas")) { | |
330 if (play_file_nas(filename)) | |
331 _exit(0); | |
332 } | |
333 #endif /* USE_NAS_AUDIO */ | |
334 | |
335 #ifdef USE_AO | |
336 file = afOpenFile(filename, "rb", NULL); | |
337 if(file) { | |
338 ao_device *device; | |
339 ao_sample_format format; | |
340 int in_fmt; | |
341 int bytes_per_frame; | |
342 | |
343 format.rate = afGetRate(file, AF_DEFAULT_TRACK); | |
344 format.channels = afGetChannels(file, AF_DEFAULT_TRACK); | |
345 afGetSampleFormat(file, AF_DEFAULT_TRACK, &in_fmt, | |
346 &format.bits); | |
347 | |
348 /* XXX: libao doesn't seem to like 8-bit sounds, so we'll | |
349 * let libaudiofile make them a bit better for us */ | |
350 if(format.bits == 8) | |
351 format.bits = 16; | |
352 | |
353 afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, | |
354 AF_SAMPFMT_TWOSCOMP, format.bits); | |
355 | |
356 #if __BYTE_ORDER == __BIG_ENDIAN | |
357 format.byte_format = AO_FMT_BIG; | |
358 afSetVirtualByteOrder(file, AF_DEFAULT_TRACK, | |
359 AF_BYTEORDER_BIGENDIAN); | |
360 #elif __BYTE_ORDER == __LITTLE_ENDIAN | |
361 format.byte_format = AO_FMT_LITTLE; | |
362 afSetVirtualByteOrder(file, AF_DEFAULT_TRACK, | |
363 AF_BYTEORDER_LITTLEENDIAN); | |
364 #endif | |
365 | |
366 bytes_per_frame = format.bits * format.channels / 8; | |
367 | |
368 device = ao_open_live(ao_driver, &format, NULL); | |
369 | |
370 if(device) { | |
371 int frames_read; | |
372 char buf[4096]; | |
373 int buf_frames = sizeof(buf) / bytes_per_frame; | |
374 | |
375 while((frames_read = afReadFrames(file, AF_DEFAULT_TRACK, | |
376 buf, buf_frames))) { | |
377 if(!ao_play(device, buf, frames_read * bytes_per_frame)) | |
378 break; | |
379 } | |
380 ao_close(device); | |
381 } | |
382 afCloseFile(file); | |
383 } | |
384 ao_shutdown(); | |
385 #endif /* USE_AO */ | |
386 _exit(0); | |
10074 | 387 } else { |
388 gaim_timeout_add(PLAY_SOUND_TIMEOUT, expire_old_child, GINT_TO_POINTER(pid)); | |
5684 | 389 } |
390 #else /* USE_NAS_AUDIO || USE_AO */ | |
391 gdk_beep(); | |
392 return; | |
393 #endif /* USE_NAS_AUDIO || USE_AO */ | |
394 #else /* _WIN32 */ | |
10322 | 395 gaim_debug_info("sound", "Playing %s\n", filename); |
5684 | 396 |
10922
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
397 if (G_WIN32_HAVE_WIDECHAR_API ()) { |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
398 wchar_t *wc_filename = g_utf8_to_utf16(filename, |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
399 -1, NULL, NULL, NULL); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
400 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
401 gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
402 g_free(wc_filename); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
403 } else { |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
404 char *l_filename = g_locale_from_utf8(filename, |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
405 -1, NULL, NULL, NULL); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
406 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
407 gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
408 g_free(l_filename); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
409 } |
5684 | 410 #endif /* _WIN32 */ |
411 } | |
412 | |
10322 | 413 static void |
414 gaim_gtk_sound_play_event(GaimSoundEventID event) | |
5684 | 415 { |
416 char *enable_pref; | |
417 char *file_pref; | |
418 | |
419 if ((event == GAIM_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | |
420 return; | |
421 | |
422 if (event >= GAIM_NUM_SOUNDS) { | |
10322 | 423 gaim_debug_error("sound", "got request for unknown sound: %d\n", event); |
5684 | 424 return; |
425 } | |
426 | |
427 enable_pref = g_strdup_printf("/gaim/gtk/sound/enabled/%s", | |
428 sounds[event].pref); | |
429 file_pref = g_strdup_printf("/gaim/gtk/sound/file/%s", sounds[event].pref); | |
430 | |
431 /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
432 if (gaim_prefs_get_bool(enable_pref)) { | |
433 char *filename = g_strdup(gaim_prefs_get_string(file_pref)); | |
434 if(!filename || !strlen(filename)) { | |
435 if(filename) g_free(filename); | |
436 filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL); | |
437 } | |
438 | |
439 gaim_sound_play_file(filename); | |
440 g_free(filename); | |
441 } | |
442 | |
443 g_free(enable_pref); | |
444 g_free(file_pref); | |
445 } | |
446 | |
447 static GaimSoundUiOps sound_ui_ops = | |
448 { | |
449 gaim_gtk_sound_init, | |
10322 | 450 gaim_gtk_sound_uninit, |
5684 | 451 gaim_gtk_sound_play_file, |
452 gaim_gtk_sound_play_event | |
453 }; | |
454 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6778
diff
changeset
|
455 GaimSoundUiOps * |
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6778
diff
changeset
|
456 gaim_gtk_sound_get_ui_ops(void) |
5684 | 457 { |
458 return &sound_ui_ops; | |
459 } |