Mercurial > libervia-web
comparison src/browser/sat_browser/chat.py @ 598:ed6d8f7c6026 frontends_multi_profiles
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Feb 2015 19:25:17 +0100 |
parents | a5019e62c3e9 |
children | 1c0d5a87c554 |
comparison
equal
deleted
inserted
replaced
597:be2891462e63 | 598:ed6d8f7c6026 |
---|---|
75 def __init__(self, host, target, type_=C.CHAT_ONE2ONE, profiles=None): | 75 def __init__(self, host, target, type_=C.CHAT_ONE2ONE, profiles=None): |
76 """Panel used for conversation (one 2 one or group chat) | 76 """Panel used for conversation (one 2 one or group chat) |
77 | 77 |
78 @param host: SatWebFrontend instance | 78 @param host: SatWebFrontend instance |
79 @param target: entity (jid.JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room) | 79 @param target: entity (jid.JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room) |
80 @param type: one2one for simple conversation, group for MUC""" | 80 @param type: one2one for simple conversation, group for MUC |
81 """ | |
81 QuickChat.__init__(self, host, target, type_, profiles=profiles) | 82 QuickChat.__init__(self, host, target, type_, profiles=profiles) |
82 self.vpanel = VerticalPanel() | 83 self.vpanel = VerticalPanel() |
83 self.vpanel.setSize('100%', '100%') | 84 self.vpanel.setSize('100%', '100%') |
84 | 85 |
85 # FIXME: temporary dirty initialization to display the OTR state | 86 # FIXME: temporary dirty initialization to display the OTR state |
125 # FIXME: for unknow reason, pyjamas doesn't use the method inherited from QuickWidget | 126 # FIXME: for unknow reason, pyjamas doesn't use the method inherited from QuickWidget |
126 # FIXME: must remove this when either pyjamas is fixed, or we use an alternative | 127 # FIXME: must remove this when either pyjamas is fixed, or we use an alternative |
127 assert len(self.profiles) == 1 and not self.PROFILES_MULTIPLE and not self.PROFILES_ALLOW_NONE | 128 assert len(self.profiles) == 1 and not self.PROFILES_MULTIPLE and not self.PROFILES_ALLOW_NONE |
128 return list(self.profiles)[0] | 129 return list(self.profiles)[0] |
129 | 130 |
130 @classmethod | 131 # @classmethod |
131 def registerClass(cls): | 132 # def createPanel(cls, host, item, type_=C.CHAT_ONE2ONE): |
132 base_widget.LiberviaWidget.addDropKey("CONTACT", cls.createPanel) | 133 # assert(item) |
133 | 134 # _contact = item if isinstance(item, jid.JID) else jid.JID(item) |
134 @classmethod | 135 # host.contact_panel.setContactMessageWaiting(_contact.bare, False) |
135 def createPanel(cls, host, item, type_=C.CHAT_ONE2ONE): | 136 # _new_panel = Chat(host, _contact, type_) # XXX: pyjamas doesn't seems to support creating with cls directly |
136 assert(item) | 137 # _new_panel.historyPrint() |
137 _contact = item if isinstance(item, jid.JID) else jid.JID(item) | 138 # host.setSelected(_new_panel) |
138 host.contact_panel.setContactMessageWaiting(_contact.bare, False) | 139 # _new_panel.refresh() |
139 _new_panel = Chat(host, _contact, type_) # XXX: pyjamas doesn't seems to support creating with cls directly | 140 # return _new_panel |
140 _new_panel.historyPrint() | |
141 host.setSelected(_new_panel) | |
142 _new_panel.refresh() | |
143 return _new_panel | |
144 | 141 |
145 def refresh(self): | 142 def refresh(self): |
146 """Refresh the display of this widget. If the unibox is disabled, | 143 """Refresh the display of this widget. If the unibox is disabled, |
147 add a message box at the bottom of the panel""" | 144 add a message box at the bottom of the panel""" |
148 # FIXME: must be checked | 145 # FIXME: must be checked |
359 | 356 |
360 def updateChatState(self, from_jid, state): | 357 def updateChatState(self, from_jid, state): |
361 #TODO | 358 #TODO |
362 pass | 359 pass |
363 | 360 |
361 | |
364 quick_widgets.register(QuickChat, Chat) | 362 quick_widgets.register(QuickChat, Chat) |
363 base_widget.LiberviaWidget.addDropKey("CONTACT", lambda host, item: host.widgets.getOrCreateWidget(Chat, jid.JID(item), profile=C.PROF_KEY_NONE, on_new_widget=None, on_existing_widget=C.WIDGET_RECREATE)) |