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

This commit is contained in:
Yann Leboulanger 2006-05-08 08:19:20 +00:00
parent b65cc5b37f
commit 5942399214
3 changed files with 35 additions and 11 deletions

View File

@ -454,7 +454,8 @@ class ChatControlBase(MessageControl):
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):
other_tags_for_text = [], count_as_new = True,
subject = None, old_kind = None):
'''prints 'chat' type messages'''
jid = self.contact.jid
full_jid = self.get_full_jid()
@ -463,7 +464,8 @@ class ChatControlBase(MessageControl):
if textview.at_the_end() or kind == 'outgoing':
end = True
textview.print_conversation_line(text, jid, kind, name, tim,
other_tags_for_name, other_tags_for_time, other_tags_for_text, subject)
other_tags_for_name, other_tags_for_time, other_tags_for_text,
subject, old_kind)
if not count_as_new:
return
@ -705,6 +707,7 @@ class ChatControlBase(MessageControl):
class ChatControl(ChatControlBase):
'''A control for standard 1-1 chat'''
TYPE_ID = message_control.TYPE_CHAT
old_msg_kind = None # last kind of the printed message
def __init__(self, parent_win, contact, acct, resource = None):
ChatControlBase.__init__(self, self.TYPE_ID, parent_win, 'chat_child_vbox',
@ -1097,7 +1100,11 @@ class ChatControl(ChatControlBase):
kind = 'outgoing'
name = gajim.nicks[self.account]
ChatControlBase.print_conversation_line(self, text, kind, name, tim,
subject = subject)
subject = subject, old_kind = self.old_msg_kind)
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 = ''
@ -1443,7 +1450,7 @@ class ChatControl(ChatControlBase):
rows = gajim.logger.get_last_conversation_lines(jid, restore_how_many,
pending_how_many, timeout)
local_old_kind = None
for row in rows: # row[0] time, row[1] has kind, row[2] the message
if not row[2]: # message is empty, we don't print it
continue
@ -1462,7 +1469,11 @@ class ChatControl(ChatControlBase):
['small'],
['small', 'restored_message'],
['small', 'restored_message'],
False)
False, old_kind = local_old_kind)
if row[2].startswith('/me ') or row[2].startswith('/me\n'):
local_old_kind = None
else:
local_old_kind = kind
if len(rows):
self.conv_textview.print_empty_line()

View File

@ -198,6 +198,8 @@ class Config:
'hide_groupchat_banner': [opt_bool, False, _('Hides the banner in a group chat window')],
'hide_chat_banner': [opt_bool, False, _('Hides the banner in two persons chat window')],
'hide_groupchat_occupants_list': [opt_bool, False, _('Hides the room occupants list in groupchat window')],
'chat_merge_consecutive_nickname': [opt_bool, False, _('Merge consecutive nickname in chat window')],
'chat_merge_consecutive_nickname_indent': [opt_str, ' ', _('Indentation when using merge consecutive nickame')],
}
__options_per_key = {

View File

@ -567,7 +567,7 @@ class ConversationTextview:
def print_conversation_line(self, text, jid, kind, name, tim,
other_tags_for_name = [], other_tags_for_time = [],
other_tags_for_text = [], subject = None):
other_tags_for_text = [], subject = None, old_kind = None):
'''prints 'chat' type messages'''
# kind = info, we print things as if it was a status: same color, ...
if kind == 'info':
@ -583,11 +583,14 @@ class ConversationTextview:
buffer.insert(end_iter, '\n')
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...
tim = time.localtime()
if gajim.config.get('print_time') == 'always':
current_print_time = gajim.config.get('print_time')
if current_print_time == 'always':
before_str = gajim.config.get('before_time')
after_str = gajim.config.get('after_time')
# get difference in days since epoch (86400 = 24*3600)
@ -611,7 +614,7 @@ class ConversationTextview:
tim_format = time.strftime(format, tim).encode('utf-8')
buffer.insert_with_tags_by_name(end_iter, tim_format + ' ',
*other_tags_for_time)
elif gajim.config.get('print_time') == 'sometimes':
elif current_print_time == 'sometimes':
every_foo_seconds = 60 * gajim.config.get(
'print_ichat_every_foo_minutes')
seconds_passed = time.mktime(tim) - self.last_time_printout
@ -627,6 +630,14 @@ class ConversationTextview:
if other_text_tag:
text_tags.append(other_text_tag)
else: # not status nor /me
if gajim.config.get(
'chat_merge_consecutive_nickname'):
if kind != old_kind:
self.print_name(name, kind, other_tags_for_name)
else:
self.print_real_text(gajim.config.get(
'chat_merge_consecutive_nickname_indent'))
else:
self.print_name(name, kind, other_tags_for_name)
self.print_subject(subject)
self.print_real_text(text, text_tags, name)