From ff93ad5737463c0f8f9a3f036b3bb4f82c94fa2a Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> Date: Wed, 29 Jan 2014 22:10:48 +0100 Subject: [PATCH] fix receiving highlighted corrected message. Fixes #7431 --- src/conversation_textview.py | 6 ++++-- src/groupchat_control.py | 40 ++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/conversation_textview.py b/src/conversation_textview.py index 5fc1962e1d..23fa8bf008 100644 --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -479,7 +479,8 @@ class ConversationTextview(GObject.GObject): self.last_sent_message_marks[1] = buffer_.create_mark(None, i2, left_gravity=True) - def correct_last_received_message(self, message, xhtml, name, old_txt): + def correct_last_received_message(self, message, xhtml, name, old_txt, + other_tags_for_name=[], other_tags_for_text=[]): if name not in self.last_received_message_marks: return m1 = self.last_received_message_marks[name][0] @@ -490,7 +491,8 @@ class ConversationTextview(GObject.GObject): txt = buffer_.get_text(i1, i2, True) buffer_.delete(i1, i2) i2 = self.print_conversation_line(message, '', 'incoming', name, None, - xhtml=xhtml, iter_=i1) + other_tags_for_name=other_tags_for_name, + other_tags_for_text=other_tags_for_text, xhtml=xhtml, iter_=i1) tt_txt = _('<b>Message was corrected. Last message was:</b>\n %s') % \ GLib.markup_escape_text(old_txt) self.show_corrected_message_warning(i2, tt_txt) diff --git a/src/groupchat_control.py b/src/groupchat_control.py index a9ab731467..6aeb17c80f 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -1035,8 +1035,44 @@ class GroupchatControl(ChatControlBase): obj.xhtml_msgtxt, obj.nick, old_txt) else: old_txt = self.last_received_txt[obj.nick] - self.conv_textview.correct_last_received_message(obj.msgtxt, - obj.xhtml_msgtxt, obj.nick, old_txt) + (highlight, sound) = self.highlighting_for_message(obj.msgtxt, obj.timestamp) + other_tags_for_name = [] + other_tags_for_text = [] + if obj.nick in self.gc_custom_colors: + other_tags_for_name.append('gc_nickname_color_' + \ + str(self.gc_custom_colors[obj.nick])) + else: + self.gc_count_nicknames_colors += 1 + if self.gc_count_nicknames_colors == \ + self.number_of_colors: + self.gc_count_nicknames_colors = 0 + self.gc_custom_colors[obj.nick] = \ + self.gc_count_nicknames_colors + other_tags_for_name.append('gc_nickname_color_' + \ + str(self.gc_count_nicknames_colors)) + if highlight: + # muc-specific chatstate + if self.parent_win: + self.parent_win.redraw_tab(self, 'attention') + else: + self.attention_flag = True + other_tags_for_name.append('bold') + other_tags_for_text.append('marked') + + if obj.nick in self.attention_list: + self.attention_list.remove(obj.nick) + elif len(self.attention_list) > 6: + self.attention_list.pop(0) # remove older + self.attention_list.append(obj.nick) + + if obj.msgtxt.startswith('/me ') or \ + obj.msgtxt.startswith('/me\n'): + other_tags_for_text.append('gc_nickname_color_' + \ + str(self.gc_custom_colors[obj.nick])) + self.conv_textview.correct_last_received_message( + obj.msgtxt, obj.xhtml_msgtxt, obj.nick, old_txt, + other_tags_for_name=other_tags_for_name, + other_tags_for_text=other_tags_for_text) self.last_received_txt[obj.nick] = obj.msgtxt self.last_received_id[obj.nick] = obj.stanza.getID() return -- GitLab