Mercurial > libervia-backend
comparison frontends/src/primitivus/chat.py @ 1580:641cfd2faefe
Primitivus: better popups handling:
- widget to remove can now be specified in removePopUp: if it is not the current one, it will be removed from queue
- Primitivus.Alert method is a shortcut to display an Alert which will be removed on "OK" press
- showDialog is now obsolete and removed, if generic dialog creation is needed, XMLUI can be used
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 11 Nov 2015 18:32:59 +0100 |
parents | e2e75c3c7c7b |
children | 95ea323e7d04 |
comparison
equal
deleted
inserted
replaced
1579:d5e332055d9f | 1580:641cfd2faefe |
---|---|
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core import log as logging | 21 from sat.core import log as logging |
22 log = logging.getLogger(__name__) | 22 log = logging.getLogger(__name__) |
23 import urwid | 23 import urwid |
24 from urwid_satext import sat_widgets | 24 from urwid_satext import sat_widgets |
25 from urwid_satext.files_management import FileDialog | 25 # from urwid_satext.files_management import FileDialog # FIXME |
26 from sat_frontends.quick_frontend import quick_widgets | 26 from sat_frontends.quick_frontend import quick_widgets |
27 from sat_frontends.quick_frontend.quick_chat import QuickChat | 27 from sat_frontends.quick_frontend.quick_chat import QuickChat |
28 from sat_frontends.quick_frontend import quick_games | 28 from sat_frontends.quick_frontend import quick_games |
29 from sat_frontends.primitivus import game_tarot | 29 from sat_frontends.primitivus import game_tarot |
30 from sat_frontends.primitivus.constants import Const as C | 30 from sat_frontends.primitivus.constants import Const as C |
376 else: | 376 else: |
377 self.host.bridge.tarotGameCreate(self.target, list(self.occupants), self.profile) | 377 self.host.bridge.tarotGameCreate(self.target, list(self.occupants), self.profile) |
378 | 378 |
379 def onSendFileRequest(self, menu): | 379 def onSendFileRequest(self, menu): |
380 # TODO: move this to core with dynamic menus | 380 # TODO: move this to core with dynamic menus |
381 dialog = FileDialog(ok_cb=self.onFileSelected, cancel_cb=self.host.removePopUp) | 381 pass |
382 self.host.showPopUp(dialog, 80, 80) | 382 # dialog = FileDialog(ok_cb=self.onFileSelected, cancel_cb=self.host.removePopUp) # FIXME: to be removed |
383 # self.host.showPopUp(dialog, 80, 80) | |
383 | 384 |
384 # MISC EVENTS # | 385 # MISC EVENTS # |
385 def onFileSelected(self, filepath): | 386 # FIXME: to be removed |
386 self.host.removePopUp() | 387 # def onFileSelected(self, filepath): |
387 try: | 388 # self.host.removePopUp() |
388 filepath = filepath.decode('utf-8') # FIXME: correctly manage unicode | 389 # try: |
389 except UnicodeError: | 390 # filepath = filepath.decode('utf-8') # FIXME: correctly manage unicode |
390 log.error("FIXME: filepath with unicode error are not managed yet") | 391 # except UnicodeError: |
391 self.host.showDialog(_(u"File has a unicode error in its name, it's not yet managed by SàT"), title=_("Can't send file"), type_="error") | 392 # log.error("FIXME: filepath with unicode error are not managed yet") |
392 return | 393 # self.host.showDialog(_(u"File has a unicode error in its name, it's not yet managed by SàT"), title=_("Can't send file"), type_="error") |
393 # FIXME: check last_resource: what if self.target.resource exists ? | 394 # return |
394 last_resource = self.host.bridge.getMainResource(unicode(self.target.bare), self.profile) | 395 # # FIXME: check last_resource: what if self.target.resource exists ? |
395 if last_resource: | 396 # last_resource = self.host.bridge.getMainResource(unicode(self.target.bare), self.profile) |
396 full_jid = jid.JID("%s/%s" % (self.target.bare, last_resource)) | 397 # if last_resource: |
397 else: | 398 # full_jid = jid.JID("%s/%s" % (self.target.bare, last_resource)) |
398 full_jid = self.target | 399 # else: |
399 progress_id = self.host.bridge.sendFile(full_jid, filepath, {}, self.profile) | 400 # full_jid = self.target |
400 self.host.addProgress(progress_id, filepath) | 401 # progress_id = self.host.bridge.sendFile(full_jid, filepath, {}, self.profile) |
401 self.host.showDialog(_(u"You file request has been sent, we are waiting for your contact answer"), title=_("File request sent")) | 402 # self.host.addProgress(progress_id, filepath) |
403 # self.host.showDialog(_(u"You file request has been sent, we are waiting for your contact answer"), title=_("File request sent")) | |
402 | 404 |
403 def onDelete(self): | 405 def onDelete(self): |
404 QuickChat.onDelete(self) | 406 QuickChat.onDelete(self) |
405 if self.type == C.CHAT_GROUP: | 407 if self.type == C.CHAT_GROUP: |
406 self.host.removeListener('presence', self.presenceListener) | 408 self.host.removeListener('presence', self.presenceListener) |