sniweef
sniweef

Reputation: 25

How to use GSettings in my own gtk program

I'm writing a gtk program and I try to take advantage of GSetings to store my own program settings. But the program failed at the statement "GSettings *settings = g_settings_new(SCHEMA);", with a message from the termial which said "Settings schema '.' is not installed". Must I install a settings schema before I create a GSettings object? If do, how to do that? If not, what should I do to store my settings? Is there a better way than using GSettings?

Upvotes: 1

Views: 1969

Answers (1)

ptomato
ptomato

Reputation: 57854

You guessed right; you have to install the schema before it will work. This is annoying because you can't run your program from your development directory without installing it anymore. Fortunately, it's easy to do right if you use Autotools:

In configure.ac, include the line

GLIB_GSETTINGS

and then put this in Makefile.am:

gsettings_SCHEMAS = org.my-domain.gschema.xml
@GSETTINGS_RULES@

where org.my-domain is a reverse domain name, used to identify your schema.

Upvotes: 1

Related Questions