Mercurial > libervia-desktop-kivy
annotate cagou/core/cagou_widget.py @ 466:cd448b877d1d
install: update requirements with alabaster==0.7.12
alembic==1.4.3
anki @ file:///build/anki/src/anki/dist/anki-2.1.35-py3-none-any.whl
ankirspy @ file:///build/anki/src/anki/dist/ankirspy-2.1.35-cp39-cp39-manylinux1_x86_64.whl
ansi2html==1.6.0
anytree==2.8.0
apipkg==1.5
apparmor==3.0.1
appdirs==1.4.4
appimage-builder==0.8.5
aqt @ file:///build/anki/src/anki/dist/aqt-2.1.35-py3-none-any.whl
argcomplete==1.12.1
argon2-cffi==20.1.0
asn1crypto==1.4.0
async-generator==1.10
attrs==20.3.0
autobahn==21.3.1
Automat==20.2.0
autopep8==1.5.5
Babel==2.9.0
backcall==0.2.0
bcrypt==3.2.0
Beaker==1.11.0
beautifulsoup4==4.9.3
black==20.8b1
bleach==3.3.0
blinker==1.4
bmap-tools==3.5
breezy==3.1.0
Brlapi==0.8.2
btrfsutil==5.11
CacheControl==0.12.6
cached-property==1.5.2
cagou==0.8.0.dev0+83c67b093350.153
cairocffi==1.2.0
CairoSVG==2.5.2
certifi==2020.6.20
cffi==1.14.5
chardet==3.0.4
click==7.1.2
colorama==0.4.4
commonmark==0.9.1
configobj==5.1.0.dev0
constantly==15.1.0
contextlib2==0.6.0.post1
coverage==5.5
cryptography==3.4.6
css-parser==1.0.6
cssselect2==0.4.1
cycler==0.10.0
Cython==0.29.22
decorator==4.4.2
defusedxml==0.6.0
diffoscope==169
distlib==0.3.1
distro==1.5.0
docker==4.4.4
docker-compose==1.28.5
docker-pycreds==0.4.0
dockerpty==0.4.1
docopt==0.6.2
docutils==0.16
dulwich==0.20.20
emrichen==0.2.3
entrypoints==0.3
extras==1.0.0
fastimport==0.9.8
file-magic==0.4.0
filelock==3.0.12
fixtures==3.0.0
flake8==3.8.4
Flask==1.1.2
Flask-BabelEx==0.9.4
Flask-Compress==1.8.0
Flask-Cors==3.0.9
Flask-Gravatar==0.5.0
Flask-Login==0.5.0
Flask-Mail==0.9.1
Flask-Migrate==2.7.0
Flask-Paranoid==0.2.0
Flask-Principal==0.4.0
Flask-Script==2.0.6
Flask-Security-Too==3.3.3
Flask-SQLAlchemy==2.4.4
Flask-WTF==0.14.3
future==0.18.2
gajim==1.2.2
gssapi==1.6.12
html2text==2020.1.16
html5lib==1.1
httpie==2.4.0
httplib2==0.19.0
hyperlink==21.0.0
idna==2.10
imagesize==1.2.0
img2pdf==0.4.0
importlib-metadata==3.4.0
incremental==17.5.0
inflect==5.3.0
iniconfig==1.1.1
ipdb==0.13.6
ipykernel==5.4.2
ipython==7.19.0
ipython-genutils==0.2.0
ipywidgets==7.6.2
isc==2.0
itsdangerous==1.1.0
jedi==0.17.2
jeepney==0.6.0
Jinja2==2.11.3
joblib==1.0.0
jsonpath-rw==1.4.0
jsonpickle==1.5.1
jsonschema==3.2.0
jupyter-client==6.1.7
jupyter-console==6.2.0
jupyter-core==4.6.3
jupyterlab-pygments==0.1.2
keyring==23.0.0
Kivy==2.0.0
kiwisolver==1.3.1
langdetect==1.0.8
ldap3==2.9.dev0
lensfun==0.3.95
LibAppArmor==3.0.1
libarchive-c==2.9
libfdt==1.6.0
libnacl==1.7.2
lockfile==0.12.2
louis==3.17.0
lxml==4.6.2
Mako==1.1.4
Markdown==3.3.3
MarkupSafe==1.1.1
matplotlib==3.3.4
mccabe==0.6.1
meld==3.20.3
mercurial==5.7.1
meson==0.57.1
miniupnpc==2.1
mistune==0.8.4
more-itertools==8.6.0
msgpack==1.0.2
mypy==0.812
mypy-extensions==0.4.3
natsort==7.1.1
nbclient==0.5.1
nbconvert==6.0.7
nbformat==5.0.8
nbxmpp==1.0.2
nest-asyncio==1.4.3
netifaces==0.10.9
netsnmp-python==1.0a1
networkx==2.5
nltk==3.5
nose==1.3.7
notebook==6.2.0
Nuitka==0.6.12.3
numpy==1.20.1
openshot-qt==2.5.1
ordered-set==4.0.2
orjson @ file:///build/python-orjson/src/python-orjson-3.5.1/target/wheels/orjson-3.5.1-cp39-cp39-manylinux2010_x86_64.whl
packaging==20.9
pandas==1.2.3
pandocfilters==1.4.3
paramiko==2.7.2
parso==0.7.1
passlib==1.7.4
path==15.1.2
pathspec==0.8.1
patiencediff==0.2.1
pbr==5.5.1
pdfarranger==1.7.0
pep517==0.9.1
pexpect==4.8.0
pickleshare==0.7.5
pikepdf==2.8.0.post2
Pillow==8.1.0
pluggy==0.13.1
ply==3.11
precis-i18n==1.0.3
progress==1.5
progressbar2==3.53.1
prometheus-client==0.9.0
prompt-toolkit==3.0.17
protobuf==3.12.4
psutil==5.8.0
psycopg2==2.8.6
ptyprocess==0.7.0
pudb==2020.1
pwquality==1.4.4
py==1.10.0
pyaml==20.4.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
PyAudio==0.2.11
pybind11==2.6.2
pycairo==1.20.0
pycodestyle==2.6.0
pycountry==20.7.3
pycparser==2.20
pydocstyle==5.1.1
pyenchant==3.2.0
pyflakes==2.2.0
Pygments==2.8.1
PyGObject==3.38.0
PyHamcrest==1.9.0
pyinotify==0.9.6
pymediainfo==5.0.3
PyNaCl==1.4.0
PyOpenGL==3.1.5
pyOpenSSL==20.0.1
pyparsing==2.4.7
pyPEG2==2.15.2
PyQt5==5.15.4
PyQt5-sip==12.8.1
PyQtWebEngine==5.15.4
pyrsistent==0.17.3
PySocks==1.7.1
pytest==6.2.2
python-dateutil==2.8.1
python-dotenv==0.15.0
python-editor==1.0.4
python-Levenshtein==0.12.2
python-mimeparse==1.6.0
python-utils==2.5.6
python-xlib==0.29
pytoml==0.1.21
pytz==2021.1
pyxdg==0.26
PyYAML==5.3.1
pyzmq==20.0.0
questionary==1.9.0
qutebrowser==2.1.0
Reflector==2021.1.10.0.6.34
regex==2020.11.13
requests==2.25.1
requests-toolbelt==0.9.1
requirements-parser==0.2.0
resolvelib==0.5.4
retrying==1.3.3
s3cmd==2.1.0
schema==0.7.4
scikit-learn==0.24.1
scipy==1.6.1
scons==3.1.2
screenkey==1.4
SecretStorage==3.3.1
Send2Trash==1.5.0
service-identity==18.1.0
sh==1.14.1
shortuuid==1.0.1
simplejson==3.17.2
sip==4.19.25
six==1.15.0
snowballstemmer==2.1.0
soupsieve==2.2
speaklater==1.3
Sphinx==3.5.2
sphinx-rtd-theme==0.5.1
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
sqlacodegen==2.3.0
SQLAlchemy==1.3.23
sqlparse==0.4.1
sshtunnel==0.1.5
subdownloader==2.1.0
systemd-python==234
team==1.0
termcolor==1.1.0
terminado==0.9.2
terminator==2.1.0
testpath==0.4.4
testtools==2.4.0
texttable==1.6.3
threadpoolctl==2.1.0
tinycss2==1.1.0
tlsh==0.2.0
toml==0.10.2
tornado==6.1
traitlets==5.0.5
treq==21.1.0
Twisted==20.3.0
txaio==21.2.1
typed-ast==1.4.2
typing-extensions==3.7.4.3
tzlocal==2.1
urllib3==1.26.3
urwid==2.1.1
validate==5.1.0.dev0
virtualenv==20.4.2
waitress==1.4.4
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==0.58.0
Werkzeug==1.0.1
Whoosh==2.7.4
widgetsnbextension==3.5.1
wsaccel==0.6.3
WTForms==2.2.1
xcffib==0.11.1
youtube-dl==2021.3.3
zipp==3.4.1
zope.interface==5.2.0
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 20 Mar 2021 14:26:33 +0100 |
parents | 3c9ba4a694ef |
children | 203755bbe0fe |
rev | line source |
---|---|
379 | 1 #!/usr/bin/env python3 |
2 | |
10 | 3 |
4 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client | |
461 | 5 # Copyright (C) 2016-2021 Jérôme Poisson (goffi@goffi.org) |
10 | 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 | |
405
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
21 from functools import total_ordering |
10 | 22 from sat.core import log as logging |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
23 from sat.core import exceptions |
25
d09bd16dbbe2
code (cagou widget), selector: icons handling + use of new muchoslava icon set
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
24 from kivy.uix.behaviors import ButtonBehavior |
10 | 25 from kivy.uix.boxlayout import BoxLayout |
26 from kivy.uix.dropdown import DropDown | |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
27 from kivy.uix.screenmanager import Screen |
387
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
28 from kivy.uix.textinput import TextInput |
20
29b507826eed
header's input field is now accessible with self.header_input and call onHeaderInput() on text entered
Goffi <goffi@goffi.org>
parents:
16
diff
changeset
|
29 from kivy import properties |
16
ba14b596b90e
host can now be get as a global value:
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
30 from cagou import G |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
31 from .common import ActionIcon |
376 | 32 from . import menu |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
33 |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
34 |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
35 log = logging.getLogger(__name__) |
10 | 36 |
37 | |
376 | 38 class HeaderChoice(ButtonBehavior, BoxLayout): |
39 pass | |
40 | |
41 | |
42 class HeaderChoiceWidget(HeaderChoice): | |
43 cagou_widget = properties.ObjectProperty() | |
44 plugin_info = properties.ObjectProperty() | |
164
60b2b2bad747
core (widget selector): adjusted selector size to content, and added some spacing
Goffi <goffi@goffi.org>
parents:
158
diff
changeset
|
45 |
376 | 46 def __init__(self, **kwargs): |
47 super().__init__(**kwargs) | |
48 self.bind(on_release=lambda btn: self.cagou_widget.switchWidget( | |
49 self.plugin_info)) | |
50 | |
51 | |
52 class HeaderChoiceExtraMenu(HeaderChoice): | |
53 pass | |
25
d09bd16dbbe2
code (cagou widget), selector: icons handling + use of new muchoslava icon set
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
54 |
d09bd16dbbe2
code (cagou widget), selector: icons handling + use of new muchoslava icon set
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
55 |
179
7177fe2d9725
common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents:
164
diff
changeset
|
56 class HeaderWidgetCurrent(ButtonBehavior, ActionIcon): |
14 | 57 pass |
58 | |
59 | |
10 | 60 class HeaderWidgetSelector(DropDown): |
14 | 61 |
62 def __init__(self, cagou_widget): | |
63 super(HeaderWidgetSelector, self).__init__() | |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
64 plg_info_cls = cagou_widget.plugin_info_class or cagou_widget.__class__ |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
65 for plugin_info in G.host.getPluggedWidgets(except_cls=plg_info_cls): |
376 | 66 choice = HeaderChoiceWidget( |
67 cagou_widget=cagou_widget, | |
68 plugin_info=plugin_info, | |
69 ) | |
25
d09bd16dbbe2
code (cagou widget), selector: icons handling + use of new muchoslava icon set
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
70 self.add_widget(choice) |
376 | 71 main_menu = HeaderChoiceExtraMenu(on_press=self.on_extra_menu) |
72 self.add_widget(main_menu) | |
10 | 73 |
164
60b2b2bad747
core (widget selector): adjusted selector size to content, and added some spacing
Goffi <goffi@goffi.org>
parents:
158
diff
changeset
|
74 def add_widget(self, *args): |
60b2b2bad747
core (widget selector): adjusted selector size to content, and added some spacing
Goffi <goffi@goffi.org>
parents:
158
diff
changeset
|
75 widget = args[0] |
60b2b2bad747
core (widget selector): adjusted selector size to content, and added some spacing
Goffi <goffi@goffi.org>
parents:
158
diff
changeset
|
76 widget.bind(minimum_width=self.set_width) |
60b2b2bad747
core (widget selector): adjusted selector size to content, and added some spacing
Goffi <goffi@goffi.org>
parents:
158
diff
changeset
|
77 return super(HeaderWidgetSelector, self).add_widget(*args) |
60b2b2bad747
core (widget selector): adjusted selector size to content, and added some spacing
Goffi <goffi@goffi.org>
parents:
158
diff
changeset
|
78 |
60b2b2bad747
core (widget selector): adjusted selector size to content, and added some spacing
Goffi <goffi@goffi.org>
parents:
158
diff
changeset
|
79 def set_width(self, choice, minimum_width): |
60b2b2bad747
core (widget selector): adjusted selector size to content, and added some spacing
Goffi <goffi@goffi.org>
parents:
158
diff
changeset
|
80 self.width = max([c.minimum_width for c in self.container.children]) |
60b2b2bad747
core (widget selector): adjusted selector size to content, and added some spacing
Goffi <goffi@goffi.org>
parents:
158
diff
changeset
|
81 |
376 | 82 def on_extra_menu(self, *args): |
83 self.dismiss() | |
84 menu.ExtraSideMenu().show() | |
85 | |
10 | 86 |
405
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
87 @total_ordering |
10 | 88 class CagouWidget(BoxLayout): |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
89 main_container = properties.ObjectProperty(None) |
20
29b507826eed
header's input field is now accessible with self.header_input and call onHeaderInput() on text entered
Goffi <goffi@goffi.org>
parents:
16
diff
changeset
|
90 header_input = properties.ObjectProperty(None) |
115
e0c41f209c28
CagouWidget: instances can now add their own extra widgets in header with headerInputAddExtra
Goffi <goffi@goffi.org>
parents:
108
diff
changeset
|
91 header_box = properties.ObjectProperty(None) |
387
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
92 use_header_input = False |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
93 # set to True if you want to be able to switch between visible widgets of this |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
94 # class using a carousel |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
95 collection_carousel = False |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
96 # set to True if you a global ScreenManager global to all widgets of this class. |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
97 # The screen manager is created in WHWrapper |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
98 global_screen_manager = False |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
99 # override this if a specific class (i.e. not self.__class__) must be used for |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
100 # plugin info. Useful when a CagouWidget is used with global_screen_manager. |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
101 plugin_info_class = None |
10 | 102 |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
103 def __init__(self, **kwargs): |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
104 plg_info_cls = self.plugin_info_class or self.__class__ |
25
d09bd16dbbe2
code (cagou widget), selector: icons handling + use of new muchoslava icon set
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
105 for p in G.host.getPluggedWidgets(): |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
106 if p['main'] == plg_info_cls: |
25
d09bd16dbbe2
code (cagou widget), selector: icons handling + use of new muchoslava icon set
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
107 self.plugin_info = p |
d09bd16dbbe2
code (cagou widget), selector: icons handling + use of new muchoslava icon set
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
108 break |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
109 super().__init__(**kwargs) |
14 | 110 self.selector = HeaderWidgetSelector(self) |
387
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
111 if self.use_header_input: |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
112 self.header_input = TextInput( |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
113 background_normal=G.host.app.expand( |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
114 '{media}/misc/borders/border_hollow_light.png'), |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
115 multiline=False, |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
116 ) |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
117 self.header_input.bind( |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
118 on_text_validate=lambda *args: self.onHeaderInput(), |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
119 text=self.onHeaderInputComplete, |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
120 ) |
d61bbbac4160
cagou widget: don't add header_input systematically anymore:
Goffi <goffi@goffi.org>
parents:
379
diff
changeset
|
121 self.header_box.add_widget(self.header_input) |
14 | 122 |
405
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
123 def __lt__(self, other): |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
124 # XXX: sorting is notably used when collection_carousel is set |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
125 try: |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
126 target = str(self.target) |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
127 except AttributeError: |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
128 target = str(list(self.targets)[0]) |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
129 other_target = str(list(other.targets)[0]) |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
130 else: |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
131 other_target = str(other.target) |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
132 return target < other_target |
84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents:
387
diff
changeset
|
133 |
353
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
134 @property |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
135 def screen_manager(self): |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
136 if ((not self.global_screen_manager |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
137 and not (self.plugin_info_class is not None |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
138 and self.plugin_info_class.global_screen_manager))): |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
139 raise exceptions.InternalError( |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
140 "screen_manager property can't be used if global_screen_manager is not " |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
141 "set") |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
142 screen = self.getAncestor(Screen) |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
143 if screen is None: |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
144 raise exceptions.NotFound("Can't find parent Screen") |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
145 if screen.manager is None: |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
146 raise exceptions.NotFound("Can't find parent ScreenManager") |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
147 return screen.manager |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
148 |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
149 @property |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
150 def whwrapper(self): |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
151 """Retrieve parent widget handler""" |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
152 return G.host.getParentWHWrapper(self) |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
153 |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
154 def screenManagerInit(self, screen_manager): |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
155 """Override this method to do init when ScreenManager is instantiated |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
156 |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
157 This is only called once even if collection_carousel is used. |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
158 """ |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
159 if not self.global_screen_manager: |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
160 raise exceptions.InternalError("screenManagerInit should not be called") |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
161 |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
162 def getAncestor(self, cls): |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
163 """Helper method to use host.getAncestorWidget with self""" |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
164 return G.host.getAncestorWidget(self, cls) |
19422bbd9c8e
core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents:
312
diff
changeset
|
165 |
14 | 166 def switchWidget(self, plugin_info): |
167 self.selector.dismiss() | |
168 factory = plugin_info["factory"] | |
20
29b507826eed
header's input field is now accessible with self.header_input and call onHeaderInput() on text entered
Goffi <goffi@goffi.org>
parents:
16
diff
changeset
|
169 new_widget = factory(plugin_info, None, iter(G.host.profiles)) |
16
ba14b596b90e
host can now be get as a global value:
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
170 G.host.switchWidget(self, new_widget) |
20
29b507826eed
header's input field is now accessible with self.header_input and call onHeaderInput() on text entered
Goffi <goffi@goffi.org>
parents:
16
diff
changeset
|
171 |
357
4d3a0c4f2430
core: better back key (ESC) management:
Goffi <goffi@goffi.org>
parents:
353
diff
changeset
|
172 def key_input(self, window, key, scancode, codepoint, modifier): |
4d3a0c4f2430
core: better back key (ESC) management:
Goffi <goffi@goffi.org>
parents:
353
diff
changeset
|
173 if key == 27: |
4d3a0c4f2430
core: better back key (ESC) management:
Goffi <goffi@goffi.org>
parents:
353
diff
changeset
|
174 # we go back to root screen |
4d3a0c4f2430
core: better back key (ESC) management:
Goffi <goffi@goffi.org>
parents:
353
diff
changeset
|
175 G.host.switchWidget(self) |
4d3a0c4f2430
core: better back key (ESC) management:
Goffi <goffi@goffi.org>
parents:
353
diff
changeset
|
176 return True |
4d3a0c4f2430
core: better back key (ESC) management:
Goffi <goffi@goffi.org>
parents:
353
diff
changeset
|
177 |
20
29b507826eed
header's input field is now accessible with self.header_input and call onHeaderInput() on text entered
Goffi <goffi@goffi.org>
parents:
16
diff
changeset
|
178 def onHeaderInput(self): |
312 | 179 log.info("header input text entered") |
51 | 180 |
108
953ddf817b8a
cagou widget: added onHeaderInputComplete method which is called when text is changed, and should be used for completion
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
181 def onHeaderInputComplete(self, wid, text): |
953ddf817b8a
cagou widget: added onHeaderInputComplete method which is called when text is changed, and should be used for completion
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
182 return |
953ddf817b8a
cagou widget: added onHeaderInputComplete method which is called when text is changed, and should be used for completion
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
183 |
51 | 184 def on_touch_down(self, touch): |
185 if self.collide_point(*touch.pos): | |
186 G.host.selected_widget = self | |
158
976f22cb3ecc
core (cagou widget): return parent value in on_touch_down
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
187 return super(CagouWidget, self).on_touch_down(touch) |
115
e0c41f209c28
CagouWidget: instances can now add their own extra widgets in header with headerInputAddExtra
Goffi <goffi@goffi.org>
parents:
108
diff
changeset
|
188 |
e0c41f209c28
CagouWidget: instances can now add their own extra widgets in header with headerInputAddExtra
Goffi <goffi@goffi.org>
parents:
108
diff
changeset
|
189 def headerInputAddExtra(self, widget): |
e0c41f209c28
CagouWidget: instances can now add their own extra widgets in header with headerInputAddExtra
Goffi <goffi@goffi.org>
parents:
108
diff
changeset
|
190 """add a widget on the right of header input""" |
e0c41f209c28
CagouWidget: instances can now add their own extra widgets in header with headerInputAddExtra
Goffi <goffi@goffi.org>
parents:
108
diff
changeset
|
191 self.header_box.add_widget(widget) |
264
3e11b5d923e2
core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget
Goffi <goffi@goffi.org>
parents:
222
diff
changeset
|
192 |
3e11b5d923e2
core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget
Goffi <goffi@goffi.org>
parents:
222
diff
changeset
|
193 def onVisible(self): |
3e11b5d923e2
core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget
Goffi <goffi@goffi.org>
parents:
222
diff
changeset
|
194 pass |
3e11b5d923e2
core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget
Goffi <goffi@goffi.org>
parents:
222
diff
changeset
|
195 # log.debug(u"{self} is visible".format(self=self)) |
3e11b5d923e2
core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget
Goffi <goffi@goffi.org>
parents:
222
diff
changeset
|
196 |
3e11b5d923e2
core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget
Goffi <goffi@goffi.org>
parents:
222
diff
changeset
|
197 def onNotVisible(self): |
3e11b5d923e2
core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget
Goffi <goffi@goffi.org>
parents:
222
diff
changeset
|
198 pass |
3e11b5d923e2
core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget
Goffi <goffi@goffi.org>
parents:
222
diff
changeset
|
199 # log.debug(u"{self} is not visible anymore".format(self=self)) |