首页 > 解决方案 > GLib-GIO-ERROR **:未安装设置架构“com.github.mfru.vala-todo”

问题描述

首先,我是和的新手Vala,所以我可能正在寻找完全错误的方向。GtkMeson

我在 Pop_OS 上运行!20.10。

我想编译一个支持 GSettings 的小示例 Vala 应用程序。

但是,当编译ninja,安装sudo ninja install然后执行时,我得到了标题中提到的错误。

似乎即使我的 gschema 文件被复制到/usr/share/glib-2.0/schemasglib-compile-schemas在我的安装后脚本中运行也没有做任何事情。

我还可以通过glib-compile-schemas手动运行然后使用 dconf Editor 检查我的设置是否可用来确认。

数据/gschema.xml

<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
    <schema path="/com/github/mfru/vala-todo" id="com.github.mfru.vala-todo">
        <key name="pos-x" type="i">
            <default>360</default>
            <summary>Horizontal position</summary>
            <description>The saved horizontal position of our window</description>
        </key>

        <key name="pos-y" type="i">
            <default>360</default>
            <summary>Vertical position</summary>
            <description>The saved vertical position of our window</description>
        </key>

        <key name="window-width" type="i">
            <default>600</default>
            <summary>Window width</summary>
            <description>The saved width of our window</description>
        </key>

        <key name="window-height" type="i">
            <default>400</default>
            <summary>Window height</summary>
            <description>The saved height of our window</description>
        </key>
    </schema>
</schemalist>

数据/介子.build

install_data(
    'gschema.xml',
    install_dir: join_paths (get_option ('datadir'), 'glib-2.0', 'schemas'),
    rename: meson.project_name () + '.geschema.xml'
)

介子/安装后.py

#!/usr/bin/env python3

import os
import subprocess

schemadir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas')
print("Schemadir is", schemadir)

if 'DESTDIR' not in os.environ:
    print("Compiling the gsettings schemas...")
    subprocess.call(['glib-compile-schemas', schemadir])

meson build --prefix=/usr --reconfigure我还用最初指向的前缀重新配置了介子前缀,/usr/local但我系统上的所有现有模式都在/usr/share

最后,我期望发生的是我的示例应用程序启动时不会因为缺少 GSettings 而崩溃。

我研究的资源:

https://mesonbuild.com/Configuring-a-build-directory.html

https://developer.gnome.org/gio/stable/glib-compile-schemas.html

在 Vala 中安装期间有什么方法可以创建 GSettings 模式?

标签: glibgsettings

解决方案


您的build.meson文件中有错字。

它应该.gschema.xml代替.geschema.xml.


推荐阅读