如何配置Gnome和Gtk的GSettings ?

时间:2022-03-20 06:56:48

I'm fairly new to Linux GUI programming and am struggling to understand GSettings and Schemas.

我对Linux GUI编程相当陌生,并且很难理解GSettings和Schemas。

If I launch a terminal and run gsettings list-schemas I see a long list of schemas for a variety of Gnome applications. I can also launch an application such as gedit from the terminal.

如果我启动一个终端并运行gsettings list-schemas—schemas,我就会看到许多Gnome应用程序的模式列表。我还可以从终端启动gedit之类的应用程序。

However, when I try to launch my own Gtk application from this terminal I get an error when I click on the File Chooser Button:

但是,当我尝试从这个终端启动我自己的Gtk应用程序时,当我点击File Chooser按钮时,我得到了一个错误:

org.gtk.Settings.FileChooser does not contain a key named 'startup-mode'

org.gtk.Settings。FileChooser不包含一个名为“startup-mode”的键

Now, if I configure my GNAT development environment first by running the GNAT GPS gtkada-env.sh then my application runs correctly. gsettings list-schemas now has a short list of a few schemas but does include one for File Chooser Button. The only thing now is I can no longer launch gedit from this environment as that is missing schemas.

现在,如果我首先通过运行GNAT GPS gtkada-env来配置GNAT开发环境。然后我的应用程序正确运行。gsettings list-schemas现在有一个简短的列表,其中包含一些schema,但是它包含一个用于文件选择器按钮的schema。现在唯一的事情是我不能再从这个环境中启动gedit,因为它缺少模式。

My application needs to be able to open files (File Chooser Button) and also launch gedit to view a text log file. How do I configure all of the GSettings to be available together?

我的应用程序需要能够打开文件(File Chooser按钮),并启动gedit来查看文本日志文件。如何将所有GSettings配置为同时可用?

The gtkada-env.sh sets an environment variable $GSETTINGS_BACKEND=memory if that is relevant? I did a printenv before and after configuring the GNAT environment and couldn't see an environment variable which specifically pointed to the schemas directory.

gtkada-env。sh设置环境变量$ gsettings_后端=内存,如果相关?在配置GNAT环境之前和之后,我做了一个printenv,但是没有看到一个环境变量专门指向schema目录。

1 个解决方案

#1


2  

I found the answer to this question here in the GIO Reference Manual.

我在GIO参考手册中找到了这个问题的答案。

The gtkada-env.sh script sets the environment variable $XDG_DATA_DIRS to the GNAT schemas path /usr/gnat/share. I changed this variable to include the original schemas path too:

gtkada-env。sh脚本将环境变量$XDG_DATA_DIRS设置为GNAT模式路径/usr/ gnat/share。我将这个变量修改为包含原来的模式路径:

$XDG_DATA_DIRS=/usr/gnat/share:/usr/share

#1


2  

I found the answer to this question here in the GIO Reference Manual.

我在GIO参考手册中找到了这个问题的答案。

The gtkada-env.sh script sets the environment variable $XDG_DATA_DIRS to the GNAT schemas path /usr/gnat/share. I changed this variable to include the original schemas path too:

gtkada-env。sh脚本将环境变量$XDG_DATA_DIRS设置为GNAT模式路径/usr/ gnat/share。我将这个变量修改为包含原来的模式路径:

$XDG_DATA_DIRS=/usr/gnat/share:/usr/share