# HG changeset patch # User Goffi # Date 1580156229 -3600 # Node ID 5d994be1161b68c615d177229819bd719dff16a2 # Parent 1481f09c917577dec3403d7871b5bfee394c9a69 core: removed root menus (i.e. global menu on top of window): root menus were not really useful as most actions doable there are doable through others widgets in Cagou. For actions without equivalent in widgets (like about screen), a new menu, more discreet, will be added soon. Kivy Garden's ContextMenu is not used anymore, so it has been removed from dependencies diff -r 1481f09c9175 -r 5d994be1161b .p4a --- a/.p4a Mon Jan 27 21:17:08 2020 +0100 +++ b/.p4a Mon Jan 27 21:17:09 2020 +0100 @@ -4,7 +4,7 @@ --dist-name cagou_dev_build --debug --bootstrap=sdl2 ---requirements "hostpython3, kivy, kivy_garden.modernmenu, kivy_garden.contextmenu>=0.1.0.dev1, sqlite3, omemo, omemo-backend-signal, service_identity, automat, attrs, hyperlink, requests, treq, twisted, wokkel, hg+https://repos.goffi.org/sat, hg+https://repos.goffi.org/sat_tmp, pillow, pyxdg, markdown, html2text, python-dateutil, pycrypto, git+https://github.com/kivy/plyer.git, android, python-potr, shortuuid, babel, lxml, pudb, urwid, cryptography, openssl, pyopenssl, pyasn1, pyasn1-modules" +--requirements "hostpython3, kivy, kivy_garden.modernmenu, sqlite3, omemo, omemo-backend-signal, service_identity, automat, attrs, hyperlink, requests, treq, twisted, wokkel, hg+https://repos.goffi.org/sat, hg+https://repos.goffi.org/sat_tmp, pillow, pyxdg, markdown, html2text, python-dateutil, pycrypto, git+https://github.com/kivy/plyer.git, android, python-potr, shortuuid, babel, lxml, pudb, urwid, cryptography, openssl, pyopenssl, pyasn1, pyasn1-modules" --private . --package=org.salutatoi.cagou --name "Cagou" --version 0.1 --whitelist .p4a_whitelist diff -r 1481f09c9175 -r 5d994be1161b cagou/core/cagou_main.py --- a/cagou/core/cagou_main.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/core/cagou_main.py Mon Jan 27 21:17:09 2020 +0100 @@ -66,7 +66,6 @@ from .share_widget import ShareWidget from . import widgets_handler from .common import IconButton -from . import menu from . import dialog from importlib import import_module import sat @@ -220,16 +219,11 @@ self.manager.switch_to(screen) -class RootMenus(menu.MenusWidget): - HEIGHT = dp(30) - - class RootBody(BoxLayout): pass class CagouRootWidget(FloatLayout): - root_menus = properties.ObjectProperty() root_body = properties.ObjectProperty def __init__(self, main_widget): @@ -365,14 +359,6 @@ else: Window.fullscreen = False return True - elif key == 109 and modifier == ['alt']: - # M-m we hide/show menu - menu = self.root.root_menus - if menu.height: - Animation(height=0, duration=0.3).start(menu) - else: - Animation(height=menu.HEIGHT, duration=0.3).start(menu) - return True elif key == 110 and modifier == ['alt']: # M-n we hide/show notifications head = self.root.head_widget @@ -908,16 +894,6 @@ self.switchWidget(None, factory(plg_infos, target=target, profiles=profiles)) - ## menus ## - - def _menusGetCb(self, backend_menus): - main_menu = self.app.root.root_menus - self.menus.addMenus(backend_menus) - self.menus.addMenu(C.MENU_GLOBAL, - (_("Help"), _("About")), - callback=main_menu.onAbout) - main_menu.update(C.MENU_GLOBAL) - ## bridge handlers ## def otrStateHandler(self, state, dest_jid, profile): @@ -953,7 +929,6 @@ def plugging_profiles(self): self.widgets_handler = widgets_handler.WidgetsHandler() self.app.root.changeWidget(self.widgets_handler) - self.bridge.menusGet("", C.NO_SECURITY_LIMIT, callback=self._menusGetCb) def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): log.info("Profile presence status set to {show}/{status}".format(show=show, diff -r 1481f09c9175 -r 5d994be1161b cagou/core/menu.py --- a/cagou/core/menu.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/core/menu.py Mon Jan 27 21:17:09 2020 +0100 @@ -27,8 +27,7 @@ from kivy.uix.popup import Popup from cagou.core.utils import FilterBehavior from kivy import properties -from kivy_garden import contextmenu, modernmenu -from sat_frontends.quick_frontend import quick_menus +from kivy_garden import modernmenu from kivy.core.window import Window from kivy.animation import Animation from kivy.metrics import dp @@ -70,115 +69,6 @@ return super(AboutPopup, self).on_touch_down(touch) -class MainMenu(contextmenu.AppMenu): - pass - - -class MenuItem(contextmenu.ContextMenuTextItem): - item = properties.ObjectProperty() - - def on_item(self, instance, item): - self.text = item.name - - def on_release(self): - super(MenuItem, self).on_release() - self.parent.hide() - selected = G.host.selected_widget - profile = None - if selected is not None: - try: - # FIXME: handle multi-profiles - profile = next(iter(selected.profiles)) - except AttributeError: - pass - - if profile is None: - try: - profile = list(selected.profiles)[0] - except (AttributeError, IndexError): - try: - profile = list(G.host.profiles)[0] - except IndexError: - log.warning("Can't find profile") - self.item.call(selected, profile) - - -class MenuSeparator(contextmenu.ContextMenuDivider): - pass - - -class RootMenuContainer(contextmenu.AppMenuTextItem): - pass - - -class MenuContainer(contextmenu.ContextMenuTextItem): - pass - - -class MenusWidget(BoxLayout): - - def update(self, type_, caller=None): - """Method to call when menus have changed - - @param type_(unicode): menu type like in sat.core.sat_main.importMenu - @param caller(Widget): instance linked to the menus - """ - self.menus_container = G.host.menus.getMainContainer(type_) - self.createMenus(caller) - - def _buildMenus(self, container, caller=None): - """Recursively build menus of the container - - @param container(quick_menus.MenuContainer): menu container - @param caller(Widget): instance linked to the menus - """ - if caller is None: - main_menu = MainMenu() - self.add_widget(main_menu) - caller = main_menu - else: - context_menu = contextmenu.ContextMenu() - caller.add_widget(context_menu) - # FIXME: next line is needed after parent is set to avoid - # a display bug in contextmenu - # TODO: fix this upstream - context_menu._on_visible(False) - - caller = context_menu - - for child in container.getActiveMenus(): - if isinstance(child, quick_menus.MenuContainer): - if isinstance(caller, MainMenu): - menu_container = RootMenuContainer() - else: - menu_container = MenuContainer() - menu_container.text = child.name - caller.add_widget(menu_container) - self._buildMenus(child, caller=menu_container) - elif isinstance(child, quick_menus.MenuSeparator): - wid = MenuSeparator() - caller.add_widget(wid) - elif isinstance(child, quick_menus.MenuItem): - wid = MenuItem(item=child) - caller.add_widget(wid) - else: - log.error("Unknown child type: {}".format(child)) - - def createMenus(self, caller): - self.clear_widgets() - self._buildMenus(self.menus_container, caller) - - def onAbout(self): - about = AboutPopup() - about.title = ABOUT_TITLE - about.content = AboutContent( - text=ABOUT_CONTENT.format( - backend_version = G.host.backend_version, - version=G.host.version), - markup=True) - about.open() - - class TransferItem(BoxLayout): plug_info = properties.DictProperty() diff -r 1481f09c9175 -r 5d994be1161b cagou/core/platform_/android.py --- a/cagou/core/platform_/android.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/core/platform_/android.py Mon Jan 27 21:17:09 2020 +0100 @@ -64,10 +64,6 @@ sys.platform = "android" C.PLUGIN_EXT = 'pyc' - def on_app_build(self, wid): - # we don't want menu on Android - wid.root_menus.height = 0 - def on_host_init(self, host): argument = '' service.start(mActivity, argument) diff -r 1481f09c9175 -r 5d994be1161b cagou/kv/menu.kv --- a/cagou/kv/menu.kv Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/kv/menu.kv Mon Jan 27 21:17:09 2020 +0100 @@ -31,22 +31,6 @@ # following is needed to fix a bug in contextmenu size_hint: 1, None -: - height: 30 - padding: app.MARGIN_LEFT-dp(5), 0, app.MARGIN_RIGHT, 0 - canvas.before: - Color: - rgba: 0.2, 0.2, 0.2, 1.0 - - Rectangle: - pos: self.pos - size: self.size - -: - cancel_handler_widget: self.parent - -: - background_color: app.c_sec if self.state == 'down' else (0.2, 0.2, 0.2, 1.0) : items_layout: items_layout diff -r 1481f09c9175 -r 5d994be1161b cagou/kv/root_widget.kv --- a/cagou/kv/root_widget.kv Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/kv/root_widget.kv Mon Jan 27 21:17:09 2020 +0100 @@ -121,21 +121,8 @@ symbol: "plug" color: 0.80, 0.0, 0.0, 1 -: - size_hint: 1, None - pos_hint: {'top': 1} - : root_body: root_body - root_menus: root_menus - # main body RootBody: id: root_body orientation: "vertical" - size_hint: 1, None - height: root.height - root_menus.height - # general menus - # need to be added at the end so it's drawed above other widgets - RootMenus: - id: root_menus - height: self.HEIGHT diff -r 1481f09c9175 -r 5d994be1161b setup.py --- a/setup.py Mon Jan 27 21:17:08 2020 +0100 +++ b/setup.py Mon Jan 27 21:17:09 2020 +0100 @@ -26,7 +26,6 @@ install_requires = [ 'kivy>=1.10.0', 'kivy_garden.modernmenu', - 'kivy_garden.contextmenu>=0.1.0.dev1', 'pillow', 'plyer', 'sat>=0.7.0dev0',