Fixes #2255 with some lambda fun
This commit is contained in:
parent
3f08e235a1
commit
a49af71f7c
2 changed files with 26 additions and 26 deletions
22
src/tabs.py
22
src/tabs.py
|
@ -58,12 +58,12 @@ SHOW_NAME = {
|
||||||
NS_MUC_USER = 'http://jabber.org/protocol/muc#user'
|
NS_MUC_USER = 'http://jabber.org/protocol/muc#user'
|
||||||
|
|
||||||
STATE_COLORS = {
|
STATE_COLORS = {
|
||||||
'disconnected': 'COLOR_TAB_DISCONNECTED',
|
'disconnected': lambda: get_theme().COLOR_TAB_DISCONNECTED,
|
||||||
'message': 'COLOR_TAB_NEW_MESSAGE',
|
'message': lambda: get_theme().COLOR_TAB_NEW_MESSAGE,
|
||||||
'highlight': 'COLOR_TAB_HIGHLIGHT',
|
'highlight': lambda: get_theme().COLOR_TAB_HIGHLIGHT,
|
||||||
'private': 'COLOR_TAB_PRIVATE',
|
'private': lambda: get_theme().COLOR_TAB_PRIVATE,
|
||||||
'normal': 'COLOR_TAB_NORMAL',
|
'normal': lambda: get_theme().COLOR_TAB_NORMAL,
|
||||||
'current': 'COLOR_TAB_CURRENT',
|
'current': lambda: get_theme().COLOR_TAB_CURRENT,
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tab(object):
|
class Tab(object):
|
||||||
|
@ -98,7 +98,7 @@ class Tab(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color(self):
|
def color(self):
|
||||||
return getattr(get_theme(), STATE_COLORS[self.state])
|
return STATE_COLORS[self.state]()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
@ -826,7 +826,7 @@ class MucTab(ChatTab):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color(self):
|
def color(self):
|
||||||
return getattr(get_theme(), STATE_COLORS[self._room.state])
|
return STATE_COLORS[self._room.state]()
|
||||||
|
|
||||||
def on_lose_focus(self):
|
def on_lose_focus(self):
|
||||||
self._room.state = 'normal'
|
self._room.state = 'normal'
|
||||||
|
@ -1181,8 +1181,8 @@ class PrivateTab(ChatTab):
|
||||||
def color(self):
|
def color(self):
|
||||||
if self._room.state == 'normal' or\
|
if self._room.state == 'normal' or\
|
||||||
self._room.state == 'current':
|
self._room.state == 'current':
|
||||||
return getattr(get_theme(), STATE_COLORS[self._room.state])
|
return STATE_COLORS[self._room.state]()
|
||||||
return getattr(get_theme(), 'COLOR_TAB_PRIVATE')
|
return get_theme().COLOR_TAB_PRIVATE
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self._room.name
|
return self._room.name
|
||||||
|
@ -1822,7 +1822,7 @@ class ConversationTab(ChatTab):
|
||||||
def color(self):
|
def color(self):
|
||||||
if self.state == 'normal' or \
|
if self.state == 'normal' or \
|
||||||
self.state == 'current':
|
self.state == 'current':
|
||||||
return getattr(get_theme(), STATE_COLORS[self.state])
|
return STATE_COLORS[self.state]()
|
||||||
return get_theme().COLOR_TAB_PRIVATE
|
return get_theme().COLOR_TAB_PRIVATE
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
|
|
|
@ -191,18 +191,18 @@ class UserList(Win):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Win.__init__(self)
|
Win.__init__(self)
|
||||||
self.pos = 0
|
self.pos = 0
|
||||||
self.color_role = {'moderator': get_theme().COLOR_USER_MODERATOR,
|
self.color_role = {'moderator': lambda: get_theme().COLOR_USER_MODERATOR,
|
||||||
'participant':get_theme().COLOR_USER_PARTICIPANT,
|
'participant': lambda: get_theme().COLOR_USER_PARTICIPANT,
|
||||||
'visitor':get_theme().COLOR_USER_VISITOR,
|
'visitor': lambda: get_theme().COLOR_USER_VISITOR,
|
||||||
'none':get_theme().COLOR_USER_NONE,
|
'none': lambda: get_theme().COLOR_USER_NONE,
|
||||||
'':get_theme().COLOR_USER_NONE
|
'': lambda: get_theme().COLOR_USER_NONE
|
||||||
}
|
}
|
||||||
self.color_show = {'xa':get_theme().COLOR_STATUS_XA,
|
self.color_show = {'xa': lambda: get_theme().COLOR_STATUS_XA,
|
||||||
'none':get_theme().COLOR_STATUS_NONE,
|
'none': lambda: get_theme().COLOR_STATUS_NONE,
|
||||||
'':get_theme().COLOR_STATUS_NONE,
|
'': lambda: get_theme().COLOR_STATUS_NONE,
|
||||||
'dnd':get_theme().COLOR_STATUS_DND,
|
'dnd': lambda: get_theme().COLOR_STATUS_DND,
|
||||||
'away':get_theme().COLOR_STATUS_AWAY,
|
'away': lambda: get_theme().COLOR_STATUS_AWAY,
|
||||||
'chat':get_theme().COLOR_STATUS_CHAT
|
'chat': lambda: get_theme().COLOR_STATUS_CHAT
|
||||||
}
|
}
|
||||||
|
|
||||||
def scroll_up(self):
|
def scroll_up(self):
|
||||||
|
@ -228,11 +228,11 @@ class UserList(Win):
|
||||||
if not user.role in self.color_role:
|
if not user.role in self.color_role:
|
||||||
role_col = get_theme().COLOR_USER_NONE
|
role_col = get_theme().COLOR_USER_NONE
|
||||||
else:
|
else:
|
||||||
role_col = self.color_role[user.role]
|
role_col = self.color_role[user.role]()
|
||||||
if not user.show in self.color_show:
|
if not user.show in self.color_show:
|
||||||
show_col = get_theme().COLOR_STATUS_NONE
|
show_col = get_theme().COLOR_STATUS_NONE
|
||||||
else:
|
else:
|
||||||
show_col = self.color_show[user.show]
|
show_col = self.color_show[user.show]()
|
||||||
if user.chatstate == 'composing':
|
if user.chatstate == 'composing':
|
||||||
char = 'X'
|
char = 'X'
|
||||||
elif user.chatstate == 'active':
|
elif user.chatstate == 'active':
|
||||||
|
|
Loading…
Reference in a new issue