From: <rl...@us...> - 2006-11-01 01:27:38
|
Revision: 17643 http://svn.sourceforge.net/gaim/?rev=17643&view=rev Author: rlaager Date: 2006-10-31 17:27:16 -0800 (Tue, 31 Oct 2006) Log Message: ----------- 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? Modified Paths: -------------- trunk/COPYRIGHT trunk/gtk/gtkprefs.c trunk/libgaim/prefs.c trunk/libgaim/sound.c Modified: trunk/COPYRIGHT =================================================================== --- trunk/COPYRIGHT 2006-11-01 00:57:39 UTC (rev 17642) +++ trunk/COPYRIGHT 2006-11-01 01:27:16 UTC (rev 17643) @@ -237,6 +237,7 @@ Federicco Mena Quintero Yosef Radchenko David Raeman +R. Ramkumar Mart Raudsepp Etan Reisner Kristian Rietveld Modified: trunk/gtk/gtkprefs.c =================================================================== --- trunk/gtk/gtkprefs.c 2006-11-01 00:57:39 UTC (rev 17642) +++ trunk/gtk/gtkprefs.c 2006-11-01 01:27:16 UTC (rev 17643) @@ -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); Modified: trunk/libgaim/prefs.c =================================================================== --- trunk/libgaim/prefs.c 2006-11-01 00:57:39 UTC (rev 17642) +++ trunk/libgaim/prefs.c 2006-11-01 01:27:16 UTC (rev 17643) @@ -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 * Modified: trunk/libgaim/sound.c =================================================================== --- trunk/libgaim/sound.c 2006-11-01 00:57:39 UTC (rev 17642) +++ trunk/libgaim/sound.c 2006-11-01 01:27:16 UTC (rev 17643) @@ -28,18 +28,45 @@ static GaimSoundUiOps *sound_ui_ops = NULL; -void -gaim_sound_play_file(const char *filename, const GaimAccount *account) +#define STATUS_AVAILABLE 1 +#define STATUS_AWAY 2 + +static gboolean +gaim_sound_play_required(const GaimAccount *account) { - GaimStatus *status; + gint pref_status = gaim_prefs_get_int("/core/sound/while_status"); - if ((account != NULL) && (!gaim_prefs_get_bool("/core/sound/while_away"))) + if (pref_status == 3) { - status = gaim_account_get_active_status(account); - if (gaim_status_is_online(status) && !gaim_status_is_available(status)) - return; + /* 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) +{ + if (!gaim_sound_play_required(account)) + return; + if(sound_ui_ops && sound_ui_ops->play_file) sound_ui_ops->play_file(filename); } @@ -47,17 +74,9 @@ void gaim_sound_play_event(GaimSoundEventID event, const GaimAccount *account) { - GaimStatus *status; + if (!gaim_sound_play_required(account)) + return; - 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(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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |