Mercurial > libervia-desktop-kivy
comparison cagou/core/cagou_main.py @ 373:5d994be1161b
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
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jan 2020 21:17:09 +0100 |
parents | 1a12bbd80943 |
children | ae9059b791fe |
comparison
equal
deleted
inserted
replaced
372:1481f09c9175 | 373:5d994be1161b |
---|---|
64 from kivy.metrics import dp | 64 from kivy.metrics import dp |
65 from .cagou_widget import CagouWidget | 65 from .cagou_widget import CagouWidget |
66 from .share_widget import ShareWidget | 66 from .share_widget import ShareWidget |
67 from . import widgets_handler | 67 from . import widgets_handler |
68 from .common import IconButton | 68 from .common import IconButton |
69 from . import menu | |
70 from . import dialog | 69 from . import dialog |
71 from importlib import import_module | 70 from importlib import import_module |
72 import sat | 71 import sat |
73 import cagou | 72 import cagou |
74 import cagou.plugins | 73 import cagou.plugins |
218 else: | 217 else: |
219 screen.add_widget(note) | 218 screen.add_widget(note) |
220 self.manager.switch_to(screen) | 219 self.manager.switch_to(screen) |
221 | 220 |
222 | 221 |
223 class RootMenus(menu.MenusWidget): | |
224 HEIGHT = dp(30) | |
225 | |
226 | |
227 class RootBody(BoxLayout): | 222 class RootBody(BoxLayout): |
228 pass | 223 pass |
229 | 224 |
230 | 225 |
231 class CagouRootWidget(FloatLayout): | 226 class CagouRootWidget(FloatLayout): |
232 root_menus = properties.ObjectProperty() | |
233 root_body = properties.ObjectProperty | 227 root_body = properties.ObjectProperty |
234 | 228 |
235 def __init__(self, main_widget): | 229 def __init__(self, main_widget): |
236 super(CagouRootWidget, self).__init__() | 230 super(CagouRootWidget, self).__init__() |
237 # header | 231 # header |
362 # F11: full screen | 356 # F11: full screen |
363 if not Window.fullscreen: | 357 if not Window.fullscreen: |
364 Window.fullscreen = 'auto' | 358 Window.fullscreen = 'auto' |
365 else: | 359 else: |
366 Window.fullscreen = False | 360 Window.fullscreen = False |
367 return True | |
368 elif key == 109 and modifier == ['alt']: | |
369 # M-m we hide/show menu | |
370 menu = self.root.root_menus | |
371 if menu.height: | |
372 Animation(height=0, duration=0.3).start(menu) | |
373 else: | |
374 Animation(height=menu.HEIGHT, duration=0.3).start(menu) | |
375 return True | 361 return True |
376 elif key == 110 and modifier == ['alt']: | 362 elif key == 110 and modifier == ['alt']: |
377 # M-n we hide/show notifications | 363 # M-n we hide/show notifications |
378 head = self.root.head_widget | 364 head = self.root.head_widget |
379 if head.height: | 365 if head.height: |
906 else: | 892 else: |
907 factory = plg_infos['factory'] | 893 factory = plg_infos['factory'] |
908 self.switchWidget(None, | 894 self.switchWidget(None, |
909 factory(plg_infos, target=target, profiles=profiles)) | 895 factory(plg_infos, target=target, profiles=profiles)) |
910 | 896 |
911 ## menus ## | |
912 | |
913 def _menusGetCb(self, backend_menus): | |
914 main_menu = self.app.root.root_menus | |
915 self.menus.addMenus(backend_menus) | |
916 self.menus.addMenu(C.MENU_GLOBAL, | |
917 (_("Help"), _("About")), | |
918 callback=main_menu.onAbout) | |
919 main_menu.update(C.MENU_GLOBAL) | |
920 | |
921 ## bridge handlers ## | 897 ## bridge handlers ## |
922 | 898 |
923 def otrStateHandler(self, state, dest_jid, profile): | 899 def otrStateHandler(self, state, dest_jid, profile): |
924 """OTR state has changed for on destinee""" | 900 """OTR state has changed for on destinee""" |
925 # XXX: this method could be in QuickApp but it's here as | 901 # XXX: this method could be in QuickApp but it's here as |
951 ## misc ## | 927 ## misc ## |
952 | 928 |
953 def plugging_profiles(self): | 929 def plugging_profiles(self): |
954 self.widgets_handler = widgets_handler.WidgetsHandler() | 930 self.widgets_handler = widgets_handler.WidgetsHandler() |
955 self.app.root.changeWidget(self.widgets_handler) | 931 self.app.root.changeWidget(self.widgets_handler) |
956 self.bridge.menusGet("", C.NO_SECURITY_LIMIT, callback=self._menusGetCb) | |
957 | 932 |
958 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): | 933 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): |
959 log.info("Profile presence status set to {show}/{status}".format(show=show, | 934 log.info("Profile presence status set to {show}/{status}".format(show=show, |
960 status=status)) | 935 status=status)) |
961 | 936 |