comparison 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
comparison
equal deleted inserted replaced
396:a71fcc27f231 397:6148e9063069
1182 self.printInfo("* " + message_day) 1182 self.printInfo("* " + message_day)
1183 previous_day = message_day 1183 previous_day = message_day
1184 self.printMessage(from_jid, message, extra, timestamp) 1184 self.printMessage(from_jid, message, extra, timestamp)
1185 self.host.bridge.call('getHistory', getHistoryCB, self.host.whoami.bare, self.target.bare, size, True) 1185 self.host.bridge.call('getHistory', getHistoryCB, self.host.whoami.bare, self.target.bare, size, True)
1186 1186
1187 def printInfo(self, msg, type='normal'): 1187 def printInfo(self, msg, type_='normal', link_cb=None):
1188 """Print general info 1188 """Print general info
1189 @param msg: message to print 1189 @param msg: message to print
1190 @type: one of: 1190 @param type_: one of:
1191 normal: general info like "toto has joined the room" 1191 "normal": general info like "toto has joined the room"
1192 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" 1192 "link": general info that is clickable like "click here to join the main room"
1193 """ 1193 "me": "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
1194 _wid = Label(msg) 1194 @param link_cb: method to call when the info is clicked, ignored if type_ is not 'link'
1195 if type == 'normal': 1195 """
1196 _wid = HTML(msg) if type_ == 'link' else Label(msg)
1197 if type_ == 'normal':
1196 _wid.setStyleName('chatTextInfo') 1198 _wid.setStyleName('chatTextInfo')
1197 elif type == 'me': 1199 elif type_ == 'link':
1200 _wid.setStyleName('chatTextInfo-link')
1201 if link_cb:
1202 _wid.addClickListener(link_cb)
1203 elif type_ == 'me':
1198 _wid.setStyleName('chatTextMe') 1204 _wid.setStyleName('chatTextMe')
1199 else: 1205 else:
1200 _wid.setStyleName('chatTextInfo') 1206 _wid.setStyleName('chatTextInfo')
1201 self.content.add(_wid) 1207 self.content.add(_wid)
1202 1208
1204 """Print message in chat window. Must be implemented by child class""" 1210 """Print message in chat window. Must be implemented by child class"""
1205 _jid = JID(from_jid) 1211 _jid = JID(from_jid)
1206 nick = _jid.node if self.type == 'one2one' else _jid.resource 1212 nick = _jid.node if self.type == 'one2one' else _jid.resource
1207 mymess = _jid.resource == self.nick if self.type == "group" else _jid.bare == self.host.whoami.bare # mymess = True if message comes from local user 1213 mymess = _jid.resource == self.nick if self.type == "group" else _jid.bare == self.host.whoami.bare # mymess = True if message comes from local user
1208 if msg.startswith('/me '): 1214 if msg.startswith('/me '):
1209 self.printInfo('* %s %s' % (nick, msg[4:]), type='me') 1215 self.printInfo('* %s %s' % (nick, msg[4:]), type_='me')
1210 return 1216 return
1211 self.content.add(ChatText(timestamp, nick, mymess, msg, extra.get('xhtml'))) 1217 self.content.add(ChatText(timestamp, nick, mymess, msg, extra.get('xhtml')))
1212 self.content_scroll.scrollToBottom() 1218 self.content_scroll.scrollToBottom()
1213 1219
1214 def startGame(self, game_type, waiting, referee, players, *args): 1220 def startGame(self, game_type, waiting, referee, players, *args):