libgnome-gnome-config.html
来自「最新gtk中文资料集」· HTML 代码 · 共 1,690 行 · 第 1/5 页
HTML
1,690 行
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>gnome-config</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"><link rel="start" href="index.html" title="GNOME Library Reference Manual"><link rel="up" href="ch01s02.html" title="Configuration"><link rel="prev" href="libgnome-gnome-gconf.html" title="gnome-gconf"><link rel="next" href="libgnome-gnome-i18n.html" title="gnome-i18n"><meta name="generator" content="GTK-Doc V1.7 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="libgnome.html" title="GNOME Library (libgnome)"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="libgnome-gnome-gconf.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="ch01s02.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GNOME Library Reference Manual</th><td><a accesskey="n" href="libgnome-gnome-i18n.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id2799145" class="shortcut">Top</a>  |  <a href="#id2800580" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="libgnome-gnome-config"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id2799145"></a><span class="refentrytitle">gnome-config</span></h2><p>gnome-config — Access to configuration files.</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include <libgnome/libgnome.h>#define <a href="libgnome-gnome-config.html#gnome-config-get-string">gnome_config_get_string</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-get-string-with-default">gnome_config_get_string_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-get-translated-string">gnome_config_get_translated_string</a>(path)#define <a href="libgnome-gnome-config.html#gnome-config-get-translated-string-with-default">gnome_config_get_translated_string_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-string">gnome_config_private_get_string</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-string-with-default">gnome_config_private_get_string_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-translated-string">gnome_config_private_get_translated_string</a>(path)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-translated-string-with-default">gnome_config_private_get_translated_string_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-set-string">gnome_config_set_string</a> (path,new_value)#define <a href="libgnome-gnome-config.html#gnome-config-set-translated-string">gnome_config_set_translated_string</a>(path,value)#define <a href="libgnome-gnome-config.html#gnome-config-private-set-string">gnome_config_private_set_string</a> (path,new_value)#define <a href="libgnome-gnome-config.html#gnome-config-private-set-translated-string">gnome_config_private_set_translated_string</a>(path,new_value)#define <a href="libgnome-gnome-config.html#gnome-config-get-int">gnome_config_get_int</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-get-int-with-default">gnome_config_get_int_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-int">gnome_config_private_get_int</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-int-with-default">gnome_config_private_get_int_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-set-int">gnome_config_set_int</a> (path,new_value)#define <a href="libgnome-gnome-config.html#gnome-config-private-set-int">gnome_config_private_set_int</a> (path,new_value)#define <a href="libgnome-gnome-config.html#gnome-config-get-float">gnome_config_get_float</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-get-float-with-default">gnome_config_get_float_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-float">gnome_config_private_get_float</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-float-with-default">gnome_config_private_get_float_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-set-float">gnome_config_set_float</a> (path,new_value)#define <a href="libgnome-gnome-config.html#gnome-config-private-set-float">gnome_config_private_set_float</a> (path,new_value)#define <a href="libgnome-gnome-config.html#gnome-config-get-bool">gnome_config_get_bool</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-get-bool-with-default">gnome_config_get_bool_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-bool">gnome_config_private_get_bool</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-bool-with-default">gnome_config_private_get_bool_with_default</a>(path,def)#define <a href="libgnome-gnome-config.html#gnome-config-set-bool">gnome_config_set_bool</a> (path,new_value)#define <a href="libgnome-gnome-config.html#gnome-config-private-set-bool">gnome_config_private_set_bool</a> (path,new_value)#define <a href="libgnome-gnome-config.html#gnome-config-get-vector">gnome_config_get_vector</a> (path, argcp, argvp)#define <a href="libgnome-gnome-config.html#gnome-config-get-vector-with-default">gnome_config_get_vector_with_default</a>(path, argcp, argvp, def)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-vector">gnome_config_private_get_vector</a> (path, argcp, argvp)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-vector-with-default">gnome_config_private_get_vector_with_default</a>(path, argcp, argvp, def)#define <a href="libgnome-gnome-config.html#gnome-config-set-vector">gnome_config_set_vector</a> (path,argc,argv)#define <a href="libgnome-gnome-config.html#gnome-config-private-set-vector">gnome_config_private_set_vector</a> (path,argc,argv)char* <a href="libgnome-gnome-config.html#gnome-config-assemble-vector">gnome_config_assemble_vector</a> (int argc, const char *const argv[]);#define <a href="libgnome-gnome-config.html#gnome-config-has-section">gnome_config_has_section</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-has-section">gnome_config_private_has_section</a>(path)#define <a href="libgnome-gnome-config.html#gnome-config-init-iterator">gnome_config_init_iterator</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-init-iterator">gnome_config_private_init_iterator</a>(path)#define <a href="libgnome-gnome-config.html#gnome-config-init-iterator-sections">gnome_config_init_iterator_sections</a>(path)#define <a href="libgnome-gnome-config.html#gnome-config-private-init-iterator-sections">gnome_config_private_init_iterator_sections</a>(path)void* <a href="libgnome-gnome-config.html#gnome-config-iterator-next">gnome_config_iterator_next</a> (void *iterator_handle, char **key, char **value);void <a href="libgnome-gnome-config.html#gnome-config-drop-all">gnome_config_drop_all</a> (void);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a href="libgnome-gnome-config.html#gnome-config-sync">gnome_config_sync</a> (void);#define <a href="libgnome-gnome-config.html#gnome-config-sync-file">gnome_config_sync_file</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-sync-file">gnome_config_private_sync_file</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-drop-file">gnome_config_drop_file</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-drop-file">gnome_config_private_drop_file</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-clean-file">gnome_config_clean_file</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-clean-file">gnome_config_private_clean_file</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-clean-section">gnome_config_clean_section</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-clean-section">gnome_config_private_clean_section</a>(path)#define <a href="libgnome-gnome-config.html#gnome-config-clean-key">gnome_config_clean_key</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-clean-key">gnome_config_private_clean_key</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-get-real-path">gnome_config_get_real_path</a> (path)#define <a href="libgnome-gnome-config.html#gnome-config-private-get-real-path">gnome_config_private_get_real_path</a>(path)void <a href="libgnome-gnome-config.html#gnome-config-push-prefix">gnome_config_push_prefix</a> (const char *path);void <a href="libgnome-gnome-config.html#gnome-config-pop-prefix">gnome_config_pop_prefix</a> (void);void <a href="libgnome-gnome-config.html#gnome-config-make-vector">gnome_config_make_vector</a> (const char *string, int *argcp, char ***argvp);</pre></div><div class="refsect1" lang="en"><a name="id2800580"></a><h2>Description</h2><p>This module provides a simple method of retrieving and storing configurationdata that resides in files. It also provides the ability to supply defaultvalues for the configuration parameters to simply client code.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> The purpose of this module is different in GNOME 2 from what it was in GNOME 1. General applications should use the <span class="type">gnome-gconf</span> module for their configuration requirements. </p><p> The gnome-config module exists for applications that </p><div class="itemizedlist"><ul type="disc"><li><p>need to provide a backwards-compatible version of their configuration files, or</p></li><li><p>need to run independently of a user and access configuration files at absolute locations (for example, a login manager), or </p></li><li><p>need to parse <em class="wordasword">.desktop</em>-style files, or</p></li><li><p>need to parse user- or shell-editable/readable files.</p></li></ul></div><p> </p></div><p><b>Definitions. </b> </p><div class="itemizedlist"><ul type="disc"><li><p><span class="emphasis"><em>config path:</em></span> a string that specifies which item to retrieve from the configuration database. The config path is composed of three elements: the first one is the filename where the information is stored, the second component is the section and the third one is the key inside the section</p><p>For example, a config path of "/myapp/toolbox/showit" could be used to retrieve the setting for whether 'myapp' should display its toolbox or not. In this example "myapp" is the file name (which is stored in <code class="filename">~/.gnome2</code> directory), "toolbox" is the section and "showit" is the key.</p><p>If you want to access an absolute file instead of a <code class="filename">~/.gnome2</code>-relative file, then you need to surround the filename with equal signs, for example, to access the key "mykey" from the section "mysection" in a configuration file located in <code class="filename">/gnome/var/myconfig</code> you need to use this path: "=/gnome/var/myconfig=/mysection/mykey".</p></li><li><p><span class="emphasis"><em>default:</em></span> when retrieving a config item, specifies the value to be used if the item is not found.</p></li><li><p><span class="emphasis"><em>private configuration data:</em></span> Normally, config item data is located in files under the <code class="filename">~user/.gnome2</code> directory in a .ini-like format. These files are world-readable. Items that have security or privacy implications are stored and retrieved using the "private" versions of the gnome-config routines, and the data for these items is stored in files under the <code class="filename">~user/.gnome2_private</code> directory, which is not accessable by anyone except that user and the system administrator.</p></li><li><p><span class="emphasis"><em>translated strings:</em></span> GNOME's multilingual support means that multiple languages must be supported for configuration items. The gnome_config_*<code class="function">get_translated_string()</code> and gnome_config_*<code class="function">set_translated_string()</code> routines allow you to specify which language a string item should be accessed for. </p></li><li><p><span class="emphasis"><em>section:</em></span> a group of config items and other config sections</p></li></ul></div><p> </p><p><b>How Config Items are Read. </b> The gnome-config module has a versatile method of storing config items. When a config item is written by a program, it is written to a file under the <code class="filename">~/.gnome2</code> hierarchy. However, when config items are read, the process is a little more complicated. There are a number of places that are searched. If the config item is not found in one, then the next place is checked, finally falling back to the default value provided by the application. The locations are as follows: </p><div class="itemizedlist"><ul type="disc"><li><p><code class="filename">$(sysconfdir)/gnome/config-override</code> - a system administrator would put config items in this directory that they don't want to be configurable.</p></li><li><p><code class="filename">~/.gnome</code> - this is where the user's config items are written to and is the next place that is searched</p></li><li><p><code class="filename">$(sysconfdir)/gnome/config</code> - this directory would hold system wide default configuration values. </p></li></ul></div><p> </p><p> Possible uses for this are setting system wide defaults such as proxy servers for the system (either using <code class="filename">config-override</code> to enforce such a policy or the <code class="filename">config</code> directory to suggest such a default). It is also possible to configure the application through its graphical interface, and then copy the configuration file accross to the appropriate system-wide directory. The <code class="filename">config-override</code> directory should be used sparingly, as it could annoy or confuse some users. Note also that some applications will not read the config items every time they are needed, so putting defaults into the <code class="filename">config-override</code> directory will not always completely enforce a setting.</p><p>Every function in this module comes in at least two forms. There is the<code class="function"><code class="function">gnome_config_get_foo()</code></code> version which retrieves theconfiguration data from the <code class="filename">~/.gnome2</code> directory (unless anabsolute configuration key is given, as defined above). Then there is the<code class="function"><code class="function">gnome_config_private_get_foo()</code></code> version, which retrievesthe information from the user's <code class="filename">~/.gnome2-private</code>directory.</p><p>For functions dealing with strings, there is a third form of each functionwhich returns the translated version of the string for the current locale.</p></div><div class="refsect1" lang="en"><a name="id2800953"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2800963"></a><h3><a name="gnome-config-get-string"></a>gnome_config_get_string()</h3><a class="indexterm" name="id2800978"></a><pre class="programlisting">#define gnome_config_get_string(path)</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gnome_config_get_string</code> is deprecated and should not be used in newly-written code.</p></div><p>Retrieves the value of a configuration item as a string. This value shouldbe freed with <ahref="/usr/share/gtk-doc/html/glib/glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when no longer needed.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>path</code></em> :</span></td><td> A gnome configuration path to an item.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> The value of the configuration item as a string.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2801052"></a><h3><a name="gnome-config-get-string-with-default"></a>gnome_config_get_string_with_default()</h3><a class="indexterm" name="id2801068"></a><pre class="programlisting">#define gnome_config_get_string_with_default(path,def)</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gnome_config_get_string_with_default</code> is deprecated and should not be used in newly-written code.</p></div><p>Retrieves the value of a configuration item as a string. This value shouldbe freed with <ahref="/usr/share/gtk-doc/html/glib/glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when no longer needed.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>path</code></em> :</span></td><td> A gnome configuration path to an item.</td></tr><tr><td><span class="term"><em class="parameter"><code>def</code></em> :</span></td><td> A pointer to a flag that will be set if the default value for the itemis returned.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> The value of the configuration item as a string, or <em class="parameter"><code>def</code></em> if theconfiguration key does not exist.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2801163"></a><h3><a name="gnome-config-get-translated-string"></a>gnome_config_get_translated_string()</h3><a class="indexterm" name="id2801180"></a><pre class="programlisting">#define gnome_config_get_translated_string(path)</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?