fix the removal of focus_out_line in groupchat since we remove old lines in textview

This commit is contained in:
Yann Leboulanger 2007-08-07 13:13:49 +00:00
parent 3b52e0d73b
commit ea015ac5e2
1 changed files with 14 additions and 10 deletions

View File

@ -142,13 +142,14 @@ class ConversationTextview:
buffer.create_tag('focus-out-line', justification = gtk.JUSTIFY_CENTER) buffer.create_tag('focus-out-line', justification = gtk.JUSTIFY_CENTER)
# One mark at the begining then 2 marks between each lines
size = gajim.config.get('max_conversation_lines') size = gajim.config.get('max_conversation_lines')
size = 2 * size - 1 size = 2 * size - 1
self.marks_queue = Queue.Queue(size) self.marks_queue = Queue.Queue(size)
self.allow_focus_out_line = True self.allow_focus_out_line = True
# holds the iter's offset which points to the end of --- line # holds a mark at the end of --- line
self.focus_out_end_iter_offset = None self.focus_out_end_mark = None
self.line_tooltip = tooltips.BaseTooltip() self.line_tooltip = tooltips.BaseTooltip()
# use it for hr too # use it for hr too
@ -218,13 +219,14 @@ class ConversationTextview:
print_focus_out_line = False print_focus_out_line = False
buffer = self.tv.get_buffer() buffer = self.tv.get_buffer()
if self.focus_out_end_iter_offset is None: if self.focus_out_end_mark is None:
# this happens only first time we focus out on this room # this happens only first time we focus out on this room
print_focus_out_line = True print_focus_out_line = True
else: else:
if self.focus_out_end_iter_offset != buffer.get_end_iter().\ focus_out_end_iter = buffer.get_iter_at_mark(self.focus_out_end_mark)
get_offset(): focus_out_end_iter_offset = focus_out_end_iter.get_offset()
if focus_out_end_iter_offset != buffer.get_end_iter().get_offset():
# this means after last-focus something was printed # this means after last-focus something was printed
# (else end_iter's offset is the same as before) # (else end_iter's offset is the same as before)
# only then print ---- line (eg. we avoid printing many following # only then print ---- line (eg. we avoid printing many following
@ -235,9 +237,9 @@ class ConversationTextview:
buffer.begin_user_action() buffer.begin_user_action()
# remove previous focus out line if such focus out line exists # remove previous focus out line if such focus out line exists
if self.focus_out_end_iter_offset is not None: if self.focus_out_end_mark is not None:
end_iter_for_previous_line = buffer.get_iter_at_offset( end_iter_for_previous_line = buffer.get_iter_at_mark(
self.focus_out_end_iter_offset) self.focus_out_end_mark)
begin_iter_for_previous_line = end_iter_for_previous_line.copy() begin_iter_for_previous_line = end_iter_for_previous_line.copy()
# img_char+1 (the '\n') # img_char+1 (the '\n')
begin_iter_for_previous_line.backward_chars(2) begin_iter_for_previous_line.backward_chars(2)
@ -245,6 +247,7 @@ class ConversationTextview:
# remove focus out line # remove focus out line
buffer.delete(begin_iter_for_previous_line, buffer.delete(begin_iter_for_previous_line,
end_iter_for_previous_line) end_iter_for_previous_line)
buffer.delete_mark(self.focus_out_end_mark)
# add the new focus out line # add the new focus out line
end_iter = buffer.get_end_iter() end_iter = buffer.get_end_iter()
@ -260,7 +263,8 @@ class ConversationTextview:
self.allow_focus_out_line = False self.allow_focus_out_line = False
# update the iter we hold to make comparison the next time # update the iter we hold to make comparison the next time
self.focus_out_end_iter_offset = buffer.get_end_iter().get_offset() self.focus_out_end_mark = buffer.create_mark(None,
buffer.get_end_iter(), left_gravity=True)
buffer.end_user_action() buffer.end_user_action()
@ -323,7 +327,7 @@ class ConversationTextview:
size = gajim.config.get('max_conversation_lines') size = gajim.config.get('max_conversation_lines')
size = 2 * size - 1 size = 2 * size - 1
self.marks_queue = Queue.Queue(size) self.marks_queue = Queue.Queue(size)
self.focus_out_end_iter_offset = None self.focus_out_end_mark = None
def visit_url_from_menuitem(self, widget, link): def visit_url_from_menuitem(self, widget, link):
'''basically it filters out the widget instance''' '''basically it filters out the widget instance'''