Gnome 小程序应该如何存储其配置数据? [英] How should a Gnome applet store its configuration data?

查看:16
本文介绍了Gnome 小程序应该如何存储其配置数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 Python 编写的 Gnome 小程序.为了保存配置数据/设置,它创建了一个文件~/.appname.

I have a Gnome applet written in Python. In order to save configuration data/settings, it creates a file ~/.appname.

但是,这会阻止将小程序的多个实例添加到面板中,因为每个实例都不能有自己的设置.

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

如何以允许每个实例拥有自己独特设置的方式存储设置?

How can I store the settings in a way that allows each instance to have its own unique settings?

更新:我特别想知道如何每个实例存储设置.

Update: I specifically want to know how to store settings per instance.

推荐答案

小程序的推荐方式是使用 GConf 用于存储首选项 并为每个实例使用一个键,以便您可以存储个人设置.来自 Panel Applet GConf Utilities:

The recommend way for an applet would be to use GConf to store preferences and to use one key per instance so that you can store individual settings. From Panel Applet GConf Utilities:

Applet 通常定义一组使用模式文件的首选项和panel_applet_add_preferences().这样的偏好仅适用于单个小程序实例.为了例如,您可以添加两个时钟小程序到面板并配置它们不一样.

Applets typically define a set of preferences using a schemas file and panel_applet_add_preferences(). Such preferences apply only to an individual applet instance. For example, you may add two clock applets to the panel and configure them differently.

为了使首选项仅适用于单个小程序,每个小程序必须有一个单独的 GConf 密钥这些偏好中的每一个.方法下面描述提供方便围绕通常的 GConfClient 的包装器功能和操作这些每个小程序的键.

In order for the preferences to only apply to a single applet, each applet must have a seperate GConf key for each of these preferences. The methods described below provide convient wrappers around the usual GConfClient functions and operate on these per-applet keys.

这篇关于Gnome 小程序应该如何存储其配置数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