]> git.0d.be Git - empathy.git/commitdiff
chat_view_append_message: take a should_highlight argument
authorWill Thompson <will@willthompson.co.uk>
Wed, 18 Jan 2012 15:54:48 +0000 (15:54 +0000)
committerWill Thompson <will@willthompson.co.uk>
Wed, 18 Jan 2012 17:47:25 +0000 (17:47 +0000)
Rather than the EmpathyChatView implementations calling
empathy_message_should_highlight() themselves, this patch makes
EmpathyChat take responsibility for doing so.

The theme preview in Preferences, whether deliberately or otherwise,
highlights the line in which Juliet mentions Romeo. This behaviour is
preserved.

libempathy-gtk/empathy-chat-text-view.c
libempathy-gtk/empathy-chat-text-view.h
libempathy-gtk/empathy-chat-view.c
libempathy-gtk/empathy-chat-view.h
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-theme-adium.c
libempathy-gtk/empathy-theme-boxes.c
libempathy-gtk/empathy-theme-irc.c
src/empathy-preferences.c

index c251f1f423d560ff2f1ba2fc7212f0764ea3c7f8..60d642ccb7bb84c9e7c1f0175980023f4eb3f978 100644 (file)
@@ -717,7 +717,8 @@ chat_text_view_scroll_down (EmpathyChatView *view)
 
 static void
 chat_text_view_append_message (EmpathyChatView *view,
-                              EmpathyMessage  *msg)
+                              EmpathyMessage  *msg,
+                              gboolean         should_highlight)
 {
        EmpathyChatTextView     *text_view = EMPATHY_CHAT_TEXT_VIEW (view);
        EmpathyChatTextViewPriv *priv = GET_PRIV (text_view);
@@ -739,7 +740,8 @@ chat_text_view_append_message (EmpathyChatView *view,
        chat_text_maybe_append_date_and_time (text_view, timestamp);
        if (EMPATHY_CHAT_TEXT_VIEW_GET_CLASS (view)->append_message) {
                EMPATHY_CHAT_TEXT_VIEW_GET_CLASS (view)->append_message (text_view,
-                                                                        msg);
+                                                                        msg,
+                                                                        should_highlight);
        }
 
        if (bottom) {
index 12edbcc64ba46e36c84ac5ad260081f38bd6c69f..ce83fd2fa8ab8a4ac8549e0d78f9b61a28192ec0 100644 (file)
@@ -56,7 +56,8 @@ struct _EmpathyChatTextViewClass {
 
        /* <vtable> */
        void (*append_message) (EmpathyChatTextView *view,
-                               EmpathyMessage      *message);
+                               EmpathyMessage      *message,
+                               gboolean             should_highlight);
 };
 
 #define EMPATHY_CHAT_TEXT_VIEW_TAG_CUT "cut"
index 088b1208478139975fcabc2e1b3aa2edd4518b02..f5d6ddf095deba9f09a1c3332edefa484a3e0e5e 100644 (file)
@@ -61,13 +61,15 @@ chat_view_base_init (gpointer klass)
 
 void
 empathy_chat_view_append_message (EmpathyChatView *view,
-                                 EmpathyMessage  *msg)
+                                 EmpathyMessage  *msg,
+                                 gboolean         should_highlight)
 {
        g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
 
        if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_message) {
                EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_message (view,
-                                                                        msg);
+                                                                        msg,
+                                                                        should_highlight);
        }
 }
 
