1 | /* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ |
---|
2 | /* GNOME Library - gnome-gconf.c |
---|
3 | * Copyright (C) 2000 Red Hat Inc., |
---|
4 | * All rights reserved. |
---|
5 | * |
---|
6 | * Author: Jonathan Blandford <jrb@redhat.com> |
---|
7 | * |
---|
8 | * This library is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU Library General Public |
---|
10 | * License as published by the Free Software Foundation; either |
---|
11 | * version 2 of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This library is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | * Library General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU Library General Public |
---|
19 | * License along with this library; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. |
---|
21 | */ |
---|
22 | /* |
---|
23 | @NOTATION@ |
---|
24 | */ |
---|
25 | |
---|
26 | |
---|
27 | #include <config.h> |
---|
28 | #include <stdlib.h> |
---|
29 | |
---|
30 | #define GCONF_ENABLE_INTERNALS |
---|
31 | #include <gconf/gconf.h> |
---|
32 | #include <gconf/gconf-client.h> |
---|
33 | extern struct poptOption gconf_options[]; |
---|
34 | |
---|
35 | #include "gnome-i18nP.h" |
---|
36 | |
---|
37 | #include <libgnome/libgnome.h> |
---|
38 | |
---|
39 | #include "gnome-gconf.h" |
---|
40 | #include "gnome-gconfP.h" |
---|
41 | |
---|
42 | /** |
---|
43 | * gnome_gconf_get_gnome_libs_settings_relative: |
---|
44 | * @subkey: key part below the gnome desktop settings directory |
---|
45 | * |
---|
46 | * Description: Gets the full key name for a GNOME desktop specific |
---|
47 | * setting for a specific application. Those keys are used to store application-specific |
---|
48 | * configuration, for example the history of a GnomeEntry. This |
---|
49 | * config space should only be used by libraries. |
---|
50 | * |
---|
51 | * Returns: A newly allocated string |
---|
52 | **/ |
---|
53 | gchar* |
---|
54 | gnome_gconf_get_gnome_libs_settings_relative (const gchar *subkey) |
---|
55 | { |
---|
56 | gchar *dir; |
---|
57 | gchar *key; |
---|
58 | gchar *tmp; |
---|
59 | |
---|
60 | tmp = gconf_escape_key (gnome_program_get_app_id (gnome_program_get()), -1); |
---|
61 | |
---|
62 | dir = g_strconcat("/apps/gnome-settings/", |
---|
63 | tmp, |
---|
64 | NULL); |
---|
65 | g_free (tmp); |
---|
66 | if (subkey && *subkey) { |
---|
67 | key = gconf_concat_dir_and_key(dir, subkey); |
---|
68 | g_free(dir); |
---|
69 | } else { |
---|
70 | /* subkey == "" */ |
---|
71 | key = dir; |
---|
72 | } |
---|
73 | |
---|
74 | return key; |
---|
75 | } |
---|
76 | |
---|
77 | /** |
---|
78 | * gnome_gconf_get_app_settings_relative: |
---|
79 | * @program: #GnomeProgram pointer or %NULL for the default |
---|
80 | * @subkey: key part below the gnome desktop settings directory |
---|
81 | * |
---|
82 | * Description: Gets the full key name for an application specific |
---|
83 | * setting. That is "/apps/<application_id>/@subkey". |
---|
84 | * |
---|
85 | * Returns: A newly allocated string |
---|
86 | **/ |
---|
87 | gchar* |
---|
88 | gnome_gconf_get_app_settings_relative (GnomeProgram *program, const gchar *subkey) |
---|
89 | { |
---|
90 | gchar *dir; |
---|
91 | gchar *key; |
---|
92 | |
---|
93 | if (program == NULL) |
---|
94 | program = gnome_program_get (); |
---|
95 | |
---|
96 | dir = g_strconcat ("/apps/", |
---|
97 | gnome_program_get_app_id (program), |
---|
98 | NULL); |
---|
99 | |
---|
100 | if (subkey && *subkey) { |
---|
101 | key = gconf_concat_dir_and_key (dir, subkey); |
---|
102 | g_free (dir); |
---|
103 | } else { |
---|
104 | /* subkey == "" */ |
---|
105 | key = dir; |
---|
106 | } |
---|
107 | |
---|
108 | return key; |
---|
109 | } |
---|
110 | |
---|
111 | /** |
---|
112 | * gnome_gconf_lazy_init |
---|
113 | * |
---|
114 | * Description: Internal libgnome/ui routine. You never have |
---|
115 | * to do this from your code. But all places in libgnome/ui |
---|
116 | * that need gconf should call this before calling any gconf |
---|
117 | * calls. |
---|
118 | **/ |
---|
119 | void |
---|
120 | _gnome_gconf_lazy_init (void) |
---|
121 | { |
---|
122 | /* Note this is the same as in libgnomeui/libgnomeui/gnome-gconf-ui.c, |
---|
123 | * keep this in sync (it's named gnomeui_gconf_lazy_init) */ |
---|
124 | gchar *settings_dir; |
---|
125 | GConfClient* client = NULL; |
---|
126 | static gboolean initialized = FALSE; |
---|
127 | |
---|
128 | if (initialized) |
---|
129 | return; |
---|
130 | |
---|
131 | initialized = TRUE; |
---|
132 | |
---|
133 | client = gconf_client_get_default (); |
---|
134 | |
---|
135 | gconf_client_add_dir (client, |
---|
136 | "/desktop/gnome", |
---|
137 | GCONF_CLIENT_PRELOAD_NONE, NULL); |
---|
138 | |
---|
139 | settings_dir = gnome_gconf_get_gnome_libs_settings_relative (""); |
---|
140 | |
---|
141 | gconf_client_add_dir (client, |
---|
142 | settings_dir, |
---|
143 | /* Possibly we should turn preload on for this */ |
---|
144 | GCONF_CLIENT_PRELOAD_NONE, |
---|
145 | NULL); |
---|
146 | g_free (settings_dir); |
---|
147 | |
---|
148 | /* Leak the GConfClient reference, we want to keep |
---|
149 | * the client alive forever. |
---|
150 | */ |
---|
151 | } |
---|
152 | |
---|
153 | /** |
---|
154 | * gnome_gconf_module_info_get |
---|
155 | * |
---|
156 | * An internal libgnome/ui routine. This will never be needed in public code. |
---|
157 | * |
---|
158 | * Returns: A #GnomeModuleInfo instance representing the GConf module. |
---|
159 | */ |
---|
160 | const GnomeModuleInfo * |
---|
161 | _gnome_gconf_module_info_get (void) |
---|
162 | { |
---|
163 | static GnomeModuleInfo module_info = { |
---|
164 | "gnome-gconf", |
---|
165 | gconf_version, |
---|
166 | NULL /* description */, |
---|
167 | NULL /* requirements */, |
---|
168 | NULL /* instance init */, |
---|
169 | NULL /* pre_args_parse */, |
---|
170 | NULL /* post_args_parse */, |
---|
171 | gconf_options, |
---|
172 | NULL /* init_pass */, |
---|
173 | NULL /* class_init */, |
---|
174 | NULL, NULL /* expansions */ |
---|
175 | }; |
---|
176 | |
---|
177 | module_info.description = _("GNOME GConf Support"); |
---|
178 | |
---|
179 | return &module_info; |
---|
180 | } |
---|