annotate cagou/backport/__init__.py @ 353:19422bbd9c8e

core (widgets handler): refactoring: - CagouWidget now has class properties (to be overridden when needed) which indicate how if the widget handle must add a wrapping ScreenManager (global_screen_manager) or show all instances of the class in a Carousel (collection_carousel). If none of those options is used, a ScrollView will be wrapping the widget, to be sure that the widget will be resized correctly when necessary (without it, the widget could still be drawn in the backround when the size is too small and overflow on the WidgetWrapper, this would be the case with WidgetSelector) - some helper methods/properties have been added to CagouWidget. Check docstrings for details - better handling of (in)visible widget in WidgetsHandler - thanks to the new wrapping ScrollView, WidgetSelect will show scroll bars if the available space is too small. - bugs fixes
author Goffi <goffi@goffi.org>
date Fri, 17 Jan 2020 18:44:35 +0100
parents 5bd583d00594
children 4d660b252487
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
323
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2016-2019 Jérôme Poisson (goffi@goffi.org)
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 import kivy
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from sat.core import log as logging
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
21
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
22
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 log = logging.getLogger(__name__)
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
24
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
25
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 def do_backport():
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 version = tuple(kivy.parse_kivy_version(kivy.__version__)[0])
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 if version < (2, 0, 0):
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 log.info("installing backport for Carousel")
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 import sys
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from kivy.uix import carousel # NOQA
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from . import carousel as carousel_backport
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 sys.modules['kivy.uix.carousel'] = carousel_backport
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 else:
5bd583d00594 backport: added a new "backport" module for using unreleased code from Kivy:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 log.info("Kivy >= 2.0.0 is used, Carousel backport is not needed anymore")