comparison cagou/plugins/plugin_wid_file_sharing.py @ 404:f7476818f9fb

core (common): JidSelector + behaviors various improvments: - renamed *Behaviour => *Behavior to be consistent with Kivy + moved to new "core.behaviors" modules - use a dedicated property in ContactItem for notification counter (which is now named "badge") - in JidSelector, well-known strings now create use a dedicated layout, add separator (except if new `add_separators` property is set to False), and are added to attribute of the same name - a new `item_class` property is now used to indicate the class to instanciate for items (by default it's a ContactItem) - FilterBahavior.do_filter now expect the parent layout instead of directly the children, this is to allow a FilterBahavior to manage several children layout at once (used with JidSelector) - core.utils has been removed, as the behavior there has been moved to core.behaviors
author Goffi <goffi@goffi.org>
date Wed, 12 Feb 2020 20:02:58 +0100
parents d61bbbac4160
children 3c9ba4a694ef
comparison
equal deleted inserted replaced
403:b0af45a92055 404:f7476818f9fb
24 from sat.core import exceptions 24 from sat.core import exceptions
25 from sat.core.i18n import _ 25 from sat.core.i18n import _
26 from sat.tools.common import files_utils 26 from sat.tools.common import files_utils
27 from sat_frontends.quick_frontend import quick_widgets 27 from sat_frontends.quick_frontend import quick_widgets
28 from sat_frontends.tools import jid 28 from sat_frontends.tools import jid
29 from cagou.core.constants import Const as C 29 from ..core.constants import Const as C
30 from cagou.core import cagou_widget 30 from ..core import cagou_widget
31 from cagou.core.menu import EntitiesSelectorMenu, TouchMenuBehaviour 31 from ..core.menu import EntitiesSelectorMenu
32 from cagou.core.utils import FilterBehavior 32 from ..core.behaviors import TouchMenuBehavior, FilterBehavior
33 from cagou.core.common_widgets import (Identities, ItemWidget, DeviceWidget, 33 from ..core.common_widgets import (Identities, ItemWidget, DeviceWidget,
34 CategorySeparator) 34 CategorySeparator)
35 from cagou import G 35 from cagou import G
36 from kivy import properties 36 from kivy import properties
37 from kivy.uix.label import Label 37 from kivy.uix.label import Label
38 from kivy.uix.button import Button 38 from kivy.uix.button import Button
146 self.main_wid.remote_entity = self.entity_jid 146 self.main_wid.remote_entity = self.entity_jid
147 self.main_wid.remote_dir = '' 147 self.main_wid.remote_dir = ''
148 148
149 149
150 class FileSharing(quick_widgets.QuickWidget, cagou_widget.CagouWidget, FilterBehavior, 150 class FileSharing(quick_widgets.QuickWidget, cagou_widget.CagouWidget, FilterBehavior,
151 TouchMenuBehaviour): 151 TouchMenuBehavior):
152 SINGLE=False 152 SINGLE=False
153 layout = properties.ObjectProperty() 153 layout = properties.ObjectProperty()
154 mode = properties.OptionProperty(MODE_VIEW, options=[MODE_VIEW, MODE_LOCAL]) 154 mode = properties.OptionProperty(MODE_VIEW, options=[MODE_VIEW, MODE_LOCAL])
155 local_dir = properties.StringProperty(expanduser('~')) 155 local_dir = properties.StringProperty(expanduser('~'))
156 remote_dir = properties.StringProperty('') 156 remote_dir = properties.StringProperty('')
161 161
162 def __init__(self, host, target, profiles): 162 def __init__(self, host, target, profiles):
163 quick_widgets.QuickWidget.__init__(self, host, target, profiles) 163 quick_widgets.QuickWidget.__init__(self, host, target, profiles)
164 cagou_widget.CagouWidget.__init__(self) 164 cagou_widget.CagouWidget.__init__(self)
165 FilterBehavior.__init__(self) 165 FilterBehavior.__init__(self)
166 TouchMenuBehaviour.__init__(self) 166 TouchMenuBehavior.__init__(self)
167 self.mode_btn = ModeBtn(self) 167 self.mode_btn = ModeBtn(self)
168 self.mode_btn.bind(on_release=self.change_mode) 168 self.mode_btn.bind(on_release=self.change_mode)
169 self.headerInputAddExtra(self.mode_btn) 169 self.headerInputAddExtra(self.mode_btn)
170 self.bind(local_dir=self.update_view, 170 self.bind(local_dir=self.update_view,
171 remote_dir=self.update_view, 171 remote_dir=self.update_view,
214 214
215 def onHeaderInputComplete(self, wid, text, **kwargs): 215 def onHeaderInputComplete(self, wid, text, **kwargs):
216 """we filter items when text is entered in input box""" 216 """we filter items when text is entered in input box"""
217 if '/' in text: 217 if '/' in text:
218 return 218 return
219 self.do_filter(self.layout.children, 219 self.do_filter(self.layout,
220 text, 220 text,
221 lambda c: c.name, 221 lambda c: c.name,
222 width_cb=lambda c: c.base_width, 222 width_cb=lambda c: c.base_width,
223 height_cb=lambda c: c.minimum_height, 223 height_cb=lambda c: c.minimum_height,
224 continue_tests=[lambda c: not isinstance(c, ItemWidget), 224 continue_tests=[lambda c: not isinstance(c, ItemWidget),