quick_frontend, primivitus: remove QuickChat.getUserNick + primivitus ChatText gets the user nick directly from parent Chat instance
This commit is contained in:
parent
294b42f15c
commit
5c1fe63580
3 changed files with 8 additions and 12 deletions
|
|
@ -37,10 +37,9 @@ from sat_frontends.tools import jid
|
|||
class ChatText(urwid.FlowWidget):
|
||||
"""Manage the printing of chat message"""
|
||||
|
||||
def __init__(self, parent, timestamp, nick, my_mess, message, align='left', is_info=False):
|
||||
def __init__(self, parent, timestamp, my_mess, message, align='left', is_info=False):
|
||||
self.parent = parent
|
||||
self.timestamp = time.localtime(timestamp)
|
||||
self.nick = nick
|
||||
self.my_mess = my_mess
|
||||
self.message = unicode(message)
|
||||
self.align = align
|
||||
|
|
@ -73,7 +72,7 @@ class ChatText(urwid.FlowWidget):
|
|||
if self.parent.show_short_nick:
|
||||
render_txt.append(('my_nick' if self.my_mess else 'other_nick', "**" if self.my_mess else "*"))
|
||||
else:
|
||||
render_txt.append(('my_nick' if self.my_mess else 'other_nick', "[%s] " % self.nick))
|
||||
render_txt.append(('my_nick' if self.my_mess else 'other_nick', "[%s] " % self.parent.nick))
|
||||
render_txt.append(self.message)
|
||||
txt_widget = urwid.Text(render_txt, align=self.align)
|
||||
if self.is_info:
|
||||
|
|
@ -170,7 +169,7 @@ class Chat(PrimitivusWidget, QuickChat):
|
|||
def _occupantsClicked(self, list_wid, clicked_wid):
|
||||
assert self.type == C.CHAT_GROUP
|
||||
nick = clicked_wid.getValue().value
|
||||
if nick == self.getUserNick():
|
||||
if nick == self.nick:
|
||||
# We ignore clicks on our own nick
|
||||
return
|
||||
contact_list = self.host.contact_lists[self.profile]
|
||||
|
|
@ -263,7 +262,7 @@ class Chat(PrimitivusWidget, QuickChat):
|
|||
except TypeError:
|
||||
# None is returned, the message is managed
|
||||
return
|
||||
new_text = ChatText(self, timestamp, nick, mymess, msg)
|
||||
new_text = ChatText(self, timestamp, mymess, msg)
|
||||
|
||||
if timestamp and self.content:
|
||||
for idx in range(len(self.content) - 1, -1, -1):
|
||||
|
|
@ -303,7 +302,7 @@ class Chat(PrimitivusWidget, QuickChat):
|
|||
timestamp = float(extra['timestamp'])
|
||||
except KeyError:
|
||||
timestamp = None
|
||||
_widget = ChatText(self, timestamp, None, False, msg, is_info=True)
|
||||
_widget = ChatText(self, timestamp, False, msg, is_info=True)
|
||||
self.content.append(_widget)
|
||||
self._notify(msg=msg)
|
||||
|
||||
|
|
@ -322,7 +321,7 @@ class Chat(PrimitivusWidget, QuickChat):
|
|||
if not self.host.x_notify.hasFocus():
|
||||
if self.type == C.CHAT_ONE2ONE:
|
||||
self.host.x_notify.sendNotification(_("Primitivus: %s is talking to you") % from_jid)
|
||||
elif self.getUserNick().lower() in msg.lower():
|
||||
elif self.nick.lower() in msg.lower():
|
||||
self.host.x_notify.sendNotification(_("Primitivus: %(user)s mentioned you in room '%(room)s'") % {'user': from_jid, 'room': self.target})
|
||||
|
||||
# MENU EVENTS #
|
||||
|
|
|
|||
|
|
@ -532,7 +532,7 @@ class QuickApp(object):
|
|||
log.debug("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s" % {'room_jid': room_jid_s, 'profile': profile, 'users': room_nicks})
|
||||
room_jid = jid.JID(room_jid_s)
|
||||
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
|
||||
chat_widget.setUserNick(user_nick)
|
||||
chat_widget.setUserNick(unicode(user_nick))
|
||||
self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP)
|
||||
|
||||
def roomLeftHandler(self, room_jid_s, profile):
|
||||
|
|
@ -642,7 +642,7 @@ class QuickApp(object):
|
|||
|
||||
def entityDataUpdatedHandler(self, entity_s, key, value, profile):
|
||||
entity = jid.JID(entity_s)
|
||||
if key == "nick":
|
||||
if key == "nick": # this is the roster nick, not the MUC nick
|
||||
if entity in self.contact_lists[profile]:
|
||||
self.contact_lists[profile].setCache(entity, 'nick', value)
|
||||
self.callListeners('nick', entity, value, profile=profile)
|
||||
|
|
|
|||
|
|
@ -114,9 +114,6 @@ class QuickChat(quick_widgets.QuickWidget):
|
|||
"""Set the nick of the user, usefull for e.g. change the color of the user"""
|
||||
self.nick = nick
|
||||
|
||||
def getUserNick(self):
|
||||
return unicode(self.nick)
|
||||
|
||||
def changeUserNick(self, old_nick, new_nick):
|
||||
"""Change nick of a user in group list"""
|
||||
self.printInfo("%s is now known as %s" % (old_nick, new_nick))
|
||||
|
|
|
|||
Loading…
Reference in a new issue