Mercurial > libervia-web
comparison src/browser/sat_browser/chat.py @ 648:6d3142b782c3 frontends_multi_profiles
browser_side: classes reorganisation:
- moved widgets in dedicated modules (base, contact, editor, libervia) and a widget module for single classes
- same thing for panels (base, main, contact)
- libervia_widget mix main panels and widget and drag n drop for technical reasons (see comments)
- renamed WebPanel to WebWidget
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Feb 2015 18:10:54 +0100 |
parents | 9092e624bb27 |
children | 0262fee86375 |
comparison
equal
deleted
inserted
replaced
647:e0021d571eef | 648:6d3142b782c3 |
---|---|
37 | 37 |
38 from datetime import datetime | 38 from datetime import datetime |
39 from time import time | 39 from time import time |
40 | 40 |
41 import html_tools | 41 import html_tools |
42 import base_panels | 42 import libervia_widget |
43 import panels | 43 import base_panel |
44 import contact_panel | |
45 import editor_widget | |
44 import card_game | 46 import card_game |
45 import radiocol | 47 import radiocol |
46 import base_widget | |
47 import contact_list | 48 import contact_list |
48 from constants import Const as C | 49 from constants import Const as C |
49 import plugin_xep_0085 | 50 import plugin_xep_0085 |
50 | 51 |
51 | 52 |
71 "msg": strings.addURLToText(html_tools.html_sanitize(msg)) if not xhtml else html_tools.inlineRoot(xhtml)} # FIXME: images and external links must be removed according to preferences | 72 "msg": strings.addURLToText(html_tools.html_sanitize(msg)) if not xhtml else html_tools.inlineRoot(xhtml)} # FIXME: images and external links must be removed according to preferences |
72 ) | 73 ) |
73 self.setStyleName('chatText') | 74 self.setStyleName('chatText') |
74 | 75 |
75 | 76 |
76 class Chat(QuickChat, base_widget.LiberviaWidget, KeyboardHandler): | 77 class Chat(QuickChat, libervia_widget.LiberviaWidget, KeyboardHandler): |
77 | 78 |
78 def __init__(self, host, target, type_=C.CHAT_ONE2ONE, profiles=None): | 79 def __init__(self, host, target, type_=C.CHAT_ONE2ONE, profiles=None): |
79 """Panel used for conversation (one 2 one or group chat) | 80 """Panel used for conversation (one 2 one or group chat) |
80 | 81 |
81 @param host: SatWebFrontend instance | 82 @param host: SatWebFrontend instance |
89 # FIXME: temporary dirty initialization to display the OTR state | 90 # FIXME: temporary dirty initialization to display the OTR state |
90 def header_info_cb(cb): | 91 def header_info_cb(cb): |
91 host.plugins['otr'].infoTextCallback(target, cb) | 92 host.plugins['otr'].infoTextCallback(target, cb) |
92 header_info = header_info_cb if (type_ == C.CHAT_ONE2ONE and 'otr' in host.plugins) else None | 93 header_info = header_info_cb if (type_ == C.CHAT_ONE2ONE and 'otr' in host.plugins) else None |
93 | 94 |
94 base_widget.LiberviaWidget.__init__(self, host, title=unicode(target.bare), info=header_info, selectable=True) | 95 libervia_widget.LiberviaWidget.__init__(self, host, title=unicode(target.bare), info=header_info, selectable=True) |
95 self._body = AbsolutePanel() | 96 self._body = AbsolutePanel() |
96 self._body.setStyleName('chatPanel_body') | 97 self._body.setStyleName('chatPanel_body') |
97 chat_area = HorizontalPanel() | 98 chat_area = HorizontalPanel() |
98 chat_area.setStyleName('chatArea') | 99 chat_area.setStyleName('chatArea') |
99 if type_ == C.CHAT_GROUP: | 100 if type_ == C.CHAT_GROUP: |
100 self.occupants_list = base_panels.OccupantsList() | 101 self.occupants_list = contact_panel.OccupantsList() |
101 self.occupants_initialised = False | 102 self.occupants_initialised = False |
102 chat_area.add(self.occupants_list) | 103 chat_area.add(self.occupants_list) |
103 self._body.add(chat_area) | 104 self._body.add(chat_area) |
104 self.content = AbsolutePanel() | 105 self.content = AbsolutePanel() |
105 self.content.setStyleName('chatContent') | 106 self.content.setStyleName('chatContent') |
106 self.content_scroll = base_widget.ScrollPanelWrapper(self.content) | 107 self.content_scroll = base_panel.ScrollPanelWrapper(self.content) |
107 chat_area.add(self.content_scroll) | 108 chat_area.add(self.content_scroll) |
108 chat_area.setCellWidth(self.content_scroll, '100%') | 109 chat_area.setCellWidth(self.content_scroll, '100%') |
109 self.vpanel.add(self._body) | 110 self.vpanel.add(self._body) |
110 self.vpanel.setCellHeight(self._body, '100%') | 111 self.vpanel.setCellHeight(self._body, '100%') |
111 self.addStyleName('chatPanel') | 112 self.addStyleName('chatPanel') |
151 | 152 |
152 enable_box = self.host.uni_box is None | 153 enable_box = self.host.uni_box is None |
153 if hasattr(self, 'message_box'): | 154 if hasattr(self, 'message_box'): |
154 self.message_box.setVisible(enable_box) | 155 self.message_box.setVisible(enable_box) |
155 elif enable_box: | 156 elif enable_box: |
156 self.message_box = panels.MessageBox(self.host) | 157 self.message_box = editor_widget.MessageBox(self.host) |
157 self.message_box.onSelectedChange(self) | 158 self.message_box.onSelectedChange(self) |
158 self.message_box.addKeyboardListener(self) | 159 self.message_box.addKeyboardListener(self) |
159 self.vpanel.add(self.message_box) | 160 self.vpanel.add(self.message_box) |
160 | 161 |
161 def onKeyDown(self, sender, keycode, modifiers): | 162 def onKeyDown(self, sender, keycode, modifiers): |
205 profile_key=C.PROF_KEY_NONE | 206 profile_key=C.PROF_KEY_NONE |
206 ) | 207 ) |
207 self.state_machine._onEvent("active") | 208 self.state_machine._onEvent("active") |
208 | 209 |
209 def onQuit(self): | 210 def onQuit(self): |
210 base_widget.LiberviaWidget.onQuit(self) | 211 libervia_widget.LiberviaWidget.onQuit(self) |
211 if self.type == C.CHAT_GROUP: | 212 if self.type == C.CHAT_GROUP: |
212 self.host.bridge.call('mucLeave', None, unicode(self.target.bare)) | 213 self.host.bridge.call('mucLeave', None, unicode(self.target.bare)) |
213 | 214 |
214 def setUserNick(self, nick): | 215 def setUserNick(self, nick): |
215 """Set the nick of the user, usefull for e.g. change the color of the user""" | 216 """Set the nick of the user, usefull for e.g. change the color of the user""" |
361 #TODO | 362 #TODO |
362 pass | 363 pass |
363 | 364 |
364 | 365 |
365 quick_widgets.register(QuickChat, Chat) | 366 quick_widgets.register(QuickChat, Chat) |
366 base_widget.LiberviaWidget.addDropKey("CONTACT", lambda host, item: host.displayWidget(Chat, jid.JID(item), dropped=True)) | 367 libervia_widget.LiberviaWidget.addDropKey("CONTACT", lambda host, item: host.displayWidget(Chat, jid.JID(item), dropped=True)) |