annotate libervia/desktop_kivy/core/cagou_widget.py @ 508:d87b9a6b0b69

doc (calls): updated documentation to describe the new UI features: fix 425
author Goffi <goffi@goffi.org>
date Wed, 25 Oct 2023 15:29:33 +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
10
8b2836b5b6c7 added CagouWidget:
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: 405
diff changeset
5 # Copyright (C) 2016-2021 Jérôme Poisson (goffi@goffi.org)
10
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
405
84ff5c917064 widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents: 387
diff changeset
21 from functools import total_ordering
493
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 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
23 from libervia.backend.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
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from kivy.uix.boxlayout import BoxLayout
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
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
493
b3cedbee561d refactoring: rename `cagou` to `libervia.desktop_kivy` + update imports and names following backend changes
Goffi <goffi@goffi.org>
parents: 491
diff changeset
30 from libervia.desktop_kivy import G
353
19422bbd9c8e core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
31 from .common import ActionIcon
376
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
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
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
36
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
37
376
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
38 class HeaderChoice(ButtonBehavior, BoxLayout):
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
39 pass
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
40
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
41
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
42 class HeaderChoiceWidget(HeaderChoice):
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
43 cagou_widget = properties.ObjectProperty()
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
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
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
46 def __init__(self, **kwargs):
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
47 super().__init__(**kwargs)
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
48 self.bind(on_release=lambda btn: self.cagou_widget.switch_widget(
376
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
49 self.plugin_info))
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
50
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
51
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
52 class HeaderChoiceExtraMenu(HeaderChoice):
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
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
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
57 pass
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
58
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
59
10
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 class HeaderWidgetSelector(DropDown):
14
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
61
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
62 def __init__(self, cagou_widget):
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
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__
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
65 for plugin_info in G.host.get_plugged_widgets(except_cls=plg_info_cls):
376
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
66 choice = HeaderChoiceWidget(
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
67 cagou_widget=cagou_widget,
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
68 plugin_info=plugin_info,
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
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
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
71 main_menu = HeaderChoiceExtraMenu(on_press=self.on_extra_menu)
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
72 self.add_widget(main_menu)
10
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
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
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
82 def on_extra_menu(self, *args):
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
83 self.dismiss()
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
84 menu.ExtraSideMenu().show()
9ef01266e3fe core: new extra menu:
Goffi <goffi@goffi.org>
parents: 357
diff changeset
85
10
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
86
405
84ff5c917064 widgets: implemented ordering in ContactItem and CagouWidget:
Goffi <goffi@goffi.org>
parents: 387
diff changeset
87 @total_ordering
493
b3cedbee561d refactoring: rename `cagou` to `libervia.desktop_kivy` + update imports and names following backend changes
Goffi <goffi@goffi.org>
parents: 491
diff changeset
88 class LiberviaDesktopKivyWidget(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
493
b3cedbee561d refactoring: rename `cagou` to `libervia.desktop_kivy` + update imports and names following backend changes
Goffi <goffi@goffi.org>
parents: 491
diff changeset
100 # plugin info. Useful when a LiberviaDesktopKivyWidget is used with global_screen_manager.
353
19422bbd9c8e core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
101 plugin_info_class = None
10
8b2836b5b6c7 added CagouWidget:
Goffi <goffi@goffi.org>
parents:
diff changeset
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__
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
105 for p in G.host.get_plugged_widgets():
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
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
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(
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
118 on_text_validate=lambda *args: self.on_header_wid_input(),
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
119 text=self.on_header_wid_input_complete,
387
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
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
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")
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
142 screen = self.get_ancestor(Screen)
353
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"""
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
152 return G.host.get_parent_wh_wrapper(self)
353
19422bbd9c8e core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
153
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
154 def screen_manager_init(self, screen_manager):
353
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:
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
160 raise exceptions.InternalError("screen_manager_init should not be called")
353
19422bbd9c8e core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
161
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
162 def get_ancestor(self, cls):
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
163 """Helper method to use host.get_ancestor_widget with self"""
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
164 return G.host.get_ancestor_widget(self, cls)
353
19422bbd9c8e core (widgets handler): refactoring:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
165
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
166 def switch_widget(self, plugin_info):
14
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
167 self.selector.dismiss()
21a432afd06d plugin system, first draft:
Goffi <goffi@goffi.org>
parents: 10
diff changeset
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))
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
170 G.host.switch_widget(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
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
175 G.host.switch_widget(self)
357
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
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
178 def on_header_wid_input(self):
312
772c170b47a9 Python3 port:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
179 log.info("header input text entered")
51
3f8599d9a766 core: menus first draft:
Goffi <goffi@goffi.org>
parents: 38
diff changeset
180
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
181 def on_header_wid_input_complete(self, wid, text):
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
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
3f8599d9a766 core: menus first draft:
Goffi <goffi@goffi.org>
parents: 38
diff changeset
184 def on_touch_down(self, touch):
3f8599d9a766 core: menus first draft:
Goffi <goffi@goffi.org>
parents: 38
diff changeset
185 if self.collide_point(*touch.pos):
3f8599d9a766 core: menus first draft:
Goffi <goffi@goffi.org>
parents: 38
diff changeset
186 G.host.selected_widget = self
493
b3cedbee561d refactoring: rename `cagou` to `libervia.desktop_kivy` + update imports and names following backend changes
Goffi <goffi@goffi.org>
parents: 491
diff changeset
187 return super(LiberviaDesktopKivyWidget, 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
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
189 def header_input_add_extra(self, widget):
115
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
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
193 def on_visible(self):
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
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
491
203755bbe0fe massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 461
diff changeset
197 def on_not_visible(self):
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
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))