Changeset 6293

Show
Ignore:
Timestamp:
05/08/06 10:19:20 (3 years ago)
Author:
asterix
Message:

[Geobert] ability to remove nickname in chat when consecutive message from same person. Fixes #1942

Location:
trunk/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/chat_control.py

    r6271 r6293  
    455455        def print_conversation_line(self, text, kind, name, tim, 
    456456                other_tags_for_name = [], other_tags_for_time = [],  
    457                 other_tags_for_text = [], count_as_new = True, subject = None): 
     457                other_tags_for_text = [], count_as_new = True, 
     458                subject = None, old_kind = None): 
    458459                '''prints 'chat' type messages''' 
    459460                jid = self.contact.jid 
     
    464465                        end = True 
    465466                textview.print_conversation_line(text, jid, kind, name, tim, 
    466                         other_tags_for_name, other_tags_for_time, other_tags_for_text, subject) 
     467                        other_tags_for_name, other_tags_for_time, other_tags_for_text, 
     468                        subject, old_kind) 
    467469 
    468470                if not count_as_new: 
     
    706708        '''A control for standard 1-1 chat''' 
    707709        TYPE_ID = message_control.TYPE_CHAT 
    708  
     710        old_msg_kind = None # last kind of the printed message 
     711         
    709712        def __init__(self, parent_win, contact, acct, resource = None): 
    710713                ChatControlBase.__init__(self, self.TYPE_ID, parent_win, 'chat_child_vbox', 
     
    10961099                        else: 
    10971100                                kind = 'outgoing' 
    1098                                 name = gajim.nicks[self.account]  
     1101                                name = gajim.nicks[self.account] 
    10991102                ChatControlBase.print_conversation_line(self, text, kind, name, tim, 
    1100                         subject = subject) 
     1103                        subject = subject, old_kind = self.old_msg_kind) 
     1104                if text.startswith('/me ') or text.startswith('/me\n'): 
     1105                        self.old_msg_kind = None 
     1106                else: 
     1107                        self.old_msg_kind = kind 
    11011108 
    11021109        def get_tab_label(self, chatstate): 
     
    14441451                rows = gajim.logger.get_last_conversation_lines(jid, restore_how_many, 
    14451452                        pending_how_many, timeout) 
    1446                  
     1453                local_old_kind = None 
    14471454                for row in rows: # row[0] time, row[1] has kind, row[2] the message 
    14481455                        if not row[2]: # message is empty, we don't print it 
     
    14631470                                                                ['small', 'restored_message'], 
    14641471                                                                ['small', 'restored_message'], 
    1465                                                                 False) 
     1472                                                                False, old_kind = local_old_kind) 
     1473                        if row[2].startswith('/me ') or row[2].startswith('/me\n'): 
     1474                                local_old_kind = None 
     1475                        else: 
     1476                                local_old_kind = kind 
    14661477                if len(rows): 
    14671478                        self.conv_textview.print_empty_line() 
  • trunk/src/common/config.py

    r6272 r6293  
    199199                'hide_chat_banner': [opt_bool, False, _('Hides the banner in two persons chat window')], 
    200200                'hide_groupchat_occupants_list': [opt_bool, False, _('Hides the room occupants list in groupchat window')], 
     201                'chat_merge_consecutive_nickname': [opt_bool, False, _('Merge consecutive nickname in chat window')], 
     202                'chat_merge_consecutive_nickname_indent': [opt_str, '  ', _('Indentation when using merge consecutive nickame')], 
    201203        } 
    202204 
  • trunk/src/conversation_textview.py

    r6271 r6293  
    568568        def print_conversation_line(self, text, jid, kind, name, tim, 
    569569                        other_tags_for_name = [], other_tags_for_time = [], 
    570                         other_tags_for_text = [], subject = None): 
     570                        other_tags_for_text = [], subject = None, old_kind = None): 
    571571                '''prints 'chat' type messages''' 
    572572                # kind = info, we print things as if it was a status: same color, ... 
     
    584584                if kind == 'incoming_queue': 
    585585                        kind = 'incoming' 
     586                if old_kind == 'incoming_queue': 
     587                        old_kind = 'incoming' 
    586588                # print the time stamp 
    587589                if not tim: 
    588590                        # We don't have tim for outgoing messages... 
    589591                        tim = time.localtime() 
    590                 if gajim.config.get('print_time') == 'always': 
     592                current_print_time = gajim.config.get('print_time') 
     593                if current_print_time == 'always': 
    591594                        before_str = gajim.config.get('before_time') 
    592595                        after_str = gajim.config.get('after_time') 
     
    612615                        buffer.insert_with_tags_by_name(end_iter, tim_format + ' ', 
    613616                                *other_tags_for_time) 
    614                 elif gajim.config.get('print_time') == 'sometimes': 
     617                elif current_print_time == 'sometimes': 
    615618                        every_foo_seconds = 60 * gajim.config.get( 
    616619                                'print_ichat_every_foo_minutes') 
     
    628631                        text_tags.append(other_text_tag) 
    629632                else: # not status nor /me 
    630                         self.print_name(name, kind, other_tags_for_name) 
     633                        if gajim.config.get( 
     634                                'chat_merge_consecutive_nickname'): 
     635                                if kind != old_kind: 
     636                                        self.print_name(name, kind, other_tags_for_name) 
     637                                else: 
     638                                        self.print_real_text(gajim.config.get( 
     639                                                'chat_merge_consecutive_nickname_indent')) 
     640                        else: 
     641                                self.print_name(name, kind, other_tags_for_name) 
    631642                self.print_subject(subject) 
    632643                self.print_real_text(text, text_tags, name)