Mercurial > pidgin
changeset 30248:9bd9ef37354f
Add sound-support for got-attention event.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 05 Jul 2010 16:57:47 +0000 |
parents | a87764155fa5 |
children | 74541f1faf3c |
files | finch/gntsound.c |
diffstat | 1 files changed, 45 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntsound.c Mon Jul 05 15:49:57 2010 +0000 +++ b/finch/gntsound.c Mon Jul 05 16:57:47 2010 +0000 @@ -104,7 +104,8 @@ {PURPLE_SOUND_CHAT_YOU_SAY, N_("You talk in chat"), "send_chat_msg", "send.wav", NULL}, {PURPLE_SOUND_CHAT_SAY, N_("Others talk in chat"), "chat_msg_recv", "receive.wav", NULL}, {PURPLE_SOUND_POUNCE_DEFAULT, NULL, "pounce_default", "alert.wav", NULL}, - {PURPLE_SOUND_CHAT_NICK, N_("Someone says your username in chat"), "nick_said", "alert.wav", NULL} + {PURPLE_SOUND_CHAT_NICK, N_("Someone says your username in chat"), "nick_said", "alert.wav", NULL}, + {PURPLE_SOUND_GOT_ATTENTION, N_("Attention received"), "got_attention", "alert.wav", NULL} }; const char * @@ -273,6 +274,14 @@ play_conv_event(conv, event); } +static void +got_attention_cb(PurpleAccount *account, const char *who, + PurpleConversation *conv, guint type, PurpleSoundEventID event) +{ + play_conv_event(conv, event); +} + + /* * We mute sounds for the 10 seconds after you log in so that * you don't get flooded with sounds when the blist shows all @@ -300,34 +309,22 @@ static void initialize_profile(const char *name, PurplePrefType type, gconstpointer val, gpointer null) { + FinchSoundEvent *event; if (purple_prefs_exists(make_pref(""))) return; purple_prefs_add_none(make_pref("")); purple_prefs_add_none(make_pref("/enabled")); purple_prefs_add_none(make_pref("/file")); - purple_prefs_add_bool(make_pref("/enabled/login"), FALSE); - purple_prefs_add_path(make_pref("/file/login"), ""); - purple_prefs_add_bool(make_pref("/enabled/logout"), FALSE); - purple_prefs_add_path(make_pref("/file/logout"), ""); - purple_prefs_add_bool(make_pref("/enabled/im_recv"), FALSE); - purple_prefs_add_path(make_pref("/file/im_recv"), ""); - purple_prefs_add_bool(make_pref("/enabled/first_im_recv"), FALSE); - purple_prefs_add_path(make_pref("/file/first_im_recv"), ""); - purple_prefs_add_bool(make_pref("/enabled/send_im"), FALSE); - purple_prefs_add_path(make_pref("/file/send_im"), ""); - purple_prefs_add_bool(make_pref("/enabled/join_chat"), FALSE); - purple_prefs_add_path(make_pref("/file/join_chat"), ""); - purple_prefs_add_bool(make_pref("/enabled/left_chat"), FALSE); - purple_prefs_add_path(make_pref("/file/left_chat"), ""); - purple_prefs_add_bool(make_pref("/enabled/send_chat_msg"), FALSE); - purple_prefs_add_path(make_pref("/file/send_chat_msg"), ""); - purple_prefs_add_bool(make_pref("/enabled/chat_msg_recv"), FALSE); - purple_prefs_add_path(make_pref("/file/chat_msg_recv"), ""); - purple_prefs_add_bool(make_pref("/enabled/nick_said"), FALSE); - purple_prefs_add_path(make_pref("/file/nick_said"), ""); - purple_prefs_add_bool(make_pref("/enabled/pounce_default"), FALSE); - purple_prefs_add_path(make_pref("/file/pounce_default"), ""); + + for (event = sounds; event - sounds < PURPLE_NUM_SOUNDS; event++) { + char pref[512]; + g_snprintf(pref, sizeof(pref), "/enabled/%s", event->pref); + purple_prefs_add_bool(make_pref(pref), FALSE); + g_snprintf(pref, sizeof(pref), "/file/%s", event->pref); + purple_prefs_add_path(make_pref(pref), ""); + } + purple_prefs_add_bool(make_pref("/conv_focus"), FALSE); purple_prefs_add_bool(make_pref("/mute"), FALSE); purple_prefs_add_path(make_pref("/command"), ""); @@ -336,6 +333,25 @@ } static void +update_profiles(void) +{ + GList *list = finch_sound_get_profiles(); + for (; list; list = g_list_delete_link(list, list)) { + char pname[512]; + + /* got_attention was added in libpurple 2.7.0 */ + g_snprintf(pname, sizeof(pname), FINCH_PREFS_ROOT "/sound/profiles/%s%s", + (char *)list->data, "/enabled/got_attention"); + purple_prefs_add_bool(pname, FALSE); + g_snprintf(pname, sizeof(pname), FINCH_PREFS_ROOT "/sound/profiles/%s%s", + (char *)list->data, "/file/got_attention"); + purple_prefs_add_path(pname, ""); + + g_free(list->data); + } +} + +static void finch_sound_init(void) { void *gnt_sound_handle = finch_sound_get_handle(); @@ -356,7 +372,7 @@ purple_prefs_connect_callback(gnt_sound_handle, FINCH_PREFS_ROOT "/sound/actprofile", initialize_profile, NULL); purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile"); - + #ifdef USE_GSTREAMER purple_debug_info("sound", "Initializing sound output drivers.\n"); #if (GST_VERSION_MAJOR > 0 || \ @@ -399,6 +415,11 @@ purple_signal_connect(conv_handle, "received-chat-msg", gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); + purple_signal_connect(conv_handle, "got-attention", + gnt_sound_handle, PURPLE_CALLBACK(got_attention_cb), + GINT_TO_POINTER(PURPLE_SOUND_GOT_ATTENTION)); + + update_profiles(); } static void