annotate libervia/desktop_kivy/plugins/plugin_wid_settings.py @ 518:196483685a63 default tip

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