fix receiving highlighted corrected message. Fixes #7431

This commit is contained in:
Yann Leboulanger 2014-01-29 22:10:48 +01:00
parent a0ecc52e20
commit ff93ad5737
2 changed files with 42 additions and 4 deletions

View File

@ -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)

View File

@ -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