comparison pidgin/gtksound.c @ 29721:c4f836780e1c

propagate from branch 'im.pidgin.pidgin' (head 5e3164a6a1df028fc66f7e072be0d78d9d995389) to branch 'im.pidgin.pidgin.next.minor' (head 6ee3a8d962ff2bb002967cc29bd5aa0b45bc2028)
author John Bailey <rekkanoryo@rekkanoryo.org>
date Sat, 28 Nov 2009 02:22:49 +0000
parents 7b1cfd48beab
children a8cc50c2279f
comparison
equal deleted inserted replaced
29042:588a7aef5f7c 29721:c4f836780e1c
70 {N_("Person leaves chat"), "left_chat", "logout.wav"}, 70 {N_("Person leaves chat"), "left_chat", "logout.wav"},
71 {N_("You talk in chat"), "send_chat_msg", "send.wav"}, 71 {N_("You talk in chat"), "send_chat_msg", "send.wav"},
72 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, 72 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"},
73 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ 73 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */
74 {NULL, "pounce_default", "alert.wav"}, 74 {NULL, "pounce_default", "alert.wav"},
75 {N_("Someone says your username in chat"), "nick_said", "alert.wav"} 75 {N_("Someone says your username in chat"), "nick_said", "alert.wav"},
76 {N_("Attention received"), "got_attention", "alert.wav"}
76 }; 77 };
77 78
78 static gboolean 79 static gboolean
79 unmute_login_sounds_cb(gpointer data) 80 unmute_login_sounds_cb(gpointer data)
80 { 81 {
142 static void 143 static void
143 im_msg_received_cb(PurpleAccount *account, char *sender, 144 im_msg_received_cb(PurpleAccount *account, char *sender,
144 char *message, PurpleConversation *conv, 145 char *message, PurpleConversation *conv,
145 PurpleMessageFlags flags, PurpleSoundEventID event) 146 PurpleMessageFlags flags, PurpleSoundEventID event)
146 { 147 {
147 if (flags & PURPLE_MESSAGE_DELAYED) 148 if (flags & PURPLE_MESSAGE_DELAYED || flags & PURPLE_MESSAGE_NOTIFY)
148 return; 149 return;
149 150
150 if (conv==NULL) 151 if (conv==NULL)
151 purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); 152 purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account);
152 else 153 else
197 char *message, PurpleConversation *conv, 198 char *message, PurpleConversation *conv,
198 PurpleMessageFlags flags, PurpleSoundEventID event) 199 PurpleMessageFlags flags, PurpleSoundEventID event)
199 { 200 {
200 PurpleConvChat *chat; 201 PurpleConvChat *chat;
201 202
202 if (flags & PURPLE_MESSAGE_DELAYED) 203 if (flags & PURPLE_MESSAGE_DELAYED || flags & PURPLE_MESSAGE_NOTIFY)
203 return; 204 return;
204 205
205 chat = purple_conversation_get_chat_data(conv); 206 chat = purple_conversation_get_chat_data(conv);
206 g_return_if_fail(chat != NULL); 207 g_return_if_fail(chat != NULL);
207 208
215 /* This isn't quite right; if you have the PURPLE_SOUND_CHAT_NICK event disabled 216 /* This isn't quite right; if you have the PURPLE_SOUND_CHAT_NICK event disabled
216 * and the PURPLE_SOUND_CHAT_SAY event enabled, you won't get a sound at all */ 217 * and the PURPLE_SOUND_CHAT_SAY event enabled, you won't get a sound at all */
217 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); 218 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK);
218 else 219 else
219 play_conv_event(conv, event); 220 play_conv_event(conv, event);
221 }
222
223 static void
224 got_attention_cb(PurpleAccount *account, const char *who,
225 PurpleConversation *conv, guint type, PurpleSoundEventID event)
226 {
227 play_conv_event(conv, event);
220 } 228 }
221 229
222 /* 230 /*
223 * We mute sounds for the 10 seconds after you log in so that 231 * We mute sounds for the 10 seconds after you log in so that
224 * you don't get flooded with sounds when the blist shows all 232 * you don't get flooded with sounds when the blist shows all
297 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/nick_said", FALSE); 305 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/nick_said", FALSE);
298 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/nick_said", ""); 306 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/nick_said", "");
299 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default", TRUE); 307 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default", TRUE);
300 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", ""); 308 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", "");
301 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/theme", ""); 309 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/theme", "");
310 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/sent_attention", TRUE);
311 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/sent_attention", "");
312 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/got_attention", TRUE);
313 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/got_attention", "");
302 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus", TRUE); 314 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus", TRUE);
303 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE); 315 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE);
304 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/command", ""); 316 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/command", "");
305 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/method", "automatic"); 317 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/method", "automatic");
306 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/sound/volume", 50); 318 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/sound/volume", 50);
343 gtk_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), 355 gtk_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb),
344 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); 356 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY));
345 purple_signal_connect(conv_handle, "received-chat-msg", 357 purple_signal_connect(conv_handle, "received-chat-msg",
346 gtk_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), 358 gtk_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb),
347 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); 359 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY));
360 purple_signal_connect(conv_handle, "got-attention", gtk_sound_handle,
361 PURPLE_CALLBACK(got_attention_cb),
362 GINT_TO_POINTER(PURPLE_SOUND_GOT_ATTENTION));
363 /* for the time being, don't handle sent-attention here, since playing a
364 sound would result induplicate sounds. And fixing that would require changing the
365 conversation signal for msg-recv */
348 } 366 }
349 367
350 static void 368 static void
351 pidgin_sound_uninit(void) 369 pidgin_sound_uninit(void)
352 { 370 {
537 #ifndef _WIN32 555 #ifndef _WIN32
538 gdk_beep(); 556 gdk_beep();
539 #else /* _WIN32 */ 557 #else /* _WIN32 */
540 purple_debug_info("sound", "Playing %s\n", filename); 558 purple_debug_info("sound", "Playing %s\n", filename);
541 559
542 if (G_WIN32_HAVE_WIDECHAR_API ()) { 560 {
543 wchar_t *wc_filename = g_utf8_to_utf16(filename, 561 wchar_t *wc_filename = g_utf8_to_utf16(filename,
544 -1, NULL, NULL, NULL); 562 -1, NULL, NULL, NULL);
545 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) 563 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME))
546 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); 564 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
547 g_free(wc_filename); 565 g_free(wc_filename);
548 } else {
549 char *l_filename = g_locale_from_utf8(filename,
550 -1, NULL, NULL, NULL);
551 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME))
552 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
553 g_free(l_filename);
554 } 566 }
555 #endif /* _WIN32 */ 567 #endif /* _WIN32 */
556 568
557 #endif /* USE_GSTREAMER */ 569 #endif /* USE_GSTREAMER */
558 } 570 }