]> git.0d.be Git - empathy.git/commitdiff
Only do sounds/notifications for text messages when they involve the user
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Wed, 27 May 2009 22:56:37 +0000 (23:56 +0100)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Wed, 27 May 2009 22:56:37 +0000 (23:56 +0100)
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

index 0ac5f4e84690a3b9000a6161943afa515069c2ce..1912b1b9ac5ebb5a750279b52cba0a72d78b668f 100644 (file)
@@ -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)) {