diff options
-rw-r--r-- | src/contact.py | 12 | ||||
-rw-r--r-- | src/gui.py | 2 | ||||
-rw-r--r-- | src/room.py | 2 | ||||
-rw-r--r-- | src/tab.py | 7 | ||||
-rw-r--r-- | src/theme.py | 10 | ||||
-rw-r--r-- | src/window.py | 38 |
6 files changed, 66 insertions, 5 deletions
diff --git a/src/contact.py b/src/contact.py index 39ec9715..435251a7 100644 --- a/src/contact.py +++ b/src/contact.py @@ -33,9 +33,15 @@ class Contact(object): def set_ask(self, ask): self._ask = ask + def get_ask(self): + return self._ask + def set_subscription(self, sub): self._subscription = sub + def get_subscription(self, sub): + return self._subscription + def get_jid(self): return self._jid @@ -52,6 +58,12 @@ class Contact(object): def get_presence(self): return self._presence + def get_status(self): + return self._status + + def set__status(self, s): + self._status = s + def set_name(self, name): self._display_name = name @@ -342,7 +342,7 @@ class Gui(object): if not jid.full: leave_msg = _('%(spec)s "[%(nick)s]" has left the room') % {'nick':from_nick.replace('"', '\\"'), 'spec':theme.CHAR_QUIT.replace('"', '\\"')} 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: leave_msg += ' (%s)' % status self.add_message_to_text_buffer(room, leave_msg, colorized=True) diff --git a/src/room.py b/src/room.py index cb6fbe43..adc2c44f 100644 --- a/src/room.py +++ b/src/room.py @@ -32,7 +32,7 @@ class Room(TextBuffer): self.name = name self.own_nick = nick 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.topic = '' @@ -369,7 +369,8 @@ class RosterInfoTab(Tab): 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.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.set_color_state(theme.COLOR_TAB_NORMAL) @@ -380,11 +381,13 @@ class RosterInfoTab(Tab): 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.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) def refresh(self, tabs, informations, roster): self.roster_win.refresh(roster) + self.contact_info_win.refresh(self.roster_win.get_selected_row()) self.v_separator.refresh() self.info_win.refresh(informations) self.tab_win.refresh(tabs, tabs[0]) diff --git a/src/theme.py b/src/theme.py index 7285ceb0..f4c5af48 100644 --- a/src/theme.py +++ b/src/theme.py @@ -157,11 +157,19 @@ if __name__ == '__main__': s = curses.initscr() curses.start_color() 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.addstr(str(i)) s.attroff(curses.color_pair(i)) s.addstr(' ') + s.refresh() s.getch() s.endwin() diff --git a/src/window.py b/src/window.py index c10d3388..6f97f660 100644 --- a/src/window.py +++ b/src/window.py @@ -27,6 +27,9 @@ from config import config from threading import Lock +from contact import Contact +from roster import RosterGroup + from message import Line from tab import MIN_WIDTH, MIN_HEIGHT @@ -1071,3 +1074,38 @@ class RosterWin(Win): def get_selected_row(self): 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() |