Mercurial > pidgin
diff libgaim/sound.c @ 14874:71149a751439
[gaim-migrate @ 17643]
SF Patch #1469315 from R.Ramkumar - andyetitmoves
"This is a small patch to make sounds enabled when
available an optional feature. The use case is: Sounds
being annoying, I would like them only when I am not
seeing the comp. When I am on the comp, I have
guifications/gaim-osd to inform me of whatever happens,
and that happens to be less intrusive (especially when
music is on :) )."
The patch originally used:
"Play sounds:" ("Always", "When available", "When away")
I changed them to the strings KingAnt suggested:
"Play sounds:" ("Always", "Only when available", "Only when not available")
The ones from the patch submitter are not quite as clear, but they're shorter.
What does everyone think about this?
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 01 Nov 2006 01:27:16 +0000 |
parents | 2f0b4d0de5bb |
children |
line wrap: on
line diff
--- a/libgaim/sound.c Wed Nov 01 00:57:39 2006 +0000 +++ b/libgaim/sound.c Wed Nov 01 01:27:16 2006 +0000 @@ -28,17 +28,44 @@ static GaimSoundUiOps *sound_ui_ops = NULL; +#define STATUS_AVAILABLE 1 +#define STATUS_AWAY 2 + +static gboolean +gaim_sound_play_required(const GaimAccount *account) +{ + gint pref_status = gaim_prefs_get_int("/core/sound/while_status"); + + if (pref_status == 3) + { + /* Play sounds: Always */ + return TRUE; + } + + if (account != NULL) + { + GaimStatus *status = gaim_account_get_active_status(account); + + if (gaim_status_is_online(status)) + { + gboolean available = gaim_status_is_available(status); + return (( available && pref_status == STATUS_AVAILABLE) || + (!available && pref_status == STATUS_AWAY)); + } + } + + /* We get here a couple of ways. Either the request has been OK'ed + * by gaim_sound_play_event() and we're here because the UI has + * called gaim_sound_play_file(), or we're here for something + * not related to an account (like testing a sound). */ + return TRUE; +} + void gaim_sound_play_file(const char *filename, const GaimAccount *account) { - GaimStatus *status; - - if ((account != NULL) && (!gaim_prefs_get_bool("/core/sound/while_away"))) - { - status = gaim_account_get_active_status(account); - if (gaim_status_is_online(status) && !gaim_status_is_available(status)) - return; - } + if (!gaim_sound_play_required(account)) + return; if(sound_ui_ops && sound_ui_ops->play_file) sound_ui_ops->play_file(filename); @@ -47,16 +74,8 @@ void gaim_sound_play_event(GaimSoundEventID event, const GaimAccount *account) { - GaimStatus *status; - - if ((account != NULL) && - (!gaim_prefs_get_bool("/core/sound/while_away"))) - { - status = gaim_account_get_active_status(account); - if (gaim_status_is_online(status) && - !gaim_status_is_available(status)) - return; - } + if (!gaim_sound_play_required(account)) + return; if(sound_ui_ops && sound_ui_ops->play_event) { int plugin_return; @@ -107,8 +126,7 @@ GAIM_SUBTYPE_ACCOUNT)); gaim_prefs_add_none("/core/sound"); - gaim_prefs_add_bool("/core/sound/while_away", FALSE); - + gaim_prefs_add_int("/core/sound/while_status", STATUS_AVAILABLE); } void