Mercurial > libervia-web
comparison browser_side/panels.py @ 273:11718798ab8a
browser_side: can identify muc members with symbols
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 21 Nov 2013 16:03:33 +0100 |
parents | 9eb9c7d41bdc |
children | a763b2ac5d41 |
comparison
equal
deleted
inserted
replaced
272:0cb9869b42b6 | 273:11718798ab8a |
---|---|
624 | 624 |
625 | 625 |
626 class Occupant(HTML): | 626 class Occupant(HTML): |
627 """Occupant of a MUC room""" | 627 """Occupant of a MUC room""" |
628 | 628 |
629 def __init__(self, nick): | 629 def __init__(self, nick, special=""): |
630 HTML.__init__(self) | |
630 self.nick = nick | 631 self.nick = nick |
631 HTML.__init__(self, "<div class='occupant'>%s</div>" % html_sanitize(nick)) | 632 self.special = special |
633 self._refresh() | |
632 | 634 |
633 def __str__(self): | 635 def __str__(self): |
634 return self.nick | 636 return self.nick |
637 | |
638 def addSpecial(self, special=""): | |
639 if special not in self.special: | |
640 self.special += special | |
641 self._refresh() | |
642 | |
643 def _refresh(self): | |
644 special = "" if len(self.special) == 0 else " %s" % self.special | |
645 self.setHTML("<div class='occupant'>%s%s</div>" % (html_sanitize(self.nick), special)) | |
635 | 646 |
636 | 647 |
637 class OccupantsList(AbsolutePanel): | 648 class OccupantsList(AbsolutePanel): |
638 """Panel user to show occupants of a room""" | 649 """Panel user to show occupants of a room""" |
639 | 650 |
654 print "ERROR: trying to remove an unexisting nick" | 665 print "ERROR: trying to remove an unexisting nick" |
655 | 666 |
656 def clear(self): | 667 def clear(self): |
657 self.occupants_list.clear() | 668 self.occupants_list.clear() |
658 AbsolutePanel.clear(self) | 669 AbsolutePanel.clear(self) |
670 | |
671 def addSpecials(self, occupants=[], html=""): | |
672 index = 0 | |
673 special = html | |
674 for occupant in occupants: | |
675 if occupant in self.occupants_list.keys(): | |
676 if isinstance(html, list): | |
677 special = html[index] | |
678 index = (index + 1) % len(html) | |
679 self.occupants_list[occupant].addSpecial(special) | |
659 | 680 |
660 | 681 |
661 class ChatPanel(base_widget.LiberviaWidget): | 682 class ChatPanel(base_widget.LiberviaWidget): |
662 | 683 |
663 def __init__(self, host, target, type_='one2one'): | 684 def __init__(self, host, target, type_='one2one'): |