Author: asterix
Date: 2006-05-08 10:19:20 +0200 (Mon, 08 May 2006)
New Revision: 6293
Modified:
trunk/src/chat_control.py
trunk/src/common/config.py
trunk/src/conversation_textview.py
Log:
[Geobert] ability to remove nickname in chat when consecutive message from same person. Fixes #1942
Modified: trunk/src/chat_control.py
===================================================================
--- trunk/src/chat_control.py 2006-05-08 08:15:37 UTC (rev 6292)
+++ trunk/src/chat_control.py 2006-05-08 08:19:20 UTC (rev 6293)
@@ -454,7 +454,8 @@
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 @@
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,7 +707,8 @@
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',
(_('Chat'), _('Chats')), contact, acct, resource)
@@ -1095,9 +1098,13 @@
name = contact.get_shown_name()
else:
kind = 'outgoing'
- name = gajim.nicks[self.account]
+ 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 @@
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 @@
['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()
Modified: trunk/src/common/config.py
===================================================================
--- trunk/src/common/config.py 2006-05-08 08:15:37 UTC (rev 6292)
+++ trunk/src/common/config.py 2006-05-08 08:19:20 UTC (rev 6293)
@@ -198,6 +198,8 @@
'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 = {
Modified: trunk/src/conversation_textview.py
===================================================================
--- trunk/src/conversation_textview.py 2006-05-08 08:15:37 UTC (rev 6292)
+++ trunk/src/conversation_textview.py 2006-05-08 08:19:20 UTC (rev 6293)
@@ -567,7 +567,7 @@
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 @@
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 @@
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,7 +630,15 @@
if other_text_tag:
text_tags.append(other_text_tag)
else: # not status nor /me
- self.print_name(name, kind, other_tags_for_name)
+ 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)