Mercurial > pidgin.yaz
changeset 20953:111f4b8084b0
Track the unseen state on the PurpleConversation for dettached convs. This
allows us to only blink the tray icon when our nick was said instead of
for every message sent to a chat (when dettached).
author | Casey Harkins <charkins@pidgin.im> |
---|---|
date | Mon, 15 Oct 2007 22:16:57 +0000 |
parents | a9f1e320d94d |
children | 2101ebd66f15 |
files | pidgin/gtkconv.c |
diffstat | 1 files changed, 54 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkconv.c Mon Oct 15 04:45:51 2007 +0000 +++ b/pidgin/gtkconv.c Mon Oct 15 22:16:57 2007 +0000 @@ -148,6 +148,7 @@ static void add_chat_buddy_common(PurpleConversation *conv, PurpleConvChatBuddy *cb, const char *old_name); static gboolean tab_complete(PurpleConversation *conv); static void pidgin_conv_updated(PurpleConversation *conv, PurpleConvUpdateType type); +static void conv_set_unseen(PurpleConversation *gtkconv, PidginUnseenState state); static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state); static void update_typing_icon(PidginConversation *gtkconv); static const char *item_factory_translate_func (const char *path, gpointer func_data); @@ -2853,7 +2854,9 @@ if (gtkconv != NULL && gtkconv->active_conv != conv) continue; if (gtkconv == NULL) { - if (!purple_conversation_get_data(conv, "unseen-count")) + if (!purple_conversation_get_data(conv, "unseen-count") || + !purple_conversation_get_data(conv, "unseen-state") || + GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-state"))<min_state) continue; r = g_list_prepend(r, conv); c++; @@ -5162,6 +5165,8 @@ conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); purple_conversation_set_ui_ops(conv, NULL); ui_ops->create_conversation = pidgin_conv_new; + } else { + /* TODO: update the unseen_state data on the conv here */ } } else { /* new message for an IM */ @@ -6668,13 +6673,24 @@ static void wrote_msg_update_unseen_cb(PurpleAccount *account, const char *who, const char *message, - PurpleConversation *conv, PurpleMessageFlags flag, gpointer null) + PurpleConversation *conv, PurpleMessageFlags flags, gpointer null) { if (conv == NULL || PIDGIN_IS_PIDGIN_CONVERSATION(conv)) return; - if (flag & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) { - purple_conversation_set_data(conv, "unseen-count", - GINT_TO_POINTER(GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count")) + 1)); + if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) { + PidginUnseenState unseen = PIDGIN_UNSEEN_NONE; + + if ((flags & PURPLE_MESSAGE_NICK) == PURPLE_MESSAGE_NICK) + unseen = PIDGIN_UNSEEN_NICK; + else if (((flags & PURPLE_MESSAGE_SYSTEM) == PURPLE_MESSAGE_SYSTEM) || + ((flags & PURPLE_MESSAGE_ERROR) == PURPLE_MESSAGE_ERROR)) + unseen = PIDGIN_UNSEEN_EVENT; + else if ((flags & PURPLE_MESSAGE_NO_LOG) == PURPLE_MESSAGE_NO_LOG) + unseen = PIDGIN_UNSEEN_NO_LOG; + else + unseen = PIDGIN_UNSEEN_TEXT; + + conv_set_unseen(conv, unseen); purple_conversation_update(conv, PURPLE_CONV_UPDATE_UNSEEN); } } @@ -7449,6 +7465,7 @@ return FALSE; purple_conversation_set_data(conv, "unseen-count", NULL); + purple_conversation_set_data(conv, "unseen-state", NULL); purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops()); private_gtkconv_new(conv, FALSE); gtkconv = PIDGIN_CONVERSATION(conv); @@ -7918,6 +7935,38 @@ } static void +conv_set_unseen(PurpleConversation *conv, PidginUnseenState state) +{ + int unseen_count = 0; + PidginUnseenState unseen_state = PIDGIN_UNSEEN_NONE; + + if(purple_conversation_get_data(conv, "unseen-count")) + unseen_count = GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count")); + + if(purple_conversation_get_data(conv, "unseen-state")) + unseen_state = GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-state")); + + if (state == PIDGIN_UNSEEN_NONE) + { + unseen_count = 0; + unseen_state = PIDGIN_UNSEEN_NONE; + } + else + { + if (state >= PIDGIN_UNSEEN_TEXT) + unseen_count++; + + if (state > unseen_state) + unseen_state = state; + } + + purple_conversation_set_data(conv, "unseen-count", GINT_TO_POINTER(unseen_count)); + purple_conversation_set_data(conv, "unseen-state", GINT_TO_POINTER(unseen_state)); + + purple_conversation_update(conv, PURPLE_CONV_UPDATE_UNSEEN); +} + +static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state) { if (state == PIDGIN_UNSEEN_NONE)