Philipp Hörist pushed to branch gajim_0.16 at gajim / gajim
Commits: 67188cee by Philipp Hörist at 2016-12-19T19:23:33+01:00 Make chat_merge_consecutive_nickname work in GC - - - - - 6d76cfb2 by Philipp Hörist at 2016-12-24T09:03:54+01:00 Merge branch 'merge_nicks' into 'gajim_0.16' Make chat_merge_consecutive_nickname work in GC See merge request !8 - - - - - 2 changed files: - src/chat_control.py - src/conversation_textview.py Changes: ===================================== src/chat_control.py ===================================== --- a/src/chat_control.py +++ b/src/chat_control.py @@ -902,7 +902,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): def print_conversation_line(self, text, kind, name, tim, other_tags_for_name=[], other_tags_for_time=[], other_tags_for_text=[], - count_as_new=True, subject=None, old_kind=None, xhtml=None, simple=False, + count_as_new=True, subject=None, xhtml=None, simple=False, xep0184_id=None, graphics=True, displaymarking=None, msg_log_id=None, correct_id=None): """ @@ -933,7 +933,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): else: textview.print_conversation_line(text, jid, kind, name, tim, other_tags_for_name, other_tags_for_time, other_tags_for_text, - subject, old_kind, xhtml, simple=simple, graphics=graphics, + subject, xhtml, simple=simple, graphics=graphics, displaymarking=displaymarking) if xep0184_id is not None: @@ -1454,7 +1454,6 @@ class ChatControl(ChatControlBase): ) = range(5) TYPE_ID = message_control.TYPE_CHAT - old_msg_kind = None # last kind of the printed message # Set a command host to bound to. Every command given through a chat will be # processed with this command host. @@ -2577,13 +2576,9 @@ class ChatControl(ChatControlBase): if xhtml: xhtml = '<body xmlns="%s">%s</body>' % (NS_XHTML, xhtml) ChatControlBase.print_conversation_line(self, text, kind, name, tim, - subject=subject, old_kind=self.old_msg_kind, xhtml=xhtml, + subject=subject, xhtml=xhtml, simple=simple, xep0184_id=xep0184_id, displaymarking=displaymarking, msg_log_id=msg_log_id, correct_id=correct_id) - if text.startswith('/me ') or text.startswith('/me\n'): - self.old_msg_kind = None - else: - self.old_msg_kind = kind def get_tab_label(self, chatstate): unread = '' @@ -3008,7 +3003,6 @@ class ChatControl(ChatControlBase): _('The database file (%s) cannot be read. Try to repair it or ' 'remove it (all history will be lost).') % common.logger.LOG_DB_PATH) rows = [] - local_old_kind = None self.conv_textview.just_cleared = True for row in rows: # row[0] time, row[1] has kind, row[2] the message msg = row[2] @@ -3040,12 +3034,7 @@ class ChatControl(ChatControlBase): {'subject': row[3], 'message': msg} ChatControlBase.print_conversation_line(self, msg, kind, name, tim, small_attr, small_attr + ['restored_message'], - small_attr + ['restored_message'], False, - old_kind=local_old_kind, xhtml=xhtml) - if row[2].startswith('/me ') or row[2].startswith('/me\n'): - local_old_kind = None - else: - local_old_kind = kind + small_attr + ['restored_message'], False, xhtml=xhtml) if len(rows): self.conv_textview.print_empty_line() ===================================== src/conversation_textview.py ===================================== --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -218,6 +218,10 @@ class ConversationTextview(gobject.GObject): # It's True when we scroll in the code, so we can detect scroll from user self.auto_scrolling = False + # This holds the last Nickname we received a msg from + # for chat_merge_consecutive_nickname feature + self.last_msg_name = None + # connect signals id_ = self.tv.connect('motion_notify_event', self.on_textview_motion_notify_event) @@ -1228,7 +1232,7 @@ class ConversationTextview(gobject.GObject): def print_conversation_line(self, text, jid, kind, name, tim, other_tags_for_name=[], other_tags_for_time=[], other_tags_for_text=[], - subject=None, old_kind=None, xhtml=None, simple=False, graphics=True, + subject=None, xhtml=None, simple=False, graphics=True, displaymarking=None, iter_=None): """ Print 'chat' type messages @@ -1275,8 +1279,6 @@ class ConversationTextview(gobject.GObject): self.marks_queue.put(mark) if kind == 'incoming_queue': kind = 'incoming' - if old_kind == 'incoming_queue': - old_kind = 'incoming' # print the time stamp if not tim: # We don't have tim for outgoing messages... @@ -1325,13 +1327,20 @@ class ConversationTextview(gobject.GObject): mark1 = mark else: # not status nor /me if gajim.config.get('chat_merge_consecutive_nickname'): - if kind != old_kind or self.just_cleared: + if self.last_msg_name != name or self.just_cleared: + # Textview is empty or this is a msg from a new user + # Print the Nickname self.print_name(name, kind, other_tags_for_name, direction_mark=direction_mark, iter_=end_iter) else: + # The last message was from the same Nickname + # Dont print the Nickname self.print_real_text(gajim.config.get( 'chat_merge_consecutive_nickname_indent'), iter_=end_iter) + # Save the last Chatname so we know if we have to + # print the nickname on the next message + self.last_msg_name = name else: self.print_name(name, kind, other_tags_for_name, direction_mark=direction_mark, iter_=end_iter) View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/bb7e4a4366f77f94d5da6c367408872f62dadca5...6d76cfb2dd39bdbd7d5b4ec2f31ba68b0780cd4b
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits