add a limit to the number of lines displayed in conversation textview.
This commit is contained in:
parent
ddd7c13e16
commit
fb3eeb4a40
|
@ -228,6 +228,7 @@ class Config:
|
||||||
'scroll_roster_to_last_message': [opt_bool, True, _('If True, Gajim will scroll and select the contact who sent you the last message, if chat window is not already opened.')],
|
'scroll_roster_to_last_message': [opt_bool, True, _('If True, Gajim will scroll and select the contact who sent you the last message, if chat window is not already opened.')],
|
||||||
'use_latex': [opt_bool, False, _('If True, Gajim will convert string between $$ and $$ to an image using dvips and convert before insterting it in chat window.')],
|
'use_latex': [opt_bool, False, _('If True, Gajim will convert string between $$ and $$ to an image using dvips and convert before insterting it in chat window.')],
|
||||||
'change_status_window_timeout': [opt_int, 15, _('Time of inactivity needed before the change status window closes down.')],
|
'change_status_window_timeout': [opt_int, 15, _('Time of inactivity needed before the change status window closes down.')],
|
||||||
|
'max_conversation_lines': [opt_int, 500, _('Maximum number of lines that are printed in conversations. Oldest lines are cleared.')],
|
||||||
}
|
}
|
||||||
|
|
||||||
__options_per_key = {
|
__options_per_key = {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import os
|
||||||
import tooltips
|
import tooltips
|
||||||
import dialogs
|
import dialogs
|
||||||
import locale
|
import locale
|
||||||
|
import Queue
|
||||||
|
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
@ -141,6 +142,10 @@ class ConversationTextview:
|
||||||
|
|
||||||
buffer.create_tag('focus-out-line', justification = gtk.JUSTIFY_CENTER)
|
buffer.create_tag('focus-out-line', justification = gtk.JUSTIFY_CENTER)
|
||||||
|
|
||||||
|
size = gajim.config.get('max_conversation_lines')
|
||||||
|
size = 2 * size - 1
|
||||||
|
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 the iter's offset which points to the end of --- line
|
||||||
self.focus_out_end_iter_offset = None
|
self.focus_out_end_iter_offset = None
|
||||||
|
@ -315,6 +320,9 @@ class ConversationTextview:
|
||||||
buffer = self.tv.get_buffer()
|
buffer = self.tv.get_buffer()
|
||||||
start, end = buffer.get_bounds()
|
start, end = buffer.get_bounds()
|
||||||
buffer.delete(start, end)
|
buffer.delete(start, end)
|
||||||
|
size = gajim.config.get('max_conversation_lines')
|
||||||
|
size = 2 * size - 1
|
||||||
|
self.marks_queue = Queue.Queue(size)
|
||||||
self.focus_out_end_iter_offset = None
|
self.focus_out_end_iter_offset = None
|
||||||
|
|
||||||
def visit_url_from_menuitem(self, widget, link):
|
def visit_url_from_menuitem(self, widget, link):
|
||||||
|
@ -767,13 +775,29 @@ class ConversationTextview:
|
||||||
'''prints 'chat' type messages'''
|
'''prints 'chat' type messages'''
|
||||||
buffer = self.tv.get_buffer()
|
buffer = self.tv.get_buffer()
|
||||||
buffer.begin_user_action()
|
buffer.begin_user_action()
|
||||||
|
if self.marks_queue.full():
|
||||||
|
# remove oldest line
|
||||||
|
m1 = self.marks_queue.get()
|
||||||
|
m2 = self.marks_queue.get()
|
||||||
|
i1 = buffer.get_iter_at_mark(m1)
|
||||||
|
i2 = buffer.get_iter_at_mark(m2)
|
||||||
|
buffer.delete(i1, i2)
|
||||||
|
buffer.delete_mark(m1)
|
||||||
end_iter = buffer.get_end_iter()
|
end_iter = buffer.get_end_iter()
|
||||||
at_the_end = False
|
at_the_end = False
|
||||||
if self.at_the_end():
|
if self.at_the_end():
|
||||||
at_the_end = True
|
at_the_end = True
|
||||||
|
|
||||||
|
# Create one mark and add it to queue once if it's the first line
|
||||||
|
# else twice (one for end bound, one for start bound)
|
||||||
|
mark = None
|
||||||
if buffer.get_char_count() > 0:
|
if buffer.get_char_count() > 0:
|
||||||
buffer.insert_with_tags_by_name(end_iter, '\n', 'eol')
|
buffer.insert_with_tags_by_name(end_iter, '\n', 'eol')
|
||||||
|
mark = buffer.create_mark(None, end_iter, left_gravity=True)
|
||||||
|
self.marks_queue.put(mark)
|
||||||
|
if not mark:
|
||||||
|
mark = buffer.create_mark(None, end_iter, left_gravity=True)
|
||||||
|
self.marks_queue.put(mark)
|
||||||
if kind == 'incoming_queue':
|
if kind == 'incoming_queue':
|
||||||
kind = 'incoming'
|
kind = 'incoming'
|
||||||
if old_kind == 'incoming_queue':
|
if old_kind == 'incoming_queue':
|
||||||
|
|
Loading…
Reference in New Issue