Mercurial > libervia-desktop-kivy
comparison libervia/desktop_kivy/plugins/plugin_wid_settings.py @ 493:b3cedbee561d
refactoring: rename `cagou` to `libervia.desktop_kivy` + update imports and names following backend changes
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 18:26:16 +0200 |
parents | cagou/plugins/plugin_wid_settings.py@203755bbe0fe |
children |
comparison
equal
deleted
inserted
replaced
492:5114bbb5daa3 | 493:b3cedbee561d |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 | |
4 #Libervia Desktop-Kivy | |
5 # Copyright (C) 2016-2021 Jérôme Poisson (goffi@goffi.org) | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 | |
21 from libervia.backend.core import log as logging | |
22 from libervia.backend.core.i18n import _ | |
23 from libervia.backend.core.constants import Const as C | |
24 from libervia.backend.tools.common import data_format | |
25 from libervia.frontends.quick_frontend import quick_widgets | |
26 from kivy.uix.label import Label | |
27 from kivy.uix.widget import Widget | |
28 from libervia.desktop_kivy.core import cagou_widget | |
29 from libervia.desktop_kivy import G | |
30 | |
31 | |
32 log = logging.getLogger(__name__) | |
33 | |
34 | |
35 PLUGIN_INFO = { | |
36 "name": _("settings"), | |
37 "main": "LiberviaDesktopKivySettings", | |
38 "description": _("LiberviaDesktopKivy/SàT settings"), | |
39 "icon_symbol": "wrench", | |
40 } | |
41 | |
42 | |
43 class LiberviaDesktopKivySettings(quick_widgets.QuickWidget, cagou_widget.LiberviaDesktopKivyWidget): | |
44 # XXX: this class can't be called "Settings", because Kivy has already a class | |
45 # of this name, and the kv there would apply | |
46 | |
47 def __init__(self, host, target, profiles): | |
48 quick_widgets.QuickWidget.__init__(self, G.host, target, profiles) | |
49 cagou_widget.LiberviaDesktopKivyWidget.__init__(self) | |
50 # the Widget() avoid LiberviaDesktopKivyWidget header to be down at the beginning | |
51 # then up when the UI is loaded | |
52 self.loading_widget = Widget() | |
53 self.add_widget(self.loading_widget) | |
54 extra = {} | |
55 G.local_platform.update_params_extra(extra) | |
56 G.host.bridge.param_ui_get( | |
57 -1, C.APP_NAME, data_format.serialise(extra), self.profile, | |
58 callback=self.get_params_ui_cb, | |
59 errback=self.get_params_ui_eb) | |
60 | |
61 def change_widget(self, widget): | |
62 self.clear_widgets([self.loading_widget]) | |
63 del self.loading_widget | |
64 self.add_widget(widget) | |
65 | |
66 def get_params_ui_cb(self, xmlui): | |
67 G.host.action_manager({"xmlui": xmlui}, ui_show_cb=self.change_widget, profile=self.profile) | |
68 | |
69 def get_params_ui_eb(self, failure): | |
70 self.change_widget(Label( | |
71 text=_("Can't load parameters!"), | |
72 bold=True, | |
73 color=(1,0,0,1))) | |
74 G.host.show_dialog("Can't load params UI", str(failure), "error") |