comparison frontends/src/quick_frontend/quick_chat.py @ 1763:9b557e76a5a8

quick_frontend (chat): scroll down after having printed the history
author souliane <souliane@mailoo.org>
date Tue, 22 Dec 2015 11:43:02 +0100
parents 2e2fb462729a
children 33c815c17fe6
comparison
equal deleted inserted replaced
1762:2e2fb462729a 1763:9b557e76a5a8
192 if self.type == C.CHAT_GROUP and target.resource and type_ != C.MESS_TYPE_GROUPCHAT: 192 if self.type == C.CHAT_GROUP and target.resource and type_ != C.MESS_TYPE_GROUPCHAT:
193 # we have a private message, we forward it to a private conversation widget 193 # we have a private message, we forward it to a private conversation widget
194 chat_widget = self.getOrCreatePrivateWidget(target) 194 chat_widget = self.getOrCreatePrivateWidget(target)
195 chat_widget.newMessage(from_jid, target, msg, type_, extra, profile) 195 chat_widget.newMessage(from_jid, target, msg, type_, extra, profile)
196 return 196 return
197 try:
198 timestamp = float(extra['timestamp'])
199 except KeyError:
200 timestamp = None
197 if type_ == C.MESS_TYPE_INFO: 201 if type_ == C.MESS_TYPE_INFO:
198 self.printInfo(msg, extra=extra) 202 self.printInfo(msg, extra=extra)
199 else: 203 else:
200 nick = self._get_nick(from_jid) 204 nick = self._get_nick(from_jid)
201 if msg.startswith('/me '): 205 if msg.startswith('/me '):
202 self.printInfo('* %s %s' % (nick, msg[4:]), type_='me', extra=extra) 206 self.printInfo('* %s %s' % (nick, msg[4:]), type_='me', extra=extra)
203 else: 207 else:
204 # my_message is True if message comes from local user 208 # my_message is True if message comes from local user
205 my_message = (from_jid.resource == self.nick) if self.type == C.CHAT_GROUP else (from_jid.bare == self.host.profiles[profile].whoami.bare) 209 my_message = (from_jid.resource == self.nick) if self.type == C.CHAT_GROUP else (from_jid.bare == self.host.profiles[profile].whoami.bare)
206 try:
207 timestamp = float(extra['timestamp'])
208 except KeyError:
209 timestamp = None
210 self.printMessage(nick, my_message, msg, timestamp, extra, profile) 210 self.printMessage(nick, my_message, msg, timestamp, extra, profile)
211 if timestamp:
212 self.afterHistoryPrint()
211 213
212 def printMessage(self, nick, my_message, message, timestamp, extra=None, profile=C.PROF_KEY_NONE): 214 def printMessage(self, nick, my_message, message, timestamp, extra=None, profile=C.PROF_KEY_NONE):
213 """Print message in chat window. 215 """Print message in chat window.
214 216
215 @param nick (unicode): author nick 217 @param nick (unicode): author nick