Mercurial > libervia-desktop-kivy
comparison src/cagou/plugins/plugin_wid_chat.py @ 97:5d2289127bb7
menu (upload): better menu using dedicated widget:
upload menu now use a decicated widget instead of context menu.
The menu take half the size of the main window, and show each upload option as an icon. Use can select upload or P2P sending, and a short text message explains how the file will be transmitted.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 29 Dec 2016 23:47:07 +0100 |
parents | 9a6121722669 |
children | 4d8c122b86a6 |
comparison
equal
deleted
inserted
replaced
96:641678ddc26c | 97:5d2289127bb7 |
---|---|
611 else: | 611 else: |
612 del self._waiting_pids[progress_id] | 612 del self._waiting_pids[progress_id] |
613 if cleaning_cb is not None: | 613 if cleaning_cb is not None: |
614 cleaning_cb() | 614 cleaning_cb() |
615 # TODO: display message to user | 615 # TODO: display message to user |
616 log.warning(u"Can't upload file: {}".format(err_msg)) | 616 log.warning(u"Can't transfer file: {}".format(err_msg)) |
617 | 617 |
618 def fileUploadDone(self, metadata, profile): | 618 def fileTransferDone(self, metadata, profile): |
619 log.debug("file uploaded: {}".format(metadata)) | 619 log.debug("file transfered: {}".format(metadata)) |
620 G.host.messageSend( | 620 G.host.messageSend( |
621 self.target, | 621 self.target, |
622 {'': metadata['url']}, | 622 {'': metadata['url']}, |
623 mess_type = C.MESS_TYPE_GROUPCHAT if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT, | 623 mess_type = C.MESS_TYPE_GROUPCHAT if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT, |
624 profile_key=profile | 624 profile_key=profile |
625 ) | 625 ) |
626 | 626 |
627 def fileUploadCb(self, progress_data, cleaning_cb): | 627 def fileTransferCb(self, progress_data, cleaning_cb): |
628 try: | 628 try: |
629 progress_id = progress_data['progress'] | 629 progress_id = progress_data['progress'] |
630 except KeyError: | 630 except KeyError: |
631 xmlui = progress_data['xmlui'] | 631 xmlui = progress_data['xmlui'] |
632 G.host.showUI(xmlui) | 632 G.host.showUI(xmlui) |
633 else: | 633 else: |
634 self._waiting_pids[progress_id] = (self.fileUploadDone, cleaning_cb) | 634 self._waiting_pids[progress_id] = (self.fileTransferDone, cleaning_cb) |
635 | 635 |
636 def onUploadOK(self, file_path, cleaning_cb): | 636 def onTransferOK(self, file_path, cleaning_cb): |
637 G.host.bridge.fileUpload( | 637 G.host.bridge.fileTransfer( |
638 file_path, | 638 file_path, |
639 "", | 639 "", |
640 "", | 640 "", |
641 {"ignore_tls_errors": C.BOOL_TRUE}, # FIXME: should not be the default | 641 {"ignore_tls_errors": C.BOOL_TRUE}, # FIXME: should not be the default |
642 self.profile, | 642 self.profile, |
643 callback = lambda progress_data: self.fileUploadCb(progress_data, cleaning_cb) | 643 callback = lambda progress_data: self.fileTransferCb(progress_data, cleaning_cb) |
644 ) | 644 ) |
645 | 645 |
646 def _mucJoinCb(self, joined_data): | 646 def _mucJoinCb(self, joined_data): |
647 joined, room_jid_s, occupants, user_nick, subject, profile = joined_data | 647 joined, room_jid_s, occupants, user_nick, subject, profile = joined_data |
648 self.host.mucRoomJoinedHandler(*joined_data[1:]) | 648 self.host.mucRoomJoinedHandler(*joined_data[1:]) |