Refresh optimization on chatstates

This commit is contained in:
Florent Le Coz 2011-04-18 03:34:51 +02:00
parent 3aa6e891a5
commit d913e71513
2 changed files with 17 additions and 21 deletions

View file

@ -298,7 +298,8 @@ class Core(object):
return False
tab.chatstate = state
if tab == self.current_tab():
self.refresh_window()
tab.refresh_info_header()
self.doupdate()
return True
def on_chatstate_private_conversation(self, message, state):
@ -307,7 +308,8 @@ class Core(object):
return
tab.chatstate = state
if tab == self.current_tab():
self.refresh_window()
tab.refresh_info_header()
self.doupdate()
return True
def on_chatstate_groupchat_conversation(self, message, state):
@ -317,7 +319,9 @@ class Core(object):
if tab and tab.get_room() and tab.get_room().get_user_by_name(nick):
tab.get_room().get_user_by_name(nick).chatstate = state
if tab == self.current_tab():
self.refresh_window()
tab.user_win.refresh(tab._room.users)
tab.input.refresh()
self.doupdate()
def open_new_form(self, form, on_cancel, on_send, **kwargs):
"""
@ -510,7 +514,7 @@ class Core(object):
if conversation is self.current_tab():
self.refresh_window()
else:
self.current_tab().tab_win.refresh()
self.refresh_tab_win()
def focus_tab_named(self, tab_name):
for tab in self.tabs:
@ -558,7 +562,7 @@ class Core(object):
logger.log_message(jid.bare, remote_nick, body)
if self.current_tab() is not conversation:
conversation.set_color_state(theme.COLOR_TAB_PRIVATE)
self.current_tab().tab_win.refresh()
self.refresh_tab_win()
else:
self.refresh_window()
@ -1434,5 +1438,4 @@ class Core(object):
def doupdate(self):
if not self.running:
return
self.current_tab().just_before_refresh()
curses.doupdate()

View file

@ -420,9 +420,6 @@ class InfoTab(ChatTab):
def on_info_win_size_changed(self):
return
def just_before_refresh(self):
return
class MucTab(ChatTab):
"""
The tab containing a multi-user-chat room.
@ -766,9 +763,6 @@ class MucTab(ChatTab):
self.info_header.resize(1, self.width, self.height-3-self.core.information_win_size, 0)
self.user_win.resize(self.height-3-self.core.information_win_size-1, self.width-text_width-1, 1, text_width+1)
def just_before_refresh(self):
return
def handle_presence(self, presence):
from_nick = presence['from'].resource
from_room = presence['from'].bare
@ -1022,6 +1016,10 @@ class PrivateTab(ChatTab):
self.tab_win.refresh()
self.input.refresh()
def refresh_info_header(self):
self.info_header.refresh(self._room, self.text_win, self.chatstate)
self.input.refresh()
def get_color_state(self):
if self._room.color_state == theme.COLOR_TAB_NORMAL or\
self._room.color_state == theme.COLOR_TAB_CURRENT:
@ -1078,9 +1076,6 @@ class PrivateTab(ChatTab):
def get_text_window(self):
return self.text_win
def just_before_refresh(self):
return
def rename_user(self, old_nick, new_nick):
"""
The user changed her nick in the corresponding muc: update the tabs name and
@ -1393,9 +1388,6 @@ class RosterInfoTab(Tab):
self.reset_help_message()
return False
def just_before_refresh(self):
return
def on_close(self):
return
@ -1467,6 +1459,10 @@ class ConversationTab(ChatTab):
self.tab_win.refresh()
self.input.refresh()
def refresh_info_header(self):
self.info_header.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()), self._room, self.text_win, self.chatstate)
self.input.refresh()
def get_color_state(self):
if self.color_state == theme.COLOR_TAB_NORMAL or\
self.color_state == theme.COLOR_TAB_CURRENT:
@ -1523,9 +1519,6 @@ class ConversationTab(ChatTab):
def get_text_window(self):
return self.text_win
def just_before_refresh(self):
return
def on_close(self):
Tab.on_close(self)
if config.get('send_chat_states', 'true') == 'true':