comparison browser_side/panels.py @ 231:fab7aa366576

browser_side: dialogs take **kwargs arguments + unibox helper method - add the **kwargs arguments to the dialog classes, especially to pass the Width='xxx' setting - add a method getTargetAndData to UniBox, for external use and to get the message recipient and body without dealing with the target hooks, selected panels...
author souliane <souliane@mailoo.org>
date Tue, 08 Oct 2013 13:38:42 +0200
parents 266e9678eec0
children 0ed09cc0566f
comparison
equal deleted inserted replaced
230:266e9678eec0 231:fab7aa366576
207 self.setText('') 207 self.setText('')
208 self._timeCb(None) # we remove the popup 208 self._timeCb(None) # we remove the popup
209 sender.cancelKey() 209 sender.cancelKey()
210 else: 210 else:
211 self.__onComposing() 211 self.__onComposing()
212
213 def getTargetAndData(self):
214 """For external use, to get information about the (hypothetical) message
215 that would be sent if we press Enter right now in the unibox.
216 @return a tuple (target, data) with:
217 - data: what would be the content of the message (body)
218 - target: JID, group with the prefix "@" or the public entity "@@"
219 """
220 _txt = self.getText()
221 target_hook, _type, _msg = self._getTarget(_txt)
222 if target_hook:
223 data, target = target_hook
224 if target is None:
225 return target_hook
226 return (data, "@%s" % (target if target != "" else "@"))
227 if isinstance(self._selected_cache, MicroblogPanel):
228 groups = self._selected_cache.accepted_groups
229 target = "@%s" % (groups[0] if len(groups) > 0 else "@")
230 if len(groups) > 1:
231 Window.alert("Sole the first group of the selected panel is taken in consideration: '%s'" % groups[0])
232 elif isinstance(self._selected_cache, ChatPanel):
233 target = self._selected_cache.target
234 return (_txt, target)
212 235
213 def __onComposing(self): 236 def __onComposing(self):
214 """Callback when the user is composing a text.""" 237 """Callback when the user is composing a text."""
215 if hasattr(self._selected_cache, "target"): 238 if hasattr(self._selected_cache, "target"):
216 self._selected_cache.state_machine._onEvent("composing") 239 self._selected_cache.state_machine._onEvent("composing")