]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-chat.c
coding style fixes
[empathy.git] / libempathy-gtk / empathy-chat.c
index 8a17189ee27ccac386095ba938935eefe9edd8ec..d273a3792536b161095434f2e5c31d7f4a052478 100644 (file)
@@ -160,6 +160,10 @@ struct _EmpathyChatPriv {
        /* A regex matching our own current nickname in the room, or %NULL if
         * !empathy_chat_is_room (). */
        GRegex            *highlight_regex;
+
+       /* TRUE if empathy_chat_is_room () and there are unread highlighted messages.
+        * Cleared by empathy_chat_messages_read (). */
+       gboolean           highlighted;
 };
 
 typedef struct {
@@ -373,11 +377,18 @@ static gboolean
 chat_composing_stop_timeout_cb (EmpathyChat *chat)
 {
        EmpathyChatPriv *priv;
+       gboolean send_chat_states;
 
        priv = GET_PRIV (chat);
 
        priv->composing_stop_timeout_id = 0;
-       set_chat_state (chat, TP_CHANNEL_CHAT_STATE_PAUSED);
+       send_chat_states = g_settings_get_boolean (priv->gsettings_chat,
+                                        EMPATHY_PREFS_CHAT_SEND_CHAT_STATES);
+       if (!send_chat_states) {
+               set_chat_state (chat, TP_CHANNEL_CHAT_STATE_ACTIVE);
+       } else {
+               set_chat_state (chat, TP_CHANNEL_CHAT_STATE_PAUSED);
+       }
 
        return FALSE;
 }
@@ -386,9 +397,16 @@ static void
 chat_composing_start (EmpathyChat *chat)
 {
        EmpathyChatPriv *priv;
+       gboolean send_chat_states;
 
        priv = GET_PRIV (chat);
 
+       send_chat_states = g_settings_get_boolean (priv->gsettings_chat,
+                                         EMPATHY_PREFS_CHAT_SEND_CHAT_STATES);
+       if (!send_chat_states) {
+               return;
+       }
+
        if (priv->composing_stop_timeout_id) {
                /* Just restart the timeout */
                chat_composing_remove_timeout (chat);
@@ -1484,6 +1502,11 @@ chat_message_received (EmpathyChat *chat,
                empathy_chat_view_edit_message (chat->view, message);
        } else {
                gboolean should_highlight = chat_should_highlight (chat, message);
+
+               if (should_highlight) {
+                       priv->highlighted = TRUE;
+               }
+
                DEBUG ("Appending new message '%s' from %s (%d)",
                        empathy_message_get_token (message),
                        empathy_contact_get_alias (sender),
@@ -1692,7 +1715,14 @@ chat_subject_changed_cb (EmpathyChat *chat)
                        gchar *str = NULL;
 
                        if (!EMP_STR_EMPTY (priv->subject)) {
-                               str = g_strdup_printf (_("Topic set to: %s"), priv->subject);
+                               const gchar *actor = empathy_tp_chat_get_subject_actor (priv->tp_chat);
+
+                               if (tp_str_empty (actor)) {
+                                       str = g_strdup_printf (_("Topic set to: %s"), priv->subject);
+                               } else {
+                                       str = g_strdup_printf (_("Topic set by %s to: %s"),
+                                                              actor, priv->subject);
+                               }
                        } else if (empathy_tp_chat_supports_subject (priv->tp_chat)) {
                                /* No need to display this 'event' is no topic can be defined anyway */
                                str = g_strdup (_("No topic defined"));
@@ -4139,7 +4169,8 @@ empathy_chat_get_contact_menu (EmpathyChat *chat)
        if (contact == NULL)
                return NULL;
 
-       individual = empathy_create_individual_from_tp_contact (contact);
+       individual = empathy_ensure_individual_from_tp_contact (contact);
+
        if (individual == NULL)
                return NULL;
 
@@ -4301,6 +4332,16 @@ empathy_chat_is_room (EmpathyChat *chat)
        return (priv->handle_type == TP_HANDLE_TYPE_ROOM);
 }
 
+gboolean
+empathy_chat_is_highlighted (EmpathyChat *chat)
+{
+       EmpathyChatPriv *priv = GET_PRIV (chat);
+
+       g_return_val_if_fail (EMPATHY_IS_CHAT (chat), FALSE);
+
+       return priv->highlighted;
+}
+
 guint
 empathy_chat_get_nb_unread_messages (EmpathyChat *self)
 {
@@ -4329,6 +4370,8 @@ empathy_chat_messages_read (EmpathyChat *self)
                        TP_TEXT_CHANNEL (priv->tp_chat), NULL, NULL);
        }
 
+       priv->highlighted = FALSE;
+
        if (priv->unread_messages_when_offline > 0) {
                /* We can't ack those as the connection has gone away so just consider
                * them as read. */