comparison cagou/core/cagou_widget.py @ 387:d61bbbac4160

cagou widget: don't add header_input systematically anymore: header input is often used in CagouWidget for e.g. filtering, but not always, and when it is not, it is weird and confusing to have a TextInput which doesn't do nothing. To avoid that, a new `use_header_input` bool attribute (set to False by default) has been added to CagouWidget.
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2020 20:47:17 +0100
parents 1da3c379205b
children 84ff5c917064
comparison
equal deleted inserted replaced
386:415de998b91d 387:d61bbbac4160
22 from sat.core import exceptions 22 from sat.core import exceptions
23 from kivy.uix.behaviors import ButtonBehavior 23 from kivy.uix.behaviors import ButtonBehavior
24 from kivy.uix.boxlayout import BoxLayout 24 from kivy.uix.boxlayout import BoxLayout
25 from kivy.uix.dropdown import DropDown 25 from kivy.uix.dropdown import DropDown
26 from kivy.uix.screenmanager import Screen 26 from kivy.uix.screenmanager import Screen
27 from kivy.uix.textinput import TextInput
27 from kivy import properties 28 from kivy import properties
28 from cagou import G 29 from cagou import G
29 from .common import ActionIcon 30 from .common import ActionIcon
30 from . import menu 31 from . import menu
31 32
84 85
85 class CagouWidget(BoxLayout): 86 class CagouWidget(BoxLayout):
86 main_container = properties.ObjectProperty(None) 87 main_container = properties.ObjectProperty(None)
87 header_input = properties.ObjectProperty(None) 88 header_input = properties.ObjectProperty(None)
88 header_box = properties.ObjectProperty(None) 89 header_box = properties.ObjectProperty(None)
90 use_header_input = False
89 # set to True if you want to be able to switch between visible widgets of this 91 # set to True if you want to be able to switch between visible widgets of this
90 # class using a carousel 92 # class using a carousel
91 collection_carousel = False 93 collection_carousel = False
92 # set to True if you a global ScreenManager global to all widgets of this class. 94 # set to True if you a global ScreenManager global to all widgets of this class.
93 # The screen manager is created in WHWrapper 95 # The screen manager is created in WHWrapper
102 if p['main'] == plg_info_cls: 104 if p['main'] == plg_info_cls:
103 self.plugin_info = p 105 self.plugin_info = p
104 break 106 break
105 super().__init__(**kwargs) 107 super().__init__(**kwargs)
106 self.selector = HeaderWidgetSelector(self) 108 self.selector = HeaderWidgetSelector(self)
109 if self.use_header_input:
110 self.header_input = TextInput(
111 background_normal=G.host.app.expand(
112 '{media}/misc/borders/border_hollow_light.png'),
113 multiline=False,
114 )
115 self.header_input.bind(
116 on_text_validate=lambda *args: self.onHeaderInput(),
117 text=self.onHeaderInputComplete,
118 )
119 self.header_box.add_widget(self.header_input)
107 120
108 @property 121 @property
109 def screen_manager(self): 122 def screen_manager(self):
110 if ((not self.global_screen_manager 123 if ((not self.global_screen_manager
111 and not (self.plugin_info_class is not None 124 and not (self.plugin_info_class is not None