How does the Gnome applet store configuration data?

I have a Gnome applet written in Python. To save configuration data / settings, it creates a ~/.appname .

However, this prevents the addition of multiple instances of the applet to the panel, because each cannot have its own settings.

How to save the settings so that each instance has its own unique settings?

Update: I specifically want to know how to store the settings for each instance.

+6
python applet gnome
source share
2 answers

The recommended way for an applet would be to use GConf to save the settings and use one key for each instance so that you can save individual settings, From the Applet GConf Utilities Panel :

Applets typically define a set of preferences using a schema file and panel_applet_add_preferences (). such preferences apply only to the individual instance of the applet. For example, you can add two time applets to the panel and configure them differently.

For preferences only apply to one applet, each applet must have a separate GConf key for each of these preferences. The methods described below provide wrappers around the usual GConfClient functions and per-applet.

+7
source share

Python example with applet:

 import gconf client = gconf.client_get_default() gconf_root_key = applet.get_preferences_key() client.set_string( gconf_root_key + "/myvar", "foobar") myvar = client.get_string( gconf_root_key + "/myvar") 
+1
source share

All Articles