Mercurial > pidgin.yaz
changeset 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 | 3a23706f9f4b |
children | 7357d46ba817 |
files | COPYRIGHT gtk/gtkprefs.c libgaim/prefs.c libgaim/sound.c |
diffstat | 4 files changed, 53 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/COPYRIGHT Wed Nov 01 00:57:39 2006 +0000 +++ b/COPYRIGHT Wed Nov 01 01:27:16 2006 +0000 @@ -237,6 +237,7 @@ Federicco Mena Quintero Yosef Radchenko David Raeman +R. Ramkumar Mart Raudsepp Etan Reisner Kristian Rietveld
--- a/gtk/gtkprefs.c Wed Nov 01 00:57:39 2006 +0000 +++ b/gtk/gtkprefs.c Wed Nov 01 01:27:16 2006 +0000 @@ -1606,8 +1606,12 @@ vbox = gaim_gtk_make_frame (ret, _("Sound Options")); gaim_gtk_prefs_checkbox(_("Sounds when conversation has _focus"), "/gaim/gtk/sound/conv_focus", vbox); - gaim_gtk_prefs_checkbox(_("_Sounds while away"), - "/core/sound/while_away", vbox); + gaim_gtk_prefs_dropdown(vbox, _("Enable sounds:"), + GAIM_PREF_INT, "/core/sound/while_status", + _("Only when available"), 1, + _("Only when not available"), 2, + _("Always"), 3, + NULL); #ifdef USE_GSTREAMER hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
--- a/libgaim/prefs.c Wed Nov 01 00:57:39 2006 +0000 +++ b/libgaim/prefs.c Wed Nov 01 01:27:16 2006 +0000 @@ -1116,6 +1116,14 @@ gaim_prefs_remove("/plugins/core/autorecon/hide_reconnecting_dialog"); gaim_prefs_remove("/plugins/core/autorecon/restore_state"); gaim_prefs_remove("/plugins/core/autorecon"); + + /* Convert old sounds while_away pref to new 3-way pref. */ + if (gaim_prefs_exists("/core/sound/while_away") && + gaim_prefs_get_bool("/core/sound/while_away")) + { + gaim_prefs_set_int("/core/sound/while_status", 3); + } + gaim_prefs_remove("/core/sound/while_away"); } void *
--- 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