gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / gnome-tweaks-search-paths.patch
1 Gnome-tweaks does not look at GSETTINGS_SCHEMA_PATH or XDG_DATA_DIRS, it
2 assumes that schemas are installed in one global directory
3 (GSETTINGS_SCHEMA_DIR/gsettingsschemadir).
4
5 Guix/GuixSD uses a different directory for every gir package and has
6 packages pick-up files using XDG_DATA_DIRS.
7
8 Upstream ticket: https://bugzilla.gnome.org/show_bug.cgi?id=764537
9 janneke@gnu.org
10
11 --- gnome-tweak-3.18.1.orig/gtweak/gsettings.py 2015-04-08 15:21:32.000000000 +0200
12 +++ gnome-tweak-tool-3.18.1/gtweak/gsettings.py 2016-04-03 11:26:38.658482704 +0200
13 @@ -16,7 +16,8 @@
14 # along with gnome-tweak-tool. If not, see <http://www.gnu.org/licenses/>.
15
16 import logging
17 -import os.path
18 +import os
19 +import sys
20 import xml.dom.minidom
21 import gettext
22
23 @@ -31,6 +32,13 @@
24 class GSettingsMissingError(Exception):
25 pass
26
27 +def file_from_path(path, file_name):
28 + for dir in path:
29 + f = os.path.join(dir, file_name)
30 + if os.path.exists(f):
31 + return f
32 + return None
33 +
34 class _GSettingsSchema:
35 def __init__(self, schema_name, schema_dir=None, schema_filename=None, **options):
36 if not schema_dir:
37 @@ -38,9 +46,14 @@
38 if not schema_filename:
39 schema_filename = schema_name + ".gschema.xml"
40
41 + schema_prefix = os.path.join('glib-2.0', 'schemas')
42 schema_path = os.path.join(schema_dir, schema_filename)
43 if not os.path.exists(schema_path):
44 - logging.critical("Could not find schema %s" % schema_path)
45 + schema_path = file_from_path(os.environ.get ('GSETTINGS_SCHEMA_PATH', '').split(os.path.pathsep), schema_filename)
46 + if not (schema_path and os.path.exists(schema_path)):
47 + schema_path = file_from_path(os.environ.get ('XDG_DATA_DIRS', '').split(os.path.pathsep), os.path.join(schema_prefix, schema_filename))
48 + if not (schema_path and os.path.exists(schema_path)):
49 + logging.critical("Could not find schema %s" % schema_filename)
50 assert(False)
51
52 self._schema_name = schema_name