summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-04-18 02:27:46 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-04-18 02:27:46 +0200
commit78d8d3e74b6367257d3adad5fba45affb17b0a65 (patch)
tree380866e121c5d7d51a7a113b9f80aef42897dc59
parentda76355af0759a9265bec470a72af129d797fa04 (diff)
downloadpoezio-78d8d3e74b6367257d3adad5fba45affb17b0a65.tar.gz
poezio-78d8d3e74b6367257d3adad5fba45affb17b0a65.tar.bz2
poezio-78d8d3e74b6367257d3adad5fba45affb17b0a65.tar.xz
poezio-78d8d3e74b6367257d3adad5fba45affb17b0a65.zip
Great roster refresh optimization
-rw-r--r--src/tabs.py12
-rw-r--r--src/windows.py44
2 files changed, 27 insertions, 29 deletions
diff --git a/src/tabs.py b/src/tabs.py
index 5f11e1f0..2061c86e 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -1308,11 +1308,17 @@ class RosterInfoTab(Tab):
def move_cursor_down(self):
self.roster_win.move_cursor_down()
- return True
+ self.roster_win.refresh(roster)
+ self.contact_info_win.refresh(self.roster_win.get_selected_row())
+ self.input.refresh()
+ self.core.doupdate()
def move_cursor_up(self):
self.roster_win.move_cursor_up()
- return True
+ self.roster_win.refresh(roster)
+ self.contact_info_win.refresh(self.roster_win.get_selected_row())
+ self.input.refresh()
+ self.core.doupdate()
def move_cursor_to_prev_group(self):
self.roster_win.move_cursor_up()
@@ -1320,6 +1326,7 @@ class RosterInfoTab(Tab):
if not self.roster_win.move_cursor_up():
break
self.roster_win.refresh(roster)
+ self.contact_info_win.refresh(self.roster_win.get_selected_row())
self.input.refresh()
self.core.doupdate()
@@ -1329,6 +1336,7 @@ class RosterInfoTab(Tab):
if not self.roster_win.move_cursor_down():
break
self.roster_win.refresh(roster)
+ self.contact_info_win.refresh(self.roster_win.get_selected_row())
self.input.refresh()
self.core.doupdate()
diff --git a/src/windows.py b/src/windows.py
index f68162ae..f10c0853 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -175,6 +175,7 @@ class UserList(Win):
self.addstr(y, self.width-2, '++', common.curses_color_pair(theme.COLOR_MORE_INDICATOR))
def refresh(self, users):
+ log.debug('Refresh: %s'%self.__class__.__name__)
with g_lock:
self._win.erase()
y = 0
@@ -218,6 +219,7 @@ class Topic(Win):
self._message = ''
def refresh(self, topic=None):
+ log.debug('Refresh: %s'%self.__class__.__name__)
with g_lock:
self._win.erase()
if topic:
@@ -240,6 +242,7 @@ class GlobalInfoBar(Win):
Win.__init__(self)
def refresh(self):
+ log.debug('Refresh: %s'%self.__class__.__name__)
def compare_room(a):
return a.nb
comp = lambda x: x.nb
@@ -292,7 +295,7 @@ class PrivateInfoWin(InfoWin):
InfoWin.__init__(self)
def refresh(self, room, window, chatstate):
-
+ log.debug('Refresh: %s'%self.__class__.__name__)
with g_lock:
self._win.erase()
self.write_room_name(room)
@@ -334,6 +337,7 @@ class ConversationInfoWin(InfoWin):
# contact can be None, if we receive a message
# from someone not in our roster. In this case, we display
# only the maximum information from the message we can get.
+ log.debug('Refresh: %s'%self.__class__.__name__)
jid = JID(jid)
if contact:
if jid.resource:
@@ -400,6 +404,7 @@ class ConversationStatusMessageWin(InfoWin):
InfoWin.__init__(self)
def refresh(self, jid, contact):
+ log.debug('Refresh: %s'%self.__class__.__name__)
jid = JID(jid)
if contact:
if jid.resource:
@@ -427,6 +432,7 @@ class MucInfoWin(InfoWin):
InfoWin.__init__(self)
def refresh(self, room, window=None):
+ log.debug('Refresh: %s'%self.__class__.__name__)
with g_lock:
self._win.erase()
self.write_room_name(room)
@@ -590,10 +596,7 @@ class TextWin(Win):
return nb
def refresh(self, room):
- """
- Build the Line objects from the messages, and then write
- them in the text area
- """
+ log.debug('Refresh: %s'%self.__class__.__name__)
if self.height <= 0:
return
if self.pos == 0:
@@ -677,6 +680,7 @@ class HelpText(Win):
self.txt = text
def refresh(self, txt=None):
+ log.debug('Refresh: %s'%self.__class__.__name__)
if txt:
self.txt = txt
with g_lock:
@@ -1059,6 +1063,7 @@ class Input(Win):
self._refresh()
def refresh(self):
+ log.debug('Refresh: %s'%self.__class__.__name__)
self.rewrite_text()
def clear_text(self):
@@ -1244,6 +1249,7 @@ class VerticalSeparator(Win):
self._refresh()
def refresh(self):
+ log.debug('Refresh: %s'%self.__class__.__name__)
self.rewrite_line()
class RosterWin(Win):
@@ -1298,6 +1304,7 @@ class RosterWin(Win):
"""
We get the roster object
"""
+ log.debug('Refresh: %s'%self.__class__.__name__)
with g_lock:
self.roster_len = len(roster)
while self.roster_len and self.pos >= self.roster_len:
@@ -1429,28 +1436,7 @@ class RosterWin(Win):
self.finish_line()
def get_selected_row(self):
- y = 1
- for group in roster.get_groups():
- if config.get('roster_show_offline', 'false') == 'false' and group.get_nb_connected_contacts() == 0:
- continue # Ignore empty groups
- if y-1 == self.pos:
- return group
- y += 1
- if group.folded:
- continue
- for contact in group.get_contacts(roster._contact_filter):
- if config.get('roster_show_offline', 'false') == 'false' and\
- contact.get_nb_resources() == 0:
- continue
- if y-1 == self.pos:
- return contact
- y += 1
- if not contact._folded:
- for resource in contact.get_resources():
- if y-1 == self.pos:
- return resource
- y += 1
- return None
+ return self.selected_row
class ContactInfoWin(Win):
def __init__(self):
@@ -1488,6 +1474,7 @@ class ContactInfoWin(Win):
self.finish_line(theme.COLOR_INFORMATION_BAR)
def refresh(self, selected_row):
+ log.debug('Refresh: %s'%self.__class__.__name__)
with g_lock:
self._win.erase()
if isinstance(selected_row, RosterGroup):
@@ -1543,6 +1530,7 @@ class ListWin(Win):
return None
def refresh(self):
+ log.debug('Refresh: %s'%self.__class__.__name__)
with g_lock:
self._win.erase()
lines = self.lines[self._starting_pos:self._starting_pos+self.height]
@@ -1603,6 +1591,7 @@ class ColumnHeaderWin(Win):
self._columns_sizes = dic
def refresh(self):
+ log.debug('Refresh: %s'%self.__class__.__name__)
with g_lock:
self._win.erase()
x = 0
@@ -1642,6 +1631,7 @@ class SimpleTextWin(Win):
self.built_lines.append(line)
def refresh(self):
+ log.debug('Refresh: %s'%self.__class__.__name__)
with g_lock:
self._win.erase()
for y, line in enumerate(self.built_lines):