Mercurial > libervia-desktop-kivy
comparison src/cagou/core/cagou_main.py @ 51:3f8599d9a766
core: menus first draft:
- menus are handled. Global menus are shown above notification for the moment, but may be displayed differently depending on plateform (e.g. using a button on mobile plateforms)
- menu are displayed after profile is connected
- backends menus are displayed but not working yet
- help/about menu has been added.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 11 Sep 2016 12:15:41 +0200 |
parents | fd9cbf6ae663 |
children | 647f32d0a004 |
comparison
equal
deleted
inserted
replaced
50:c45d6e9ec731 | 51:3f8599d9a766 |
---|---|
46 from kivy.uix.screenmanager import ScreenManager, Screen, FallOutTransition, RiseInTransition | 46 from kivy.uix.screenmanager import ScreenManager, Screen, FallOutTransition, RiseInTransition |
47 from kivy.uix.dropdown import DropDown | 47 from kivy.uix.dropdown import DropDown |
48 from cagou_widget import CagouWidget | 48 from cagou_widget import CagouWidget |
49 from . import widgets_handler | 49 from . import widgets_handler |
50 from .common import IconButton | 50 from .common import IconButton |
51 from .menu import MenusWidget | |
51 from importlib import import_module | 52 from importlib import import_module |
52 import os.path | 53 import os.path |
53 import glob | 54 import glob |
54 import cagou.plugins | 55 import cagou.plugins |
55 import cagou.kv | 56 import cagou.kv |
136 | 137 |
137 class CagouRootWidget(BoxLayout): | 138 class CagouRootWidget(BoxLayout): |
138 | 139 |
139 def __init__(self, main_widget): | 140 def __init__(self, main_widget): |
140 super(CagouRootWidget, self).__init__(orientation=("vertical")) | 141 super(CagouRootWidget, self).__init__(orientation=("vertical")) |
142 # general menus | |
143 self.menus_widget = MenusWidget() | |
144 self.add_widget(self.menus_widget) | |
141 # header | 145 # header |
142 self._head_widget = RootHeadWidget() | 146 self._head_widget = RootHeadWidget() |
143 self.add_widget(self._head_widget) | 147 self.add_widget(self._head_widget) |
144 | |
145 # body | 148 # body |
146 self._manager = ScreenManager() | 149 self._manager = ScreenManager() |
147 # main widgets | 150 # main widgets |
148 main_screen = Screen(name='main') | 151 main_screen = Screen(name='main') |
149 main_screen.add_widget(main_widget) | 152 main_screen.add_widget(main_widget) |
338 continue | 341 continue |
339 return plugin_info | 342 return plugin_info |
340 | 343 |
341 ## widgets handling | 344 ## widgets handling |
342 | 345 |
343 | |
344 def newWidget(self, widget): | 346 def newWidget(self, widget): |
345 log.debug(u"new widget created: {}".format(widget)) | 347 log.debug(u"new widget created: {}".format(widget)) |
346 if isinstance(widget, quick_chat.QuickChat) and widget.type == C.CHAT_GROUP: | 348 if isinstance(widget, quick_chat.QuickChat) and widget.type == C.CHAT_GROUP: |
347 self.addNote(u"", _(u"room {} has been joined").format(widget.target)) | 349 self.addNote(u"", _(u"room {} has been joined").format(widget.target)) |
348 | 350 |
411 w = self.widgets.getOrCreateWidget(widget.__class__, targets[0], on_new_widget=None, on_existing_widget=C.WIDGET_RECREATE, profiles=widget.profiles) | 413 w = self.widgets.getOrCreateWidget(widget.__class__, targets[0], on_new_widget=None, on_existing_widget=C.WIDGET_RECREATE, profiles=widget.profiles) |
412 for t in targets[1:]: | 414 for t in targets[1:]: |
413 w.addTarget(t) | 415 w.addTarget(t) |
414 return w | 416 return w |
415 | 417 |
418 ## menus ## | |
419 | |
420 def _getMenusCb(self, backend_menus): | |
421 main_menu = self.app.root.menus_widget | |
422 self.menus.addMenus(backend_menus) | |
423 self.menus.addMenu(C.MENU_GLOBAL, (_(u"Help"), _(u"About")), callback=main_menu.onAbout) | |
424 main_menu.update(C.MENU_GLOBAL) | |
425 | |
416 ## misc ## | 426 ## misc ## |
417 | 427 |
418 def plugging_profiles(self): | 428 def plugging_profiles(self): |
419 self.app.root.changeWidget(WidgetsHandler()) | 429 self.app.root.changeWidget(WidgetsHandler()) |
430 self.bridge.getMenus("", C.NO_SECURITY_LIMIT, callback=self._getMenusCb) | |
420 | 431 |
421 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): | 432 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): |
422 log.info(u"Profile presence status set to {show}/{status}".format(show=show, status=status)) | 433 log.info(u"Profile presence status set to {show}/{status}".format(show=show, status=status)) |
423 | 434 |
424 def addNote(self, title, message, level=C.XMLUI_DATA_LVL_INFO): | 435 def addNote(self, title, message, level=C.XMLUI_DATA_LVL_INFO): |