aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Thompson <will@willthompson.co.uk>2012-01-18 23:54:48 +0800
committerWill Thompson <will@willthompson.co.uk>2012-01-19 01:47:25 +0800
commit3030fa4e082c695fa25b564e513307f3423feaae (patch)
tree3d2795a6a2662a708cfad2a83165000e78640b76
parentaded85c91fb409bafb06492ddb85aa1224178d4c (diff)
downloadgsoc2013-empathy-3030fa4e082c695fa25b564e513307f3423feaae.tar
gsoc2013-empathy-3030fa4e082c695fa25b564e513307f3423feaae.tar.gz
gsoc2013-empathy-3030fa4e082c695fa25b564e513307f3423feaae.tar.bz2
gsoc2013-empathy-3030fa4e082c695fa25b564e513307f3423feaae.tar.lz
gsoc2013-empathy-3030fa4e082c695fa25b564e513307f3423feaae.tar.xz
gsoc2013-empathy-3030fa4e082c695fa25b564e513307f3423feaae.tar.zst
gsoc2013-empathy-3030fa4e082c695fa25b564e513307f3423feaae.zip
chat_view_append_message: take a should_highlight argument
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.
-rw-r--r--libempathy-gtk/empathy-chat-text-view.c6
-rw-r--r--libempathy-gtk/empathy-chat-text-view.h3
-rw-r--r--libempathy-gtk/empathy-chat-view.c6
-rw-r--r--libempathy-gtk/empathy-chat-view.h6
-rw-r--r--libempathy-gtk/empathy-chat.c9
-rw-r--r--libempathy-gtk/empathy-theme-adium.c19
-rw-r--r--libempathy-gtk/empathy-theme-boxes.c3
-rw-r--r--libempathy-gtk/empathy-theme-irc.c5
-rw-r--r--src/empathy-preferences.c16
9 files changed, 46 insertions, 27 deletions
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c
index c251f1f42..60d642ccb 100644
--- a/libempathy-gtk/empathy-chat-text-view.c
+++ b/libempathy-gtk/empathy-chat-text-view.c
@@ -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) {
diff --git a/libempathy-gtk/empathy-chat-text-view.h b/libempathy-gtk/empathy-chat-text-view.h
index 12edbcc64..ce83fd2fa 100644
--- a/libempathy-gtk/empathy-chat-text-view.h
+++ b/libempathy-gtk/empathy-chat-text-view.h
@@ -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"
diff --git a/libempathy-gtk/empathy-chat-view.c b/libempathy-gtk/empathy-chat-view.c
index 088b12084..f5d6ddf09 100644
--- a/libempathy-gtk/empathy-chat-view.c
+++ b/libempathy-gtk/empathy-chat-view.c
@@ -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);
}
}
diff --git a/libempathy-gtk/empathy-chat-view.h b/libempathy-gtk/empathy-chat-view.h
index bc9e91761..2c47e0429 100644
--- a/libempathy-gtk/empathy-chat-view.h
+++ b/libempathy-gtk/empathy-chat-view.h
@@ -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,
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 1496f582d..c8ef24809 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -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);
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c
index 7b0cd2169..98df46b79 100644
--- a/libempathy-gtk/empathy-theme-adium.c
+++ b/libempathy-gtk/empathy-theme-adium.c
@@ -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:
diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c
index b9fd08d84..cf0c65268 100644
--- a/libempathy-gtk/empathy-theme-boxes.c
+++ b/libempathy-gtk/empathy-theme-boxes.c
@@ -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;
diff --git a/libempathy-gtk/empathy-theme-irc.c b/libempathy-gtk/empathy-theme-irc.c
index 2ee81a23e..ed8e3b380 100644
--- a/libempathy-gtk/empathy-theme-irc.c
+++ b/libempathy-gtk/empathy-theme-irc.c
@@ -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;
diff --git a/src/empathy-preferences.c b/src/empathy-preferences.c
index 6775d4a24..cd755a9ae 100644
--- a/src/empathy-preferences.c
+++ b/src/empathy-preferences.c
@@ -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"));