[empathy: 2/10] chat_view_append_message: take a should_highlight argument
- From: Will Thompson <wjt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy: 2/10] chat_view_append_message: take a should_highlight argument
- Date: Wed, 25 Jan 2012 16:17:17 +0000 (UTC)
commit 3030fa4e082c695fa25b564e513307f3423feaae
Author: Will Thompson <will willthompson co uk>
Date: Wed Jan 18 15:54:48 2012 +0000
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.
libempathy-gtk/empathy-chat-text-view.c | 6 ++++--
libempathy-gtk/empathy-chat-text-view.h | 3 ++-
libempathy-gtk/empathy-chat-view.c | 6 ++++--
libempathy-gtk/empathy-chat-view.h | 6 ++++--
libempathy-gtk/empathy-chat.c | 9 ++++++---
libempathy-gtk/empathy-theme-adium.c | 19 ++++++++++++-------
libempathy-gtk/empathy-theme-boxes.c | 3 ++-
libempathy-gtk/empathy-theme-irc.c | 5 +++--
src/empathy-preferences.c | 16 +++++++++-------
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 c251f1f..60d642c 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 12edbcc..ce83fd2 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 088b120..f5d6ddf 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 bc9e917..2c47e04 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 1496f58..c8ef248 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 7b0cd21..98df46b 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 b9fd08d..cf0c652 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 2ee81a2..ed8e3b3 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 6775d4a..cd755a9 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"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]