Mercurial > libervia-desktop
annotate cagou/plugins/plugin_wid_widget_selector.py @ 233:ba8f3a4a5ac7
plugin chat: e2e encryption improvments:
OTR buttons has been replaced with a more generic one, which use new encryption mechanisms
to retrieve all current encryption algorithms (+ a button for plain text).
"refresh" and "authentify" buttons for OTR are temporarily removed.
Encryption state is checked on chat widget startup, and current encryption method is
selected (it will appear with a different background in encryption menu).
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 11 Aug 2018 18:34:16 +0200 |
parents | 0ddd2b20cc6b |
children | 896f78760b63 |
rev | line source |
---|---|
12 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client | |
126 | 5 # Copyright (C) 2016-2018 Jérôme Poisson (goffi@goffi.org) |
12 | 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__) | |
14 | 23 from sat.core.i18n import _ |
15
56838ad5c84b
files reorganisation, cagou is now launched with python2 cagou.py in src/
Goffi <goffi@goffi.org>
parents:
14
diff
changeset
|
24 from cagou.core.constants import Const as C |
169
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
25 from kivy.uix.widget import Widget |
12 | 26 from kivy.uix.boxlayout import BoxLayout |
27 from kivy import properties | |
28 from kivy.uix.behaviors import ButtonBehavior | |
15
56838ad5c84b
files reorganisation, cagou is now launched with python2 cagou.py in src/
Goffi <goffi@goffi.org>
parents:
14
diff
changeset
|
29 from cagou.core import cagou_widget |
16
ba14b596b90e
host can now be get as a global value:
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
30 from cagou import G |
12 | 31 |
32 | |
14 | 33 PLUGIN_INFO = { |
34 "name": _(u"widget selector"), | |
35 "import_name": C.WID_SELECTOR, | |
36 "main": "WidgetSelector", | |
37 "description": _(u"show available widgets and allow to select one"), | |
180
0ddd2b20cc6b
plugins chat, contact_list, settings, widget_selector: changed icons theme
Goffi <goffi@goffi.org>
parents:
169
diff
changeset
|
38 "icon_medium": u"{media}/icons/muchoslava/png/selector_no_border_blue_44.png" |
14 | 39 } |
40 | |
41 | |
12 | 42 class WidgetSelItem(ButtonBehavior, BoxLayout): |
14 | 43 plugin_info = properties.DictProperty() |
169
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
44 item = properties.ObjectProperty() |
12 | 45 |
169
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
46 def on_release(self, *args): |
14 | 47 log.debug(u"widget selection: {}".format(self.plugin_info["name"])) |
48 factory = self.plugin_info["factory"] | |
18
790dbc5c4e89
plugin widget selector: display improvment + host profiles are now used by default
Goffi <goffi@goffi.org>
parents:
16
diff
changeset
|
49 G.host.switchWidget(self, factory(self.plugin_info, None, profiles=iter(G.host.profiles))) |
12 | 50 |
51 | |
15
56838ad5c84b
files reorganisation, cagou is now launched with python2 cagou.py in src/
Goffi <goffi@goffi.org>
parents:
14
diff
changeset
|
52 class WidgetSelector(cagou_widget.CagouWidget): |
12 | 53 |
16
ba14b596b90e
host can now be get as a global value:
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
54 def __init__(self): |
ba14b596b90e
host can now be get as a global value:
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
55 super(WidgetSelector, self).__init__() |
169
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
56 self.items = [] |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
57 for plugin_info in G.host.getPluggedWidgets(except_cls=self.__class__): |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
58 item = WidgetSelItem(plugin_info=plugin_info) |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
59 self.items.append(item.item) |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
60 item.item.bind(minimum_width=self.adjust_width) |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
61 self.add_widget(item) |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
62 self.add_widget(Widget()) |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
63 |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
64 def adjust_width(self, label, texture_size): |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
65 width = max([i.minimum_width for i in self.items]) |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
66 for i in self.items: |
6a288d4a493f
widget selector: replaced deprecated ListView by BoxLayout
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
67 i.width = width |
12 | 68 |
14 | 69 @classmethod |
16
ba14b596b90e
host can now be get as a global value:
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
70 def factory(cls, plugin_info, target, profiles): |
ba14b596b90e
host can now be get as a global value:
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
71 return cls() |
14 | 72 |
73 | |
74 PLUGIN_INFO["factory"] = WidgetSelector.factory |