Mercurial > libervia-backend
changeset 531:3bd8f84f920d
primitivus: fixed info messages timestamp
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 28 Oct 2012 17:59:24 +0100 |
parents | 6c07127ad2ed |
children | db4ae4d18f09 |
files | frontends/src/primitivus/chat.py frontends/src/quick_frontend/quick_chat.py |
diffstat | 2 files changed, 15 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py Sun Oct 28 17:58:47 2012 +0100 +++ b/frontends/src/primitivus/chat.py Sun Oct 28 17:59:24 2012 +0100 @@ -32,13 +32,14 @@ class ChatText(urwid.FlowWidget): """Manage the printing of chat message""" - def __init__(self, parent, timestamp, nick, my_mess, message, align='left'): + def __init__(self, parent, timestamp, nick, 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 + self.is_info = is_info def selectable(self): return True @@ -61,13 +62,14 @@ def display_widget(self, size, focus): render_txt = [] - if self.parent.show_timestamp: - time_format = "%c" if self.timestamp < self.parent.day_change else "%H:%M" #if the message was sent before today, we print the full date - render_txt.append(('date',"[%s]" % time.strftime(time_format, self.timestamp).decode('utf-8'))) - 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)) + if not self.is_info: + if self.parent.show_timestamp: + time_format = "%c" if self.timestamp < self.parent.day_change else "%H:%M" #if the message was sent before today, we print the full date + render_txt.append(('date',"[%s]" % time.strftime(time_format, self.timestamp).decode('utf-8'))) + 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(self.message) return urwid.Text(render_txt, align=self.align) @@ -272,14 +274,16 @@ elif self.getUserNick().lower() in msg.lower(): self.host.x_notify.sendNotification(_("Primitivus: Somebody pinged your name in %s room") % self.target) - def printInfo(self, msg, type='normal'): + def printInfo(self, msg, type='normal', timestamp=""): """Print general info @param msg: message to print @type: one of: normal: general info like "toto has joined the room" me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" """ - self.content.append(sat_widgets.ClickableText(msg)) + #FIXME: duplicated code, this must be refactored + _widget = ChatText(self, timestamp or None, None, False, msg, is_info=True) + self.content.append(_widget) if self.text_list.get_focus()[1] == len(self.content)-2: #we don't change focus if user is not at the bottom #as that mean that he is probably watching discussion history
--- a/frontends/src/quick_frontend/quick_chat.py Sun Oct 28 17:58:47 2012 +0100 +++ b/frontends/src/quick_frontend/quick_chat.py Sun Oct 28 17:59:24 2012 +0100 @@ -130,7 +130,7 @@ nick = self._get_nick(jid) mymess = (jid.resource == self.nick) if self.type == "group" else (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user if msg.startswith('/me '): - self.printInfo('* %s %s' % (nick, msg[4:]),type='me') + self.printInfo('* %s %s' % (nick, msg[4:]),type='me', timestamp=timestamp) return return jid, nick, mymess