From d6bb19572e3a5557f1e125b68ec1676cced1448a Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Mon, 4 Oct 2010 00:27:40 +0000 Subject: contact information buffer in the roster tab (yet empty) --- src/contact.py | 12 ++++++++++++ src/gui.py | 2 +- src/room.py | 2 +- src/tab.py | 7 +++++-- src/theme.py | 10 +++++++++- src/window.py | 38 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 5 deletions(-) (limited to 'src') 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 diff --git a/src/gui.py b/src/gui.py index 4f647930..09e6f0f6 100644 --- a/src/gui.py +++ b/src/gui.py @@ -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 = '' diff --git a/src/tab.py b/src/tab.py index dadd2f7f..d5734941 100644 --- a/src/tab.py +++ b/src/tab.py @@ -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() -- cgit v1.2.3