From 1ac9feb35ad294d9011ea319b0e6f5db35046a84 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 2 Jun 2005 19:38:22 +0000 Subject: [PATCH] we now print the restored conversation in small (I think it's not enough and we should print it grey too, comments ?) --- src/chat.py | 47 +++++++++++++++++---------------------- src/groupchat_window.py | 4 ++-- src/tabbed_chat_window.py | 3 ++- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/chat.py b/src/chat.py index 1d4526cf2..3d6321a29 100644 --- a/src/chat.py +++ b/src/chat.py @@ -265,6 +265,9 @@ class Chat: tag.set_property('scale', pango.SCALE_SMALL) tag.set_property('justification', gtk.JUSTIFY_CENTER) + tag = conversation_buffer.create_tag('small') + tag.set_property('scale', pango.SCALE_SMALL) + tag = conversation_buffer.create_tag('url') tag.set_property('foreground', '#0000ff') tag.set_property('underline', pango.UNDERLINE_SINGLE) @@ -546,8 +549,7 @@ class Chat: buffer.apply_tag_by_name(tag, begin_tagged, iter) buffer.delete_mark(begin_mark) - def detect_and_print_special_text(self, otext, jid, other_tags, - print_all_special): + def detect_and_print_special_text(self, otext, jid, other_tags): textview = self.xmls[jid].get_widget('conversation_textview') buffer = textview.get_buffer() @@ -566,15 +568,8 @@ class Chat: if start != 0: text_before_special_text = otext[index:start] end_iter = buffer.get_end_iter() - if print_all_special: - self.print_with_tag_list(buffer, - text_before_special_text, - end_iter, other_tags) - else: - buffer.insert(end_iter, - text_before_special_text) - if not print_all_special: - other_tags = [] + self.print_with_tag_list(buffer, text_before_special_text, + end_iter, other_tags) index = end # update index #now print it @@ -654,10 +649,10 @@ class Chat: return False def print_conversation_line(self, text, jid, kind, name, tim, - other_tags_for_name = []): + other_tags_for_name = [], other_tags_for_time = [], + other_tags_for_text = []): textview = self.xmls[jid].get_widget('conversation_textview') buffer = textview.get_buffer() - print_all_special = False at_the_end = False end_iter = buffer.get_end_iter() end_rect = textview.get_iter_location(end_iter) @@ -675,36 +670,34 @@ class Chat: after_str = gajim.config.get('after_time') format = before_str + '%H:%M:%S' + after_str tim_format = time.strftime(format, tim) - buffer.insert(end_iter, tim_format + ' ') + self.print_with_tag_list(buffer, tim_format + ' ', end_iter, + other_tags_for_time) + text_tags = other_tags_for_text[:] if kind == 'status': - print_all_special = True + text_tags.append(kind) elif text.startswith('/me ') or text.startswith('/me\n'): text = name + text[3:] - print_all_special = True + text_tags.append(kind) if kind == 'incoming': self.last_message_time[jid] = time.time() - tags = other_tags_for_name[:] #create a new list - tags.append(kind) - if name and not print_all_special: + if name and len(text_tags) == len(other_tags_for_text): + # not status nor /me + name_tags = other_tags_for_name[:] #create a new list + name_tags.append(kind) before_str = gajim.config.get('before_nickname') after_str = gajim.config.get('after_nickname') format = before_str + name + after_str + ' ' - self.print_with_tag_list(buffer, format, end_iter, tags) + self.print_with_tag_list(buffer, format, end_iter, name_tags) # detect urls formatting and if the user has it on emoticons - index = self.detect_and_print_special_text(text, jid, - tags, print_all_special) + index = self.detect_and_print_special_text(text, jid, text_tags) # add the rest of text located in the index and after end_iter = buffer.get_end_iter() - if print_all_special: - buffer.insert_with_tags_by_name(end_iter, - text[index:], kind) - else: - buffer.insert(end_iter, text[index:]) + self.print_with_tag_list(buffer, text[index:], end_iter, text_tags) #scroll to the end of the textview end = False diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 9c9a5fd9b..08dc0a620 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -361,8 +361,8 @@ class Groupchat_window(chat.Chat): text.lower().split()): other_tags_for_name.append('bold') - chat.Chat.print_conversation_line(self, text, room_jid, kind, contact, tim, \ - other_tags_for_name) + chat.Chat.print_conversation_line(self, text, room_jid, kind, contact, + tim, other_tags_for_name) def kick(self, widget, room_jid, nick): """kick a user""" diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index 221113840..e586284d5 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -359,4 +359,5 @@ class Tabbed_chat_window(chat.Chat): tim = time.gmtime(float(msg[0])) text = ':'.join(msg[2:])[0:-1] #remove the latest \n - self.print_conversation_line(text, jid, kind, name, tim) + self.print_conversation_line(text, jid, kind, name, tim, + ['small'], ['small'], ['small'])