# HG changeset patch # User Mark Doliner # Date 1081699746 0 # Node ID ff2c1e946a5ca801f8f201a10bd11f66a393ea36 # Parent fdff0f31002d420aa97ddf97944e28de760c4355 [gaim-migrate @ 9382] Add an option for "No sounds when conversation has focus" Thanks goes to nosnilmot, I think committer: Tailor Script diff -r fdff0f31002d -r ff2c1e946a5c src/gtkconv.c --- a/src/gtkconv.c Sun Apr 11 03:27:11 2004 +0000 +++ b/src/gtkconv.c Sun Apr 11 16:09:06 2004 +0000 @@ -4374,8 +4374,15 @@ 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 @@ } /* 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 @@ 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) { diff -r fdff0f31002d -r ff2c1e946a5c src/gtkprefs.c --- a/src/gtkprefs.c Sun Apr 11 03:27:11 2004 +0000 +++ b/src/gtkprefs.c Sun Apr 11 16:09:06 2004 +0000 @@ -1536,6 +1536,8 @@ 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(_("No sounds when conversation has _focus"), + "/gaim/gtk/sound/silent_focus", vbox); gaim_gtk_prefs_checkbox(_("_Sounds while away"), "/core/sound/while_away", vbox); diff -r fdff0f31002d -r ff2c1e946a5c src/gtksound.c --- a/src/gtksound.c Sun Apr 11 03:27:11 2004 +0000 +++ b/src/gtksound.c Sun Apr 11 16:09:06 2004 +0000 @@ -108,6 +108,7 @@ 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", FALSE); gaim_prefs_add_string("/gaim/gtk/sound/command", ""); gaim_prefs_add_string("/gaim/gtk/sound/method", "automatic");