Mercurial > libervia-desktop-kivy
comparison cagou/core/menu.py @ 312:772c170b47a9
Python3 port:
/!\ Cagou now runs with Python 3.6+
Port has been done in the same way as for backend (check backend commit b2d067339de3
message for details).
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Aug 2019 19:14:22 +0200 |
parents | f55b60659ec1 |
children | e2b51663d8b8 |
comparison
equal
deleted
inserted
replaced
311:a0d978d3ce84 | 312:772c170b47a9 |
---|---|
37 from functools import partial | 37 from functools import partial |
38 import webbrowser | 38 import webbrowser |
39 | 39 |
40 log = logging.getLogger(__name__) | 40 log = logging.getLogger(__name__) |
41 | 41 |
42 ABOUT_TITLE = _(u"About {}".format(C.APP_NAME)) | 42 ABOUT_TITLE = _("About {}".format(C.APP_NAME)) |
43 ABOUT_CONTENT = _(u"""[b]Cagou (Salut à Toi)[/b] | 43 ABOUT_CONTENT = _("""[b]Cagou (Salut à Toi)[/b] |
44 | 44 |
45 [u]cagou version[/u]: | 45 [u]cagou version[/u]: |
46 {version} | 46 {version} |
47 | 47 |
48 [u]backend version[/u]: | 48 [u]backend version[/u]: |
97 profile = list(selected.profiles)[0] | 97 profile = list(selected.profiles)[0] |
98 except (AttributeError, IndexError): | 98 except (AttributeError, IndexError): |
99 try: | 99 try: |
100 profile = list(G.host.profiles)[0] | 100 profile = list(G.host.profiles)[0] |
101 except IndexError: | 101 except IndexError: |
102 log.warning(u"Can't find profile") | 102 log.warning("Can't find profile") |
103 self.item.call(selected, profile) | 103 self.item.call(selected, profile) |
104 | 104 |
105 | 105 |
106 class MenuSeparator(contextmenu.ContextMenuDivider): | 106 class MenuSeparator(contextmenu.ContextMenuDivider): |
107 pass | 107 pass |
160 caller.add_widget(wid) | 160 caller.add_widget(wid) |
161 elif isinstance(child, quick_menus.MenuItem): | 161 elif isinstance(child, quick_menus.MenuItem): |
162 wid = MenuItem(item=child) | 162 wid = MenuItem(item=child) |
163 caller.add_widget(wid) | 163 caller.add_widget(wid) |
164 else: | 164 else: |
165 log.error(u"Unknown child type: {}".format(child)) | 165 log.error("Unknown child type: {}".format(child)) |
166 | 166 |
167 def createMenus(self, caller): | 167 def createMenus(self, caller): |
168 self.clear_widgets() | 168 self.clear_widgets() |
169 self._buildMenus(self.menus_container, caller) | 169 self._buildMenus(self.menus_container, caller) |
170 | 170 |
271 | 271 |
272 def _closeUI(self, wid): | 272 def _closeUI(self, wid): |
273 G.host.closeUI() | 273 G.host.closeUI() |
274 | 274 |
275 def do_callback(self, *args, **kwargs): | 275 def do_callback(self, *args, **kwargs): |
276 log.warning(u"callback not implemented") | 276 log.warning("callback not implemented") |
277 | 277 |
278 | 278 |
279 class TransferMenu(SideMenu): | 279 class TransferMenu(SideMenu): |
280 """transfer menu which handle display and callbacks""" | 280 """transfer menu which handle display and callbacks""" |
281 # callback will be called with path to file to transfer | 281 # callback will be called with path to file to transfer |
282 # profiles if set will be sent to transfer widget, may be used to get specific files | 282 # profiles if set will be sent to transfer widget, may be used to get specific files |
283 profiles = properties.ObjectProperty() | 283 profiles = properties.ObjectProperty() |
284 transfer_txt = _(u"Beware! The file will be sent to your server and stay unencrypted " | 284 transfer_txt = _("Beware! The file will be sent to your server and stay unencrypted " |
285 u"there\nServer admin(s) can see the file, and they choose how, " | 285 "there\nServer admin(s) can see the file, and they choose how, " |
286 u"when and if it will be deleted") | 286 "when and if it will be deleted") |
287 send_txt = _(u"The file will be sent unencrypted directly to your contact " | 287 send_txt = _("The file will be sent unencrypted directly to your contact " |
288 u"(without transiting by the server), except in some cases") | 288 "(without transiting by the server), except in some cases") |
289 items_layout = properties.ObjectProperty() | 289 items_layout = properties.ObjectProperty() |
290 size_hint_close = (1, 0) | 290 size_hint_close = (1, 0) |
291 size_hint_open = (1, 0.5) | 291 size_hint_open = (1, 0.5) |
292 | 292 |
293 def __init__(self, **kwargs): | 293 def __init__(self, **kwargs): |
301 self.items_layout.add_widget(item) | 301 self.items_layout.add_widget(item) |
302 | 302 |
303 def do_callback(self, plug_info): | 303 def do_callback(self, plug_info): |
304 self.parent.remove_widget(self) | 304 self.parent.remove_widget(self) |
305 if self.callback is None: | 305 if self.callback is None: |
306 log.warning(u"TransferMenu callback is not set") | 306 log.warning("TransferMenu callback is not set") |
307 else: | 307 else: |
308 wid = None | 308 wid = None |
309 external = plug_info.get('external', False) | 309 external = plug_info.get('external', False) |
310 def onTransferCb(file_path, cleaning_cb=None): | 310 def onTransferCb(file_path, cleaning_cb=None): |
311 if not external: | 311 if not external: |
325 | 325 |
326 class EntitiesSelectorMenu(SideMenu, FilterBehavior): | 326 class EntitiesSelectorMenu(SideMenu, FilterBehavior): |
327 """allow to select entities from roster""" | 327 """allow to select entities from roster""" |
328 profiles = properties.ObjectProperty() | 328 profiles = properties.ObjectProperty() |
329 layout = properties.ObjectProperty() | 329 layout = properties.ObjectProperty() |
330 instructions = properties.StringProperty(_(u"Please select entities")) | 330 instructions = properties.StringProperty(_("Please select entities")) |
331 filter_input = properties.ObjectProperty() | 331 filter_input = properties.ObjectProperty() |
332 size_hint_close = (None, 1) | 332 size_hint_close = (None, 1) |
333 size_hint_open = (None, 1) | 333 size_hint_open = (None, 1) |
334 size_open = (dp(250), 100) | 334 size_open = (dp(250), 100) |
335 size_close = (0, 100) | 335 size_close = (0, 100) |