Index: src/gtkconv.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkconv.c,v retrieving revision 1.347 diff -u -p -u -r1.347 gtkconv.c --- src/gtkconv.c 8 Apr 2004 17:29:49 -0000 1.347 +++ src/gtkconv.c 11 Apr 2004 15:54:29 -0000 @@ -4374,8 +4374,15 @@ gaim_gtkconv_write_im(GaimConversation * time_t mtime) { GaimGtkConversation *gtkconv; + GaimConvWindow *gaimwin; + GaimGtkWindow *gtkwin; + gboolean has_focus; gtkconv = GAIM_GTK_CONVERSATION(conv); + gaimwin = gaim_conversation_get_window(conv); + gtkwin = GAIM_GTK_WINDOW(gaimwin); + + g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); if (!(flags & GAIM_MESSAGE_NO_LOG) && gaim_prefs_get_bool("/gaim/gtk/conversations/im/raise_on_events")) { @@ -4384,7 +4391,8 @@ gaim_gtkconv_write_im(GaimConversation * } /* Play a sound, if specified in prefs. */ - if (gtkconv->make_sound) { + if (gtkconv->make_sound && !((gaim_conv_window_get_active_conversation(gaimwin) == conv) && + gaim_prefs_get_bool("/gaim/gtk/sound/silent_focus") && has_focus)) { if (flags & GAIM_MESSAGE_RECV) { if (gtkconv->u.im->a_virgin && gaim_prefs_get_bool("/gaim/gtk/sound/enabled/first_im_recv")) { @@ -4409,11 +4417,19 @@ gaim_gtkconv_write_chat(GaimConversation const char *message, GaimMessageFlags flags, time_t mtime) { GaimGtkConversation *gtkconv; + GaimConvWindow *gaimwin; + GaimGtkWindow *gtkwin; + gboolean has_focus; gtkconv = GAIM_GTK_CONVERSATION(conv); + gaimwin = gaim_conversation_get_window(conv); + gtkwin = GAIM_GTK_WINDOW(gaimwin); + + g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); /* Play a sound, if specified in prefs. */ - if (gtkconv->make_sound) { + if (gtkconv->make_sound && !((gaim_conv_window_get_active_conversation(gaimwin) == conv) && + gaim_prefs_get_bool("/gaim/gtk/sound/silent_focus") && has_focus)) { if (!(flags & GAIM_MESSAGE_WHISPER) && (flags & GAIM_MESSAGE_SEND)) gaim_sound_play_event(GAIM_SOUND_CHAT_YOU_SAY); else if (flags & GAIM_MESSAGE_RECV) { Index: src/gtksound.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtksound.c,v retrieving revision 1.12 diff -u -p -u -r1.12 gtksound.c --- src/gtksound.c 10 Jan 2004 04:04:56 -0000 1.12 +++ src/gtksound.c 11 Apr 2004 15:54:29 -0000 @@ -108,6 +108,7 @@ static void gaim_gtk_sound_init(void) gaim_prefs_add_bool("/gaim/gtk/sound/enabled/pounce_default", TRUE); gaim_prefs_add_string("/gaim/gtk/sound/file/pounce_default", ""); gaim_prefs_add_bool("/gaim/gtk/sound/silent_signon", TRUE); + gaim_prefs_add_bool("/gaim/gtk/sound/silent_focus", TRUE); gaim_prefs_add_string("/gaim/gtk/sound/command", ""); gaim_prefs_add_string("/gaim/gtk/sound/method", "automatic"); Index: src/gtkprefs.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkprefs.c,v retrieving revision 1.133 diff -u -p -u -r1.133 gtkprefs.c --- src/gtkprefs.c 7 Apr 2004 07:01:06 -0000 1.133 +++ src/gtkprefs.c 11 Apr 2004 15:54:29 -0000 @@ -1536,6 +1536,8 @@ GtkWidget *sound_page() { vbox = gaim_gtk_make_frame (ret, _("Sound Options")); gaim_gtk_prefs_checkbox(_("_No sounds when you log in"), "/gaim/gtk/sound/silent_signon", vbox); + gaim_gtk_prefs_checkbox(_("Play sounds when conversation has _focus"), + "/gaim/gtk/sound/silent_focus", vbox); gaim_gtk_prefs_checkbox(_("_Sounds while away"), "/core/sound/while_away", vbox);