summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-05 21:25:17 +0100
committermathieui <mathieui@mathieui.net>2011-11-05 21:25:17 +0100
commita49af71f7c18eb7373423ab45cb543f2141d049b (patch)
treef275e9c7192eac18e1bfffbe642def801da378f4
parent3f08e235a11ccc201e672e306fa7543437a589c0 (diff)
downloadpoezio-a49af71f7c18eb7373423ab45cb543f2141d049b.tar.gz
poezio-a49af71f7c18eb7373423ab45cb543f2141d049b.tar.bz2
poezio-a49af71f7c18eb7373423ab45cb543f2141d049b.tar.xz
poezio-a49af71f7c18eb7373423ab45cb543f2141d049b.zip
Fixes #2255 with some lambda fun
-rw-r--r--src/tabs.py22
-rw-r--r--src/windows.py30
2 files changed, 26 insertions, 26 deletions
diff --git a/src/tabs.py b/src/tabs.py
index ae20128c..2e4a8901 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -58,12 +58,12 @@ SHOW_NAME = {
NS_MUC_USER = 'http://jabber.org/protocol/muc#user'
STATE_COLORS = {
- 'disconnected': 'COLOR_TAB_DISCONNECTED',
- 'message': 'COLOR_TAB_NEW_MESSAGE',
- 'highlight': 'COLOR_TAB_HIGHLIGHT',
- 'private': 'COLOR_TAB_PRIVATE',
- 'normal': 'COLOR_TAB_NORMAL',
- 'current': 'COLOR_TAB_CURRENT',
+ 'disconnected': lambda: get_theme().COLOR_TAB_DISCONNECTED,
+ 'message': lambda: get_theme().COLOR_TAB_NEW_MESSAGE,
+ 'highlight': lambda: get_theme().COLOR_TAB_HIGHLIGHT,
+ 'private': lambda: get_theme().COLOR_TAB_PRIVATE,
+ 'normal': lambda: get_theme().COLOR_TAB_NORMAL,
+ 'current': lambda: get_theme().COLOR_TAB_CURRENT,
}
class Tab(object):
@@ -98,7 +98,7 @@ class Tab(object):
@property
def color(self):
- return getattr(get_theme(), STATE_COLORS[self.state])
+ return STATE_COLORS[self.state]()
@property
def state(self):
@@ -826,7 +826,7 @@ class MucTab(ChatTab):
@property
def color(self):
- return getattr(get_theme(), STATE_COLORS[self._room.state])
+ return STATE_COLORS[self._room.state]()
def on_lose_focus(self):
self._room.state = 'normal'
@@ -1181,8 +1181,8 @@ class PrivateTab(ChatTab):
def color(self):
if self._room.state == 'normal' or\
self._room.state == 'current':
- return getattr(get_theme(), STATE_COLORS[self._room.state])
- return getattr(get_theme(), 'COLOR_TAB_PRIVATE')
+ return STATE_COLORS[self._room.state]()
+ return get_theme().COLOR_TAB_PRIVATE
def get_name(self):
return self._room.name
@@ -1822,7 +1822,7 @@ class ConversationTab(ChatTab):
def color(self):
if self.state == 'normal' or \
self.state == 'current':
- return getattr(get_theme(), STATE_COLORS[self.state])
+ return STATE_COLORS[self.state]()
return get_theme().COLOR_TAB_PRIVATE
def get_name(self):
diff --git a/src/windows.py b/src/windows.py
index c2c35170..1612e416 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -191,19 +191,19 @@ class UserList(Win):
def __init__(self):
Win.__init__(self)
self.pos = 0
- self.color_role = {'moderator': get_theme().COLOR_USER_MODERATOR,
- 'participant':get_theme().COLOR_USER_PARTICIPANT,
- 'visitor':get_theme().COLOR_USER_VISITOR,
- 'none':get_theme().COLOR_USER_NONE,
- '':get_theme().COLOR_USER_NONE
- }
- self.color_show = {'xa':get_theme().COLOR_STATUS_XA,
- 'none':get_theme().COLOR_STATUS_NONE,
- '':get_theme().COLOR_STATUS_NONE,
- 'dnd':get_theme().COLOR_STATUS_DND,
- 'away':get_theme().COLOR_STATUS_AWAY,
- 'chat':get_theme().COLOR_STATUS_CHAT
- }
+ self.color_role = {'moderator': lambda: get_theme().COLOR_USER_MODERATOR,
+ 'participant': lambda: get_theme().COLOR_USER_PARTICIPANT,
+ 'visitor': lambda: get_theme().COLOR_USER_VISITOR,
+ 'none': lambda: get_theme().COLOR_USER_NONE,
+ '': lambda: get_theme().COLOR_USER_NONE
+ }
+ self.color_show = {'xa': lambda: get_theme().COLOR_STATUS_XA,
+ 'none': lambda: get_theme().COLOR_STATUS_NONE,
+ '': lambda: get_theme().COLOR_STATUS_NONE,
+ 'dnd': lambda: get_theme().COLOR_STATUS_DND,
+ 'away': lambda: get_theme().COLOR_STATUS_AWAY,
+ 'chat': lambda: get_theme().COLOR_STATUS_CHAT
+ }
def scroll_up(self):
self.pos += self.height-1
@@ -228,11 +228,11 @@ class UserList(Win):
if not user.role in self.color_role:
role_col = get_theme().COLOR_USER_NONE
else:
- role_col = self.color_role[user.role]
+ role_col = self.color_role[user.role]()
if not user.show in self.color_show:
show_col = get_theme().COLOR_STATUS_NONE
else:
- show_col = self.color_show[user.show]
+ show_col = self.color_show[user.show]()
if user.chatstate == 'composing':
char = 'X'
elif user.chatstate == 'active':