diff options
author | mathieui <mathieui@mathieui.net> | 2011-11-05 19:35:24 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2011-11-05 19:35:24 +0100 |
commit | 4a8ef778399e652c304a82cd3b326d4f604f05d6 (patch) | |
tree | 02ac2d450da97366a3ca05de32f68d590e8f6511 /src/room.py | |
parent | fc77f2d1d0e93d3b2c88e53d8c33d14db13f88a9 (diff) | |
download | poezio-4a8ef778399e652c304a82cd3b326d4f604f05d6.tar.gz poezio-4a8ef778399e652c304a82cd3b326d4f604f05d6.tar.bz2 poezio-4a8ef778399e652c304a82cd3b326d4f604f05d6.tar.xz poezio-4a8ef778399e652c304a82cd3b326d4f604f05d6.zip |
Partial fix to #2266 and #2255 (removes the idea of "color state" and
adds state, that are computed to the current theme color)
Diffstat (limited to 'src/room.py')
-rw-r--r-- | src/room.py | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/room.py b/src/room.py index b97dd0b6..ad52451c 100644 --- a/src/room.py +++ b/src/room.py @@ -24,7 +24,7 @@ class Room(TextBuffer): TextBuffer.__init__(self, messages_nb_limit) self.name = name self.own_nick = nick - self.color_state = get_theme().COLOR_TAB_NORMAL # color used in RoomInfo + self.state = 'normal' # color used in RoomInfo self.joined = False # false until self presence is receied self.users = [] # User objects self.topic = '' @@ -35,7 +35,7 @@ class Room(TextBuffer): we can know if we can join it, send messages to it, etc """ self.users = [] - self.color_state = get_theme().COLOR_TAB_DISCONNECTED + self.state = 'disconnected' self.joined = False def get_single_line_topic(self): @@ -59,15 +59,15 @@ class Room(TextBuffer): color = None if not time and nickname and nickname != self.own_nick and self.joined: if self.own_nick.lower() in txt.lower(): - if self.color_state != get_theme().COLOR_TAB_CURRENT: - self.set_color_state(get_theme().COLOR_TAB_HIGHLIGHT) + if self.state != 'current': + self.state = 'highlight' color = get_theme().COLOR_HIGHLIGHT_NICK else: highlight_words = config.get('highlight_on', '').split(':') for word in highlight_words: if word and word.lower() in txt.lower(): - if self.color_state != get_theme().COLOR_TAB_CURRENT: - self.set_color_state(get_theme().COLOR_TAB_HIGHLIGHT) + if self.state != 'current': + self.state = 'highlight' color = get_theme().COLOR_HIGHLIGHT_NICK break if color: @@ -85,13 +85,6 @@ class Room(TextBuffer): return user return None - def set_color_state(self, color): - """ - Set the color that will be used to display the room's - number in the RoomInfo window - """ - self.color_state = color - def add_message(self, txt, time=None, nickname=None, forced_user=None, nick_color=None, history=None): """ Note that user can be None even if nickname is not None. It happens @@ -110,9 +103,9 @@ class Room(TextBuffer): user = forced_user if not time and nickname and\ nickname != self.own_nick and\ - self.color_state != get_theme().COLOR_TAB_CURRENT: - if self.color_state != get_theme().COLOR_TAB_HIGHLIGHT: - self.set_color_state(get_theme().COLOR_TAB_NEW_MESSAGE) + self.state != 'current': + if self.state != 'highlight': + self.state = 'message' nick_color = nick_color or None if not nickname or time: txt = '\x195}%s' % (txt,) |