index bc9e9176105921abb18bfbe722635e3d71ace512..2c47e042929a96f892053fce29737f8ddb70d2b3 100644 (file)
@@ -43,7 +43,8 @@ struct _EmpathyChatViewIface {
 
        /* VTabled */
        void             (*append_message)       (EmpathyChatView *view,
-                                                 EmpathyMessage  *msg);
+                                                 EmpathyMessage  *msg,
+                                                 gboolean         should_highlight);
        void             (*append_event)         (EmpathyChatView *view,
                                                  const gchar     *str);
        void             (*append_event_markup)  (EmpathyChatView *view,
@@ -81,7 +82,8 @@ struct _EmpathyChatViewIface {
 
 GType            empathy_chat_view_get_type             (void) G_GNUC_CONST;
 void             empathy_chat_view_append_message       (EmpathyChatView *view,
-                                                        EmpathyMessage  *msg);
+                                                        EmpathyMessage  *msg,
+                                                        gboolean         should_highlight);
 void             empathy_chat_view_append_event         (EmpathyChatView *view,
                                                         const gchar     *str);
 void             empathy_chat_view_append_event_markup  (EmpathyChatView *view,
index 1496f582dfc5b6b7775882c5e2f75635a2400a2c..c8ef248096998a40c0f0266a6f06644be2666a15 100644 (file)
@@ -1400,12 +1400,13 @@ chat_message_received (EmpathyChat *chat,
 
                empathy_chat_view_edit_message (chat->view, message);
        } else {
+               gboolean should_highlight = empathy_message_should_highlight (message);
                DEBUG ("Appending new message '%s' from %s (%d)",
                        empathy_message_get_token (message),
                        empathy_contact_get_alias (sender),
                        empathy_contact_get_handle (sender));
 
-               empathy_chat_view_append_message (chat->view, message);
+               empathy_chat_view_append_message (chat->view, message, should_highlight);
 
                if (empathy_message_is_incoming (message)) {
                        priv->unread_messages++;
@@ -2491,13 +2492,15 @@ got_filtered_messages_cb (GObject *manager,
                                "sender", empathy_message_get_sender (message),
                                NULL);
 
-                       empathy_chat_view_append_message (chat->view, syn_msg);
+                       empathy_chat_view_append_message (chat->view, syn_msg,
+                                                         empathy_message_should_highlight (syn_msg));
                        empathy_chat_view_edit_message (chat->view, message);
 
                        g_object_unref (syn_msg);
                } else {
                        /* append the latest message */
-                       empathy_chat_view_append_message (chat->view, message);
+                       empathy_chat_view_append_message (chat->view, message,
+                                                         empathy_message_should_highlight (message));
                }
 
                g_object_unref (message);
index 7b0cd21696479d134f08d6c0d0faf8b4b4e0bbf3..98df46b79a9de43ee019f56544b9a46e0a461e33 100644 (file)
@@ -132,13 +132,15 @@ typedef struct {
        guint type;
        EmpathyMessage *msg;
        char *str;
+       gboolean should_highlight;
 } QueuedItem;
 
 static QueuedItem *
 queue_item (GQueue *queue,
            guint type,
            EmpathyMessage *msg,
-           const char *str)
+           const char *str,
+           gboolean should_highlight)
 {
        QueuedItem *item = g_slice_new0 (QueuedItem);
 
@@ -146,6 +148,7 @@ queue_item (GQueue *queue,
        if (msg != NULL)
                item->msg = g_object_ref (msg);
        item->str = g_strdup (str);
+       item->should_highlight = should_highlight;
 
        g_queue_push_tail (queue, item);
 
@@ -775,7 +778,8 @@ theme_adium_remove_all_focus_marks (EmpathyThemeAdium *theme)
 
 static void
 theme_adium_append_message (EmpathyChatView *view,
-                           EmpathyMessage  *msg)
+                           EmpathyMessage  *msg,
+                           gboolean         should_highlight)
 {
        EmpathyThemeAdium     *theme = EMPATHY_THEME_ADIUM (view);
        EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
@@ -797,7 +801,7 @@ theme_adium_append_message (EmpathyChatView *view,
        gboolean               action;
 
        if (priv->pages_loading != 0) {
-               queue_item (&priv->message_queue, QUEUED_MESSAGE, msg, NULL);
+               queue_item (&priv->message_queue, QUEUED_MESSAGE, msg, NULL, should_highlight);
                return;
        }
 
@@ -886,7 +890,7 @@ theme_adium_append_message (EmpathyChatView *view,
        } else {
                g_string_append (message_classes, " incoming");
        }
-       if (empathy_message_should_highlight (msg)) {
+       if (should_highlight) {
                g_string_append (message_classes, " mention");
        }
        if (empathy_message_get_tptype (msg) == TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY) {
@@ -975,7 +979,7 @@ theme_adium_append_event (EmpathyChatView *view,
        gchar *str_escaped;
 
        if (priv->pages_loading != 0) {
-               queue_item (&priv->message_queue, QUEUED_EVENT, NULL, str);
+               queue_item (&priv->message_queue, QUEUED_EVENT, NULL, str, FALSE);
                return;
        }
 
@@ -1005,7 +1009,7 @@ theme_adium_edit_message (EmpathyChatView *view,
        GError *error = NULL;
 
        if (priv->pages_loading != 0) {
-               queue_item (&priv->message_queue, QUEUED_EDIT, message, NULL);
+               queue_item (&priv->message_queue, QUEUED_EDIT, message, NULL, FALSE);
                return;
        }
 
@@ -1345,7 +1349,8 @@ theme_adium_load_finished_cb (WebKitWebView  *view,
                switch (item->type)
                {
                        case QUEUED_MESSAGE:
-                               theme_adium_append_message (chat_view, item->msg);
+                               theme_adium_append_message (chat_view, item->msg,
+                                       item->should_highlight);
                                break;
 
                        case QUEUED_EDIT:
index b9fd08d84b27e5738fcb05d753a283d980e0473c..cf0c652686893ed224c8d53cddd198ecbaf9b461 100644 (file)
@@ -337,7 +337,8 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme,
 
 static void
 theme_boxes_append_message (EmpathyChatTextView *view,
-                           EmpathyMessage      *message)
+                           EmpathyMessage      *message,
+                           gboolean             should_highlight)
 {
        EmpathyContact *sender;
 
index 2ee81a23ef64bfdb319ba70672ee8a7761b50753..ed8e3b38049c6303e45c66df5342141daf01e299 100644 (file)
@@ -50,7 +50,8 @@ theme_irc_create_tags (EmpathyThemeIrc *theme)
 
 static void
 theme_irc_append_message (EmpathyChatTextView *view,
-                         EmpathyMessage      *message)
+                         EmpathyMessage      *message,
+                         gboolean             should_highlight)
 {
        GtkTextBuffer *buffer;
        const gchar   *name;
@@ -77,7 +78,7 @@ theme_irc_append_message (EmpathyChatTextView *view,
        if (empathy_contact_is_user (contact)) {
                nick_tag = EMPATHY_THEME_IRC_TAG_NICK_SELF;
        } else {
-               if (empathy_message_should_highlight (message)) {
+               if (should_highlight) {
                        nick_tag = EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT;
                } else {
                        nick_tag = EMPATHY_THEME_IRC_TAG_NICK_OTHER;
index 6775d4a245bb5f7c88a00e3a5cfe9c3abd57c6ee..cd755a9ae420e8d6684147184b62916ad7f76583 100644 (file)
@@ -678,7 +678,8 @@ static void
 preferences_preview_theme_append_message (EmpathyChatView *view,
                                          EmpathyContact *sender,
                                          EmpathyContact *receiver,
-                                         const gchar *text)
+                                         const gchar *text,
+                                         gboolean should_highlight)
 {
        EmpathyMessage *message;
 
@@ -688,7 +689,7 @@ preferences_preview_theme_append_message (EmpathyChatView *view,
                "body", text,
                NULL);
 
-       empathy_chat_view_append_message (view, message);
+       empathy_chat_view_append_message (view, message, should_highlight);
        g_object_unref (message);
 }
 
@@ -735,19 +736,20 @@ preferences_preview_theme_changed_cb (EmpathyThemeManager *manager,
 
        preferences_preview_theme_append_message (priv->chat_theme_preview,
                /* translators: Quote from Romeo & Julier, for chat theme preview */
-               juliet, romeo, _("O Romeo, Romeo, wherefore art thou Romeo?"));
+               juliet, romeo, _("O Romeo, Romeo, wherefore art thou Romeo?"),
+               TRUE /* this message mentions Romeo */);
        preferences_preview_theme_append_message (priv->chat_theme_preview,
                /* translators: Quote from Romeo & Julier, for chat theme preview */
-               juliet, romeo, _("Deny thy father and refuse thy name;"));
+               juliet, romeo, _("Deny thy father and refuse thy name;"), FALSE);
        preferences_preview_theme_append_message (priv->chat_theme_preview,
                /* translators: Quote from Romeo & Julier, for chat theme preview */
-               juliet, romeo, _("Or if thou wilt not, be but sworn my love"));
+               juliet, romeo, _("Or if thou wilt not, be but sworn my love"), FALSE);
        preferences_preview_theme_append_message (priv->chat_theme_preview,
                /* translators: Quote from Romeo & Julier, for chat theme preview */
-               juliet, romeo, _("And I'll no longer be a Capulet."));
+               juliet, romeo, _("And I'll no longer be a Capulet."), FALSE);
        preferences_preview_theme_append_message (priv->chat_theme_preview,
                /* translators: Quote from Romeo & Julier, for chat theme preview */
-               romeo, juliet, _("Shall I hear more, or shall I speak at this?"));
+               romeo, juliet, _("Shall I hear more, or shall I speak at this?"), FALSE);
 
        /* translators: Quote from Romeo & Julier, for chat theme preview */
        empathy_chat_view_append_event (priv->chat_theme_preview, _("Juliet has disconnected"));