MattP MattP - 8 months ago 39
Linux Question

How to configure GSettings for Gnome and Gtk

I'm fairly new to Linux GUI programming and am struggling to understand GSettings and 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
from the terminal.

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:

org.gtk.Settings.FileChooser does not contain a key named

Now, if I configure my GNAT development environment first by running the GNAT GPS
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.

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?

The 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.


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

The 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: