changeset 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 19fc2ebc02dd
children 331cb6ea0235
files src/browser/sat_browser/panels.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/sat_browser/panels.py	Fri Sep 05 19:29:35 2014 +0200
+++ b/src/browser/sat_browser/panels.py	Fri Sep 05 19:29:35 2014 +0200
@@ -1265,23 +1265,26 @@
         """Print general info
         @param msg: message to print
         @param type_: one of:
-            "normal": general info like "toto has joined the room"
-            "link": general info that is clickable like "click here to join the main room"
-            "me": "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
+            "normal": general info like "toto has joined the room" (will be sanitized)
+            "link": general info that is clickable like "click here to join the main room" (no sanitize done)
+            "me": "/me" information like "/me clenches his fist" ==> "toto clenches his fist" (will stay on one line)
         @param link_cb: method to call when the info is clicked, ignored if type_ is not 'link'
         """
-        _wid = HTML(msg) if type_ == 'link' else Label(msg)
         if type_ == 'normal':
+            _wid = HTML(addURLToText(html_tools.XHTML2Text(msg)))
             _wid.setStyleName('chatTextInfo')
         elif type_ == 'link':
+            _wid = HTML(msg)
             _wid.setStyleName('chatTextInfo-link')
             if link_cb:
                 _wid.addClickListener(link_cb)
         elif type_ == 'me':
+            _wid = Label(msg)
             _wid.setStyleName('chatTextMe')
         else:
-            _wid.setStyleName('chatTextInfo')
+            raise ValueError("Unknown printInfo type %s" % type_)
         self.content.add(_wid)
+        self.content_scroll.scrollToBottom()
 
     def printMessage(self, from_jid, msg, extra, timestamp=None):
         """Print message in chat window. Must be implemented by child class"""