changeset 130:0ec3c3c0ed92

core (kv): new base.kv to handle default properties overriding on Kivy widgets
author Goffi <goffi@goffi.org>
date Fri, 06 Apr 2018 16:12:14 +0200
parents 0704f3be65cb
children 36fc269e2a32
files cagou/core/cagou_main.py cagou/kv/base.kv
diffstat 2 files changed, 29 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Fri Apr 06 16:11:00 2018 +0200
+++ b/cagou/core/cagou_main.py	Fri Apr 06 16:12:14 2018 +0200
@@ -376,9 +376,20 @@
     def _import_kv(self):
         """import all kv files in cagou.kv"""
         path = os.path.dirname(cagou.kv.__file__)
-        for kv_path in glob.glob(os.path.join(path, "*.kv")):
-            Builder.load_file(kv_path)
-            log.debug(u"kv file {} loaded".format(kv_path))
+        kv_files = glob.glob(os.path.join(path, "*.kv"))
+        # we want to be sure that base.kv is loaded first
+        # as it override some Kivy widgets properties
+        for kv_file in kv_files:
+            if kv_file.endswith('base.kv'):
+                kv_files.remove(kv_file)
+                kv_files.insert(0, kv_file)
+                break
+        else:
+            raise exceptions.InternalError("base.kv is missing")
+
+        for kv_file in kv_files:
+            Builder.load_file(kv_file)
+            log.debug(u"kv file {} loaded".format(kv_file))
 
     def _import_plugins(self):
         """import all plugins"""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cagou/kv/base.kv	Fri Apr 06 16:12:14 2018 +0200
@@ -0,0 +1,15 @@
+# Cagou: desktop/mobile frontend for Salut à Toi XMPP client
+# Copyright (C) 2016-2018 Jérôme Poisson (goffi@goffi.org)
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.