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