summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2016-08-29 20:36:36 +0200
committermathieui <mathieui@mathieui.net>2016-08-29 20:36:36 +0200
commit859dc90d510775b700ce5716b53a0b8fde39eecc (patch)
treed5ef5a28019b1525da2f2a8ca344e9627dd48a78
parent8eb7daad3a458f09840ed02432ca356dee5ab924 (diff)
downloadpoezio-859dc90d510775b700ce5716b53a0b8fde39eecc.tar.gz
poezio-859dc90d510775b700ce5716b53a0b8fde39eecc.tar.bz2
poezio-859dc90d510775b700ce5716b53a0b8fde39eecc.tar.xz
poezio-859dc90d510775b700ce5716b53a0b8fde39eecc.zip
Fix coloring of messages in the privatetab
-rw-r--r--poezio/core/core.py10
-rw-r--r--poezio/tabs/muctab.py16
-rw-r--r--poezio/tabs/privatetab.py46
3 files changed, 49 insertions, 23 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py
index e4f4687d..b3aea9a6 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -1285,7 +1285,7 @@ class Core(object):
### Modifying actions ###
- def rename_private_tabs(self, room_name, old_nick, new_nick):
+ def rename_private_tabs(self, room_name, old_nick, user):
"""
Call this method when someone changes his/her nick in a MUC,
this updates the name of all the opened private conversations
@@ -1294,16 +1294,16 @@ class Core(object):
tab = self.get_tab_by_name('%s/%s' % (room_name, old_nick),
tabs.PrivateTab)
if tab:
- tab.rename_user(old_nick, new_nick)
+ tab.rename_user(old_nick, user)
- def on_user_left_private_conversation(self, room_name, nick, status_message):
+ def on_user_left_private_conversation(self, room_name, user, status_message):
"""
The user left the MUC: add a message in the associated
private conversation
"""
- tab = self.get_tab_by_name('%s/%s' % (room_name, nick), tabs.PrivateTab)
+ tab = self.get_tab_by_name('%s/%s' % (room_name, user.nick), tabs.PrivateTab)
if tab:
- tab.user_left(status_message, nick)
+ tab.user_left(status_message, user)
def on_user_rejoined_private_conversation(self, room_name, nick):
"""
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index e112c78d..db1e88b6 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -1133,19 +1133,17 @@ class MucTab(ChatTab):
info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
warn_col = dump_tuple(get_theme().COLOR_WARNING_TEXT)
spec_col = dump_tuple(get_theme().COLOR_JOIN_CHAR)
-
- self.add_message(
+ enable_message = (
'\x19%(color_spec)s}%(spec)s\x19%(info_col)s} You '
'(\x19%(nick_col)s}%(nick)s\x19%(info_col)s}) joined'
- ' the chatroom' %
- {
+ ' the chatroom') % {
'nick': from_nick,
'spec': get_theme().CHAR_JOIN,
'color_spec': spec_col,
'nick_col': color,
'info_col': info_col,
- },
- typ=2)
+ }
+ self.add_message(enable_message, typ=2)
if '201' in status_codes:
self.add_message(
'\x19%(info_col)s}Info: The room '
@@ -1170,7 +1168,7 @@ class MucTab(ChatTab):
self.refresh_tab_win()
self.core.current_tab().input.refresh()
self.core.doupdate()
- self.core.enable_private_tabs(self.name)
+ self.core.enable_private_tabs(self.name, enable_message)
# Enable the self ping event, to regularly check if we
# are still in the room.
self.enable_self_ping_event()
@@ -1310,7 +1308,7 @@ class MucTab(ChatTab):
'color':color, 'info_col': info_col},
typ=2)
# rename the private tabs if needed
- self.core.rename_private_tabs(self.name, from_nick, new_nick)
+ self.core.rename_private_tabs(self.name, from_nick, user)
def on_user_banned(self, presence, user, from_nick):
"""
@@ -1494,7 +1492,7 @@ class MucTab(ChatTab):
if status:
leave_msg += ' (\x19o%s\x19%s})' % (status, info_col)
self.add_message(leave_msg, typ=2)
- self.core.on_user_left_private_conversation(from_room, from_nick,
+ self.core.on_user_left_private_conversation(from_room, user,
status)
def on_user_change_status(
diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py
index 54bcff96..e9e8ff6e 100644
--- a/poezio/tabs/privatetab.py
+++ b/poezio/tabs/privatetab.py
@@ -307,26 +307,49 @@ class PrivateTab(OneToOneTab):
return self.text_win
@refresh_wrapper.conditional
- def rename_user(self, old_nick, new_nick):
+ def rename_user(self, old_nick, user):
"""
The user changed her nick in the corresponding muc: update the tab’s name and
display a message.
"""
- self.add_message('\x193}%(old)s\x19%(info_col)s} is now known as \x193}%(new)s' % {'old':old_nick, 'new':new_nick, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2)
- new_jid = safeJID(self.name).bare+'/'+new_nick
+ self.add_message('\x19%(nick_col)s}%(old)s\x19%(info_col)s} is now '
+ 'known as \x19%(nick_col)s}%(new)s' % {
+ 'old':old_nick, 'new': user.nick,
+ 'nick_col': dump_tuple(user.color),
+ 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)},
+ typ=2)
+ new_jid = safeJID(self.name).bare+'/'+user.nick
self.name = new_jid
return self.core.current_tab() is self
@refresh_wrapper.conditional
- def user_left(self, status_message, from_nick):
+ def user_left(self, status_message, user):
"""
The user left the associated MUC
"""
self.deactivate()
+ if config.get_by_tabname('display_user_color_in_join_part', self.general_jid):
+ color = dump_tuple(user.color)
+ else:
+ color = dump_tuple(get_theme().COLOR_REMOTE_USER)
+
if not status_message:
- self.add_message('\x191}%(spec)s \x193}%(nick)s\x19%(info_col)s} has left the room' % {'nick':from_nick, 'spec':get_theme().CHAR_QUIT, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2)
+ self.add_message('\x19%(join_col)s}%(spec)s \x19%(nick_col)s}'
+ '%(nick)s\x19%(info_col)s} has left the room' % {
+ 'nick': user.nick, 'spec': get_theme().CHAR_QUIT,
+ 'nick_col': color,
+ 'join_col': dump_tuple(get_theme().COLOR_JOIN_CHAR),
+ 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)},
+ typ=2)
else:
- self.add_message('\x191}%(spec)s \x193}%(nick)s\x19%(info_col)s} has left the room (%(status)s)"' % {'nick':from_nick, 'spec':get_theme().CHAR_QUIT, 'status': status_message, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2)
+ self.add_message('\x19%(join_col)s}%(spec)s \x19%(nick_col)s}'
+ '%(nick)s\x19%(info_col)s} has left the room'
+ ' (%(status)s)' % { 'status': status_message,
+ 'nick': user.nick, 'spec': get_theme().CHAR_QUIT,
+ 'nick_col': color,
+ 'join_col': dump_tuple(get_theme().COLOR_JOIN_CHAR),
+ 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)},
+ typ=2)
return self.core.current_tab() is self
@refresh_wrapper.conditional
@@ -336,14 +359,19 @@ class PrivateTab(OneToOneTab):
"""
self.activate()
self.check_features()
- tab = self.core.get_tab_by_name(safeJID(self.name).bare, MucTab)
- color = 3
+ tab = self.parent_muc
+ color = dump_tuple(get_theme().COLOR_REMOTE_USER)
if tab and config.get_by_tabname('display_user_color_in_join_part',
self.general_jid):
user = tab.get_user_by_name(nick)
if user:
color = dump_tuple(user.color)
- self.add_message('\x194}%(spec)s \x19%(color)s}%(nick)s\x19%(info_col)s} joined the room' % {'nick':nick, 'color': color, 'spec':get_theme().CHAR_JOIN, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}, typ=2)
+ self.add_message('\x19%(join_col)s}%(spec)s \x19%(color)s}%(nick)s\x19'
+ '%(info_col)s} joined the room' % {'nick':nick,
+ 'color': color, 'spec':get_theme().CHAR_JOIN,
+ 'join_col': dump_tuple(get_theme().COLOR_JOIN_CHAR),
+ 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)},
+ typ=2)
return self.core.current_tab() is self
def activate(self, reason=None):