settings - 未安装设置架构“com.github.Suzie97.epoch”
问题描述
这是我的应用程序的 gschema.xml 代码:
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema path="/com/github/Suzie97/epoch"
id="com.github.Suzie97.epoch"
gettext-domain - "com.github.Suzie97.epoch">
<key name="pos-x" type="i">
<default>360</default>
<summary>Most recent x position of Epoch</summary>
<description>Most recent x position of Epoch</description>
</key>
<key name="pos-y" type="i">
<default>360</default>
<summary>Most recent y position of Epoch</summary>
<description>Most recent y position of Epoch</description>
</key>
</schema>
</schemalist>
这是安装 gschema 的 meson.build 文件:
install_data(
'gschema.xml',
install_dir: join_paths (get_option ('datadir'), 'glib-2.0', 'schemas'),
rename: meson.project_name() + '.gschema.xml'
)
当我编译时显示此错误:
Settings schema 'com.github.Suzie97.epoch' is not installed
这是 post_install.py 脚本:
#!/usr/bin/env python3
import os
import subprocess
install_prefix = os.environ['MESON_INSTALL_PREFIX']
schemadir = os.path.join(install_prefix, 'share/glib-2.0/schemas')
if not os.environ.get('DESTDIR'):
print('Compiling the gsettings schemas ... ')
subprocess.call(['glib-compile-schemas', schemadir])
为什么会这样?
解决方案
有各种各样的问题在起作用:
- 架构文件的名称应该与您的应用程序的标识符相匹配——在这种情况下,它将是
com.github.Suzie97.epoch.gschema.xml
- 您不应该在安装时重命名文件;只需将其安装在
glib-2.0/schemas
数据目录下就足够了 glib-compile-schemas $datadir/glib-2.0/schemas
安装应用程序后,您应该调用“编译”所有模式;这通常作为 Meson 中的安装后脚本完成,使用meson.add_install_script()
.
GSettings本身不使用 XML :该glib-compile-schemas
工具将生成一个缓存文件,该文件将由使用 GSettings 的所有应用程序共享,并且加载速度很快。这就是 GSettings 会警告您未安装架构的原因:您缺少最后一个编译步骤。
推荐阅读
- python - Excel 编码影响 pandas 过滤
- android - 如何下载受 NTLM 身份验证保护的文件
- linux - 使用第一个重命名 HTML 文件
- c# - 如何使用正则表达式将字符串`{{key.value}}`拆分为两个字符串`key`和`value`?
- java - 使用 pagefactory 时出现 NullPointerException
- asp.net - 在 .NET 框架 SDK 样式的 web 项目中启动浏览器
- express - 我们如何在 Expressjs 中使部分路由可选?
- flutter - Flutter/Dart:从 Switch/Case 返回值
- c# - 单击按钮后单元格颜色更改
- wpf - 如果等于和 gethashcode,wpf 绑定不刷新(不需要 IPROPERTYCHANGED!)