comparison frontends/src/quick_frontend/quick_games.py @ 1379:da2ea16fabc6

quick_frontend: display MUC games symbols
author souliane <souliane@mailoo.org>
date Fri, 20 Mar 2015 16:29:03 +0100
parents 8ea8fa13c351
children a025242bebe7
comparison
equal deleted inserted replaced
1378:3dae6964c071 1379:da2ea16fabc6
21 log = getLogger(__name__) 21 log = getLogger(__name__)
22 22
23 from sat.core.i18n import _ 23 from sat.core.i18n import _
24 24
25 from sat_frontends.tools import jid 25 from sat_frontends.tools import jid
26 from sat_frontends.tools import games
26 from sat_frontends.quick_frontend.constants import Const as C 27 from sat_frontends.quick_frontend.constants import Const as C
27 28
28 import quick_chat 29 import quick_chat
29 30
30 31
51 def startedHandler(cls, host, suffix, *args): 52 def startedHandler(cls, host, suffix, *args):
52 room_jid, args, profile = jid.JID(args[0]), args[1:-1], args[-1] 53 room_jid, args, profile = jid.JID(args[0]), args[1:-1], args[-1]
53 referee, players, args = args[0], args[1], args[2:] 54 referee, players, args = args[0], args[1], args[2:]
54 chat_widget = host.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile) 55 chat_widget = host.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
55 56
56 # self.occupants_panel.updateSpecials(players, SYMBOLS[self._game_name.lower()]) # FIXME 57 # update symbols
58 if cls._game_name not in chat_widget.visible_states:
59 chat_widget.visible_states.append(cls._game_name)
60 symbols = games.SYMBOLS[cls._game_name]
61 index = 0
62 for occupant in chat_widget.occupants:
63 occupant_jid = jid.newResource(room_jid, occupant)
64 if occupant in players:
65 chat_widget.updateEntityState(occupant_jid, cls._game_name, symbols[index % len(symbols)])
66 else:
67 chat_widget.updateEntityState(occupant_jid, cls._game_name, None)
68
57 if suffix == "Players" or chat_widget.nick not in players: 69 if suffix == "Players" or chat_widget.nick not in players:
58 return # waiting for other players to join, or not playing 70 return # waiting for other players to join, or not playing
59 if cls._game_name in chat_widget.games: 71 if cls._game_name in chat_widget.games:
60 return # game panel is already there 72 return # game panel is already there
61 real_class = host.widgets.getRealClass(cls) 73 real_class = host.widgets.getRealClass(cls)