Mercurial > libervia-desktop-kivy
comparison cagou/core/menu.py @ 376:9ef01266e3fe
core: new extra menu:
a new "extra" menu is added in CagouWidget's header selector (at the end). This activate a
side menu with global actions, like showing the "about" screen. Platform specific menus
can be added with `local_platform.on_extra_menu_init`.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jan 2020 21:17:09 +0100 |
parents | 5d994be1161b |
children | 4d660b252487 |
comparison
equal
deleted
inserted
replaced
375:ae9059b791fe | 376:9ef01266e3fe |
---|---|
22 from sat.core import log as logging | 22 from sat.core import log as logging |
23 from cagou.core.constants import Const as C | 23 from cagou.core.constants import Const as C |
24 from cagou.core.common import JidToggle | 24 from cagou.core.common import JidToggle |
25 from kivy.uix.boxlayout import BoxLayout | 25 from kivy.uix.boxlayout import BoxLayout |
26 from kivy.uix.label import Label | 26 from kivy.uix.label import Label |
27 from kivy.uix.button import Button | |
27 from kivy.uix.popup import Popup | 28 from kivy.uix.popup import Popup |
28 from cagou.core.utils import FilterBehavior | 29 from cagou.core.utils import FilterBehavior |
29 from kivy import properties | 30 from kivy import properties |
30 from kivy_garden import modernmenu | 31 from kivy_garden import modernmenu |
31 from kivy.core.window import Window | 32 from kivy.core.window import Window |
162 def _closeUI(self, wid): | 163 def _closeUI(self, wid): |
163 G.host.closeUI() | 164 G.host.closeUI() |
164 | 165 |
165 def do_callback(self, *args, **kwargs): | 166 def do_callback(self, *args, **kwargs): |
166 log.warning("callback not implemented") | 167 log.warning("callback not implemented") |
168 | |
169 | |
170 class ExtraMenuItem(Button): | |
171 pass | |
172 | |
173 | |
174 class ExtraSideMenu(SideMenu): | |
175 """Menu with general app actions like showing the about widget""" | |
176 | |
177 def __init__(self, **kwargs): | |
178 super().__init__(**kwargs) | |
179 G.local_platform.on_extra_menu_init(self) | |
180 | |
181 def addItem(self, label, callback): | |
182 self.add_widget( | |
183 ExtraMenuItem( | |
184 text=label, | |
185 on_press=partial(self.onItemPress, callback=callback), | |
186 ), | |
187 # we want the new item above "About" and last empty Widget | |
188 index=2) | |
189 | |
190 def onItemPress(self, *args, callback): | |
191 self.hide() | |
192 callback() | |
193 | |
194 def onAbout(self): | |
195 self.hide() | |
196 about = AboutPopup() | |
197 about.title = ABOUT_TITLE | |
198 about.content = AboutContent( | |
199 text=ABOUT_CONTENT.format( | |
200 backend_version = G.host.backend_version, | |
201 version=G.host.version), | |
202 markup=True) | |
203 about.open() | |
167 | 204 |
168 | 205 |
169 class TransferMenu(SideMenu): | 206 class TransferMenu(SideMenu): |
170 """transfer menu which handle display and callbacks""" | 207 """transfer menu which handle display and callbacks""" |
171 # callback will be called with path to file to transfer | 208 # callback will be called with path to file to transfer |