diff options
Diffstat (limited to 'poezio/windows/info_wins.py')
-rw-r--r-- | poezio/windows/info_wins.py | 112 |
1 files changed, 77 insertions, 35 deletions
diff --git a/poezio/windows/info_wins.py b/poezio/windows/info_wins.py index 27f9e1cf..3a8d1863 100644 --- a/poezio/windows/info_wins.py +++ b/poezio/windows/info_wins.py @@ -20,6 +20,8 @@ class InfoWin(Win): MucInfoWin, etc. Provides some useful methods. """ + __slots__ = () + def __init__(self): Win.__init__(self) @@ -40,6 +42,8 @@ class XMLInfoWin(InfoWin): Info about the latest xml filter used and the state of the buffer. """ + __slots__ = () + def __init__(self): InfoWin.__init__(self) @@ -63,6 +67,8 @@ class PrivateInfoWin(InfoWin): about the MUC user we are talking to """ + __slots__ = () + def __init__(self): InfoWin.__init__(self) @@ -81,16 +87,17 @@ class PrivateInfoWin(InfoWin): Write all information added by plugins by getting the value returned by the callbacks. """ - for key in information: - self.addstr(information[key](jid), + for plugin in information.values(): + self.addstr(plugin(jid), to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) def write_room_name(self, name): jid = safeJID(name) room_name, nick = jid.bare, jid.resource - self.addstr(nick, to_curses_attr(get_theme().COLOR_PRIVATE_NAME)) + theme = get_theme() + self.addstr(nick, to_curses_attr(theme.COLOR_PRIVATE_NAME)) txt = ' from room %s' % room_name - self.addstr(txt, to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + self.addstr(txt, to_curses_attr(theme.COLOR_INFORMATION_BAR)) def write_chatstate(self, state): if state: @@ -104,6 +111,8 @@ class MucListInfoWin(InfoWin): about the muc server being listed """ + __slots__ = ('message') + def __init__(self, message=''): InfoWin.__init__(self) self.message = message @@ -111,15 +120,16 @@ class MucListInfoWin(InfoWin): def refresh(self, name=None, window=None): log.debug('Refresh: %s', self.__class__.__name__) self._win.erase() + theme = get_theme() if name: self.addstr(name, - to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + to_curses_attr(theme.COLOR_INFORMATION_BAR)) else: self.addstr(self.message, - to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + to_curses_attr(theme.COLOR_INFORMATION_BAR)) if window: self.print_scroll_position(window) - self.finish_line(get_theme().COLOR_INFORMATION_BAR) + self.finish_line(theme.COLOR_INFORMATION_BAR) self._refresh() @@ -129,6 +139,8 @@ class ConversationInfoWin(InfoWin): about the user we are talking to """ + __slots__ = () + def __init__(self): InfoWin.__init__(self) @@ -166,9 +178,9 @@ class ConversationInfoWin(InfoWin): Write all information added by plugins by getting the value returned by the callbacks. """ - for key in information: - self.addstr(information[key](jid), - to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + color = to_curses_attr(get_theme().COLOR_INFORMATION_BAR) + for plugin in information.values(): + self.addstr(plugin(jid), color) def write_resource_information(self, resource): """ @@ -178,38 +190,40 @@ class ConversationInfoWin(InfoWin): presence = "unavailable" else: presence = resource.presence - color = get_theme().color_show(presence) + theme = get_theme() + color = theme.color_show(presence) if not presence: - presence = get_theme().CHAR_STATUS - self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + presence = theme.CHAR_STATUS + self.addstr('[', to_curses_attr(theme.COLOR_INFORMATION_BAR)) self.addstr(presence, to_curses_attr(color)) if resource and resource.status: shortened = resource.status[:20] + (resource.status[:20] and '…') self.addstr(' %s' % shortened, - to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) - self.addstr(']', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + to_curses_attr(theme.COLOR_INFORMATION_BAR)) + self.addstr(']', to_curses_attr(theme.COLOR_INFORMATION_BAR)) def write_contact_information(self, contact): """ Write the information about the contact """ + color = to_curses_attr(get_theme().COLOR_INFORMATION_BAR) if not contact: - self.addstr("(contact not in roster)", - to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + self.addstr("(contact not in roster)", color) return display_name = contact.name if display_name: - self.addstr('%s ' % (display_name), - to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + self.addstr('%s ' % (display_name), color) def write_contact_jid(self, jid): """ Just write the jid that we are talking to """ - self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + theme = get_theme() + color = to_curses_attr(theme.COLOR_INFORMATION_BAR) + self.addstr('[', color) self.addstr(jid.full, - to_curses_attr(get_theme().COLOR_CONVERSATION_NAME)) - self.addstr('] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + to_curses_attr(theme.COLOR_CONVERSATION_NAME)) + self.addstr('] ', color) def write_chatstate(self, state): if state: @@ -218,20 +232,24 @@ class ConversationInfoWin(InfoWin): class DynamicConversationInfoWin(ConversationInfoWin): + __slots__ = () + def write_contact_jid(self, jid): """ Just displays the resource in an other color """ log.debug("write_contact_jid DynamicConversationInfoWin, jid: %s", jid.resource) - self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + theme = get_theme() + color = to_curses_attr(theme.COLOR_INFORMATION_BAR) + self.addstr('[', color) self.addstr(jid.bare, - to_curses_attr(get_theme().COLOR_CONVERSATION_NAME)) + to_curses_attr(theme.COLOR_CONVERSATION_NAME)) if jid.resource: self.addstr( "/%s" % (jid.resource, ), - to_curses_attr(get_theme().COLOR_CONVERSATION_RESOURCE)) - self.addstr('] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + to_curses_attr(theme.COLOR_CONVERSATION_RESOURCE)) + self.addstr('] ', color) class MucInfoWin(InfoWin): @@ -240,10 +258,12 @@ class MucInfoWin(InfoWin): about the MUC we are viewing """ + __slots__ = () + def __init__(self): InfoWin.__init__(self) - def refresh(self, room, window=None, user=None): + def refresh(self, room, window=None, user=None, information=None): log.debug('Refresh: %s', self.__class__.__name__) self._win.erase() self.write_room_name(room) @@ -251,23 +271,38 @@ class MucInfoWin(InfoWin): self.write_own_nick(room) self.write_disconnected(room) self.write_role(room, user) + if information: + self.write_additional_information(information, room.name) if window: self.print_scroll_position(window) self.finish_line(get_theme().COLOR_INFORMATION_BAR) self._refresh() + def write_additional_information(self, information, jid): + """ + Write all information added by plugins by getting the + value returned by the callbacks. + """ + color = to_curses_attr(get_theme().COLOR_INFORMATION_BAR) + for plugin in information.values(): + self.addstr(plugin(jid), color) + def write_room_name(self, room): - self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + theme = get_theme() + color = to_curses_attr(theme.COLOR_INFORMATION_BAR) + self.addstr('[', color) self.addstr(room.name, - to_curses_attr(get_theme().COLOR_GROUPCHAT_NAME)) - self.addstr(']', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + to_curses_attr(theme.COLOR_GROUPCHAT_NAME)) + self.addstr(']', color) def write_participants_number(self, room): - self.addstr('{', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + theme = get_theme() + color = to_curses_attr(theme.COLOR_INFORMATION_BAR) + self.addstr('{', color) self.addstr( str(len(room.users)), - to_curses_attr(get_theme().COLOR_GROUPCHAT_NAME)) - self.addstr('} ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) + to_curses_attr(theme.COLOR_GROUPCHAT_NAME)) + self.addstr('} ', color) def write_disconnected(self, room): """ @@ -306,6 +341,8 @@ class ConversationStatusMessageWin(InfoWin): The upper bar displaying the status message of the contact """ + __slots__ = () + def __init__(self): InfoWin.__init__(self) @@ -331,6 +368,8 @@ class ConversationStatusMessageWin(InfoWin): class BookmarksInfoWin(InfoWin): + __slots__ = () + def __init__(self): InfoWin.__init__(self) @@ -347,6 +386,8 @@ class BookmarksInfoWin(InfoWin): class ConfirmStatusWin(Win): + __slots__ = ('text', 'critical') + def __init__(self, text, critical=False): Win.__init__(self) self.text = text @@ -355,10 +396,11 @@ class ConfirmStatusWin(Win): def refresh(self): log.debug('Refresh: %s', self.__class__.__name__) self._win.erase() + theme = get_theme() if self.critical: - color = get_theme().COLOR_WARNING_PROMPT + color = theme.COLOR_WARNING_PROMPT else: - color = get_theme().COLOR_INFORMATION_BAR + color = theme.COLOR_INFORMATION_BAR c_color = to_curses_attr(color) self.addstr(self.text, c_color) self.finish_line(color) |