diff browser_side/panels.py @ 397:6148e9063069

browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
author souliane <souliane@mailoo.org>
date Tue, 11 Mar 2014 11:53:03 +0100
parents 98cd5387d291
children 487dd238ab88
line wrap: on
line diff
--- a/browser_side/panels.py	Tue Mar 11 10:45:52 2014 +0100
+++ b/browser_side/panels.py	Tue Mar 11 11:53:03 2014 +0100
@@ -1184,17 +1184,23 @@
                 self.printMessage(from_jid, message, extra, timestamp)
         self.host.bridge.call('getHistory', getHistoryCB, self.host.whoami.bare, self.target.bare, size, True)
 
-    def printInfo(self, msg, type='normal'):
+    def printInfo(self, msg, type_='normal', link_cb=None):
         """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"
+        @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"
+        @param link_cb: method to call when the info is clicked, ignored if type_ is not 'link'
         """
-        _wid = Label(msg)
-        if type == 'normal':
+        _wid = HTML(msg) if type_ == 'link' else Label(msg)
+        if type_ == 'normal':
             _wid.setStyleName('chatTextInfo')
-        elif type == 'me':
+        elif type_ == 'link':
+            _wid.setStyleName('chatTextInfo-link')
+            if link_cb:
+                _wid.addClickListener(link_cb)
+        elif type_ == 'me':
             _wid.setStyleName('chatTextMe')
         else:
             _wid.setStyleName('chatTextInfo')
@@ -1206,7 +1212,7 @@
         nick = _jid.node if self.type == 'one2one' else _jid.resource
         mymess = _jid.resource == self.nick if self.type == "group" else _jid.bare == self.host.whoami.bare  # 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')
             return
         self.content.add(ChatText(timestamp, nick, mymess, msg, extra.get('xhtml')))
         self.content_scroll.scrollToBottom()