Commit 416ceddb authored by mathieui's avatar mathieui

Add the same pluggable "information element" to the PrivateTab

parent d01f6208
......@@ -1837,6 +1837,7 @@ class PrivateTab(ChatTab):
"""
message_type = 'chat'
plugin_commands = {}
additional_informations = {}
plugin_keys = {}
def __init__(self, name, nick):
ChatTab.__init__(self, name)
......@@ -1870,6 +1871,21 @@ class PrivateTab(ChatTab):
def general_jid(self):
return self.get_name()
@property
def nick(self):
return self.get_nick()
@staticmethod
def add_information_element(plugin_name, callback):
"""
Lets a plugin add its own information to the PrivateInfoWin
"""
PrivateTab.additional_informations[plugin_name] = callback
@staticmethod
def remove_information_element(plugin_name):
del PrivateTab.additional_informations[plugin_name]
def log_message(self, txt, nickname, time=None, typ=1):
"""
Log the messages in the archives.
......@@ -2019,13 +2035,13 @@ class PrivateTab(ChatTab):
self.resize()
log.debug(' TAB Refresh: %s',self.__class__.__name__)
self.text_win.refresh()
self.info_header.refresh(self.name, self.text_win, self.chatstate)
self.info_header.refresh(self.name, self.text_win, self.chatstate, PrivateTab.additional_informations)
self.info_win.refresh()
self.refresh_tab_win()
self.input.refresh()
def refresh_info_header(self):
self.info_header.refresh(self.name, self.text_win, self.chatstate)
self.info_header.refresh(self.name, self.text_win, self.chatstate, PrivateTab.additional_informations)
self.input.refresh()
def get_name(self):
......
......@@ -467,16 +467,25 @@ class PrivateInfoWin(InfoWin):
def __init__(self):
InfoWin.__init__(self)
def refresh(self, name, window, chatstate):
def refresh(self, name, window, chatstate, informations):
log.debug('Refresh: %s',self.__class__.__name__)
with g_lock:
self._win.erase()
self.write_room_name(name)
self.print_scroll_position(window)
self.write_chatstate(chatstate)
self.write_additional_informations(informations, name)
self.finish_line(get_theme().COLOR_INFORMATION_BAR)
self._refresh()
def write_additional_informations(self, informations, jid):
"""
Write all informations added by plugins by getting the
value returned by the callbacks.
"""
for key in informations:
self.addstr(informations[key](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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment