contact information buffer in the roster tab (yet empty)

parent 3ea295f8
...@@ -33,9 +33,15 @@ class Contact(object): ...@@ -33,9 +33,15 @@ class Contact(object):
def set_ask(self, ask): def set_ask(self, ask):
self._ask = ask self._ask = ask
def get_ask(self):
return self._ask
def set_subscription(self, sub): def set_subscription(self, sub):
self._subscription = sub self._subscription = sub
def get_subscription(self, sub):
return self._subscription
def get_jid(self): def get_jid(self):
return self._jid return self._jid
...@@ -52,6 +58,12 @@ class Contact(object): ...@@ -52,6 +58,12 @@ class Contact(object):
def get_presence(self): def get_presence(self):
return self._presence return self._presence
def get_status(self):
return self._status
def set__status(self, s):
self._status = s
def set_name(self, name): def set_name(self, name):
self._display_name = name self._display_name = name
......
...@@ -342,7 +342,7 @@ class Gui(object): ...@@ -342,7 +342,7 @@ class Gui(object):
if not jid.full: if not jid.full:
leave_msg = _('%(spec)s "[%(nick)s]" has left the room') % {'nick':from_nick.replace('"', '\\"'), 'spec':theme.CHAR_QUIT.replace('"', '\\"')} leave_msg = _('%(spec)s "[%(nick)s]" has left the room') % {'nick':from_nick.replace('"', '\\"'), 'spec':theme.CHAR_QUIT.replace('"', '\\"')}
else: else:
leave_msg = _('%(spec)s "[%(nick)s]" (%(jid)s) has left the room') % {'spec':theme.CHAR_QUIT.replace('"', '\\"'), 'nick':from_nick.replace('"', '\\"'), 'jid':jid.full.replace('"', '\\"')} leave_msg = _('%(spec)s "[%(nick)s]" "(%(jid)s)" has left the room') % {'spec':theme.CHAR_QUIT.replace('"', '\\"'), 'nick':from_nick.replace('"', '\\"'), 'jid':jid.full.replace('"', '\\"')}
if status: if status:
leave_msg += ' (%s)' % status leave_msg += ' (%s)' % status
self.add_message_to_text_buffer(room, leave_msg, colorized=True) self.add_message_to_text_buffer(room, leave_msg, colorized=True)
......
...@@ -32,7 +32,7 @@ class Room(TextBuffer): ...@@ -32,7 +32,7 @@ class Room(TextBuffer):
self.name = name self.name = name
self.own_nick = nick self.own_nick = nick
self.color_state = theme.COLOR_TAB_NORMAL # color used in RoomInfo self.color_state = theme.COLOR_TAB_NORMAL # color used in RoomInfo
self.joined = False # false until self presence is received self.joined = False # false until self presence is receied
self.users = [] # User objects self.users = [] # User objects
self.topic = '' self.topic = ''
......
...@@ -369,7 +369,8 @@ class RosterInfoTab(Tab): ...@@ -369,7 +369,8 @@ class RosterInfoTab(Tab):
self.v_separator = window.VerticalSeparator(self.height-2, 1, 0, roster_width, stdscr, self.visible) self.v_separator = window.VerticalSeparator(self.height-2, 1, 0, roster_width, stdscr, self.visible)
self.tab_win = window.GlobalInfoBar(1, self.width, self.height-2, 0, stdscr, self.visible) self.tab_win = window.GlobalInfoBar(1, self.width, self.height-2, 0, stdscr, self.visible)
self.info_win = window.TextWin(self.height-2, info_width, 0, roster_width+1, stdscr, self.visible) self.info_win = window.TextWin(self.height-2, info_width, 0, roster_width+1, stdscr, self.visible)
self.roster_win = window.RosterWin(self.height-2, roster_width, 0, 0, stdscr, self.visible) self.roster_win = window.RosterWin(self.height-2-3, roster_width, 0, 0, stdscr, self.visible)
self.contact_info_win = window.ContactInfoWin(3, roster_width, self.height-2-3, 0, stdscr, self.visible)
self.input = window.Input(1, self.width, self.height-1, 0, stdscr, self.visible) self.input = window.Input(1, self.width, self.height-1, 0, stdscr, self.visible)
self.set_color_state(theme.COLOR_TAB_NORMAL) self.set_color_state(theme.COLOR_TAB_NORMAL)
...@@ -380,11 +381,13 @@ class RosterInfoTab(Tab): ...@@ -380,11 +381,13 @@ class RosterInfoTab(Tab):
self.v_separator.resize(self.height-2, 1, 0, roster_width, stdscr, self.visible) self.v_separator.resize(self.height-2, 1, 0, roster_width, stdscr, self.visible)
self.tab_win.resize(1, self.width, self.height-2, 0, stdscr, self.visible) self.tab_win.resize(1, self.width, self.height-2, 0, stdscr, self.visible)
self.info_win.resize(self.height-2, info_width, 0, roster_width+1, stdscr, self.visible) self.info_win.resize(self.height-2, info_width, 0, roster_width+1, stdscr, self.visible)
self.roster_win.resize(self.height-2, roster_width, 0, 0, stdscr, self.visible) self.roster_win.resize(self.height-2-3, roster_width, 0, 0, stdscr, self.visible)
self.contact_info_win.resize(3, roster_width, self.height-2-3, 0, stdscr, self.visible)
self.input.resize(1, self.width, self.height-1, 0, stdscr, self.visible) self.input.resize(1, self.width, self.height-1, 0, stdscr, self.visible)
def refresh(self, tabs, informations, roster): def refresh(self, tabs, informations, roster):
self.roster_win.refresh(roster) self.roster_win.refresh(roster)
self.contact_info_win.refresh(self.roster_win.get_selected_row())
self.v_separator.refresh() self.v_separator.refresh()
self.info_win.refresh(informations) self.info_win.refresh(informations)
self.tab_win.refresh(tabs, tabs[0]) self.tab_win.refresh(tabs, tabs[0])
......
...@@ -157,11 +157,19 @@ if __name__ == '__main__': ...@@ -157,11 +157,19 @@ if __name__ == '__main__':
s = curses.initscr() s = curses.initscr()
curses.start_color() curses.start_color()
curses.use_default_colors() curses.use_default_colors()
for i in range(80): init_colors()
for i in range(64):
s.attron(curses.color_pair(i) | curses.A_BOLD)
s.addstr(str(curses.color_pair(i) | curses.A_BOLD))
s.attroff(curses.color_pair(i) | curses.A_BOLD)
s.addstr(' ')
s.addstr('\n')
for i in range(64):
s.attron(curses.color_pair(i)) s.attron(curses.color_pair(i))
s.addstr(str(i)) s.addstr(str(i))
s.attroff(curses.color_pair(i)) s.attroff(curses.color_pair(i))
s.addstr(' ') s.addstr(' ')
s.refresh() s.refresh()
s.getch() s.getch()
s.endwin() s.endwin()
...@@ -27,6 +27,9 @@ from config import config ...@@ -27,6 +27,9 @@ from config import config
from threading import Lock from threading import Lock
from contact import Contact
from roster import RosterGroup
from message import Line from message import Line
from tab import MIN_WIDTH, MIN_HEIGHT from tab import MIN_WIDTH, MIN_HEIGHT
...@@ -1071,3 +1074,38 @@ class RosterWin(Win): ...@@ -1071,3 +1074,38 @@ class RosterWin(Win):
def get_selected_row(self): def get_selected_row(self):
return self.selected_row return self.selected_row
class ContactInfoWin(Win):
def __init__(self, height, width, y, x, parent_win, visible):
self.visible = visible
Win.__init__(self, height, width, y, x, parent_win)
def resize(self, height, width, y, x, stdscr, visible):
self._resize(height, width, y, x, stdscr, visible)
self.visible = visible
def draw_contact_info(self, contact):
"""
draw the contact information
"""
self.addnstr(0, 0, contact.get_jid().full, len(contact.get_jid().full), curses.color_pair(theme.COLOR_INFORMATION_BAR))
self.addnstr(' (%s)'%(contact.get_presence(),), len(contact.get_presence())+3, curses.color_pair(theme.COLOR_INFORMATION_BAR))
self.finish_line(theme.COLOR_INFORMATION_BAR)
def draw_group_info(self, group):
"""
draw the group information
"""
self.addnstr(0, 0, group.name, len(group.name), curses.color_pair(theme.COLOR_INFORMATION_BAR))
self.finish_line(theme.COLOR_INFORMATION_BAR)
def refresh(self, selected_row):
if not self.visible:
return
g_lock.acquire()
self.win.erase()
if isinstance(selected_row, RosterGroup):
self.draw_group_info(selected_row)
elif isinstance(selected_row, Contact):
self.draw_contact_info(selected_row)
self.win.refresh()
g_lock.release()
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