Commit 859dc90d authored by mathieui's avatar mathieui

Fix coloring of messages in the privatetab

parent 8eb7daad
...@@ -1285,7 +1285,7 @@ class Core(object): ...@@ -1285,7 +1285,7 @@ class Core(object):
### Modifying actions ### ### 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, Call this method when someone changes his/her nick in a MUC,
this updates the name of all the opened private conversations this updates the name of all the opened private conversations
...@@ -1294,16 +1294,16 @@ class Core(object): ...@@ -1294,16 +1294,16 @@ class Core(object):
tab = self.get_tab_by_name('%s/%s' % (room_name, old_nick), tab = self.get_tab_by_name('%s/%s' % (room_name, old_nick),
tabs.PrivateTab) tabs.PrivateTab)
if tab: 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 The user left the MUC: add a message in the associated
private conversation 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: if tab:
tab.user_left(status_message, nick) tab.user_left(status_message, user)
def on_user_rejoined_private_conversation(self, room_name, nick): def on_user_rejoined_private_conversation(self, room_name, nick):
""" """
......
...@@ -1133,19 +1133,17 @@ class MucTab(ChatTab): ...@@ -1133,19 +1133,17 @@ class MucTab(ChatTab):
info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT) info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
warn_col = dump_tuple(get_theme().COLOR_WARNING_TEXT) warn_col = dump_tuple(get_theme().COLOR_WARNING_TEXT)
spec_col = dump_tuple(get_theme().COLOR_JOIN_CHAR) spec_col = dump_tuple(get_theme().COLOR_JOIN_CHAR)
enable_message = (
self.add_message(
'\x19%(color_spec)s}%(spec)s\x19%(info_col)s} You ' '\x19%(color_spec)s}%(spec)s\x19%(info_col)s} You '
'(\x19%(nick_col)s}%(nick)s\x19%(info_col)s}) joined' '(\x19%(nick_col)s}%(nick)s\x19%(info_col)s}) joined'
' the chatroom' % ' the chatroom') % {
{
'nick': from_nick, 'nick': from_nick,
'spec': get_theme().CHAR_JOIN, 'spec': get_theme().CHAR_JOIN,
'color_spec': spec_col, 'color_spec': spec_col,
'nick_col': color, 'nick_col': color,
'info_col': info_col, 'info_col': info_col,
}, }
typ=2) self.add_message(enable_message, typ=2)
if '201' in status_codes: if '201' in status_codes:
self.add_message( self.add_message(
'\x19%(info_col)s}Info: The room ' '\x19%(info_col)s}Info: The room '
...@@ -1170,7 +1168,7 @@ class MucTab(ChatTab): ...@@ -1170,7 +1168,7 @@ class MucTab(ChatTab):
self.refresh_tab_win() self.refresh_tab_win()
self.core.current_tab().input.refresh() self.core.current_tab().input.refresh()
self.core.doupdate() 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 # Enable the self ping event, to regularly check if we
# are still in the room. # are still in the room.
self.enable_self_ping_event() self.enable_self_ping_event()
...@@ -1310,7 +1308,7 @@ class MucTab(ChatTab): ...@@ -1310,7 +1308,7 @@ class MucTab(ChatTab):
'color':color, 'info_col': info_col}, 'color':color, 'info_col': info_col},
typ=2) typ=2)
# rename the private tabs if needed # 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): def on_user_banned(self, presence, user, from_nick):
""" """
...@@ -1494,7 +1492,7 @@ class MucTab(ChatTab): ...@@ -1494,7 +1492,7 @@ class MucTab(ChatTab):
if status: if status:
leave_msg += ' (\x19o%s\x19%s})' % (status, info_col) leave_msg += ' (\x19o%s\x19%s})' % (status, info_col)
self.add_message(leave_msg, typ=2) 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) status)
def on_user_change_status( def on_user_change_status(
......
...@@ -307,26 +307,49 @@ class PrivateTab(OneToOneTab): ...@@ -307,26 +307,49 @@ class PrivateTab(OneToOneTab):
return self.text_win return self.text_win
@refresh_wrapper.conditional @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 The user changed her nick in the corresponding muc: update the tab’s name and
display a message. 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) self.add_message('\x19%(nick_col)s}%(old)s\x19%(info_col)s} is now '
new_jid = safeJID(self.name).bare+'/'+new_nick '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 self.name = new_jid
return self.core.current_tab() is self return self.core.current_tab() is self
@refresh_wrapper.conditional @refresh_wrapper.conditional
def user_left(self, status_message, from_nick): def user_left(self, status_message, user):
""" """
The user left the associated MUC The user left the associated MUC
""" """
self.deactivate() 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: 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: 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 return self.core.current_tab() is self
@refresh_wrapper.conditional @refresh_wrapper.conditional
...@@ -336,14 +359,19 @@ class PrivateTab(OneToOneTab): ...@@ -336,14 +359,19 @@ class PrivateTab(OneToOneTab):
""" """
self.activate() self.activate()
self.check_features() self.check_features()
tab = self.core.get_tab_by_name(safeJID(self.name).bare, MucTab) tab = self.parent_muc
color = 3 color = dump_tuple(get_theme().COLOR_REMOTE_USER)
if tab and config.get_by_tabname('display_user_color_in_join_part', if tab and config.get_by_tabname('display_user_color_in_join_part',
self.general_jid): self.general_jid):
user = tab.get_user_by_name(nick) user = tab.get_user_by_name(nick)
if user: if user:
color = dump_tuple(user.color) 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 return self.core.current_tab() is self
def activate(self, reason=None): def activate(self, reason=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment