comparison src/browser/sat_browser/panels.py @ 534:d2bf317b2d28

browser_side: printInfo fixes: - type_ is managed as follow: - me: a Label will be used - link: a *NOT SANITIZED* HTML will be used - normal: a sanitized HTML with url added will be used - scrolling fixed
author Goffi <goffi@goffi.org>
date Fri, 05 Sep 2014 19:29:35 +0200
parents 3d8e8f693576
children 048ae7314156
comparison
equal deleted inserted replaced
533:19fc2ebc02dd 534:d2bf317b2d28
1263 1263
1264 def printInfo(self, msg, type_='normal', link_cb=None): 1264 def printInfo(self, msg, type_='normal', link_cb=None):
1265 """Print general info 1265 """Print general info
1266 @param msg: message to print 1266 @param msg: message to print
1267 @param type_: one of: 1267 @param type_: one of:
1268 "normal": general info like "toto has joined the room" 1268 "normal": general info like "toto has joined the room" (will be sanitized)
1269 "link": general info that is clickable like "click here to join the main room" 1269 "link": general info that is clickable like "click here to join the main room" (no sanitize done)
1270 "me": "/me" information like "/me clenches his fist" ==> "toto clenches his fist" 1270 "me": "/me" information like "/me clenches his fist" ==> "toto clenches his fist" (will stay on one line)
1271 @param link_cb: method to call when the info is clicked, ignored if type_ is not 'link' 1271 @param link_cb: method to call when the info is clicked, ignored if type_ is not 'link'
1272 """ 1272 """
1273 _wid = HTML(msg) if type_ == 'link' else Label(msg)
1274 if type_ == 'normal': 1273 if type_ == 'normal':
1274 _wid = HTML(addURLToText(html_tools.XHTML2Text(msg)))
1275 _wid.setStyleName('chatTextInfo') 1275 _wid.setStyleName('chatTextInfo')
1276 elif type_ == 'link': 1276 elif type_ == 'link':
1277 _wid = HTML(msg)
1277 _wid.setStyleName('chatTextInfo-link') 1278 _wid.setStyleName('chatTextInfo-link')
1278 if link_cb: 1279 if link_cb:
1279 _wid.addClickListener(link_cb) 1280 _wid.addClickListener(link_cb)
1280 elif type_ == 'me': 1281 elif type_ == 'me':
1282 _wid = Label(msg)
1281 _wid.setStyleName('chatTextMe') 1283 _wid.setStyleName('chatTextMe')
1282 else: 1284 else:
1283 _wid.setStyleName('chatTextInfo') 1285 raise ValueError("Unknown printInfo type %s" % type_)
1284 self.content.add(_wid) 1286 self.content.add(_wid)
1287 self.content_scroll.scrollToBottom()
1285 1288
1286 def printMessage(self, from_jid, msg, extra, timestamp=None): 1289 def printMessage(self, from_jid, msg, extra, timestamp=None):
1287 """Print message in chat window. Must be implemented by child class""" 1290 """Print message in chat window. Must be implemented by child class"""
1288 nick = from_jid.node if self.type == 'one2one' else from_jid.resource 1291 nick = from_jid.node if self.type == 'one2one' else from_jid.resource
1289 mymess = from_jid.resource == self.nick if self.type == "group" else from_jid.bare == self.host.whoami.bare # mymess = True if message comes from local user 1292 mymess = from_jid.resource == self.nick if self.type == "group" else from_jid.bare == self.host.whoami.bare # mymess = True if message comes from local user