Mercurial > libervia-desktop-kivy
comparison src/cagou/plugins/plugin_wid_settings.py @ 70:46b5f3ecf6a1
settings: settings widget plugin, first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 18 Dec 2016 10:27:34 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
69:a9c6b089070d | 70:46b5f3ecf6a1 |
---|---|
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client | |
5 # Copyright (C) 2016 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 sat.core import log as logging | |
22 log = logging.getLogger(__name__) | |
23 from sat.core.i18n import _ | |
24 from sat.core.constants import Const as C | |
25 from sat_frontends.quick_frontend import quick_widgets | |
26 from kivy.uix.label import Label | |
27 from kivy.uix.widget import Widget | |
28 from cagou.core import cagou_widget | |
29 from cagou import G | |
30 | |
31 | |
32 PLUGIN_INFO = { | |
33 "name": _(u"settings"), | |
34 "main": "Settings", | |
35 "description": _(u"Cagou/SàT settings"), | |
36 "icon_small": u"{media}/icons/muchoslava/png/settings_32.png", | |
37 "icon_medium": u"{media}/icons/muchoslava/png/settings_44.png" | |
38 } | |
39 | |
40 | |
41 class Settings(quick_widgets.QuickWidget, cagou_widget.CagouWidget): | |
42 | |
43 def __init__(self, host, target, profiles): | |
44 quick_widgets.QuickWidget.__init__(self, G.host, target, profiles) | |
45 cagou_widget.CagouWidget.__init__(self) | |
46 # the Widget() avoid CagouWidget header to be down at the beginning | |
47 # then up when the UI is loaded | |
48 self.loading_widget = Widget() | |
49 self.add_widget(self.loading_widget) | |
50 G.host.bridge.getParamsUI(-1, C.APP_NAME, self.profile, callback=self.getParamsUICb, errback=self.getParamsUIEb) | |
51 | |
52 def changeWidget(self, widget): | |
53 self.clear_widgets([self.loading_widget]) | |
54 del self.loading_widget | |
55 self.add_widget(widget) | |
56 | |
57 def getParamsUICb(self, xmlui): | |
58 G.host.actionManager({"xmlui": xmlui}, ui_show_cb=self.changeWidget, profile=self.profile) | |
59 | |
60 def getParamsUIEb(self, failure): | |
61 self.changeWidget(Label( | |
62 text=_(u"Can't load parameters!"), | |
63 bold=True, | |
64 color=(1,0,0,1))) | |
65 G.host.showDialog(u"Can't load params UI", failure, "error") |