Mercurial > pidgin
annotate finch/gntsound.c @ 19119:086cfcb71b01
Created SoundPrefDialog to store dialog data.
Cleaned up the Sounds pref window to look better.
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Fri, 29 Jun 2007 01:51:13 +0000 |
parents | cfe8f791d7c1 |
children | 915ef65d68e3 |
rev | line source |
---|---|
19100 | 1 /** |
2 * @file gntsound.c GNT Sound API | |
3 * @ingroup finch | |
4 * | |
5 * finch | |
6 * | |
7 * Finch 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. | |
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 #include "internal.h" | |
26 #include "finch.h" | |
27 | |
28 #ifdef _WIN32 | |
29 #include <windows.h> | |
30 #include <mmsystem.h> | |
31 #endif | |
32 | |
33 #ifdef USE_GSTREAMER | |
34 #include <gst/gst.h> | |
35 #endif /* USE_GSTREAMER */ | |
36 | |
37 #include "debug.h" | |
38 #include "notify.h" | |
39 #include "prefs.h" | |
40 #include "sound.h" | |
41 #include "util.h" | |
42 | |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
43 #include "gntbox.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
44 #include "gntwindow.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
45 #include "gntcombobox.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
46 #include "gntlabel.h" |
19100 | 47 #include "gntconv.h" |
48 #include "gntsound.h" | |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
49 #include "gntwidget.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
50 #include "gntentry.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
51 #include "gntcheckbox.h" |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
52 #include "gntline.h" |
19100 | 53 |
54 struct finch_sound_event { | |
55 char *label; | |
56 char *pref; | |
57 char *def; | |
58 }; | |
59 | |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
60 typedef struct { |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
61 GntWidget *method; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
62 GntWidget *command; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
63 GntWidget *conv_focus; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
64 GntWidget *while_status; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
65 GntWidget *volume; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
66 GntWidget *window; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
67 } SoundPrefDialog; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
68 |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
69 static struct { |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
70 const gchar *method; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
71 const gchar *command; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
72 gboolean conv_focus; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
73 gint while_status; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
74 gint volume; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
75 GntTree *events; |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
76 SoundPrefDialog *dialog; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
77 } sound_pref_data; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
78 |
19100 | 79 #define PLAY_SOUND_TIMEOUT 15000 |
80 | |
81 static guint mute_login_sounds_timeout = 0; | |
82 static gboolean mute_login_sounds = FALSE; | |
83 | |
84 #ifdef USE_GSTREAMER | |
85 static gboolean gst_init_failed; | |
86 #endif /* USE_GSTREAMER */ | |
87 | |
88 static struct finch_sound_event sounds[PURPLE_NUM_SOUNDS] = { | |
89 {N_("Buddy logs in"), "login", "login.wav"}, | |
90 {N_("Buddy logs out"), "logout", "logout.wav"}, | |
91 {N_("Message received"), "im_recv", "receive.wav"}, | |
92 {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, | |
93 {N_("Message sent"), "send_im", "send.wav"}, | |
94 {N_("Person enters chat"), "join_chat", "login.wav"}, | |
95 {N_("Person leaves chat"), "left_chat", "logout.wav"}, | |
96 {N_("You talk in chat"), "send_chat_msg", "send.wav"}, | |
97 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, | |
98 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ | |
99 {NULL, "pounce_default", "alert.wav"}, | |
100 {N_("Someone says your screen name in chat"), "nick_said", "alert.wav"} | |
101 }; | |
102 | |
103 static gboolean | |
104 unmute_login_sounds_cb(gpointer data) | |
105 { | |
106 mute_login_sounds = FALSE; | |
107 mute_login_sounds_timeout = 0; | |
108 return FALSE; | |
109 } | |
110 | |
111 static gboolean | |
112 chat_nick_matches_name(PurpleConversation *conv, const char *aname) | |
113 { | |
114 PurpleConvChat *chat = NULL; | |
115 char *nick = NULL; | |
116 char *name = NULL; | |
117 gboolean ret = FALSE; | |
118 chat = purple_conversation_get_chat_data(conv); | |
119 | |
120 if (chat==NULL) | |
121 return ret; | |
122 | |
123 nick = g_strdup(purple_normalize(conv->account, chat->nick)); | |
124 name = g_strdup(purple_normalize(conv->account, aname)); | |
125 | |
126 if (g_utf8_collate(nick, name) == 0) | |
127 ret = TRUE; | |
128 | |
129 g_free(nick); | |
130 g_free(name); | |
131 | |
132 return ret; | |
133 } | |
134 | |
135 /* | |
136 * play a sound event for a conversation, honoring make_sound flag | |
137 * of conversation and checking for focus if conv_focus pref is set | |
138 */ | |
139 static void | |
140 play_conv_event(PurpleConversation *conv, PurpleSoundEventID event) | |
141 { | |
142 /* If we should not play the sound for some reason, then exit early */ | |
143 if (conv != NULL) | |
144 { | |
145 FinchConv *gntconv; | |
146 gboolean has_focus; | |
147 | |
148 gntconv = FINCH_CONV(conv); | |
149 | |
150 has_focus = purple_conversation_has_focus(conv); | |
151 | |
152 if (has_focus && !purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus")) | |
153 { | |
154 return; | |
155 } | |
156 } | |
157 | |
158 purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL); | |
159 } | |
160 | |
161 static void | |
162 buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event) | |
163 { | |
164 purple_sound_play_event(event, purple_buddy_get_account(buddy)); | |
165 } | |
166 | |
167 static void | |
168 im_msg_received_cb(PurpleAccount *account, char *sender, | |
169 char *message, PurpleConversation *conv, | |
170 PurpleMessageFlags flags, PurpleSoundEventID event) | |
171 { | |
172 if (flags & PURPLE_MESSAGE_DELAYED) | |
173 return; | |
174 | |
175 if (conv==NULL){ | |
176 purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); | |
177 } | |
178 else{ | |
179 play_conv_event(conv, event); | |
180 } | |
181 } | |
182 | |
183 static void | |
184 im_msg_sent_cb(PurpleAccount *account, const char *receiver, | |
185 const char *message, PurpleSoundEventID event) | |
186 { | |
187 PurpleConversation *conv = purple_find_conversation_with_account( | |
188 PURPLE_CONV_TYPE_ANY, receiver, account); | |
189 play_conv_event(conv, event); | |
190 } | |
191 | |
192 static void | |
193 chat_buddy_join_cb(PurpleConversation *conv, const char *name, | |
194 PurpleConvChatBuddyFlags flags, gboolean new_arrival, | |
195 PurpleSoundEventID event) | |
196 { | |
197 if (new_arrival && !chat_nick_matches_name(conv, name)) | |
198 play_conv_event(conv, event); | |
199 } | |
200 | |
201 static void | |
202 chat_buddy_left_cb(PurpleConversation *conv, const char *name, | |
203 const char *reason, PurpleSoundEventID event) | |
204 { | |
205 if (!chat_nick_matches_name(conv, name)) | |
206 play_conv_event(conv, event); | |
207 } | |
208 | |
209 static void | |
210 chat_msg_sent_cb(PurpleAccount *account, const char *message, | |
211 int id, PurpleSoundEventID event) | |
212 { | |
213 PurpleConnection *conn = purple_account_get_connection(account); | |
214 PurpleConversation *conv = NULL; | |
215 | |
216 if (conn!=NULL) | |
217 conv = purple_find_chat(conn,id); | |
218 | |
219 play_conv_event(conv, event); | |
220 } | |
221 | |
222 static void | |
223 chat_msg_received_cb(PurpleAccount *account, char *sender, | |
224 char *message, PurpleConversation *conv, | |
225 PurpleMessageFlags flags, PurpleSoundEventID event) | |
226 { | |
227 PurpleConvChat *chat; | |
228 | |
229 if (flags & PURPLE_MESSAGE_DELAYED) | |
230 return; | |
231 | |
232 chat = purple_conversation_get_chat_data(conv); | |
233 g_return_if_fail(chat != NULL); | |
234 | |
235 if (purple_conv_chat_is_user_ignored(chat, sender)) | |
236 return; | |
237 | |
238 if (chat_nick_matches_name(conv, sender)) | |
239 return; | |
240 | |
241 if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, chat->nick)) | |
242 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); | |
243 else | |
244 play_conv_event(conv, event); | |
245 } | |
246 | |
247 /* | |
248 * We mute sounds for the 10 seconds after you log in so that | |
249 * you don't get flooded with sounds when the blist shows all | |
250 * your buddies logging in. | |
251 */ | |
252 static void | |
253 account_signon_cb(PurpleConnection *gc, gpointer data) | |
254 { | |
255 if (mute_login_sounds_timeout != 0) | |
256 g_source_remove(mute_login_sounds_timeout); | |
257 mute_login_sounds = TRUE; | |
258 mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL); | |
259 } | |
260 | |
261 const char * | |
262 finch_sound_get_event_option(PurpleSoundEventID event) | |
263 { | |
264 if(event >= PURPLE_NUM_SOUNDS) | |
265 return 0; | |
266 | |
267 return sounds[event].pref; | |
268 } | |
269 | |
270 const char * | |
271 finch_sound_get_event_label(PurpleSoundEventID event) | |
272 { | |
273 if(event >= PURPLE_NUM_SOUNDS) | |
274 return NULL; | |
275 | |
276 return sounds[event].label; | |
277 } | |
278 | |
279 void * | |
280 finch_sound_get_handle() | |
281 { | |
282 static int handle; | |
283 | |
284 return &handle; | |
285 } | |
286 | |
287 static void | |
288 finch_sound_init(void) | |
289 { | |
290 void *gnt_sound_handle = finch_sound_get_handle(); | |
291 void *blist_handle = purple_blist_get_handle(); | |
292 void *conv_handle = purple_conversations_get_handle(); | |
293 #ifdef USE_GSTREAMER | |
294 GError *error = NULL; | |
295 #endif | |
296 | |
297 purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
298 gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb), | |
299 NULL); | |
300 | |
301 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound"); | |
302 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/enabled"); | |
303 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/file"); | |
304 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/login", TRUE); | |
305 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/login", ""); | |
306 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/logout", TRUE); | |
307 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/logout", ""); | |
308 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/im_recv", TRUE); | |
309 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/im_recv", ""); | |
310 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/first_im_recv", FALSE); | |
311 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/first_im_recv", ""); | |
312 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/send_im", TRUE); | |
313 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/send_im", ""); | |
314 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/join_chat", FALSE); | |
315 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/join_chat", ""); | |
316 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/left_chat", FALSE); | |
317 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/left_chat", ""); | |
318 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/send_chat_msg", FALSE); | |
319 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/send_chat_msg", ""); | |
320 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/chat_msg_recv", FALSE); | |
321 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/chat_msg_recv", ""); | |
322 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/nick_said", FALSE); | |
323 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/nick_said", ""); | |
324 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/pounce_default", TRUE); | |
325 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/pounce_default", ""); | |
326 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/conv_focus", TRUE); | |
327 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/mute", FALSE); | |
328 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/command", ""); | |
329 purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/method", "automatic"); | |
330 purple_prefs_add_int(FINCH_PREFS_ROOT "/sound/volume", 50); | |
331 | |
332 #ifdef USE_GSTREAMER | |
333 purple_debug_info("sound", "Initializing sound output drivers.\n"); | |
334 if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { | |
335 purple_notify_error(NULL, _("GStreamer Failure"), | |
336 _("GStreamer failed to initialize."), | |
337 error ? error->message : ""); | |
338 if (error) { | |
339 g_error_free(error); | |
340 error = NULL; | |
341 } | |
342 } | |
343 #endif /* USE_GSTREAMER */ | |
344 | |
345 purple_signal_connect(blist_handle, "buddy-signed-on", | |
346 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
347 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE)); | |
348 purple_signal_connect(blist_handle, "buddy-signed-off", | |
349 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
350 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE)); | |
351 purple_signal_connect(conv_handle, "received-im-msg", | |
352 gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb), | |
353 GINT_TO_POINTER(PURPLE_SOUND_RECEIVE)); | |
354 purple_signal_connect(conv_handle, "sent-im-msg", | |
355 gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb), | |
356 GINT_TO_POINTER(PURPLE_SOUND_SEND)); | |
357 purple_signal_connect(conv_handle, "chat-buddy-joined", | |
358 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb), | |
359 GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN)); | |
360 purple_signal_connect(conv_handle, "chat-buddy-left", | |
361 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb), | |
362 GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE)); | |
363 purple_signal_connect(conv_handle, "sent-chat-msg", | |
364 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), | |
365 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); | |
366 purple_signal_connect(conv_handle, "received-chat-msg", | |
367 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), | |
368 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); | |
369 } | |
370 | |
371 static void | |
372 finch_sound_uninit(void) | |
373 { | |
374 #ifdef USE_GSTREAMER | |
375 if (!gst_init_failed) | |
376 gst_deinit(); | |
377 #endif | |
378 | |
379 purple_signals_disconnect_by_handle(finch_sound_get_handle()); | |
380 } | |
381 | |
382 #ifdef USE_GSTREAMER | |
383 static gboolean | |
384 bus_call (GstBus *bus, GstMessage *msg, gpointer data) | |
385 { | |
386 GstElement *play = data; | |
387 GError *err = NULL; | |
388 | |
389 switch (GST_MESSAGE_TYPE (msg)) { | |
390 case GST_MESSAGE_EOS: | |
391 gst_element_set_state(play, GST_STATE_NULL); | |
392 gst_object_unref(GST_OBJECT(play)); | |
393 break; | |
394 case GST_MESSAGE_ERROR: | |
395 gst_message_parse_error(msg, &err, NULL); | |
396 purple_debug_error("gstreamer", err->message); | |
397 g_error_free(err); | |
398 break; | |
399 case GST_MESSAGE_WARNING: | |
400 gst_message_parse_warning(msg, &err, NULL); | |
401 purple_debug_warning("gstreamer", err->message); | |
402 g_error_free(err); | |
403 break; | |
404 default: | |
405 break; | |
406 } | |
407 return TRUE; | |
408 } | |
409 #endif | |
410 | |
411 static void | |
412 finch_sound_play_file(const char *filename) | |
413 { | |
414 const char *method; | |
415 #ifdef USE_GSTREAMER | |
416 float volume; | |
417 char *uri; | |
418 GstElement *sink = NULL; | |
419 GstElement *play = NULL; | |
420 GstBus *bus = NULL; | |
421 #endif | |
422 if (purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/mute")) | |
423 return; | |
424 | |
425 method = purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method"); | |
426 | |
427 if (!strcmp(method, "none")) { | |
428 return; | |
429 } else if (!strcmp(method, "beep")) { | |
430 beep(); | |
431 return; | |
432 } | |
433 | |
434 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
435 purple_debug_error("gntsound", "sound file (%s) does not exist.\n", filename); | |
436 return; | |
437 } | |
438 | |
439 #ifndef _WIN32 | |
440 if (!strcmp(method, "custom")) { | |
441 const char *sound_cmd; | |
442 char *command; | |
443 char *esc_filename; | |
444 GError *error = NULL; | |
445 | |
446 sound_cmd = purple_prefs_get_path(FINCH_PREFS_ROOT "/sound/command"); | |
447 | |
448 if (!sound_cmd || *sound_cmd == '\0') { | |
449 purple_debug_error("gntsound", | |
450 "'Command' sound method has been chosen, " | |
451 "but no command has been set."); | |
452 return; | |
453 } | |
454 | |
455 esc_filename = g_shell_quote(filename); | |
456 | |
457 if(strstr(sound_cmd, "%s")) | |
458 command = purple_strreplace(sound_cmd, "%s", esc_filename); | |
459 else | |
460 command = g_strdup_printf("%s %s", sound_cmd, esc_filename); | |
461 | |
462 if(!g_spawn_command_line_async(command, &error)) { | |
463 purple_debug_error("gntsound", "sound command could not be launched: %s\n", error->message); | |
464 g_error_free(error); | |
465 } | |
466 | |
467 g_free(esc_filename); | |
468 g_free(command); | |
469 return; | |
470 } | |
471 #ifdef USE_GSTREAMER | |
472 if (gst_init_failed) /* Perhaps do beep instead? */ | |
473 return; | |
474 volume = (float)(CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100)) / 50; | |
475 if (!strcmp(method, "automatic")) { | |
476 if (purple_running_gnome()) { | |
477 sink = gst_element_factory_make("gconfaudiosink", "sink"); | |
478 } | |
479 if (!sink) | |
480 sink = gst_element_factory_make("autoaudiosink", "sink"); | |
481 if (!sink) { | |
482 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
483 return; | |
484 } | |
485 } else if (!strcmp(method, "esd")) { | |
486 sink = gst_element_factory_make("esdsink", "sink"); | |
487 if (!sink) { | |
488 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
489 return; | |
490 } | |
491 } else if (!strcmp(method, "alsa")) { | |
492 sink = gst_element_factory_make("alsasink", "sink"); | |
493 if (!sink) { | |
494 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
495 return; | |
496 } | |
497 } else { | |
498 purple_debug_error("sound", "Unknown sound method '%s'\n", method); | |
499 return; | |
500 } | |
501 | |
502 play = gst_element_factory_make("playbin", "play"); | |
503 | |
504 if (play == NULL) { | |
505 return; | |
506 } | |
507 | |
508 uri = g_strdup_printf("file://%s", filename); | |
509 | |
510 g_object_set(G_OBJECT(play), "uri", uri, | |
511 "volume", volume, | |
512 "audio-sink", sink, NULL); | |
513 | |
514 bus = gst_pipeline_get_bus(GST_PIPELINE(play)); | |
515 gst_bus_add_watch(bus, bus_call, play); | |
516 | |
517 gst_element_set_state(play, GST_STATE_PLAYING); | |
518 | |
519 gst_object_unref(bus); | |
520 g_free(uri); | |
521 | |
522 #else /* USE_GSTREAMER */ | |
523 beep(); | |
524 return; | |
525 #endif /* USE_GSTREAMER */ | |
526 #else /* _WIN32 */ | |
527 purple_debug_info("sound", "Playing %s\n", filename); | |
528 | |
529 if (G_WIN32_HAVE_WIDECHAR_API ()) { | |
530 wchar_t *wc_filename = g_utf8_to_utf16(filename, | |
531 -1, NULL, NULL, NULL); | |
532 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
533 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
534 g_free(wc_filename); | |
535 } else { | |
536 char *l_filename = g_locale_from_utf8(filename, | |
537 -1, NULL, NULL, NULL); | |
538 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
539 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
540 g_free(l_filename); | |
541 } | |
542 #endif /* _WIN32 */ | |
543 } | |
544 | |
545 static void | |
546 finch_sound_play_event(PurpleSoundEventID event) | |
547 { | |
548 char *enable_pref; | |
549 char *file_pref; | |
550 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | |
551 return; | |
552 | |
553 if (event >= PURPLE_NUM_SOUNDS) { | |
554 purple_debug_error("sound", "got request for unknown sound: %d\n", event); | |
555 return; | |
556 } | |
557 | |
558 enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/enabled/%s", | |
559 sounds[event].pref); | |
560 file_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/file/%s", sounds[event].pref); | |
561 | |
562 /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
563 if (purple_prefs_get_bool(enable_pref)) { | |
564 char *filename = g_strdup(purple_prefs_get_path(file_pref)); | |
565 if(!filename || !strlen(filename)) { | |
566 g_free(filename); | |
19115 | 567 /* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */ |
568 filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); | |
19100 | 569 } |
570 | |
571 purple_sound_play_file(filename, NULL); | |
572 g_free(filename); | |
573 } | |
574 | |
575 g_free(enable_pref); | |
576 g_free(file_pref); | |
577 } | |
578 | |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
579 static void init_pref_data() |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
580 { |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
581 GntTree *events = NULL; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
582 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
583 if(sound_pref_data.method){ |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
584 return; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
585 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
586 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
587 /* TODO Setup the events tree */ |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
588 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
589 sound_pref_data.method = purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method"); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
590 sound_pref_data.command = purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/command"); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
591 sound_pref_data.conv_focus = purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus"); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
592 sound_pref_data.while_status = purple_prefs_get_int(FINCH_PREFS_ROOT "/purple/sound/while_status"); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
593 sound_pref_data.volume = CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
594 sound_pref_data.events = events; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
595 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
596 return; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
597 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
598 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
599 static gboolean |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
600 save_cb(GntBindable *data, gpointer *win) |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
601 { |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
602 gnt_widget_destroy(GNT_WIDGET(win)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
603 return TRUE; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
604 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
605 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
606 static gboolean |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
607 cancel_cb(GntBindable *data, gpointer win) |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
608 { |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
609 gnt_widget_destroy(GNT_WIDGET(win)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
610 return TRUE; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
611 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
612 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
613 static void release_pref_window(GntBindable *data, gpointer null) { |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
614 g_free(sound_pref_data.dialog); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
615 sound_pref_data.dialog = NULL; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
616 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
617 |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
618 void |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
619 finch_sounds_show_all(void) |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
620 { |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
621 GntWidget *box; |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
622 GntWidget *cmbox; |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
623 GntWidget *entry; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
624 GntWidget *chkbox; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
625 GntWidget *button; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
626 GntWidget *label; |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
627 GntWidget *win; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
628 gchar *buf; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
629 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
630 if(sound_pref_data.dialog){ |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
631 gnt_window_present(sound_pref_data.dialog->window); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
632 return; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
633 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
634 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
635 init_pref_data(); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
636 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
637 sound_pref_data.dialog = g_new0(SoundPrefDialog,1); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
638 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
639 sound_pref_data.dialog->window = win = gnt_window_box_new(FALSE,TRUE); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
640 gnt_box_set_pad(GNT_BOX(win),0); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
641 gnt_box_set_fill(GNT_BOX(win),FALSE); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
642 gnt_box_set_toplevel(GNT_BOX(win), TRUE); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
643 gnt_box_set_title(GNT_BOX(win),_("Sound Preferences")); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
644 gnt_box_set_fill(GNT_BOX(win),TRUE); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
645 gnt_box_set_alignment(GNT_BOX(win),GNT_ALIGN_MID); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
646 gnt_widget_set_name(win, "sounds"); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
647 |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
648 sound_pref_data.dialog->method = cmbox = gnt_combo_box_new(); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
649 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"automatic",_("Automatic")); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
650 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"alsa","ALSA"); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
651 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"esd","ESD"); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
652 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"beep",_("Console Beep")); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
653 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"custom",_("Command")); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
654 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"nosound",_("No Sound")); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
655 gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),sound_pref_data.method); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
656 |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
657 label = gnt_label_new_with_format(_("Sound Method"),GNT_TEXT_FLAG_BOLD); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
658 gnt_box_add_widget(GNT_BOX(win),label); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
659 box = gnt_hbox_new(TRUE); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
660 gnt_box_set_fill(GNT_BOX(box),FALSE); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
661 gnt_box_set_pad(GNT_BOX(box),0); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
662 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Method: "))); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
663 gnt_box_add_widget(GNT_BOX(box),cmbox); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
664 gnt_box_add_widget(GNT_BOX(win),box); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
665 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
666 box = gnt_hbox_new(TRUE); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
667 gnt_box_set_pad(GNT_BOX(box),0); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
668 gnt_box_set_fill(GNT_BOX(box),FALSE); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
669 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Sound Command\n(%s for filename)"))); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
670 sound_pref_data.dialog->command = entry = gnt_entry_new(sound_pref_data.command); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
671 gnt_box_add_widget(GNT_BOX(box),entry); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
672 gnt_box_add_widget(GNT_BOX(win),box); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
673 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
674 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
675 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
676 gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Options"),GNT_TEXT_FLAG_BOLD)); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
677 sound_pref_data.dialog->conv_focus = chkbox = gnt_check_box_new("Sounds when conversation has focus"); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
678 gnt_check_box_set_checked(GNT_CHECK_BOX(chkbox),sound_pref_data.conv_focus); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
679 gnt_box_add_widget(GNT_BOX(win),chkbox); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
680 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
681 box = gnt_hbox_new(TRUE); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
682 gnt_box_set_pad(GNT_BOX(box),0); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
683 gnt_box_set_fill(GNT_BOX(box),FALSE); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
684 gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Enable Sounds:")); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
685 sound_pref_data.dialog->while_status = cmbox = gnt_combo_box_new(); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
686 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"always","Always"); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
687 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"available","Only when available"); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
688 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"away","Only when not available"); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
689 switch(sound_pref_data.while_status){ |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
690 case 1:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"available");break; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
691 case 2:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"away");break; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
692 default:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"always");break; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
693 } |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
694 gnt_box_add_widget(GNT_BOX(box),cmbox); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
695 gnt_box_add_widget(GNT_BOX(win),box); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
696 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
697 box = gnt_hbox_new(TRUE); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
698 gnt_box_set_pad(GNT_BOX(box),0); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
699 gnt_box_set_fill(GNT_BOX(box),FALSE); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
700 gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Volume(0-100):")); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
701 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
702 buf = g_strdup_printf("%d",sound_pref_data.volume); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
703 sound_pref_data.dialog->volume = entry = gnt_entry_new(buf); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
704 g_free(buf); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
705 gnt_widget_set_name(entry,"volume"); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
706 gnt_box_add_widget(GNT_BOX(box),entry); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
707 gnt_box_add_widget(GNT_BOX(win),box); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
708 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
709 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
710 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
711 gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Events"),GNT_TEXT_FLAG_BOLD)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
712 /* Put events tree here */ |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
713 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
714 box = gnt_hbox_new(TRUE); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
715 gnt_box_set_pad(GNT_BOX(box),0); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
716 gnt_box_set_fill(GNT_BOX(box),TRUE); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
717 button = gnt_button_new("Save"); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
718 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(save_cb),NULL); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
719 gnt_box_add_widget(GNT_BOX(box),button); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
720 button = gnt_button_new("Cancel"); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
721 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(cancel_cb),NULL); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
722 gnt_box_add_widget(GNT_BOX(box),button); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
723 gnt_box_add_widget(GNT_BOX(win),box); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
724 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
725 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
726 g_signal_connect(G_OBJECT(win),"destroy",G_CALLBACK(release_pref_window),NULL); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
727 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
728 gnt_widget_show(win); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
729 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
730 } |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
731 |
19100 | 732 static PurpleSoundUiOps sound_ui_ops = |
733 { | |
734 finch_sound_init, | |
735 finch_sound_uninit, | |
736 finch_sound_play_file, | |
737 finch_sound_play_event, | |
738 NULL, | |
739 NULL, | |
740 NULL, | |
741 NULL | |
742 }; | |
743 | |
744 PurpleSoundUiOps * | |
745 finch_sound_get_ui_ops(void) | |
746 { | |
747 return &sound_ui_ops; | |
748 } |