This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

{X} Warning:
This is a proposal which has been refused, and will not be turned into a GNOME Goal.
See why this Goal is seen as a misinterpretation of the GConf guidelines, as Window state should be stored in GConf. As saving to GConf is acceptable, then libgconf-bridge has code to bind window size, position, and maximise state to GConf.

GNOME Goal: Saving state in a file, not GConf

A lot of applications use GConf to save their state, like window sizes, window states, and paths of the last files opened. This should not be saved in GConf as per GConf's homepage:

Do not store anything but preferences in GConf. Documents, session state, random data blobs do not belong in GConf. Stuff breaks if you do this.

You should instead save this data on-disk, in a file. The file should be under ~/.gnome2/, and contain the name of your application. I recommend using GKeyFile to load and save this data.

An example of how to save state using a GKeyfile is available in this Totem bug.

Implementation notes

Read Havoc describing the sort of high-level functions we need:

So you would do


Why stop at just window information? I've put together some routines that make it possible to save

The only requirements are that g_set_application_name () has been called, and any widget that needs its state saved has the "name" property set.

Saving requires you to explicitly specify which widgets and which states you want saved. Loading only requires you give it the parent widget (such as the window) and then all of its children's states are implicitly loaded.

Here's the files: gpersist.h, gpersist.c, test.c, testui.glade

Compile with


2024-10-23 11:17