# HG changeset patch # User souliane # Date 1394535183 -3600 # Node ID 6148e90630696db331ccb97f58f92742227dbd55 # Parent a71fcc27f231a4f2e16658fc805da1d7f46f516d browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo diff -r a71fcc27f231 -r 6148e9063069 browser_side/panels.py --- 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() diff -r a71fcc27f231 -r 6148e9063069 browser_side/radiocol.py --- a/browser_side/radiocol.py Tue Mar 11 10:45:52 2014 +0100 +++ b/browser_side/radiocol.py Tue Mar 11 11:53:03 2014 +0100 @@ -217,6 +217,13 @@ class RadioColPanel(HorizontalPanel, ClickHandler): def __init__(self, parent, referee, player_nick, players, queue_data): + """ + @param parent + @param referee + @param player_nick + @param players + @param queue_data: list of integers (queue to start, queue limit) + """ # We need to set it here and not in the CSS :( HorizontalPanel.__init__(self, Height="90px") ClickHandler.__init__(self) @@ -240,13 +247,11 @@ self.add(player) self.addClickListener(self) - help_msg = HTML("""Accepted file formats: Ogg Vorbis (recommended), MP3.
+ help_msg = """Accepted file formats: Ogg Vorbis (recommended), MP3.
Please do not submit files that are protected by copyright.
- Click here if you need some support :) - """) - help_msg.setStyleName('chatTextInfo-link') - help_msg.addClickListener(lambda: self._parent.host.bridge.call('joinMUC', None, DEFAULT_MUC, self._parent.nick)) - self._parent.content.add(help_msg) + Click here if you need some support :)""" + link_cb = lambda: self._parent.host.bridge.call('joinMUC', None, DEFAULT_MUC, self._parent.nick) + self._parent.printInfo(help_msg, type_='link', link_cb=link_cb) def pushNextSong(self, title): """Add a song to the left panel's next songs queue""" @@ -273,7 +278,7 @@ return False return True - def radiocolPreload(self, timestamp, filename, title, artist, album): + def radiocolPreload(self, timestamp, filename, title, artist, album, sender): if not self.radiocolCheckPreload(timestamp): return # song already preloaded preloaded = False @@ -286,9 +291,10 @@ preloaded = True break if not preloaded: - print("WARNING: Can't preload song, we are getting too many songs to preload, we shouldn't have more than 2 at once") + print(_("WARNING: Can't preload song, we are getting too many songs to preload, we shouldn't have more than %d at once") % self.queue_data[1]) else: self.pushNextSong(title) + self._parent.printInfo(_('%(user)s uploaded %(artist)s - %(title)s') % {'user': sender, 'artist': artist, 'title': title}) def radiocolPlay(self, filename): found = False