we now print the restored conversation in small (I think it's not enough and we should print it grey too, comments ?)

This commit is contained in:
Yann Leboulanger 2005-06-02 19:38:22 +00:00
parent 5e793a252c
commit 1ac9feb35a
3 changed files with 24 additions and 30 deletions

View File

@ -265,6 +265,9 @@ class Chat:
tag.set_property('scale', pango.SCALE_SMALL) tag.set_property('scale', pango.SCALE_SMALL)
tag.set_property('justification', gtk.JUSTIFY_CENTER) 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 = conversation_buffer.create_tag('url')
tag.set_property('foreground', '#0000ff') tag.set_property('foreground', '#0000ff')
tag.set_property('underline', pango.UNDERLINE_SINGLE) tag.set_property('underline', pango.UNDERLINE_SINGLE)
@ -546,8 +549,7 @@ class Chat:
buffer.apply_tag_by_name(tag, begin_tagged, iter) buffer.apply_tag_by_name(tag, begin_tagged, iter)
buffer.delete_mark(begin_mark) buffer.delete_mark(begin_mark)
def detect_and_print_special_text(self, otext, jid, other_tags, def detect_and_print_special_text(self, otext, jid, other_tags):
print_all_special):
textview = self.xmls[jid].get_widget('conversation_textview') textview = self.xmls[jid].get_widget('conversation_textview')
buffer = textview.get_buffer() buffer = textview.get_buffer()
@ -566,15 +568,8 @@ class Chat:
if start != 0: if start != 0:
text_before_special_text = otext[index:start] text_before_special_text = otext[index:start]
end_iter = buffer.get_end_iter() end_iter = buffer.get_end_iter()
if print_all_special: self.print_with_tag_list(buffer, text_before_special_text,
self.print_with_tag_list(buffer,
text_before_special_text,
end_iter, other_tags) end_iter, other_tags)
else:
buffer.insert(end_iter,
text_before_special_text)
if not print_all_special:
other_tags = []
index = end # update index index = end # update index
#now print it #now print it
@ -654,10 +649,10 @@ class Chat:
return False return False
def print_conversation_line(self, text, jid, kind, name, tim, 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') textview = self.xmls[jid].get_widget('conversation_textview')
buffer = textview.get_buffer() buffer = textview.get_buffer()
print_all_special = False
at_the_end = False at_the_end = False
end_iter = buffer.get_end_iter() end_iter = buffer.get_end_iter()
end_rect = textview.get_iter_location(end_iter) end_rect = textview.get_iter_location(end_iter)
@ -675,36 +670,34 @@ class Chat:
after_str = gajim.config.get('after_time') after_str = gajim.config.get('after_time')
format = before_str + '%H:%M:%S' + after_str format = before_str + '%H:%M:%S' + after_str
tim_format = time.strftime(format, tim) 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': if kind == 'status':
print_all_special = True text_tags.append(kind)
elif text.startswith('/me ') or text.startswith('/me\n'): elif text.startswith('/me ') or text.startswith('/me\n'):
text = name + text[3:] text = name + text[3:]
print_all_special = True text_tags.append(kind)
if kind == 'incoming': if kind == 'incoming':
self.last_message_time[jid] = time.time() self.last_message_time[jid] = time.time()
tags = other_tags_for_name[:] #create a new list if name and len(text_tags) == len(other_tags_for_text):
tags.append(kind) # not status nor /me
if name and not print_all_special: name_tags = other_tags_for_name[:] #create a new list
name_tags.append(kind)
before_str = gajim.config.get('before_nickname') before_str = gajim.config.get('before_nickname')
after_str = gajim.config.get('after_nickname') after_str = gajim.config.get('after_nickname')
format = before_str + name + after_str + ' ' 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 # detect urls formatting and if the user has it on emoticons
index = self.detect_and_print_special_text(text, jid, index = self.detect_and_print_special_text(text, jid, text_tags)
tags, print_all_special)
# add the rest of text located in the index and after # add the rest of text located in the index and after
end_iter = buffer.get_end_iter() end_iter = buffer.get_end_iter()
if print_all_special: self.print_with_tag_list(buffer, text[index:], end_iter, text_tags)
buffer.insert_with_tags_by_name(end_iter,
text[index:], kind)
else:
buffer.insert(end_iter, text[index:])
#scroll to the end of the textview #scroll to the end of the textview
end = False end = False

View File

@ -361,8 +361,8 @@ class Groupchat_window(chat.Chat):
text.lower().split()): text.lower().split()):
other_tags_for_name.append('bold') other_tags_for_name.append('bold')
chat.Chat.print_conversation_line(self, text, room_jid, kind, contact, tim, \ chat.Chat.print_conversation_line(self, text, room_jid, kind, contact,
other_tags_for_name) tim, other_tags_for_name)
def kick(self, widget, room_jid, nick): def kick(self, widget, room_jid, nick):
"""kick a user""" """kick a user"""

View File

@ -359,4 +359,5 @@ class Tabbed_chat_window(chat.Chat):
tim = time.gmtime(float(msg[0])) tim = time.gmtime(float(msg[0]))
text = ':'.join(msg[2:])[0:-1] #remove the latest \n 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'])