[empathy] Only do sounds/notifications for text messages when they involve the user



commit 05a941a4b071189b819faf9c5a8b54712b2d5467
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Wed May 27 23:56:37 2009 +0100

    Only do sounds/notifications for text messages when they involve the user
    
    When in a chatroom notifications and sounds should only happen when the users
    is part of the message (either someone is speaking to them or referring to
    them), otherwise the user will go crazy when in a lot of different muc
    channels. For a peer to peer text channel, all messages sent are targetted at
    the user so always do sounds/notifications in that case.
---
 src/empathy-chat-window.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 0ac5f4e..1912b1b 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -926,24 +926,15 @@ chat_window_new_message_cb (EmpathyChat       *chat,
 	/* - if we're the sender, we play the sound if it's specified in the
 	 *   preferences and we're not away.
 	 * - if we receive a message, we play the sound if it's specified in the
-	 *   prefereces and the window does not have focus on the chat receiving
+	 *   preferences and the window does not have focus on the chat receiving
 	 *   the message.
 	 */
 
 	sender = empathy_message_get_sender (message);
 
-	if (empathy_contact_is_user (sender) != FALSE) {
+	if (empathy_contact_is_user (sender)) {
 		empathy_sound_play (GTK_WIDGET (priv->dialog),
 				    EMPATHY_SOUND_MESSAGE_OUTGOING);
-	} else {
-		if ((!has_focus || priv->current_chat != chat)) {
-			empathy_sound_play (GTK_WIDGET (priv->dialog),
-					    EMPATHY_SOUND_MESSAGE_INCOMING);
-		}
-	}
-
-	if (!has_focus) {
-		chat_window_show_or_update_notification (window, message, chat);
 	}
 
 	if (has_focus && priv->current_chat == chat) {
@@ -962,8 +953,13 @@ chat_window_new_message_cb (EmpathyChat       *chat,
 		needs_urgency = TRUE;
 	}
 
-	if (needs_urgency && !has_focus) {
-		chat_window_set_urgency_hint (window, TRUE);
+	if (needs_urgency) {
+		if (!has_focus)
+			chat_window_set_urgency_hint (window, TRUE);
+
+		empathy_sound_play (GTK_WIDGET (priv->dialog),
+		    EMPATHY_SOUND_MESSAGE_INCOMING);
+		chat_window_show_or_update_notification (window, message, chat);
 	}
 
 	if (!g_list_find (priv->chats_new_msg, chat)) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]