changeset 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 415de998b91d
children de066b72f5a8
files cagou/core/cagou_widget.py cagou/kv/cagou_widget.kv cagou/plugins/plugin_wid_chat.py cagou/plugins/plugin_wid_contact_list.py cagou/plugins/plugin_wid_file_sharing.py
diffstat 5 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_widget.py	Tue Feb 04 20:47:17 2020 +0100
+++ b/cagou/core/cagou_widget.py	Tue Feb 04 20:47:17 2020 +0100
@@ -24,6 +24,7 @@
 from kivy.uix.boxlayout import BoxLayout
 from kivy.uix.dropdown import DropDown
 from kivy.uix.screenmanager import Screen
+from kivy.uix.textinput import TextInput
 from kivy import properties
 from cagou import G
 from .common import ActionIcon
@@ -86,6 +87,7 @@
     main_container = properties.ObjectProperty(None)
     header_input = properties.ObjectProperty(None)
     header_box = properties.ObjectProperty(None)
+    use_header_input = False
     # set to True if you want to be able to switch between visible widgets of this
     # class using a carousel
     collection_carousel = False
@@ -104,6 +106,17 @@
                 break
         super().__init__(**kwargs)
         self.selector = HeaderWidgetSelector(self)
+        if self.use_header_input:
+            self.header_input = TextInput(
+                background_normal=G.host.app.expand(
+                    '{media}/misc/borders/border_hollow_light.png'),
+                multiline=False,
+            )
+            self.header_input.bind(
+                on_text_validate=lambda *args: self.onHeaderInput(),
+                text=self.onHeaderInputComplete,
+            )
+            self.header_box.add_widget(self.header_input)
 
     @property
     def screen_manager(self):
--- a/cagou/kv/cagou_widget.kv	Tue Feb 04 20:47:17 2020 +0100
+++ b/cagou/kv/cagou_widget.kv	Tue Feb 04 20:47:17 2020 +0100
@@ -69,7 +69,6 @@
             size: self.size
 
 <CagouWidget>:
-    header_input: header_input
     header_box: header_box
     orientation: "vertical"
     BoxLayout:
@@ -83,9 +82,3 @@
             size_hint: None, 1
             width: self.height
             on_release: root.selector.open(self)
-        TextInput:
-            id: header_input
-            background_normal: app.expand('{media}/misc/borders/border_hollow_light.png')
-            multiline: False
-            on_text_validate: root.onHeaderInput()
-            on_text: root.onHeaderInputComplete(*args)
--- a/cagou/plugins/plugin_wid_chat.py	Tue Feb 04 20:47:17 2020 +0100
+++ b/cagou/plugins/plugin_wid_chat.py	Tue Feb 04 20:47:17 2020 +0100
@@ -383,6 +383,7 @@
     message_input = properties.ObjectProperty()
     messages_widget = properties.ObjectProperty()
     history_scroll = properties.ObjectProperty()
+    use_header_input = True
     global_screen_manager = True
     collection_carousel = True
 
--- a/cagou/plugins/plugin_wid_contact_list.py	Tue Feb 04 20:47:17 2020 +0100
+++ b/cagou/plugins/plugin_wid_contact_list.py	Tue Feb 04 20:47:17 2020 +0100
@@ -119,6 +119,7 @@
                   TouchMenuBehaviour):
     float_layout = properties.ObjectProperty()
     layout = properties.ObjectProperty()
+    use_header_input = True
 
     def __init__(self, host, target, profiles):
         QuickContactList.__init__(self, G.host, profiles)
--- a/cagou/plugins/plugin_wid_file_sharing.py	Tue Feb 04 20:47:17 2020 +0100
+++ b/cagou/plugins/plugin_wid_file_sharing.py	Tue Feb 04 20:47:17 2020 +0100
@@ -156,6 +156,7 @@
     remote_dir = properties.StringProperty('')
     remote_entity = properties.StringProperty('')
     shared_paths = properties.ListProperty()
+    use_header_input = True
     signals_registered = False
 
     def __init__(self, host, target, profiles):