Mercurial > libervia-desktop-kivy
comparison src/cagou/core/cagou_main.py @ 85:c2a7234d13d2
menu: use of garden's contextmenu for menus
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 24 Dec 2016 14:20:49 +0100 |
parents | 46d962910801 |
children | c711be670ecd |
comparison
equal
deleted
inserted
replaced
84:2caee196d19a | 85:c2a7234d13d2 |
---|---|
48 from profile_manager import ProfileManager | 48 from profile_manager import ProfileManager |
49 from widgets_handler import WidgetsHandler | 49 from widgets_handler import WidgetsHandler |
50 from kivy.clock import Clock | 50 from kivy.clock import Clock |
51 from kivy.uix.label import Label | 51 from kivy.uix.label import Label |
52 from kivy.uix.boxlayout import BoxLayout | 52 from kivy.uix.boxlayout import BoxLayout |
53 from kivy.uix.floatlayout import FloatLayout | |
53 from kivy.uix.screenmanager import ScreenManager, Screen, FallOutTransition, RiseInTransition | 54 from kivy.uix.screenmanager import ScreenManager, Screen, FallOutTransition, RiseInTransition |
54 from kivy.uix.dropdown import DropDown | 55 from kivy.uix.dropdown import DropDown |
55 from cagou_widget import CagouWidget | 56 from cagou_widget import CagouWidget |
56 from . import widgets_handler | 57 from . import widgets_handler |
57 from .common import IconButton | 58 from .common import IconButton |
149 else: | 150 else: |
150 screen.add_widget(note) | 151 screen.add_widget(note) |
151 self.manager.switch_to(screen) | 152 self.manager.switch_to(screen) |
152 | 153 |
153 | 154 |
154 class CagouRootWidget(BoxLayout): | 155 class RootMenus(MenusWidget): |
156 pass | |
157 | |
158 | |
159 class RootBody(BoxLayout): | |
160 pass | |
161 | |
162 | |
163 class CagouRootWidget(FloatLayout): | |
164 root_menus = properties.ObjectProperty() | |
165 root_body = properties.ObjectProperty | |
155 | 166 |
156 def __init__(self, main_widget): | 167 def __init__(self, main_widget): |
157 super(CagouRootWidget, self).__init__(orientation=("vertical")) | 168 super(CagouRootWidget, self).__init__() |
158 # general menus | |
159 self.menus_widget = MenusWidget() | |
160 self.add_widget(self.menus_widget) | |
161 # header | 169 # header |
162 self._head_widget = RootHeadWidget() | 170 self._head_widget = RootHeadWidget() |
163 self.add_widget(self._head_widget) | 171 self.root_body.add_widget(self._head_widget) |
164 # body | 172 # body |
165 self._manager = ScreenManager() | 173 self._manager = ScreenManager() |
166 # main widgets | 174 # main widgets |
167 main_screen = Screen(name='main') | 175 main_screen = Screen(name='main') |
168 main_screen.add_widget(main_widget) | 176 main_screen.add_widget(main_widget) |
171 xmlui_screen = Screen(name='xmlui') | 179 xmlui_screen = Screen(name='xmlui') |
172 self._manager.add_widget(xmlui_screen) | 180 self._manager.add_widget(xmlui_screen) |
173 # extra (file chooser, audio record, etc) | 181 # extra (file chooser, audio record, etc) |
174 extra_screen = Screen(name='extra') | 182 extra_screen = Screen(name='extra') |
175 self._manager.add_widget(extra_screen) | 183 self._manager.add_widget(extra_screen) |
176 self.add_widget(self._manager) | 184 self.root_body.add_widget(self._manager) |
177 | 185 |
178 def changeWidget(self, widget, screen_name="main"): | 186 def changeWidget(self, widget, screen_name="main"): |
179 """change main widget""" | 187 """change main widget""" |
180 if self._manager.transition.is_active: | 188 if self._manager.transition.is_active: |
181 # FIXME: workaround for what seems a Kivy bug | 189 # FIXME: workaround for what seems a Kivy bug |
528 return w | 536 return w |
529 | 537 |
530 ## menus ## | 538 ## menus ## |
531 | 539 |
532 def _getMenusCb(self, backend_menus): | 540 def _getMenusCb(self, backend_menus): |
533 main_menu = self.app.root.menus_widget | 541 main_menu = self.app.root.root_menus |
534 self.menus.addMenus(backend_menus) | 542 self.menus.addMenus(backend_menus) |
535 self.menus.addMenu(C.MENU_GLOBAL, (_(u"Help"), _(u"About")), callback=main_menu.onAbout) | 543 self.menus.addMenu(C.MENU_GLOBAL, (_(u"Help"), _(u"About")), callback=main_menu.onAbout) |
536 main_menu.update(C.MENU_GLOBAL) | 544 main_menu.update(C.MENU_GLOBAL) |
537 | 545 |
538 ## misc ## | 546 ## misc ## |