Mercurial > libervia-desktop-kivy
diff src/cagou/plugins/plugin_wid_chat.py @ 86:c711be670ecd
core, chat: upload plugin system:
- extented plugin system so it's not only used with main widget. It is also used for upload widgets and can be extended more
- plugin file name is used to detect the type: plugin_wid_* for main widgets, plugin_upload_* for upload widget plugins
- a new UploadMenu class allows to easily add an upload button which will use loaded plugins
- plugin_info can now specify a list of allowed platforms in "platforms" key
- file upload in chat has been moved to a plugin
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 25 Dec 2016 16:41:21 +0100 |
parents | 46d962910801 |
children | 3dc526bb4a5a |
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_chat.py Sat Dec 24 14:20:49 2016 +0100 +++ b/src/cagou/plugins/plugin_wid_chat.py Sun Dec 25 16:41:21 2016 +0100 @@ -25,7 +25,6 @@ from kivy.uix.boxlayout import BoxLayout from kivy.uix.gridlayout import GridLayout from kivy.uix.stacklayout import StackLayout -from kivy.uix.scrollview import ScrollView from kivy.uix.textinput import TextInput from kivy.uix.label import Label from kivy.uix.image import AsyncImage @@ -548,25 +547,14 @@ pass -class FileUploader(BoxLayout): - - def __init__(self, parent_chat, **kwargs): - self.parent_chat = parent_chat - super(FileUploader, self).__init__(orientation='vertical', **kwargs) - - class Chat(quick_chat.QuickChat, cagou_widget.CagouWidget): message_input = properties.ObjectProperty() + messages_widget = properties.ObjectProperty() def __init__(self, host, target, type_=C.CHAT_ONE2ONE, nick=None, occupants=None, subject=None, profiles=None): quick_chat.QuickChat.__init__(self, host, target, type_, nick, occupants, subject, profiles=profiles) cagou_widget.CagouWidget.__init__(self) self.header_input.hint_text = u"{}".format(target) - scroll_view = ScrollView(size_hint=(1,0.8), scroll_y=0, do_scroll_x=False) - self.messages_widget = MessagesWidget() - scroll_view.add_widget(self.messages_widget) - self.add_widget(scroll_view) - self.add_widget(MessageInputBox()) self.host.addListener('progressError', self.onProgressError, profiles) self.host.addListener('progressFinished', self.onProgressFinished, profiles) self._waiting_pids = {} # waiting progress ids @@ -621,9 +609,6 @@ # TODO: display message to user log.warning(u"Can't upload file: {}".format(err_msg)) - def onUploadButton(self): - G.host.showExtraUI(FileUploader(self)) - def fileUploadDone(self, metadata, profile): log.debug("file uploaded: {}".format(metadata)) G.host.messageSend( @@ -642,21 +627,15 @@ else: self._waiting_pids[progress_id] = self.fileUploadDone - def onUploadOK(self, file_chooser): - if file_chooser.selection: - file_path = file_chooser.selection[0] - G.host.bridge.fileUpload( - file_path, - "", - "", - {"ignore_tls_errors": C.BOOL_TRUE}, # FIXME: should not be the default - self.profile, - callback = self.fileUploadCb - ) - G.host.closeUI() - - def onUploadCancel(self, file_chooser): - G.host.closeUI() + def onUploadOK(self, file_path): + G.host.bridge.fileUpload( + file_path, + "", + "", + {"ignore_tls_errors": C.BOOL_TRUE}, # FIXME: should not be the default + self.profile, + callback = self.fileUploadCb + ) def _mucJoinCb(self, joined_data): joined, room_jid_s, occupants, user_nick, subject, profile = joined_data