|
Lines 2-12
Link Here
|
| 2 |
/* |
2 |
/* |
| 3 |
* gnumeric-gconf.c: |
3 |
* gnumeric-gconf.c: |
| 4 |
* |
4 |
* |
| 5 |
* |
|
|
| 6 |
* Author: |
5 |
* Author: |
| 7 |
* Andreas J. Guelzow <aguelzow@taliesin.ca> |
6 |
* Andreas J. Guelzow <aguelzow@taliesin.ca> |
| 8 |
* |
7 |
* |
| 9 |
* (C) Copyright 2002-2004 Andreas J. Guelzow <aguelzow@taliesin.ca> |
8 |
* (C) Copyright 2002-2005 Andreas J. Guelzow <aguelzow@taliesin.ca> |
|
|
9 |
* |
| 10 |
* Introduced the concept of "node" and implemented the win32 backend |
| 11 |
* by Ivan, Wong Yat Cheung <email@ivanwong.info>, 2005 |
| 10 |
* |
12 |
* |
| 11 |
* This program is free software; you can redistribute it and/or modify |
13 |
* This program is free software; you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU General Public License as published by |
14 |
* it under the terms of the GNU General Public License as published by |
|
Lines 33-38
Link Here
|
| 33 |
|
35 |
|
| 34 |
static GnmAppPrefs prefs; |
36 |
static GnmAppPrefs prefs; |
| 35 |
GnmAppPrefs const *gnm_app_prefs = &prefs; |
37 |
GnmAppPrefs const *gnm_app_prefs = &prefs; |
|
|
38 |
static GOConfNode *root = NULL; |
| 36 |
|
39 |
|
| 37 |
#ifdef WITH_GNOME |
40 |
#ifdef WITH_GNOME |
| 38 |
#include <format.h> |
41 |
#include <format.h> |
|
Lines 40-128
GnmAppPrefs const *gnm_app_prefs = &pref
Link Here
|
| 40 |
#include <number-match.h> |
43 |
#include <number-match.h> |
| 41 |
#include <gconf/gconf-client.h> |
44 |
#include <gconf/gconf-client.h> |
| 42 |
|
45 |
|
|
|
46 |
struct _GOConfNode { |
| 47 |
gchar *path; |
| 48 |
gboolean root; |
| 49 |
}; |
| 50 |
|
| 43 |
static GConfClient *gconf_client = NULL; |
51 |
static GConfClient *gconf_client = NULL; |
| 44 |
static GConfClient * |
52 |
|
| 45 |
gnm_app_get_gconf_client (void) |
53 |
|
|
|
54 |
static void |
| 55 |
go_conf_init () |
| 46 |
{ |
56 |
{ |
| 47 |
if (!gconf_client) { |
57 |
if (!gconf_client) |
| 48 |
gconf_client = gconf_client_get_default (); |
58 |
gconf_client = gconf_client_get_default (); |
| 49 |
gconf_client_add_dir (gconf_client, "/apps/gnumeric", |
59 |
} |
|
|
60 |
|
| 61 |
static void |
| 62 |
go_conf_shutdown () |
| 63 |
{ |
| 64 |
if (gconf_client) { |
| 65 |
g_object_unref (G_OBJECT (gconf_client)); |
| 66 |
gconf_client = NULL; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
static gchar * |
| 71 |
go_conf_get_real_key (GOConfNode const *key, gchar const *subkey) |
| 72 |
{ |
| 73 |
return key ? g_strconcat ((key)->path, "/", subkey, NULL) : |
| 74 |
g_strdup (subkey); |
| 75 |
} |
| 76 |
|
| 77 |
GOConfNode * |
| 78 |
go_conf_get_node (GOConfNode *parent, gchar const *key) |
| 79 |
{ |
| 80 |
GOConfNode *node; |
| 81 |
|
| 82 |
node = g_new (GOConfNode, 1); |
| 83 |
gconf_client = gconf_client; |
| 84 |
node->root = !parent; |
| 85 |
if (node->root) { |
| 86 |
node->path = g_strconcat ("/apps/", key, NULL); |
| 87 |
gconf_client_add_dir (gconf_client, node->path, |
| 50 |
GCONF_CLIENT_PRELOAD_RECURSIVE, |
88 |
GCONF_CLIENT_PRELOAD_RECURSIVE, |
| 51 |
NULL); |
89 |
NULL); |
| 52 |
} |
90 |
} |
| 53 |
return gconf_client; |
91 |
else |
|
|
92 |
node->path = go_conf_get_real_key (parent, key); |
| 93 |
|
| 94 |
return node; |
| 95 |
} |
| 96 |
|
| 97 |
void |
| 98 |
go_conf_free_node (GOConfNode *node) |
| 99 |
{ |
| 100 |
if (node) { |
| 101 |
if (node->root) |
| 102 |
gconf_client_remove_dir (gconf_client, node->path, NULL); |
| 103 |
g_free (node->path); |
| 104 |
g_free (node); |
| 105 |
} |
| 54 |
} |
106 |
} |
|
|
107 |
|
| 55 |
void |
108 |
void |
| 56 |
go_conf_sync (void) |
109 |
go_conf_sync (GOConfNode *node) |
| 57 |
{ |
110 |
{ |
| 58 |
gconf_client_suggest_sync (gnm_app_get_gconf_client (), NULL); |
111 |
gconf_client_suggest_sync (gconf_client, NULL); |
| 59 |
} |
112 |
} |
| 60 |
|
113 |
|
| 61 |
void |
114 |
void |
| 62 |
go_conf_set_bool (char const *key, gboolean val) |
115 |
go_conf_set_bool (GOConfNode *node, gchar const *key, gboolean val) |
| 63 |
{ |
116 |
{ |
| 64 |
gconf_client_set_bool (gnm_app_get_gconf_client (), key, val, NULL); |
117 |
gchar *real_key = go_conf_get_real_key (node, key); |
|
|
118 |
gconf_client_set_bool (gconf_client, real_key, val, NULL); |
| 119 |
g_free (real_key); |
| 65 |
} |
120 |
} |
|
|
121 |
|
| 66 |
void |
122 |
void |
| 67 |
go_conf_set_int (char const *key, gint val) |
123 |
go_conf_set_int (GOConfNode *node, gchar const *key, gint val) |
| 68 |
{ |
124 |
{ |
| 69 |
gconf_client_set_int (gnm_app_get_gconf_client (), key, val, NULL); |
125 |
gchar *real_key = go_conf_get_real_key (node, key); |
|
|
126 |
gconf_client_set_int (gconf_client, real_key, val, NULL); |
| 127 |
g_free (real_key); |
| 70 |
} |
128 |
} |
|
|
129 |
|
| 71 |
void |
130 |
void |
| 72 |
go_conf_set_double (char const *key, gnm_float val) |
131 |
go_conf_set_double (GOConfNode *node, gchar const *key, gnm_float val) |
| 73 |
{ |
132 |
{ |
| 74 |
gconf_client_set_float (gnm_app_get_gconf_client (), key, val, NULL); |
133 |
gchar *real_key = go_conf_get_real_key (node, key); |
|
|
134 |
gconf_client_set_float (gconf_client, real_key, val, NULL); |
| 135 |
g_free (real_key); |
| 75 |
} |
136 |
} |
|
|
137 |
|
| 76 |
void |
138 |
void |
| 77 |
go_conf_set_string (char const *key, char const *str) |
139 |
go_conf_set_string (GOConfNode *node, gchar const *key, gchar const *str) |
| 78 |
{ |
140 |
{ |
| 79 |
gconf_client_set_string (gnm_app_get_gconf_client (), key, str, NULL); |
141 |
gchar *real_key = go_conf_get_real_key (node, key); |
|
|
142 |
gconf_client_set_string (gconf_client, real_key, str, NULL); |
| 143 |
g_free (real_key); |
| 80 |
} |
144 |
} |
|
|
145 |
|
| 81 |
void |
146 |
void |
| 82 |
go_conf_set_str_list (char const *key, GSList *list) |
147 |
go_conf_set_str_list (GOConfNode *node, gchar const *key, GSList *list) |
| 83 |
{ |
148 |
{ |
| 84 |
gconf_client_set_list (gnm_app_get_gconf_client (), |
149 |
gchar *real_key = go_conf_get_real_key (node, key); |
| 85 |
key, GCONF_VALUE_STRING, list, NULL); |
150 |
gconf_client_set_list (gconf_client, real_key, |
|
|
151 |
GCONF_VALUE_STRING, list, NULL); |
| 152 |
g_free (real_key); |
| 86 |
} |
153 |
} |
| 87 |
|
154 |
|
| 88 |
static GConfValue * |
155 |
static GConfValue * |
| 89 |
go_conf_get (char const *key, GConfValueType t) |
156 |
go_conf_get (GOConfNode *node, gchar const *key, GConfValueType t) |
| 90 |
{ |
157 |
{ |
| 91 |
GError *err = NULL; |
158 |
GError *err = NULL; |
| 92 |
GConfValue *val = gconf_client_get (gnm_app_get_gconf_client (), key, &err); |
159 |
GConfValue *val; |
|
|
160 |
gchar *real_key; |
| 161 |
|
| 162 |
real_key = go_conf_get_real_key (node, key); |
| 163 |
val = gconf_client_get (gconf_client, real_key, &err); |
| 93 |
|
164 |
|
| 94 |
if (err != NULL) { |
165 |
if (err != NULL) { |
| 95 |
g_warning ("Unable to load key '%s' : because %s", |
166 |
g_warning ("Unable to load key '%s' : because %s", |
| 96 |
key, err->message); |
167 |
real_key, err->message); |
|
|
168 |
g_free (real_key); |
| 97 |
g_error_free (err); |
169 |
g_error_free (err); |
| 98 |
return NULL; |
170 |
return NULL; |
| 99 |
} |
171 |
} |
| 100 |
if (val == NULL) { |
172 |
if (val == NULL) { |
| 101 |
g_warning ("Unable to load key '%s'", key); |
173 |
g_warning ("Unable to load key '%s'", real_key); |
|
|
174 |
g_free (real_key); |
| 102 |
return NULL; |
175 |
return NULL; |
| 103 |
} |
176 |
} |
| 104 |
|
177 |
|
| 105 |
if (val->type != t) { |
178 |
if (val->type != t) { |
| 106 |
#if 1 /* gconf_value_type_to_string is internal */ |
179 |
#if 1 /* gconf_value_type_to_string is internal */ |
| 107 |
g_warning ("Expected `%d' got `%d' for key %s", |
180 |
g_warning ("Expected `%d' got `%d' for key %s", |
| 108 |
t, val->type, key); |
181 |
t, val->type, real_key); |
| 109 |
#else |
182 |
#else |
| 110 |
g_warning ("Expected `%s' got `%s' for key %s", |
183 |
g_warning ("Expected `%s' got `%s' for key %s", |
| 111 |
gconf_value_type_to_string (t), |
184 |
gconf_value_type_to_string (t), |
| 112 |
gconf_value_type_to_string (val->type), |
185 |
gconf_value_type_to_string (val->type), |
| 113 |
key); |
186 |
real_key); |
| 114 |
#endif |
187 |
#endif |
|
|
188 |
g_free (real_key); |
| 115 |
gconf_value_free (val); |
189 |
gconf_value_free (val); |
| 116 |
return NULL; |
190 |
return NULL; |
| 117 |
} |
191 |
} |
|
|
192 |
g_free (real_key); |
| 118 |
|
193 |
|
| 119 |
return val; |
194 |
return val; |
| 120 |
} |
195 |
} |
| 121 |
gboolean |
196 |
gboolean |
| 122 |
go_conf_load_bool (char const *key, gboolean default_val) |
197 |
go_conf_load_bool (GOConfNode *node, gchar const *key, gboolean default_val) |
| 123 |
{ |
198 |
{ |
| 124 |
gboolean res; |
199 |
gboolean res; |
| 125 |
GConfValue *val = go_conf_get (key, GCONF_VALUE_BOOL); |
200 |
GConfValue *val = go_conf_get (node, key, GCONF_VALUE_BOOL); |
| 126 |
|
201 |
|
| 127 |
if (val != NULL) { |
202 |
if (val != NULL) { |
| 128 |
res = gconf_value_get_bool (val); |
203 |
res = gconf_value_get_bool (val); |
|
Lines 134-144
go_conf_load_bool (char const *key, gboo
Link Here
|
| 134 |
return res; |
209 |
return res; |
| 135 |
} |
210 |
} |
| 136 |
|
211 |
|
| 137 |
int |
212 |
gint |
| 138 |
go_conf_load_int (char const *key, int minima, int maxima, int default_val) |
213 |
go_conf_load_int (GOConfNode *node, gchar const *key, gint minima, gint maxima, gint default_val) |
| 139 |
{ |
214 |
{ |
| 140 |
int res = -1; |
215 |
gint res = -1; |
| 141 |
GConfValue *val = go_conf_get (key, GCONF_VALUE_INT); |
216 |
GConfValue *val = go_conf_get (node, key, GCONF_VALUE_INT); |
| 142 |
|
217 |
|
| 143 |
if (val != NULL) { |
218 |
if (val != NULL) { |
| 144 |
res = gconf_value_get_int (val); |
219 |
res = gconf_value_get_int (val); |
|
Lines 156-167
go_conf_load_int (char const *key, int m
Link Here
|
| 156 |
return res; |
231 |
return res; |
| 157 |
} |
232 |
} |
| 158 |
|
233 |
|
| 159 |
double |
234 |
gdouble |
| 160 |
go_conf_load_double (char const *key, |
235 |
go_conf_load_double (GOConfNode *node, gchar const *key, |
| 161 |
double minima, double maxima, double default_val) |
236 |
gdouble minima, gdouble maxima, gdouble default_val) |
| 162 |
{ |
237 |
{ |
| 163 |
double res = -1; |
238 |
gdouble res = -1; |
| 164 |
GConfValue *val = go_conf_get (key, GCONF_VALUE_FLOAT); |
239 |
GConfValue *val = go_conf_get (node, key, GCONF_VALUE_FLOAT); |
| 165 |
|
240 |
|
| 166 |
if (val != NULL) { |
241 |
if (val != NULL) { |
| 167 |
res = gconf_value_get_float (val); |
242 |
res = gconf_value_get_float (val); |
|
Lines 178-223
go_conf_load_double (char const *key,
Link Here
|
| 178 |
} |
253 |
} |
| 179 |
return res; |
254 |
return res; |
| 180 |
} |
255 |
} |
| 181 |
char * |
256 |
|
| 182 |
go_conf_load_string (char const *key) |
257 |
gchar * |
|
|
258 |
go_conf_load_string (GOConfNode *node, gchar const *key) |
| 183 |
{ |
259 |
{ |
| 184 |
return gconf_client_get_string (gnm_app_get_gconf_client (), key, NULL); |
260 |
gchar *val; |
|
|
261 |
|
| 262 |
gchar *real_key = go_conf_get_real_key (node, key); |
| 263 |
val = gconf_client_get_string (gconf_client, real_key, NULL); |
| 264 |
g_free (real_key); |
| 265 |
|
| 266 |
return val; |
| 185 |
} |
267 |
} |
|
|
268 |
|
| 186 |
GSList * |
269 |
GSList * |
| 187 |
go_conf_load_str_list (char const *key) |
270 |
go_conf_load_str_list (GOConfNode *node, gchar const *key) |
| 188 |
{ |
271 |
{ |
| 189 |
return gconf_client_get_list (gnm_app_get_gconf_client (), |
272 |
GSList *list; |
| 190 |
key, GCONF_VALUE_STRING, NULL); |
273 |
|
|
|
274 |
gchar *real_key = go_conf_get_real_key (node, key); |
| 275 |
list = gconf_client_get_list (gconf_client, real_key, |
| 276 |
GCONF_VALUE_STRING, NULL); |
| 277 |
g_free (real_key); |
| 278 |
|
| 279 |
return list; |
| 191 |
} |
280 |
} |
| 192 |
|
281 |
|
| 193 |
static GConfSchema * |
282 |
static GConfSchema * |
| 194 |
get_schema (char const *key) |
283 |
get_schema (GOConfNode *node, gchar const *key) |
| 195 |
{ |
284 |
{ |
| 196 |
char *schema_key = g_strconcat ("/schemas", key, NULL); |
285 |
gchar *schema_key = g_strconcat ( |
|
|
286 |
"/schemas", node->path, "/", key, NULL); |
| 197 |
GConfSchema *schema = gconf_client_get_schema ( |
287 |
GConfSchema *schema = gconf_client_get_schema ( |
| 198 |
gnm_app_get_gconf_client (), schema_key, NULL); |
288 |
gconf_client, schema_key, NULL); |
| 199 |
g_free (schema_key); |
289 |
g_free (schema_key); |
| 200 |
return schema; |
290 |
return schema; |
| 201 |
} |
291 |
} |
| 202 |
char * |
292 |
|
| 203 |
go_conf_get_short_desc (char const *key) |
293 |
gchar * |
|
|
294 |
go_conf_get_short_desc (GOConfNode *node, gchar const *key) |
| 204 |
{ |
295 |
{ |
| 205 |
GConfSchema *schema = get_schema (key); |
296 |
GConfSchema *schema = get_schema (node, key); |
| 206 |
|
297 |
|
| 207 |
if (schema != NULL) { |
298 |
if (schema != NULL) { |
| 208 |
char *desc = g_strdup (gconf_schema_get_short_desc (schema)); |
299 |
gchar *desc = g_strdup (gconf_schema_get_short_desc (schema)); |
| 209 |
gconf_schema_free (schema); |
300 |
gconf_schema_free (schema); |
| 210 |
return desc; |
301 |
return desc; |
| 211 |
} |
302 |
} |
| 212 |
return NULL; |
303 |
return NULL; |
| 213 |
} |
304 |
} |
| 214 |
char * |
305 |
|
| 215 |
go_conf_get_long_desc (char const *key) |
306 |
gchar * |
|
|
307 |
go_conf_get_long_desc (GOConfNode *node, gchar const *key) |
| 216 |
{ |
308 |
{ |
| 217 |
GConfSchema *schema = get_schema (key); |
309 |
GConfSchema *schema = get_schema (node, key); |
| 218 |
|
310 |
|
| 219 |
if (schema != NULL) { |
311 |
if (schema != NULL) { |
| 220 |
char *desc = g_strdup (gconf_schema_get_long_desc (schema)); |
312 |
gchar *desc = g_strdup (gconf_schema_get_long_desc (schema)); |
| 221 |
gconf_schema_free (schema); |
313 |
gconf_schema_free (schema); |
| 222 |
return desc; |
314 |
return desc; |
| 223 |
} |
315 |
} |
|
Lines 225-233
go_conf_get_long_desc (char const *key)
Link Here
|
| 225 |
} |
317 |
} |
| 226 |
|
318 |
|
| 227 |
GType |
319 |
GType |
| 228 |
go_conf_get_type (char const *key) |
320 |
go_conf_get_type (GOConfNode *node, gchar const *key) |
| 229 |
{ |
321 |
{ |
| 230 |
GConfSchema *schema = get_schema (key); |
322 |
GConfSchema *schema = get_schema (node, key); |
| 231 |
GType t; |
323 |
GType t; |
| 232 |
|
324 |
|
| 233 |
switch (gconf_schema_get_type (schema)) { |
325 |
switch (gconf_schema_get_type (schema)) { |
|
Lines 244-270
go_conf_get_type (char const *key)
Link Here
|
| 244 |
return t; |
336 |
return t; |
| 245 |
} |
337 |
} |
| 246 |
|
338 |
|
| 247 |
char * |
339 |
gchar * |
| 248 |
go_conf_get_value_as_str (char const *key) |
340 |
go_conf_get_value_as_str (GOConfNode *node, gchar const *key) |
| 249 |
{ |
341 |
{ |
| 250 |
char *value_string; |
342 |
gchar *value_string; |
| 251 |
GConfClient *gconf = gnm_app_get_gconf_client (); |
343 |
GConfClient *gconf = gconf_client; |
| 252 |
|
344 |
|
| 253 |
switch (go_conf_get_type (key)) { |
345 |
switch (go_conf_get_type (node, key)) { |
| 254 |
case G_TYPE_STRING: |
346 |
case G_TYPE_STRING: |
| 255 |
value_string = gconf_client_get_string (gconf, key, NULL); |
347 |
value_string = gconf_client_get_string (gconf, key, NULL); |
| 256 |
|
348 |
|
| 257 |
break; |
349 |
break; |
| 258 |
case G_TYPE_INT: |
350 |
case G_TYPE_INT: |
| 259 |
value_string = g_strdup_printf ("%i", gconf_client_get_int (gconf, key, |
351 |
value_string = g_strdup_printf ("%i", go_conf_get_int (node, key)); |
| 260 |
NULL)); |
|
|
| 261 |
break; |
352 |
break; |
| 262 |
case G_TYPE_FLOAT: |
353 |
case G_TYPE_FLOAT: |
| 263 |
value_string = g_strdup_printf ("%f", gconf_client_get_float (gconf, key, |
354 |
value_string = g_strdup_printf ("%f", go_conf_get_double (node, key)); |
| 264 |
NULL)); |
|
|
| 265 |
break; |
355 |
break; |
| 266 |
case G_TYPE_BOOLEAN: |
356 |
case G_TYPE_BOOLEAN: |
| 267 |
value_string = g_strdup (format_boolean (gconf_client_get_bool (gconf, key, NULL))); |
357 |
value_string = g_strdup (format_boolean (go_conf_get_bool (node, key))); |
| 268 |
break; |
358 |
break; |
| 269 |
default: |
359 |
default: |
| 270 |
value_string = g_strdup ("ERROR FIXME"); |
360 |
value_string = g_strdup ("ERROR FIXME"); |
|
Lines 273-315
go_conf_get_value_as_str (char const *ke
Link Here
|
| 273 |
return value_string; |
363 |
return value_string; |
| 274 |
} |
364 |
} |
| 275 |
|
365 |
|
| 276 |
int |
366 |
gboolean |
| 277 |
go_conf_get_bool (char const *key) |
367 |
go_conf_get_bool (GOConfNode *node, gchar const *key) |
| 278 |
{ |
368 |
{ |
| 279 |
GConfClient *gconf = gnm_app_get_gconf_client (); |
369 |
gboolean val; |
| 280 |
return gconf_client_get_bool (gconf, key, NULL); |
370 |
gchar *real_key; |
|
|
371 |
|
| 372 |
real_key = go_conf_get_real_key (node, key); |
| 373 |
val = gconf_client_get_bool (gconf_client, real_key, NULL); |
| 374 |
g_free (real_key); |
| 375 |
|
| 376 |
return val; |
| 281 |
} |
377 |
} |
| 282 |
|
378 |
|
| 283 |
int |
379 |
gint |
| 284 |
go_conf_get_int (char const *key) |
380 |
go_conf_get_int (GOConfNode *node, gchar const *key) |
| 285 |
{ |
381 |
{ |
| 286 |
GConfClient *gconf = gnm_app_get_gconf_client (); |
382 |
gint val; |
| 287 |
return gconf_client_get_int (gconf, key, NULL); |
383 |
gchar *real_key; |
|
|
384 |
|
| 385 |
real_key = go_conf_get_real_key (node, key); |
| 386 |
val = gconf_client_get_int (gconf_client, real_key, NULL); |
| 387 |
g_free (real_key); |
| 388 |
|
| 389 |
return val; |
| 288 |
} |
390 |
} |
| 289 |
|
391 |
|
| 290 |
double |
392 |
gdouble |
| 291 |
go_conf_get_double (char const *key) |
393 |
go_conf_get_double (GOConfNode *node, gchar const *key) |
| 292 |
{ |
394 |
{ |
| 293 |
GConfClient *gconf = gnm_app_get_gconf_client (); |
395 |
gdouble val; |
| 294 |
return gconf_client_get_float (gconf, key, NULL); |
396 |
gchar *real_key; |
| 295 |
} |
|
|
| 296 |
|
397 |
|
|
|
398 |
real_key = go_conf_get_real_key (node, key); |
| 399 |
val = gconf_client_get_float (gconf_client, real_key, NULL); |
| 400 |
g_free (real_key); |
| 401 |
|
| 402 |
return val; |
| 403 |
} |
| 297 |
|
404 |
|
| 298 |
gboolean |
405 |
gboolean |
| 299 |
go_conf_set_value_from_str (char const *key, char const *val_str) |
406 |
go_conf_set_value_from_str (GOConfNode *node, gchar const *key, gchar const *val_str) |
| 300 |
{ |
407 |
{ |
| 301 |
GConfClient *client = gnm_app_get_gconf_client (); |
408 |
switch (go_conf_get_type (node, key)) { |
| 302 |
|
|
|
| 303 |
switch (go_conf_get_type (key)) { |
| 304 |
case G_TYPE_STRING: |
409 |
case G_TYPE_STRING: |
| 305 |
go_conf_set_string (key, val_str); |
410 |
go_conf_set_string (node, key, val_str); |
| 306 |
break; |
411 |
break; |
| 307 |
case G_TYPE_FLOAT: { |
412 |
case G_TYPE_FLOAT: { |
| 308 |
GnmDateConventions const *conv = NULL; /* workbook_date_conv (state->wb); */ |
413 |
GnmDateConventions const *conv = NULL; /* workbook_date_conv (state->wb); */ |
| 309 |
GnmValue *value = format_match_number (val_str, NULL, conv); |
414 |
GnmValue *value = format_match_number (val_str, NULL, conv); |
| 310 |
if (value != NULL) { |
415 |
if (value != NULL) { |
| 311 |
gnm_float the_float = value_get_as_float (value); |
416 |
gnm_float the_float = value_get_as_float (value); |
| 312 |
gconf_client_set_float (client, key, the_float, NULL); |
417 |
go_conf_set_double (node, key, the_float); |
| 313 |
} |
418 |
} |
| 314 |
if (value) |
419 |
if (value) |
| 315 |
value_release (value); |
420 |
value_release (value); |
|
Lines 319-326
go_conf_set_value_from_str (char const *
Link Here
|
| 319 |
GnmDateConventions const *conv = NULL; /* workbook_date_conv (state->wb); */ |
424 |
GnmDateConventions const *conv = NULL; /* workbook_date_conv (state->wb); */ |
| 320 |
GnmValue *value = format_match_number (val_str, NULL, conv); |
425 |
GnmValue *value = format_match_number (val_str, NULL, conv); |
| 321 |
if (value != NULL) { |
426 |
if (value != NULL) { |
| 322 |
int the_int = value_get_as_int (value); |
427 |
gint the_int = value_get_as_int (value); |
| 323 |
go_conf_set_int (key, the_int); |
428 |
go_conf_set_int (node, key, the_int); |
| 324 |
} |
429 |
} |
| 325 |
if (value) |
430 |
if (value) |
| 326 |
value_release (value); |
431 |
value_release (value); |
|
Lines 333-339
go_conf_set_value_from_str (char const *
Link Here
|
| 333 |
if (value != NULL) { |
438 |
if (value != NULL) { |
| 334 |
err = FALSE; |
439 |
err = FALSE; |
| 335 |
the_bool = value_get_as_bool (value, &err); |
440 |
the_bool = value_get_as_bool (value, &err); |
| 336 |
gconf_client_set_bool (client, key, the_bool, NULL); |
441 |
go_conf_set_bool (node, key, the_bool); |
| 337 |
} |
442 |
} |
| 338 |
if (value) |
443 |
if (value) |
| 339 |
value_release (value); |
444 |
value_release (value); |
|
Lines 349-491
go_conf_set_value_from_str (char const *
Link Here
|
| 349 |
void |
454 |
void |
| 350 |
go_conf_remove_monitor (guint monitor_id) |
455 |
go_conf_remove_monitor (guint monitor_id) |
| 351 |
{ |
456 |
{ |
| 352 |
gconf_client_notify_remove (gnm_app_get_gconf_client (), |
457 |
gconf_client_notify_remove (gconf_client, |
| 353 |
GPOINTER_TO_INT (monitor_id)); |
458 |
GPOINTER_TO_INT (monitor_id)); |
| 354 |
} |
459 |
} |
| 355 |
|
460 |
|
| 356 |
typedef struct { |
461 |
typedef struct { |
| 357 |
void (*monitor) (char const *key, gpointer data); |
462 |
GOConfMonitorFunc monitor; |
| 358 |
gpointer data; |
463 |
gpointer data; |
| 359 |
} GOConfClosure; |
464 |
} GOConfClosure; |
|
|
465 |
|
| 360 |
static void |
466 |
static void |
| 361 |
cb_key_changed (GConfClient *client, guint cnxn_id, |
467 |
cb_key_changed (GConfClient *client, guint cnxn_id, |
| 362 |
GConfEntry *entry, GOConfClosure *close) |
468 |
GConfEntry *entry, GOConfClosure *close) |
| 363 |
{ |
469 |
{ |
| 364 |
close->monitor (gconf_entry_get_key (entry), close->data); |
470 |
close->monitor (NULL, gconf_entry_get_key (entry), close->data); |
| 365 |
} |
471 |
} |
|
|
472 |
|
| 366 |
guint |
473 |
guint |
| 367 |
go_conf_add_monitor (char const *key, |
474 |
go_conf_add_monitor (GOConfNode *node, gchar const *key, |
| 368 |
GOConfMonitorFunc monitor, gpointer data) |
475 |
GOConfMonitorFunc monitor, gpointer data) |
| 369 |
{ |
476 |
{ |
|
|
477 |
guint ret; |
| 370 |
GOConfClosure *close = g_new0 (GOConfClosure, 1); |
478 |
GOConfClosure *close = g_new0 (GOConfClosure, 1); |
|
|
479 |
gchar *real_key; |
| 480 |
|
| 371 |
close->monitor = monitor; |
481 |
close->monitor = monitor; |
| 372 |
close->data = data; |
482 |
close->data = data; |
| 373 |
return gconf_client_notify_add (gnm_app_get_gconf_client (), key, |
483 |
real_key = go_conf_get_real_key (node, key); |
|
|
484 |
ret = gconf_client_notify_add (gconf_client, real_key, |
| 374 |
(GConfClientNotifyFunc) cb_key_changed, close, g_free, NULL); |
485 |
(GConfClientNotifyFunc) cb_key_changed, close, g_free, NULL); |
|
|
486 |
g_free (real_key); |
| 487 |
|
| 488 |
return ret; |
| 489 |
} |
| 490 |
|
| 491 |
#elif defined G_OS_WIN32 |
| 492 |
|
| 493 |
#include <windows.h> |
| 494 |
#include <format.h> |
| 495 |
#include <value.h> |
| 496 |
#include <number-match.h> |
| 497 |
|
| 498 |
#ifndef ERANGE |
| 499 |
/* mingw has not defined ERANGE (yet), MSVC has it though */ |
| 500 |
# define ERANGE 34 |
| 501 |
#endif |
| 502 |
|
| 503 |
struct _GOConfNode { |
| 504 |
HKEY hKey; |
| 505 |
gchar *path; |
| 506 |
}; |
| 507 |
|
| 508 |
static void |
| 509 |
go_conf_init () |
| 510 |
{ |
| 511 |
} |
| 512 |
|
| 513 |
static void |
| 514 |
go_conf_shutdown () |
| 515 |
{ |
| 516 |
} |
| 517 |
|
| 518 |
static gboolean |
| 519 |
go_conf_win32_get_node (GOConfNode *node, HKEY *phKey, gchar const *key, gboolean *is_new) |
| 520 |
{ |
| 521 |
gchar *path, *c; |
| 522 |
LONG ret; |
| 523 |
DWORD disposition; |
| 524 |
|
| 525 |
path = g_strconcat (node ? "" : "Software\\", key, NULL); |
| 526 |
for (c = path; *c; ++c) { |
| 527 |
if (*c == '/') |
| 528 |
*c = '\\'; |
| 529 |
} |
| 530 |
ret = RegCreateKeyEx (node ? node->hKey : HKEY_CURRENT_USER, path, |
| 531 |
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, |
| 532 |
NULL, phKey, &disposition); |
| 533 |
g_free (path); |
| 534 |
|
| 535 |
if (is_new) |
| 536 |
*is_new = disposition == REG_CREATED_NEW_KEY; |
| 537 |
|
| 538 |
return ret == ERROR_SUCCESS; |
| 539 |
} |
| 540 |
|
| 541 |
static gboolean |
| 542 |
go_conf_win32_set (GOConfNode *node, gchar const *key, |
| 543 |
gint type, guchar *data, gint size) |
| 544 |
{ |
| 545 |
gchar *last_sep, *path = NULL; |
| 546 |
HKEY hKey; |
| 547 |
gboolean ok; |
| 548 |
|
| 549 |
if ((last_sep = strrchr (key, '/')) != NULL) { |
| 550 |
path = g_strndup (key, last_sep - key); |
| 551 |
ok = go_conf_win32_get_node (node, &hKey, path, NULL); |
| 552 |
g_free (path); |
| 553 |
if (!ok) |
| 554 |
return FALSE; |
| 555 |
key = last_sep + 1; |
| 556 |
} |
| 557 |
else |
| 558 |
hKey = node->hKey; |
| 559 |
RegSetValueEx (hKey, key, 0, type, data, size); |
| 560 |
if (path) |
| 561 |
RegCloseKey (hKey); |
| 562 |
|
| 563 |
return TRUE; |
| 564 |
} |
| 565 |
|
| 566 |
static gboolean |
| 567 |
go_conf_win32_get (GOConfNode *node, gchar const *key, |
| 568 |
gulong *type, guchar **data, gulong *size, |
| 569 |
gboolean realloc, gint *ret_code) |
| 570 |
{ |
| 571 |
gchar *last_sep, *path = NULL; |
| 572 |
HKEY hKey; |
| 573 |
LONG ret; |
| 574 |
gboolean ok; |
| 575 |
|
| 576 |
if ((last_sep = strrchr (key, '/')) != NULL) { |
| 577 |
path = g_strndup (key, last_sep - key); |
| 578 |
ok = go_conf_win32_get_node (node, &hKey, path, NULL); |
| 579 |
g_free (path); |
| 580 |
if (!ok) |
| 581 |
return FALSE; |
| 582 |
key = last_sep + 1; |
| 583 |
} |
| 584 |
else |
| 585 |
hKey = node->hKey; |
| 586 |
if (!*data && realloc) { |
| 587 |
RegQueryValueEx (hKey, key, NULL, type, NULL, size); |
| 588 |
*data = g_new (guchar, *size); |
| 589 |
} |
| 590 |
while ((ret = RegQueryValueEx (hKey, key, NULL, |
| 591 |
type, *data, size)) == ERROR_MORE_DATA && |
| 592 |
realloc) |
| 593 |
*data = g_realloc (*data, *size); |
| 594 |
if (path) |
| 595 |
RegCloseKey (hKey); |
| 596 |
if (ret_code) |
| 597 |
*ret_code = ret; |
| 598 |
|
| 599 |
return ret == ERROR_SUCCESS; |
| 600 |
} |
| 601 |
|
| 602 |
static void |
| 603 |
go_conf_win32_clone (HKEY hSrcKey, gchar *key, HKEY hDstKey, gchar *buf1, gchar *buf2, gchar *buf3) |
| 604 |
{ |
| 605 |
#define WIN32_MAX_REG_KEYNAME_LEN 256 |
| 606 |
#define WIN32_MAX_REG_VALUENAME_LEN 32767 |
| 607 |
#define WIN32_INIT_VALUE_DATA_LEN 2048 |
| 608 |
gint i; |
| 609 |
gchar *subkey, *value_name, *data; |
| 610 |
DWORD name_size, type, data_size; |
| 611 |
HKEY hSrcSK, hDstSK; |
| 612 |
FILETIME ft; |
| 613 |
LONG ret; |
| 614 |
|
| 615 |
if (RegOpenKeyEx (hSrcKey, key, 0, KEY_READ, &hSrcSK) != ERROR_SUCCESS) |
| 616 |
return; |
| 617 |
|
| 618 |
if (!buf1) { |
| 619 |
subkey = g_malloc (WIN32_MAX_REG_KEYNAME_LEN); |
| 620 |
value_name = g_malloc (WIN32_MAX_REG_VALUENAME_LEN); |
| 621 |
data = g_malloc (WIN32_INIT_VALUE_DATA_LEN); |
| 622 |
} |
| 623 |
else { |
| 624 |
subkey = buf1; |
| 625 |
value_name = buf2; |
| 626 |
data = buf3; |
| 627 |
} |
| 628 |
|
| 629 |
ret = ERROR_SUCCESS; |
| 630 |
for (i = 0; ret == ERROR_SUCCESS; ++i) { |
| 631 |
name_size = WIN32_MAX_REG_KEYNAME_LEN; |
| 632 |
ret = RegEnumKeyEx (hSrcSK, i, subkey, &name_size, NULL, NULL, NULL, &ft); |
| 633 |
if (ret != ERROR_SUCCESS) |
| 634 |
continue; |
| 635 |
|
| 636 |
if (RegCreateKeyEx (hDstKey, subkey, 0, NULL, 0, KEY_WRITE, |
| 637 |
NULL, &hDstSK, NULL) == ERROR_SUCCESS) { |
| 638 |
go_conf_win32_clone (hSrcSK, subkey, hDstSK, subkey, value_name, data); |
| 639 |
RegCloseKey (hDstSK); |
| 640 |
} |
| 641 |
} |
| 642 |
|
| 643 |
ret = ERROR_SUCCESS; |
| 644 |
for (i = 0; ret == ERROR_SUCCESS; ++i) { |
| 645 |
name_size = WIN32_MAX_REG_KEYNAME_LEN; |
| 646 |
data_size = WIN32_MAX_REG_VALUENAME_LEN; |
| 647 |
while ((ret = RegEnumValue (hSrcSK, i, value_name, &name_size, |
| 648 |
NULL, &type, data, &data_size)) == |
| 649 |
ERROR_MORE_DATA) |
| 650 |
data = g_realloc (data, data_size); |
| 651 |
if (ret != ERROR_SUCCESS) |
| 652 |
continue; |
| 653 |
|
| 654 |
RegSetValueEx (hDstKey, value_name, 0, type, data, data_size); |
| 655 |
} |
| 656 |
|
| 657 |
RegCloseKey (hSrcSK); |
| 658 |
if (!buf1) { |
| 659 |
g_free (subkey); |
| 660 |
g_free (value_name); |
| 661 |
g_free (data); |
| 662 |
} |
| 663 |
} |
| 664 |
|
| 665 |
GOConfNode * |
| 666 |
go_conf_get_node (GOConfNode *parent, const gchar *key) |
| 667 |
{ |
| 668 |
HKEY hKey; |
| 669 |
GOConfNode *node = NULL; |
| 670 |
gboolean is_new; |
| 671 |
|
| 672 |
if (go_conf_win32_get_node (parent, &hKey, key, &is_new)) { |
| 673 |
if (!parent && is_new) { |
| 674 |
gchar *path; |
| 675 |
|
| 676 |
path = g_strconcat (".DEFAULT\\Software\\", key, NULL); |
| 677 |
go_conf_win32_clone (HKEY_USERS, path, hKey, NULL, NULL, NULL); |
| 678 |
g_free (path); |
| 679 |
} |
| 680 |
node = g_malloc (sizeof (GOConfNode)); |
| 681 |
node->hKey = hKey; |
| 682 |
node->path = g_strdup (key); |
| 683 |
} |
| 684 |
|
| 685 |
return node; |
| 686 |
} |
| 687 |
|
| 688 |
void |
| 689 |
go_conf_free_node (GOConfNode *node) |
| 690 |
{ |
| 691 |
if (node) { |
| 692 |
RegCloseKey (node->hKey); |
| 693 |
g_free (node->path); |
| 694 |
g_free (node); |
| 695 |
} |
| 696 |
} |
| 697 |
|
| 698 |
void |
| 699 |
go_conf_set_bool (GOConfNode *node, gchar const *key, gboolean val) |
| 700 |
{ |
| 701 |
guchar bool = val ? 1 : 0; |
| 702 |
|
| 703 |
go_conf_win32_set (node, key, REG_BINARY, (guchar *) &bool, |
| 704 |
sizeof (bool)); |
| 705 |
} |
| 706 |
|
| 707 |
void |
| 708 |
go_conf_set_int (GOConfNode *node, gchar const *key, gint val) |
| 709 |
{ |
| 710 |
go_conf_win32_set (node, key, REG_DWORD, (guchar *) &val, |
| 711 |
sizeof (DWORD)); |
| 712 |
} |
| 713 |
|
| 714 |
void |
| 715 |
go_conf_set_double (GOConfNode *node, gchar const *key, gnm_float val) |
| 716 |
{ |
| 717 |
gchar str[G_ASCII_DTOSTR_BUF_SIZE]; |
| 718 |
|
| 719 |
g_ascii_dtostr (str, sizeof (str), val); |
| 720 |
go_conf_win32_set (node, key, REG_SZ, (guchar *) str, |
| 721 |
strlen (str) + 1); |
| 722 |
} |
| 723 |
|
| 724 |
void |
| 725 |
go_conf_set_string (GOConfNode *node, gchar const *key, gchar const *str) |
| 726 |
{ |
| 727 |
go_conf_win32_set (node, key, REG_SZ, (guchar *) str, |
| 728 |
strlen (str) + 1); |
| 729 |
} |
| 730 |
|
| 731 |
void |
| 732 |
go_conf_set_str_list (GOConfNode *node, gchar const *key, GSList *list) |
| 733 |
{ |
| 734 |
GString *str_list; |
| 735 |
|
| 736 |
str_list = g_string_new (""); |
| 737 |
while (list) { |
| 738 |
g_string_append (str_list, g_strescape (list->data, NULL)); |
| 739 |
g_string_append_c (str_list, '\n'); |
| 740 |
list = list->next; |
| 741 |
} |
| 742 |
go_conf_win32_set (node, key, REG_SZ, (guchar *) str_list->str, |
| 743 |
str_list->len + 1); |
| 744 |
g_string_free (str_list, TRUE); |
| 745 |
} |
| 746 |
|
| 747 |
gboolean |
| 748 |
go_conf_get_bool (GOConfNode *node, gchar const *key) |
| 749 |
{ |
| 750 |
guchar val, *ptr = &val; |
| 751 |
gulong type, size = sizeof (val); |
| 752 |
|
| 753 |
if (go_conf_win32_get (node, key, &type, &ptr, &size, FALSE, NULL) && |
| 754 |
type == REG_BINARY) |
| 755 |
return val; |
| 756 |
|
| 757 |
return FALSE; |
| 758 |
} |
| 759 |
|
| 760 |
gint |
| 761 |
go_conf_get_int (GOConfNode *node, gchar const *key) |
| 762 |
{ |
| 763 |
gint val; |
| 764 |
gulong type, size = sizeof (DWORD); |
| 765 |
guchar *ptr = (guchar *) &val; |
| 766 |
|
| 767 |
if (go_conf_win32_get (node, key, &type, &ptr, &size, FALSE, NULL) && |
| 768 |
type == REG_DWORD) |
| 769 |
return val; |
| 770 |
|
| 771 |
return 0; |
| 772 |
} |
| 773 |
|
| 774 |
gdouble |
| 775 |
go_conf_get_double (GOConfNode *node, gchar const *key) |
| 776 |
{ |
| 777 |
gchar *ptr = go_conf_get_string (node, key); |
| 778 |
gdouble val; |
| 779 |
|
| 780 |
if (ptr) { |
| 781 |
val = g_ascii_strtod (ptr, NULL); |
| 782 |
g_free (ptr); |
| 783 |
if (errno != ERANGE) |
| 784 |
return val; |
| 785 |
} |
| 786 |
|
| 787 |
return 0.0; |
| 788 |
} |
| 789 |
|
| 790 |
gchar * |
| 791 |
go_conf_get_string (GOConfNode *node, gchar const *key) |
| 792 |
{ |
| 793 |
DWORD type, size = 0; |
| 794 |
guchar *ptr = NULL; |
| 795 |
|
| 796 |
if (go_conf_win32_get (node, key, &type, &ptr, &size, TRUE, NULL) && |
| 797 |
type == REG_SZ) |
| 798 |
return ptr; |
| 799 |
|
| 800 |
g_free (ptr); |
| 801 |
|
| 802 |
return NULL; |
| 803 |
} |
| 804 |
|
| 805 |
GSList * |
| 806 |
go_conf_get_str_list (GOConfNode *node, gchar const *key) |
| 807 |
{ |
| 808 |
GSList *list = NULL; |
| 809 |
gchar *ptr; |
| 810 |
gchar **str_list; |
| 811 |
gint i; |
| 812 |
|
| 813 |
if ((ptr = go_conf_get_string (node, key)) != NULL) { |
| 814 |
str_list = g_strsplit ((const gchar *) ptr, "\n", 0); |
| 815 |
for (i = 0; str_list[i]; ++i) |
| 816 |
list = g_slist_prepend (list, g_strcompress (str_list[i])); |
| 817 |
g_slist_reverse (list); |
| 818 |
g_strfreev (str_list); |
| 819 |
g_free (ptr); |
| 820 |
} |
| 821 |
|
| 822 |
return list; |
| 823 |
} |
| 824 |
|
| 825 |
static guchar * |
| 826 |
go_conf_get (GOConfNode *node, gchar const *key, gulong expected) |
| 827 |
{ |
| 828 |
gulong type, size = 0; |
| 829 |
guchar *ptr = NULL; |
| 830 |
gint ret_code; |
| 831 |
|
| 832 |
if (!go_conf_win32_get (node, key, &type, &ptr, &size, TRUE, &ret_code)) { |
| 833 |
LPTSTR msg_buf; |
| 834 |
|
| 835 |
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | |
| 836 |
FORMAT_MESSAGE_FROM_SYSTEM | |
| 837 |
FORMAT_MESSAGE_IGNORE_INSERTS, |
| 838 |
NULL, |
| 839 |
ret_code, |
| 840 |
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), |
| 841 |
(LPTSTR) &msg_buf, |
| 842 |
0, |
| 843 |
NULL); |
| 844 |
g_warning ("Unable to load key '%s' : because %s", |
| 845 |
key, msg_buf); |
| 846 |
LocalFree (msg_buf); |
| 847 |
g_free (ptr); |
| 848 |
return NULL; |
| 375 |
} |
849 |
} |
|
|
850 |
|
| 851 |
if (type != expected) { |
| 852 |
g_warning ("Expected `%lu' got `%lu' for key %s of node %s", |
| 853 |
expected, type, key, node->path); |
| 854 |
g_free (ptr); |
| 855 |
return NULL; |
| 856 |
} |
| 857 |
|
| 858 |
return ptr; |
| 859 |
} |
| 860 |
|
| 861 |
gboolean |
| 862 |
go_conf_load_bool (GOConfNode *node, gchar const *key, |
| 863 |
gboolean default_val) |
| 864 |
{ |
| 865 |
guchar *val = go_conf_get (node, key, REG_BINARY); |
| 866 |
gboolean res; |
| 867 |
|
| 868 |
if (val) { |
| 869 |
res = (gboolean) *val; |
| 870 |
g_free (val); |
| 871 |
} else { |
| 872 |
g_warning ("Using default value '%s'", default_val ? "true" : "false"); |
| 873 |
return default_val; |
| 874 |
} |
| 875 |
|
| 876 |
return res; |
| 877 |
} |
| 878 |
|
| 879 |
gint |
| 880 |
go_conf_load_int (GOConfNode *node, gchar const *key, |
| 881 |
gint minima, gint maxima, gint default_val) |
| 882 |
{ |
| 883 |
guchar *val = go_conf_get (node, key, REG_DWORD); |
| 884 |
gint res; |
| 885 |
|
| 886 |
if (val) { |
| 887 |
res = *(gint *) val; |
| 888 |
g_free (val); |
| 889 |
if (res < minima || maxima < res) { |
| 890 |
g_warning ("Invalid value '%d' for %s. If should be >= %d and <= %d", |
| 891 |
res, key, minima, maxima); |
| 892 |
val = NULL; |
| 893 |
} |
| 894 |
} |
| 895 |
if (!val) { |
| 896 |
g_warning ("Using default value '%d'", default_val); |
| 897 |
return default_val; |
| 898 |
} |
| 899 |
|
| 900 |
return res; |
| 901 |
} |
| 902 |
|
| 903 |
gdouble |
| 904 |
go_conf_load_double (GOConfNode *node, gchar const *key, |
| 905 |
gdouble minima, gdouble maxima, gdouble default_val) |
| 906 |
{ |
| 907 |
gdouble res = -1; |
| 908 |
gchar *val = (gchar *) go_conf_get (node, key, REG_SZ); |
| 909 |
|
| 910 |
if (val) { |
| 911 |
res = g_ascii_strtod (val, NULL); |
| 912 |
g_free (val); |
| 913 |
if (errno == ERANGE || res < minima || maxima < res) { |
| 914 |
g_warning ("Invalid value '%g' for %s. If should be >= %g and <= %g", |
| 915 |
res, key, minima, maxima); |
| 916 |
val = NULL; |
| 917 |
} |
| 918 |
} |
| 919 |
if (!val) { |
| 920 |
g_warning ("Using default value '%g'", default_val); |
| 921 |
return default_val; |
| 922 |
} |
| 923 |
|
| 924 |
return res; |
| 925 |
} |
| 926 |
|
| 927 |
gchar * |
| 928 |
go_conf_load_string (GOConfNode *node, gchar const *key) |
| 929 |
{ |
| 930 |
return go_conf_get (node, key, REG_SZ); |
| 931 |
} |
| 932 |
|
| 933 |
GSList * |
| 934 |
go_conf_load_str_list (GOConfNode *node, gchar const *key) |
| 935 |
{ |
| 936 |
return go_conf_get_str_list (node, key); |
| 937 |
} |
| 938 |
|
| 939 |
gchar * |
| 940 |
go_conf_get_short_desc (GOConfNode *node, gchar const *key) |
| 941 |
{ |
| 942 |
return NULL; |
| 943 |
} |
| 944 |
|
| 945 |
gchar * |
| 946 |
go_conf_get_long_desc (GOConfNode *node, gchar const *key) |
| 947 |
{ |
| 948 |
return NULL; |
| 949 |
} |
| 950 |
|
| 951 |
GType |
| 952 |
go_conf_get_type (GOConfNode *node, gchar const *key) |
| 953 |
{ |
| 954 |
gulong type, size; |
| 955 |
guchar *ptr = NULL; |
| 956 |
GType t = G_TYPE_NONE; |
| 957 |
|
| 958 |
if (go_conf_win32_get (node, key, &type, &ptr, &size, FALSE, NULL)) { |
| 959 |
switch (type) { |
| 960 |
case REG_BINARY: |
| 961 |
t = G_TYPE_BOOLEAN; break; |
| 962 |
case REG_DWORD: |
| 963 |
t = G_TYPE_INT; break; |
| 964 |
case REG_SZ: |
| 965 |
t = G_TYPE_STRING; break; |
| 966 |
} |
| 967 |
} |
| 968 |
|
| 969 |
return t; |
| 970 |
} |
| 971 |
|
| 972 |
gchar * |
| 973 |
go_conf_get_value_as_str (GOConfNode *node, gchar const *key) |
| 974 |
{ |
| 975 |
gchar *value_string; |
| 976 |
|
| 977 |
switch (go_conf_get_type (node, key)) { |
| 978 |
case G_TYPE_STRING: |
| 979 |
value_string = go_conf_get_string (node, key); |
| 980 |
break; |
| 981 |
case G_TYPE_INT: |
| 982 |
value_string = g_strdup_printf ("%i", go_conf_get_int (node, key)); |
| 983 |
break; |
| 984 |
case G_TYPE_FLOAT: |
| 985 |
value_string = go_conf_get_string (node, key); |
| 986 |
break; |
| 987 |
case G_TYPE_BOOLEAN: |
| 988 |
value_string = g_strdup (format_boolean (go_conf_get_bool (node, key))); |
| 989 |
break; |
| 990 |
default: |
| 991 |
value_string = g_strdup ("ERROR FIXME"); |
| 992 |
} |
| 993 |
|
| 994 |
return value_string; |
| 995 |
} |
| 996 |
|
| 997 |
gboolean |
| 998 |
go_conf_set_value_from_str (GOConfNode *node, gchar const *key, |
| 999 |
gchar const *val_str) |
| 1000 |
{ |
| 1001 |
switch (go_conf_get_type (node, key)) { |
| 1002 |
case G_TYPE_STRING: |
| 1003 |
go_conf_set_string (node, key, val_str); |
| 1004 |
break; |
| 1005 |
case G_TYPE_INT: { |
| 1006 |
GnmDateConventions const *conv = NULL; /* workbook_date_conv (state->wb); */ |
| 1007 |
GnmValue *value = format_match_number (val_str, NULL, conv); |
| 1008 |
if (value != NULL) { |
| 1009 |
gint the_int = value_get_as_int (value); |
| 1010 |
go_conf_set_int (node, key, the_int); |
| 1011 |
} |
| 1012 |
if (value) |
| 1013 |
value_release (value); |
| 1014 |
break; |
| 1015 |
} |
| 1016 |
case G_TYPE_BOOLEAN: { |
| 1017 |
GnmDateConventions const *conv = NULL; /* workbook_date_conv (state->wb); */ |
| 1018 |
GnmValue *value = format_match_number (val_str, NULL, conv); |
| 1019 |
gboolean err, the_bool; |
| 1020 |
if (value != NULL) { |
| 1021 |
err = FALSE; |
| 1022 |
the_bool = value_get_as_bool (value, &err); |
| 1023 |
go_conf_set_bool (node, key, the_bool); |
| 1024 |
} |
| 1025 |
if (value) |
| 1026 |
value_release (value); |
| 1027 |
break; |
| 1028 |
} |
| 1029 |
default: |
| 1030 |
g_warning ("Unsupported gconf type in preference dialog"); |
| 1031 |
} |
| 1032 |
|
| 1033 |
return TRUE; |
| 1034 |
} |
| 1035 |
|
| 1036 |
void |
| 1037 |
go_conf_sync (GOConfNode *node) |
| 1038 |
{ |
| 1039 |
if (node) |
| 1040 |
RegFlushKey (node->hKey); |
| 1041 |
} |
| 1042 |
|
| 1043 |
void |
| 1044 |
go_conf_remove_monitor (guint monitor_id) |
| 1045 |
{ |
| 1046 |
} |
| 1047 |
|
| 1048 |
guint |
| 1049 |
go_conf_add_monitor (GOConfNode *node, gchar const *key, |
| 1050 |
GOConfMonitorFunc monitor, gpointer data) |
| 1051 |
{ |
| 1052 |
return 1; |
| 1053 |
} |
| 1054 |
|
| 376 |
#else |
1055 |
#else |
|
|
1056 |
|
| 377 |
void |
1057 |
void |
| 378 |
go_conf_set_bool (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED gboolean val) |
1058 |
go_conf_set_bool (GOConfNode *node, gchar const *key, gboolean val) |
| 379 |
{ |
1059 |
{ |
| 380 |
} |
1060 |
} |
|
|
1061 |
|
| 381 |
void |
1062 |
void |
| 382 |
go_conf_set_int (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED gint val) |
1063 |
go_conf_set_int (GOConfNode *node, gchar const *key, gint val) |
| 383 |
{ |
1064 |
{ |
| 384 |
} |
1065 |
} |
|
|
1066 |
|
| 385 |
void |
1067 |
void |
| 386 |
go_conf_set_double (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED gnm_float val) |
1068 |
go_conf_set_double (GOConfNode *node, gchar const *key, gnm_float val) |
| 387 |
{ |
1069 |
{ |
| 388 |
} |
1070 |
} |
|
|
1071 |
|
| 389 |
void |
1072 |
void |
| 390 |
go_conf_set_string (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED char const *str) |
1073 |
go_conf_set_string (GOConfNode *node, gchar const *key, char const *str) |
| 391 |
{ |
1074 |
{ |
| 392 |
} |
1075 |
} |
|
|
1076 |
|
| 393 |
void |
1077 |
void |
| 394 |
go_conf_set_str_list (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED GSList *list) |
1078 |
go_conf_set_str_list (GOConfNode *node, gchar const *key, GSList *list) |
| 395 |
{ |
1079 |
{ |
| 396 |
} |
1080 |
} |
|
|
1081 |
|
| 397 |
gboolean |
1082 |
gboolean |
| 398 |
go_conf_get_bool (char const *key) |
1083 |
go_conf_get_bool (GOConfNode *node, gchar const *key) |
| 399 |
{ |
1084 |
{ |
| 400 |
return FALSE; |
1085 |
return FALSE; |
| 401 |
} |
1086 |
} |
| 402 |
|
1087 |
|
| 403 |
int |
1088 |
gint |
| 404 |
go_conf_get_int (char const *key) |
1089 |
go_conf_get_int (GOConfNode *node, gchar const *key) |
| 405 |
{ |
1090 |
{ |
| 406 |
return 0; |
1091 |
return 0; |
| 407 |
} |
1092 |
} |
| 408 |
|
1093 |
|
| 409 |
double |
1094 |
gdouble |
| 410 |
go_conf_get_double (char const *key) |
1095 |
go_conf_get_double (GOConfNode *node, gchar const *key) |
| 411 |
{ |
1096 |
{ |
| 412 |
return 0.; |
1097 |
return 0.; |
| 413 |
} |
1098 |
} |
| 414 |
|
1099 |
|
| 415 |
char * |
1100 |
gchar * |
| 416 |
go_conf_get_string (char const *key) |
1101 |
go_conf_get_string (GOConfNode *node, gchar const *key) |
| 417 |
{ |
1102 |
{ |
| 418 |
return g_strdup (""); |
1103 |
return g_strdup (""); |
| 419 |
} |
1104 |
} |
| 420 |
|
1105 |
|
| 421 |
GSList * |
1106 |
GSList * |
| 422 |
go_conf_get_str_list (char const *key) |
1107 |
go_conf_get_str_list (GOConfNode *node, gchar const *key) |
| 423 |
{ |
1108 |
{ |
| 424 |
return NULL; |
1109 |
return NULL; |
| 425 |
} |
1110 |
} |
| 426 |
|
1111 |
|
| 427 |
gboolean |
1112 |
gboolean |
| 428 |
go_conf_load_bool (G_GNUC_UNUSED char const *key, |
1113 |
go_conf_load_bool (GOConfNode *node, gchar const *key, |
| 429 |
gboolean default_val) |
1114 |
gboolean default_val) |
| 430 |
{ |
1115 |
{ |
| 431 |
return default_val; |
1116 |
return default_val; |
| 432 |
} |
1117 |
} |
| 433 |
int |
1118 |
int |
| 434 |
go_conf_load_int (G_GNUC_UNUSED char const *key, |
1119 |
go_conf_load_int (GOConfNode *node, gchar const *key, |
| 435 |
G_GNUC_UNUSED int minima, G_GNUC_UNUSED int maxima, |
1120 |
gint minima, gint maxima, |
| 436 |
int default_val) |
1121 |
gint default_val) |
| 437 |
{ |
1122 |
{ |
| 438 |
return default_val; |
1123 |
return default_val; |
| 439 |
} |
1124 |
} |
| 440 |
|
1125 |
|
| 441 |
double |
1126 |
double |
| 442 |
go_conf_load_double (G_GNUC_UNUSED char const *key, |
1127 |
go_conf_load_double (GOConfNode *node, gchar const *key, |
| 443 |
G_GNUC_UNUSED double minima, G_GNUC_UNUSED double maxima, |
1128 |
gdouble minima, gdouble maxima, |
| 444 |
double default_val) |
1129 |
gdouble default_val) |
| 445 |
{ |
1130 |
{ |
| 446 |
return default_val; |
1131 |
gchar *real_key; |
|
|
1132 |
gchar *ptr; |
| 1133 |
double val; |
| 1134 |
GError *err = NULL; |
| 1135 |
|
| 1136 |
real_key = go_conf_get_real_key (node, key); |
| 1137 |
ptr = g_key_file_get_value (key_file, DOUBLE_GROUP, real_key, &err); |
| 1138 |
|
| 1139 |
if (err) { |
| 1140 |
val = default_val; |
| 1141 |
g_error_free (err); |
| 1142 |
} else { |
| 1143 |
val = g_ascii_strtod (ptr, NULL); |
| 1144 |
if (val < minima || val > maxima) { |
| 1145 |
val = default_val; |
| 447 |
} |
1146 |
} |
|
|
1147 |
} |
| 1148 |
|
| 1149 |
g_free(ptr); |
| 1150 |
g_free (real_key); |
| 1151 |
return val; |
| 1152 |
} |
| 1153 |
|
| 448 |
char * |
1154 |
char * |
| 449 |
go_conf_load_string (G_GNUC_UNUSED char const *key) |
1155 |
go_conf_load_string (GOConfNode *node, gchar const *key) |
| 450 |
{ |
1156 |
{ |
| 451 |
return NULL; |
1157 |
gchar *real_key; |
|
|
1158 |
char *val = NULL; |
| 1159 |
GError *err = NULL; |
| 1160 |
|
| 1161 |
real_key = go_conf_get_real_key (node, key); |
| 1162 |
val = g_key_file_get_string (key_file, STRING_GROUP, real_key, &err); |
| 1163 |
|
| 1164 |
if (err) { |
| 1165 |
#if 0 |
| 1166 |
g_warning (err->message); |
| 1167 |
#endif |
| 1168 |
g_error_free (err); |
| 452 |
} |
1169 |
} |
|
|
1170 |
|
| 1171 |
g_free (real_key); |
| 1172 |
return val; |
| 1173 |
} |
| 1174 |
|
| 453 |
GSList * |
1175 |
GSList * |
| 454 |
go_conf_load_str_list (G_GNUC_UNUSED char const *key) |
1176 |
go_conf_load_str_list (GOConfNode *node, gchar const *key) |
| 455 |
{ |
1177 |
{ |
| 456 |
return NULL; |
1178 |
return go_conf_get_str_list (node, key); |
| 457 |
} |
1179 |
} |
|
|
1180 |
|
| 458 |
char * |
1181 |
char * |
| 459 |
go_conf_get_short_desc (char const *key) |
1182 |
go_conf_get_short_desc (GOConfNode *node, gchar const *key) |
| 460 |
{ |
1183 |
{ |
| 461 |
return NULL; |
1184 |
return NULL; |
| 462 |
} |
1185 |
} |
| 463 |
char * |
1186 |
|
| 464 |
go_conf_get_long_desc (char const *key) |
1187 |
gchar * |
|
|
1188 |
go_conf_get_long_desc (GOConfNode *node, gchar const *key) |
| 465 |
{ |
1189 |
{ |
| 466 |
return NULL; |
1190 |
return NULL; |
| 467 |
} |
1191 |
} |
| 468 |
|
1192 |
|
| 469 |
GType |
1193 |
GType |
| 470 |
go_conf_get_type (char const *key) |
1194 |
go_conf_get_type (GOConfNode *node, gchar const *key) |
| 471 |
{ |
1195 |
{ |
| 472 |
return G_TYPE_NONE; |
1196 |
gchar **groups; |
|
|
1197 |
gchar *real_key; |
| 1198 |
GType type = G_TYPE_NONE; |
| 1199 |
int i, ng; |
| 1200 |
|
| 1201 |
real_key = go_conf_get_real_key (node, key); |
| 1202 |
groups = g_key_file_get_groups (key_file, &ng); |
| 1203 |
|
| 1204 |
if (groups != NULL) { |
| 1205 |
for (i = 0; i < ng; i++) { |
| 1206 |
if (g_key_file_has_key (key_file, groups[i], real_key, NULL)) { |
| 1207 |
if (!g_ascii_strcasecmp (groups[i], BOOL_GROUP)) { |
| 1208 |
type = G_TYPE_BOOLEAN; |
| 1209 |
} else if (!g_ascii_strcasecmp (groups[i], INT_GROUP)) { |
| 1210 |
type = G_TYPE_INT; |
| 1211 |
} else if (!g_ascii_strcasecmp (groups[i], DOUBLE_GROUP)) { |
| 1212 |
type = G_TYPE_DOUBLE; |
| 1213 |
} else if (!g_ascii_strcasecmp (groups[i], STRING_GROUP)) { |
| 1214 |
type = G_TYPE_STRING; |
| 1215 |
} else if (!g_ascii_strcasecmp (groups[i], STRLIST_GROUP)) { |
| 1216 |
type = G_TYPE_STRING; |
| 1217 |
} |
| 1218 |
break; |
| 1219 |
} |
| 1220 |
} |
| 1221 |
g_strfreev (groups); |
| 473 |
} |
1222 |
} |
| 474 |
|
1223 |
|
| 475 |
char * |
1224 |
g_free (real_key); |
| 476 |
go_conf_get_value_as_str (char const *key) |
1225 |
|
|
|
1226 |
return type; |
| 1227 |
} |
| 1228 |
|
| 1229 |
gchar * |
| 1230 |
go_conf_get_value_as_str (GOConfNode *node, gchar const *key) |
| 477 |
{ |
1231 |
{ |
| 478 |
return g_strdup (""); |
1232 |
gchar *val = NULL; |
|
|
1233 |
gchar *real_key = go_conf_get_real_key (node, key); |
| 1234 |
val = g_key_file_get_string (key_file, STRING_GROUP, real_key, NULL); |
| 1235 |
g_free (real_key); |
| 1236 |
return val; |
| 479 |
} |
1237 |
} |
| 480 |
|
1238 |
|
| 481 |
gboolean |
1239 |
gboolean |
| 482 |
go_conf_set_value_from_str (char const *key, char const *val_str) |
1240 |
go_conf_set_value_from_str (GOConfNode *node, gchar const *key, gchar const *val_str) |
| 483 |
{ |
1241 |
{ |
|
|
1242 |
gchar *real_key = go_conf_get_real_key (node, key); |
| 1243 |
g_key_file_set_value (key_file, STRING_GROUP, real_key, val_str); |
| 1244 |
g_free (real_key); |
| 484 |
return TRUE; |
1245 |
return TRUE; |
| 485 |
} |
1246 |
} |
| 486 |
|
1247 |
|
| 487 |
void |
1248 |
void |
| 488 |
go_conf_sync (void) |
1249 |
go_conf_sync (GOConfNode *node) |
| 489 |
{ |
1250 |
{ |
| 490 |
} |
1251 |
} |
| 491 |
|
1252 |
|
|
Lines 495-501
go_conf_remove_monitor (guint monitor_id
Link Here
|
| 495 |
} |
1256 |
} |
| 496 |
|
1257 |
|
| 497 |
guint |
1258 |
guint |
| 498 |
go_conf_add_monitor (char const *key, |
1259 |
go_conf_add_monitor (GOConfNode *node, gchar const *key, |
| 499 |
GOConfMonitorFunc monitor, gpointer data) |
1260 |
GOConfMonitorFunc monitor, gpointer data) |
| 500 |
{ |
1261 |
{ |
| 501 |
return 1; |
1262 |
return 1; |
|
Lines 506-596
go_conf_add_monitor (char const *key,
Link Here
|
| 506 |
static void |
1267 |
static void |
| 507 |
gnm_conf_init_printer_decoration_font (void) |
1268 |
gnm_conf_init_printer_decoration_font (void) |
| 508 |
{ |
1269 |
{ |
|
|
1270 |
GOConfNode *node; |
| 509 |
gchar *name; |
1271 |
gchar *name; |
| 510 |
if (prefs.printer_decoration_font == NULL) |
1272 |
if (prefs.printer_decoration_font == NULL) |
| 511 |
prefs.printer_decoration_font = mstyle_new (); |
1273 |
prefs.printer_decoration_font = mstyle_new (); |
| 512 |
|
1274 |
|
| 513 |
name = go_conf_load_string (PRINTSETUP_GCONF_HF_FONT_NAME); |
1275 |
node = go_conf_get_node (root, PRINTSETUP_GCONF_DIR); |
|
|
1276 |
name = go_conf_load_string (node, PRINTSETUP_GCONF_HF_FONT_NAME); |
| 514 |
if (name) { |
1277 |
if (name) { |
| 515 |
mstyle_set_font_name (prefs.printer_decoration_font, name); |
1278 |
mstyle_set_font_name (prefs.printer_decoration_font, name); |
| 516 |
g_free (name); |
1279 |
g_free (name); |
| 517 |
} else |
1280 |
} else |
| 518 |
mstyle_set_font_name (prefs.printer_decoration_font, DEFAULT_FONT); |
1281 |
mstyle_set_font_name (prefs.printer_decoration_font, DEFAULT_FONT); |
| 519 |
mstyle_set_font_size (prefs.printer_decoration_font, |
1282 |
mstyle_set_font_size (prefs.printer_decoration_font, |
| 520 |
go_conf_load_double (PRINTSETUP_GCONF_HF_FONT_SIZE, 1., 100., DEFAULT_SIZE)); |
1283 |
go_conf_load_double (node, PRINTSETUP_GCONF_HF_FONT_SIZE, 1., 100., DEFAULT_SIZE)); |
| 521 |
mstyle_set_font_bold (prefs.printer_decoration_font, |
1284 |
mstyle_set_font_bold (prefs.printer_decoration_font, |
| 522 |
go_conf_load_bool (PRINTSETUP_GCONF_HF_FONT_BOLD, FALSE)); |
1285 |
go_conf_load_bool (node, PRINTSETUP_GCONF_HF_FONT_BOLD, FALSE)); |
| 523 |
mstyle_set_font_italic (prefs.printer_decoration_font, |
1286 |
mstyle_set_font_italic (prefs.printer_decoration_font, |
| 524 |
go_conf_load_bool (PRINTSETUP_GCONF_HF_FONT_ITALIC, FALSE)); |
1287 |
go_conf_load_bool (node, PRINTSETUP_GCONF_HF_FONT_ITALIC, FALSE)); |
|
|
1288 |
go_conf_free_node (node); |
| 525 |
} |
1289 |
} |
| 526 |
|
1290 |
|
| 527 |
static void |
1291 |
static void |
| 528 |
gnm_conf_init_essential (void) |
1292 |
gnm_conf_init_essential (void) |
| 529 |
{ |
1293 |
{ |
| 530 |
prefs.default_font.name = go_conf_load_string (CONF_DEFAULT_FONT_NAME); |
1294 |
GOConfNode *node; |
|
|
1295 |
|
| 1296 |
node = go_conf_get_node (root, CONF_DEFAULT_FONT_DIR); |
| 1297 |
prefs.default_font.name = go_conf_load_string (node, CONF_DEFAULT_FONT_NAME); |
| 531 |
if (prefs.default_font.name == NULL) |
1298 |
if (prefs.default_font.name == NULL) |
| 532 |
prefs.default_font.name = g_strdup (DEFAULT_FONT); |
1299 |
prefs.default_font.name = g_strdup (DEFAULT_FONT); |
| 533 |
prefs.default_font.size = go_conf_load_double ( |
1300 |
prefs.default_font.size = go_conf_load_double ( |
| 534 |
CONF_DEFAULT_FONT_SIZE, 1., 100., DEFAULT_SIZE); |
1301 |
node, CONF_DEFAULT_FONT_SIZE, 1., 100., DEFAULT_SIZE); |
| 535 |
prefs.default_font.is_bold = go_conf_load_bool ( |
1302 |
prefs.default_font.is_bold = go_conf_load_bool ( |
| 536 |
CONF_DEFAULT_FONT_BOLD, FALSE); |
1303 |
node, CONF_DEFAULT_FONT_BOLD, FALSE); |
| 537 |
prefs.default_font.is_italic = go_conf_load_bool ( |
1304 |
prefs.default_font.is_italic = go_conf_load_bool ( |
| 538 |
CONF_DEFAULT_FONT_ITALIC, FALSE); |
1305 |
node, CONF_DEFAULT_FONT_ITALIC, FALSE); |
|
|
1306 |
go_conf_free_node (node); |
| 539 |
|
1307 |
|
|
|
1308 |
node = go_conf_get_node (root, GNM_CONF_FILE_DIR); |
| 540 |
prefs.file_history_max = go_conf_load_int ( |
1309 |
prefs.file_history_max = go_conf_load_int ( |
| 541 |
GNM_CONF_FILE_HISTORY_N, 0, 20, 4); |
1310 |
node, GNM_CONF_FILE_HISTORY_N, 0, 20, 4); |
| 542 |
prefs.file_history_files = go_conf_load_str_list (GNM_CONF_FILE_HISTORY_FILES); |
1311 |
prefs.file_history_files = go_conf_load_str_list (node, GNM_CONF_FILE_HISTORY_FILES); |
| 543 |
prefs.plugin_file_states = go_conf_load_str_list (PLUGIN_GCONF_FILE_STATES); |
1312 |
go_conf_free_node (node); |
| 544 |
prefs.plugin_extra_dirs = go_conf_load_str_list (PLUGIN_GCONF_EXTRA_DIRS); |
1313 |
|
| 545 |
prefs.active_plugins = go_conf_load_str_list (PLUGIN_GCONF_ACTIVE); |
1314 |
node = go_conf_get_node (root, PLUGIN_GCONF_DIR); |
|
|
1315 |
prefs.plugin_file_states = go_conf_load_str_list (node, PLUGIN_GCONF_FILE_STATES); |
| 1316 |
prefs.plugin_extra_dirs = go_conf_load_str_list (node, PLUGIN_GCONF_EXTRA_DIRS); |
| 1317 |
prefs.active_plugins = go_conf_load_str_list (node, PLUGIN_GCONF_ACTIVE); |
| 546 |
prefs.activate_new_plugins = go_conf_load_bool ( |
1318 |
prefs.activate_new_plugins = go_conf_load_bool ( |
| 547 |
PLUGIN_GCONF_ACTIVATE_NEW, TRUE); |
1319 |
node, PLUGIN_GCONF_ACTIVATE_NEW, TRUE); |
|
|
1320 |
go_conf_free_node (node); |
| 548 |
|
1321 |
|
|
|
1322 |
node = go_conf_get_node (root, GNM_CONF_GUI_DIR); |
| 549 |
prefs.horizontal_dpi = go_conf_load_double ( |
1323 |
prefs.horizontal_dpi = go_conf_load_double ( |
| 550 |
GNM_CONF_GUI_RES_H, 10., 1000., 96.); |
1324 |
node, GNM_CONF_GUI_RES_H, 10., 1000., 96.); |
| 551 |
prefs.vertical_dpi = go_conf_load_double ( |
1325 |
prefs.vertical_dpi = go_conf_load_double ( |
| 552 |
GNM_CONF_GUI_RES_V, 10., 1000., 96.); |
1326 |
node, GNM_CONF_GUI_RES_V, 10., 1000., 96.); |
| 553 |
prefs.initial_sheet_number = go_conf_load_int ( |
1327 |
prefs.initial_sheet_number = go_conf_load_int ( |
| 554 |
GNM_CONF_WORKBOOK_NSHEETS, 1, 64, 3); |
1328 |
root, GNM_CONF_WORKBOOK_NSHEETS, 1, 64, 3); |
| 555 |
prefs.horizontal_window_fraction = go_conf_load_double ( |
1329 |
prefs.horizontal_window_fraction = go_conf_load_double ( |
| 556 |
GNM_CONF_GUI_WINDOW_X, .1, 1., .6); |
1330 |
node, GNM_CONF_GUI_WINDOW_X, .1, 1., .6); |
| 557 |
prefs.vertical_window_fraction = go_conf_load_double ( |
1331 |
prefs.vertical_window_fraction = go_conf_load_double ( |
| 558 |
GNM_CONF_GUI_WINDOW_Y, .1, 1., .6); |
1332 |
node, GNM_CONF_GUI_WINDOW_Y, .1, 1., .6); |
| 559 |
prefs.zoom = go_conf_load_double ( |
1333 |
prefs.zoom = go_conf_load_double ( |
| 560 |
GNM_CONF_GUI_ZOOM, .1, 5., 1.); |
1334 |
node, GNM_CONF_GUI_ZOOM, .1, 5., 1.); |
|
|
1335 |
prefs.auto_complete = go_conf_load_bool ( |
| 1336 |
node, GNM_CONF_GUI_ED_AUTOCOMPLETE, TRUE); |
| 1337 |
prefs.live_scrolling = go_conf_load_bool ( |
| 1338 |
node, GNM_CONF_GUI_ED_LIVESCROLLING, TRUE); |
| 1339 |
go_conf_free_node (node); |
| 561 |
|
1340 |
|
| 562 |
/* Unfortunately we need the printing stuff in essentials since the */ |
1341 |
/* Unfortunately we need the printing stuff in essentials since the */ |
| 563 |
/* first pi is created for the new sheet before the idle loop has a */ |
1342 |
/* first pi is created for the new sheet before the idle loop has a */ |
| 564 |
/* chance to run */ |
1343 |
/* chance to run */ |
| 565 |
prefs.printer_config = go_conf_load_string (PRINTSETUP_GCONF_PRINTER_CONFIG); |
1344 |
node = go_conf_get_node (root, PRINTSETUP_GCONF_DIR); |
|
|
1345 |
prefs.printer_config = go_conf_load_string (node, PRINTSETUP_GCONF_PRINTER_CONFIG); |
| 566 |
prefs.print_center_horizontally = go_conf_load_bool |
1346 |
prefs.print_center_horizontally = go_conf_load_bool |
| 567 |
(PRINTSETUP_GCONF_CENTER_HORIZONTALLY, FALSE); |
1347 |
(node, PRINTSETUP_GCONF_CENTER_HORIZONTALLY, FALSE); |
| 568 |
prefs.print_center_vertically = go_conf_load_bool |
1348 |
prefs.print_center_vertically = go_conf_load_bool |
| 569 |
(PRINTSETUP_GCONF_CENTER_VERTICALLY, FALSE); |
1349 |
(node, PRINTSETUP_GCONF_CENTER_VERTICALLY, FALSE); |
| 570 |
prefs.print_grid_lines = go_conf_load_bool |
1350 |
prefs.print_grid_lines = go_conf_load_bool |
| 571 |
(PRINTSETUP_GCONF_PRINT_GRID_LINES, FALSE); |
1351 |
(node, PRINTSETUP_GCONF_PRINT_GRID_LINES, FALSE); |
| 572 |
prefs.print_even_if_only_styles = go_conf_load_bool |
1352 |
prefs.print_even_if_only_styles = go_conf_load_bool |
| 573 |
(PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES, FALSE); |
1353 |
(node, PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES, FALSE); |
| 574 |
prefs.print_black_and_white = go_conf_load_bool |
1354 |
prefs.print_black_and_white = go_conf_load_bool |
| 575 |
(PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE, FALSE); |
1355 |
(node, PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE, FALSE); |
| 576 |
prefs.print_titles = go_conf_load_bool |
1356 |
prefs.print_titles = go_conf_load_bool |
| 577 |
(PRINTSETUP_GCONF_PRINT_TITLES, FALSE); |
1357 |
(node, PRINTSETUP_GCONF_PRINT_TITLES, FALSE); |
| 578 |
prefs.print_order_right_then_down = go_conf_load_bool |
1358 |
prefs.print_order_right_then_down = go_conf_load_bool |
| 579 |
(PRINTSETUP_GCONF_RIGHT_THEN_DOWN, FALSE); |
1359 |
(node, PRINTSETUP_GCONF_RIGHT_THEN_DOWN, FALSE); |
| 580 |
prefs.print_scale_percentage = go_conf_load_bool |
1360 |
prefs.print_scale_percentage = go_conf_load_bool |
| 581 |
(PRINTSETUP_GCONF_SCALE_PERCENTAGE, TRUE); |
1361 |
(node, PRINTSETUP_GCONF_SCALE_PERCENTAGE, TRUE); |
| 582 |
prefs.print_scale_percentage_value = go_conf_load_double |
1362 |
prefs.print_scale_percentage_value = go_conf_load_double |
| 583 |
(PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE, 1, 500, 100); |
1363 |
(node, PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE, 1, 500, 100); |
| 584 |
prefs.print_scale_width = go_conf_load_int |
1364 |
prefs.print_scale_width = go_conf_load_int |
| 585 |
(PRINTSETUP_GCONF_SCALE_WIDTH, 0, 100, 1); |
1365 |
(node, PRINTSETUP_GCONF_SCALE_WIDTH, 0, 100, 1); |
| 586 |
prefs.print_scale_height = go_conf_load_int |
1366 |
prefs.print_scale_height = go_conf_load_int |
| 587 |
(PRINTSETUP_GCONF_SCALE_HEIGHT, 0, 100, 1); |
1367 |
(node, PRINTSETUP_GCONF_SCALE_HEIGHT, 0, 100, 1); |
| 588 |
prefs.print_repeat_top = go_conf_load_string (PRINTSETUP_GCONF_REPEAT_TOP); |
1368 |
prefs.print_repeat_top = go_conf_load_string (node, PRINTSETUP_GCONF_REPEAT_TOP); |
| 589 |
prefs.print_repeat_left = go_conf_load_string (PRINTSETUP_GCONF_REPEAT_LEFT); |
1369 |
prefs.print_repeat_left = go_conf_load_string (node, PRINTSETUP_GCONF_REPEAT_LEFT); |
| 590 |
prefs.print_tb_margins.top.points = go_conf_load_double |
1370 |
prefs.print_tb_margins.top.points = go_conf_load_double |
| 591 |
(PRINTSETUP_GCONF_MARGIN_TOP, 0.0, 10000.0, 120.0); |
1371 |
(node, PRINTSETUP_GCONF_MARGIN_TOP, 0.0, 10000.0, 120.0); |
| 592 |
prefs.print_tb_margins.bottom.points = go_conf_load_double |
1372 |
prefs.print_tb_margins.bottom.points = go_conf_load_double |
| 593 |
(PRINTSETUP_GCONF_MARGIN_BOTTOM, 0.0, 10000.0, 120.0); |
1373 |
(node, PRINTSETUP_GCONF_MARGIN_BOTTOM, 0.0, 10000.0, 120.0); |
| 594 |
{ |
1374 |
{ |
| 595 |
/* Note: the desired display unit is stored in the */ |
1375 |
/* Note: the desired display unit is stored in the */ |
| 596 |
/* printer config. So we are never using this field */ |
1376 |
/* printer config. So we are never using this field */ |
|
Lines 602-672
gnm_conf_init_essential (void)
Link Here
|
| 602 |
= prefs.print_tb_margins.top.desired_display; |
1382 |
= prefs.print_tb_margins.top.desired_display; |
| 603 |
} |
1383 |
} |
| 604 |
prefs.print_all_sheets = go_conf_load_bool ( |
1384 |
prefs.print_all_sheets = go_conf_load_bool ( |
| 605 |
PRINTSETUP_GCONF_ALL_SHEETS, TRUE); |
1385 |
node, PRINTSETUP_GCONF_ALL_SHEETS, TRUE); |
| 606 |
prefs.printer_header = go_conf_load_str_list (PRINTSETUP_GCONF_HEADER); |
1386 |
prefs.printer_header = go_conf_load_str_list (node, PRINTSETUP_GCONF_HEADER); |
| 607 |
prefs.printer_footer = go_conf_load_str_list (PRINTSETUP_GCONF_FOOTER); |
1387 |
prefs.printer_footer = go_conf_load_str_list (node, PRINTSETUP_GCONF_FOOTER); |
| 608 |
prefs.printer_header_formats_left = go_conf_load_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_LEFT); |
1388 |
prefs.printer_header_formats_left = go_conf_load_str_list (node, PRINTSETUP_GCONF_HEADER_FORMAT_LEFT); |
| 609 |
prefs.printer_header_formats_middle = go_conf_load_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE); |
1389 |
prefs.printer_header_formats_middle = go_conf_load_str_list (node, PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE); |
| 610 |
prefs.printer_header_formats_right = go_conf_load_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT); |
1390 |
prefs.printer_header_formats_right = go_conf_load_str_list (node, PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT); |
| 611 |
|
1391 |
go_conf_free_node (node); |
| 612 |
prefs.auto_complete = go_conf_load_bool (GNM_CONF_GUI_ED_AUTOCOMPLETE, TRUE); |
|
|
| 613 |
prefs.live_scrolling = go_conf_load_bool (GNM_CONF_GUI_ED_LIVESCROLLING, TRUE); |
| 614 |
} |
1392 |
} |
| 615 |
|
1393 |
|
| 616 |
static gboolean |
1394 |
static gboolean |
| 617 |
gnm_conf_init_extras (void) |
1395 |
gnm_conf_init_extras (void) |
| 618 |
{ |
1396 |
{ |
| 619 |
char *tmp; |
1397 |
char *tmp; |
|
|
1398 |
GOConfNode *node; |
| 620 |
|
1399 |
|
|
|
1400 |
node = go_conf_get_node (root, FUNCTION_SELECT_GCONF_DIR); |
| 621 |
prefs.num_of_recent_funcs = go_conf_load_int ( |
1401 |
prefs.num_of_recent_funcs = go_conf_load_int ( |
| 622 |
FUNCTION_SELECT_GCONF_NUM_OF_RECENT, 0, 40, 10); |
1402 |
node, FUNCTION_SELECT_GCONF_NUM_OF_RECENT, 0, 40, 10); |
| 623 |
prefs.recent_funcs = go_conf_load_str_list (FUNCTION_SELECT_GCONF_RECENT); |
1403 |
prefs.recent_funcs = go_conf_load_str_list (node, FUNCTION_SELECT_GCONF_RECENT); |
|
|
1404 |
go_conf_free_node (node); |
| 624 |
|
1405 |
|
|
|
1406 |
node = go_conf_get_node (root, GNM_CONF_GUI_DIR); |
| 625 |
prefs.transition_keys = go_conf_load_bool ( |
1407 |
prefs.transition_keys = go_conf_load_bool ( |
| 626 |
GNM_CONF_GUI_ED_TRANSITION_KEYS, FALSE); |
1408 |
node, GNM_CONF_GUI_ED_TRANSITION_KEYS, FALSE); |
| 627 |
prefs.recalc_lag = go_conf_load_int ( |
1409 |
prefs.recalc_lag = go_conf_load_int ( |
| 628 |
GNM_CONF_GUI_ED_RECALC_LAG, -5000, 5000, 200); |
1410 |
node, GNM_CONF_GUI_ED_RECALC_LAG, -5000, 5000, 200); |
|
|
1411 |
go_conf_free_node (node); |
| 1412 |
|
| 1413 |
node = go_conf_get_node (root, GNM_CONF_UNDO_DIR); |
| 629 |
prefs.show_sheet_name = go_conf_load_bool ( |
1414 |
prefs.show_sheet_name = go_conf_load_bool ( |
| 630 |
GNM_CONF_UNDO_SHOW_SHEET_NAME, TRUE); |
1415 |
node, GNM_CONF_UNDO_SHOW_SHEET_NAME, TRUE); |
| 631 |
prefs.max_descriptor_width = go_conf_load_int ( |
1416 |
prefs.max_descriptor_width = go_conf_load_int ( |
| 632 |
GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH, 5, 256, 15); |
1417 |
node, GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH, 5, 256, 15); |
| 633 |
prefs.undo_size = go_conf_load_int ( |
1418 |
prefs.undo_size = go_conf_load_int ( |
| 634 |
GNM_CONF_UNDO_SIZE, 1, 1000000, 100000); |
1419 |
node, GNM_CONF_UNDO_SIZE, 1, 1000000, 100000); |
| 635 |
prefs.undo_max_number = go_conf_load_int ( |
1420 |
prefs.undo_max_number = go_conf_load_int ( |
| 636 |
GNM_CONF_UNDO_MAXNUM, 0, 10000, 100); |
1421 |
node, GNM_CONF_UNDO_MAXNUM, 0, 10000, 100); |
|
|
1422 |
go_conf_free_node (node); |
| 637 |
|
1423 |
|
| 638 |
prefs.autoformat.extra_dirs = go_conf_load_str_list (AUTOFORMAT_GCONF_EXTRA_DIRS); |
1424 |
node = go_conf_get_node (root, AUTOFORMAT_GCONF_DIR); |
| 639 |
tmp = go_conf_load_string (AUTOFORMAT_GCONF_SYS_DIR); |
1425 |
prefs.autoformat.extra_dirs = go_conf_load_str_list (node, AUTOFORMAT_GCONF_EXTRA_DIRS); |
|
|
1426 |
tmp = go_conf_load_string (node, AUTOFORMAT_GCONF_SYS_DIR); |
| 640 |
if (tmp == NULL) |
1427 |
if (tmp == NULL) |
| 641 |
tmp = g_strdup ("autoformat-templates"); |
1428 |
tmp = g_strdup ("autoformat-templates"); |
| 642 |
prefs.autoformat.sys_dir = gnm_sys_data_dir (tmp); |
1429 |
prefs.autoformat.sys_dir = gnm_sys_data_dir (tmp); |
| 643 |
g_free (tmp); |
1430 |
g_free (tmp); |
| 644 |
tmp = go_conf_load_string (AUTOFORMAT_GCONF_USR_DIR); |
1431 |
tmp = go_conf_load_string (node, AUTOFORMAT_GCONF_USR_DIR); |
| 645 |
if (tmp == NULL) |
1432 |
if (tmp == NULL) |
| 646 |
tmp = g_strdup ("autoformat-templates"); |
1433 |
tmp = g_strdup ("autoformat-templates"); |
| 647 |
prefs.autoformat.usr_dir = gnm_usr_dir (tmp); |
1434 |
prefs.autoformat.usr_dir = gnm_usr_dir (tmp); |
| 648 |
g_free (tmp); |
1435 |
g_free (tmp); |
|
|
1436 |
go_conf_free_node (node); |
| 649 |
|
1437 |
|
| 650 |
prefs.xml_compression_level = go_conf_load_int ( |
1438 |
prefs.xml_compression_level = go_conf_load_int ( |
| 651 |
GNM_CONF_XML_COMPRESSION, 0, 9, 9); |
1439 |
root, GNM_CONF_XML_COMPRESSION, 0, 9, 9); |
|
|
1440 |
|
| 1441 |
node = go_conf_get_node (root, GNM_CONF_FILE_DIR); |
| 652 |
prefs.file_overwrite_default_answer = go_conf_load_bool ( |
1442 |
prefs.file_overwrite_default_answer = go_conf_load_bool ( |
| 653 |
GNM_CONF_FILE_OVERWRITE_DEFAULT, FALSE); |
1443 |
node, GNM_CONF_FILE_OVERWRITE_DEFAULT, FALSE); |
| 654 |
prefs.file_ask_single_sheet_save = go_conf_load_bool ( |
1444 |
prefs.file_ask_single_sheet_save = go_conf_load_bool ( |
| 655 |
GNM_CONF_FILE_SINGLE_SHEET_SAVE, TRUE); |
1445 |
node, GNM_CONF_FILE_SINGLE_SHEET_SAVE, TRUE); |
|
|
1446 |
go_conf_free_node (node); |
| 1447 |
|
| 1448 |
node = go_conf_get_node (root, GNM_CONF_SORT_DIR); |
| 656 |
prefs.sort_default_by_case = go_conf_load_bool ( |
1449 |
prefs.sort_default_by_case = go_conf_load_bool ( |
| 657 |
GNM_CONF_SORT_DEFAULT_BY_CASE, FALSE); |
1450 |
node, GNM_CONF_SORT_DEFAULT_BY_CASE, FALSE); |
| 658 |
prefs.sort_default_retain_formats = go_conf_load_bool ( |
1451 |
prefs.sort_default_retain_formats = go_conf_load_bool ( |
| 659 |
GNM_CONF_SORT_DEFAULT_RETAIN_FORM, TRUE); |
1452 |
node, GNM_CONF_SORT_DEFAULT_RETAIN_FORM, TRUE); |
| 660 |
prefs.sort_default_ascending = go_conf_load_bool ( |
1453 |
prefs.sort_default_ascending = go_conf_load_bool ( |
| 661 |
GNM_CONF_SORT_DEFAULT_ASCENDING, TRUE); |
1454 |
node, GNM_CONF_SORT_DEFAULT_ASCENDING, TRUE); |
| 662 |
prefs.sort_max_initial_clauses = go_conf_load_int ( |
1455 |
prefs.sort_max_initial_clauses = go_conf_load_int ( |
| 663 |
GNM_CONF_SORT_DIALOG_MAX_INITIAL, 0, 256, 10); |
1456 |
node, GNM_CONF_SORT_DIALOG_MAX_INITIAL, 0, 256, 10); |
|
|
1457 |
go_conf_free_node (node); |
| 1458 |
|
| 664 |
prefs.unfocused_range_selection = go_conf_load_bool ( |
1459 |
prefs.unfocused_range_selection = go_conf_load_bool ( |
| 665 |
DIALOGS_GCONF_UNFOCUSED_RS, TRUE); |
1460 |
root, DIALOGS_GCONF_DIR "/" DIALOGS_GCONF_UNFOCUSED_RS, TRUE); |
| 666 |
prefs.prefer_clipboard_selection = go_conf_load_bool ( |
1461 |
prefs.prefer_clipboard_selection = go_conf_load_bool ( |
| 667 |
GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD, TRUE); |
1462 |
root, GNM_CONF_CUTANDPASTE_DIR "/" GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD, TRUE); |
| 668 |
prefs.latex_use_utf8 = go_conf_load_bool ( |
1463 |
prefs.latex_use_utf8 = go_conf_load_bool ( |
| 669 |
PLUGIN_GCONF_LATEX_USE_UTF8, TRUE); |
1464 |
root, PLUGIN_GCONF_LATEX "/" PLUGIN_GCONF_LATEX_USE_UTF8, TRUE); |
| 670 |
|
1465 |
|
| 671 |
gnm_conf_init_printer_decoration_font (); |
1466 |
gnm_conf_init_printer_decoration_font (); |
| 672 |
|
1467 |
|
|
Lines 681-686
gnm_conf_init_extras (void)
Link Here
|
| 681 |
void |
1476 |
void |
| 682 |
gnm_conf_init (gboolean fast) |
1477 |
gnm_conf_init (gboolean fast) |
| 683 |
{ |
1478 |
{ |
|
|
1479 |
go_conf_init (); |
| 1480 |
root = go_conf_get_node (NULL, GNM_CONF_DIR); |
| 684 |
gnm_conf_init_essential (); |
1481 |
gnm_conf_init_essential (); |
| 685 |
if (fast) |
1482 |
if (fast) |
| 686 |
g_timeout_add (1000, (GSourceFunc) gnm_conf_init_extras, NULL); |
1483 |
g_timeout_add (1000, (GSourceFunc) gnm_conf_init_extras, NULL); |
|
Lines 691-705
gnm_conf_init (gboolean fast)
Link Here
|
| 691 |
void |
1488 |
void |
| 692 |
gnm_conf_shutdown (void) |
1489 |
gnm_conf_shutdown (void) |
| 693 |
{ |
1490 |
{ |
|
|
1491 |
if (prefs.printer_decoration_font) { |
| 694 |
mstyle_unref (prefs.printer_decoration_font); |
1492 |
mstyle_unref (prefs.printer_decoration_font); |
| 695 |
prefs.printer_decoration_font = NULL; |
1493 |
prefs.printer_decoration_font = NULL; |
| 696 |
#ifdef WITH_GNOME |
|
|
| 697 |
if (gconf_client) { |
| 698 |
gconf_client_remove_dir (gconf_client, "/apps/gnumeric", NULL); |
| 699 |
g_object_unref (G_OBJECT (gconf_client)); |
| 700 |
gconf_client = NULL; |
| 701 |
} |
1494 |
} |
| 702 |
#endif |
1495 |
go_conf_free_node (root); |
|
|
1496 |
go_conf_shutdown (); |
| 1497 |
} |
| 1498 |
|
| 1499 |
GOConfNode * |
| 1500 |
gnm_conf_get_root (void) |
| 1501 |
{ |
| 1502 |
return root; |
| 703 |
} |
1503 |
} |
| 704 |
|
1504 |
|
| 705 |
void |
1505 |
void |
|
Lines 713-719
gnm_gconf_set_plugin_file_states (GSList
Link Here
|
| 713 |
g_slist_free ((GSList *)prefs.plugin_file_states); |
1513 |
g_slist_free ((GSList *)prefs.plugin_file_states); |
| 714 |
prefs.plugin_file_states = list; |
1514 |
prefs.plugin_file_states = list; |
| 715 |
|
1515 |
|
| 716 |
go_conf_set_str_list (PLUGIN_GCONF_FILE_STATES, list); |
1516 |
go_conf_set_str_list (root, PLUGIN_GCONF_DIR "/" PLUGIN_GCONF_FILE_STATES, list); |
| 717 |
} |
1517 |
} |
| 718 |
|
1518 |
|
| 719 |
void |
1519 |
void |
|
Lines 727-751
gnm_gconf_set_plugin_extra_dirs (GSList
Link Here
|
| 727 |
g_slist_free ((GSList *)prefs.plugin_extra_dirs); |
1527 |
g_slist_free ((GSList *)prefs.plugin_extra_dirs); |
| 728 |
prefs.plugin_extra_dirs = list; |
1528 |
prefs.plugin_extra_dirs = list; |
| 729 |
|
1529 |
|
| 730 |
go_conf_set_str_list (PLUGIN_GCONF_EXTRA_DIRS, list); |
1530 |
go_conf_set_str_list (root, PLUGIN_GCONF_DIR "/" PLUGIN_GCONF_EXTRA_DIRS, list); |
| 731 |
} |
1531 |
} |
| 732 |
|
1532 |
|
| 733 |
void |
1533 |
void |
| 734 |
gnm_gconf_set_active_plugins (GSList *list) |
1534 |
gnm_gconf_set_active_plugins (GSList *list) |
| 735 |
{ |
1535 |
{ |
| 736 |
go_conf_set_str_list (PLUGIN_GCONF_ACTIVE, list); |
1536 |
go_conf_set_str_list (root, PLUGIN_GCONF_DIR "/" PLUGIN_GCONF_ACTIVE, list); |
| 737 |
} |
1537 |
} |
| 738 |
|
1538 |
|
| 739 |
void |
1539 |
void |
| 740 |
gnm_gconf_set_activate_new_plugins (gboolean val) |
1540 |
gnm_gconf_set_activate_new_plugins (gboolean val) |
| 741 |
{ |
1541 |
{ |
| 742 |
go_conf_set_bool (PLUGIN_GCONF_ACTIVATE_NEW, val); |
1542 |
go_conf_set_bool (root, PLUGIN_GCONF_DIR "/" PLUGIN_GCONF_ACTIVATE_NEW, val); |
| 743 |
} |
1543 |
} |
| 744 |
|
1544 |
|
| 745 |
void |
1545 |
void |
| 746 |
gnm_gconf_set_recent_funcs (GSList *list) |
1546 |
gnm_gconf_set_recent_funcs (GSList *list) |
| 747 |
{ |
1547 |
{ |
| 748 |
go_conf_set_str_list (FUNCTION_SELECT_GCONF_RECENT, list); |
1548 |
go_conf_set_str_list (root, FUNCTION_SELECT_GCONF_DIR "/" FUNCTION_SELECT_GCONF_RECENT, list); |
| 749 |
|
1549 |
|
| 750 |
/* the const_casts are ok, the const in the header is just to keep |
1550 |
/* the const_casts are ok, the const in the header is just to keep |
| 751 |
* people for doing stupid things */ |
1551 |
* people for doing stupid things */ |
|
Lines 761-767
gnm_gconf_set_num_recent_functions (gint
Link Here
|
| 761 |
if (val < 0) |
1561 |
if (val < 0) |
| 762 |
val = 0; |
1562 |
val = 0; |
| 763 |
prefs.num_of_recent_funcs = val; |
1563 |
prefs.num_of_recent_funcs = val; |
| 764 |
go_conf_set_int ( FUNCTION_SELECT_GCONF_NUM_OF_RECENT, val); |
1564 |
go_conf_set_int (root, FUNCTION_SELECT_GCONF_DIR "/" FUNCTION_SELECT_GCONF_NUM_OF_RECENT, val); |
| 765 |
} |
1565 |
} |
| 766 |
|
1566 |
|
| 767 |
void |
1567 |
void |
|
Lines 774-780
gnm_gconf_set_file_history_files (GSList
Link Here
|
| 774 |
g_slist_foreach ((GSList *)prefs.file_history_files, (GFunc)g_free, NULL); |
1574 |
g_slist_foreach ((GSList *)prefs.file_history_files, (GFunc)g_free, NULL); |
| 775 |
g_slist_free ((GSList *)prefs.file_history_files); |
1575 |
g_slist_free ((GSList *)prefs.file_history_files); |
| 776 |
prefs.file_history_files = list; |
1576 |
prefs.file_history_files = list; |
| 777 |
go_conf_set_str_list (GNM_CONF_FILE_HISTORY_FILES, list); |
1577 |
go_conf_set_str_list (root, GNM_CONF_FILE_DIR "/" GNM_CONF_FILE_HISTORY_FILES, list); |
| 778 |
} |
1578 |
} |
| 779 |
|
1579 |
|
| 780 |
void |
1580 |
void |
|
Lines 783-789
gnm_gconf_set_file_history_number (gint
Link Here
|
| 783 |
if (val < 0) |
1583 |
if (val < 0) |
| 784 |
val = 0; |
1584 |
val = 0; |
| 785 |
prefs.file_history_max = val; |
1585 |
prefs.file_history_max = val; |
| 786 |
go_conf_set_int (GNM_CONF_FILE_HISTORY_N, val); |
1586 |
go_conf_set_int (root, GNM_CONF_FILE_DIR "/" GNM_CONF_FILE_HISTORY_N, val); |
| 787 |
} |
1587 |
} |
| 788 |
|
1588 |
|
| 789 |
|
1589 |
|
|
Lines 793-799
gnm_gconf_set_undo_size (gint val)
Link Here
|
| 793 |
if (val < 1) |
1593 |
if (val < 1) |
| 794 |
val = 1; |
1594 |
val = 1; |
| 795 |
prefs.undo_size = val; |
1595 |
prefs.undo_size = val; |
| 796 |
go_conf_set_int (GNM_CONF_UNDO_SIZE, val); |
1596 |
go_conf_set_int (root, GNM_CONF_UNDO_DIR "/" GNM_CONF_UNDO_SIZE, val); |
| 797 |
} |
1597 |
} |
| 798 |
|
1598 |
|
| 799 |
|
1599 |
|
|
Lines 803-835
gnm_gconf_set_undo_max_number (gint val)
Link Here
|
| 803 |
if (val < 1) |
1603 |
if (val < 1) |
| 804 |
val = 1; |
1604 |
val = 1; |
| 805 |
prefs.undo_max_number = val; |
1605 |
prefs.undo_max_number = val; |
| 806 |
go_conf_set_int (GNM_CONF_UNDO_MAXNUM, val); |
1606 |
go_conf_set_int (root, GNM_CONF_UNDO_DIR "/" GNM_CONF_UNDO_MAXNUM, val); |
| 807 |
} |
1607 |
} |
| 808 |
|
1608 |
|
| 809 |
void |
1609 |
void |
| 810 |
gnm_gconf_set_autoformat_sys_dirs (char const * string) |
1610 |
gnm_gconf_set_autoformat_sys_dirs (char const * string) |
| 811 |
{ |
1611 |
{ |
| 812 |
go_conf_set_string (AUTOFORMAT_GCONF_SYS_DIR, string); |
1612 |
go_conf_set_string (root, AUTOFORMAT_GCONF_DIR "/" AUTOFORMAT_GCONF_SYS_DIR, string); |
| 813 |
} |
1613 |
} |
| 814 |
|
1614 |
|
| 815 |
void |
1615 |
void |
| 816 |
gnm_gconf_set_autoformat_usr_dirs (char const * string) |
1616 |
gnm_gconf_set_autoformat_usr_dirs (char const * string) |
| 817 |
{ |
1617 |
{ |
| 818 |
go_conf_set_string (AUTOFORMAT_GCONF_USR_DIR, string); |
1618 |
go_conf_set_string (root, AUTOFORMAT_GCONF_DIR "/" AUTOFORMAT_GCONF_USR_DIR, string); |
| 819 |
} |
1619 |
} |
| 820 |
|
1620 |
|
| 821 |
void |
1621 |
void |
| 822 |
gnm_gconf_set_all_sheets (gboolean val) |
1622 |
gnm_gconf_set_all_sheets (gboolean val) |
| 823 |
{ |
1623 |
{ |
| 824 |
go_conf_set_bool (PRINTSETUP_GCONF_ALL_SHEETS, val); |
1624 |
go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_ALL_SHEETS, val); |
| 825 |
} |
1625 |
} |
| 826 |
|
1626 |
|
| 827 |
void |
1627 |
void |
| 828 |
gnm_gconf_set_printer_config (gchar *str) |
1628 |
gnm_gconf_set_printer_config (gchar const *str) |
| 829 |
{ |
1629 |
{ |
| 830 |
go_conf_set_string (PRINTSETUP_GCONF_PRINTER_CONFIG, str); |
1630 |
go_conf_set_string (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_PRINTER_CONFIG, str); |
|
|
1631 |
if (prefs.printer_config != str) { |
| 831 |
g_free (prefs.printer_config); |
1632 |
g_free (prefs.printer_config); |
| 832 |
prefs.printer_config = str; |
1633 |
prefs.printer_config = g_strdup (str); |
|
|
1634 |
} |
| 833 |
} |
1635 |
} |
| 834 |
|
1636 |
|
| 835 |
void |
1637 |
void |
|
Lines 840-846
gnm_gconf_set_printer_header (gchar cons
Link Here
|
| 840 |
list = g_slist_prepend (list, g_strdup (right)); |
1642 |
list = g_slist_prepend (list, g_strdup (right)); |
| 841 |
list = g_slist_prepend (list, g_strdup (middle)); |
1643 |
list = g_slist_prepend (list, g_strdup (middle)); |
| 842 |
list = g_slist_prepend (list, g_strdup (left)); |
1644 |
list = g_slist_prepend (list, g_strdup (left)); |
| 843 |
go_conf_set_str_list (PRINTSETUP_GCONF_HEADER, list); |
1645 |
go_conf_set_str_list (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HEADER, list); |
| 844 |
gnm_slist_free_custom ((GSList *)prefs.printer_header, g_free); |
1646 |
gnm_slist_free_custom ((GSList *)prefs.printer_header, g_free); |
| 845 |
prefs.printer_header = list; |
1647 |
prefs.printer_header = list; |
| 846 |
} |
1648 |
} |
|
Lines 853-859
gnm_gconf_set_printer_footer (gchar cons
Link Here
|
| 853 |
list = g_slist_prepend (list, g_strdup (right)); |
1655 |
list = g_slist_prepend (list, g_strdup (right)); |
| 854 |
list = g_slist_prepend (list, g_strdup (middle)); |
1656 |
list = g_slist_prepend (list, g_strdup (middle)); |
| 855 |
list = g_slist_prepend (list, g_strdup (left)); |
1657 |
list = g_slist_prepend (list, g_strdup (left)); |
| 856 |
go_conf_set_str_list (PRINTSETUP_GCONF_FOOTER, list); |
1658 |
go_conf_set_str_list (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_FOOTER, list); |
| 857 |
gnm_slist_free_custom ((GSList *)prefs.printer_footer, g_free); |
1659 |
gnm_slist_free_custom ((GSList *)prefs.printer_footer, g_free); |
| 858 |
prefs.printer_footer = list; |
1660 |
prefs.printer_footer = list; |
| 859 |
} |
1661 |
} |
|
Lines 861-915
gnm_gconf_set_printer_footer (gchar cons
Link Here
|
| 861 |
void |
1663 |
void |
| 862 |
gnm_gconf_set_print_center_horizontally (gboolean val) |
1664 |
gnm_gconf_set_print_center_horizontally (gboolean val) |
| 863 |
{ |
1665 |
{ |
| 864 |
go_conf_set_bool (PRINTSETUP_GCONF_CENTER_HORIZONTALLY, val); |
1666 |
go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_CENTER_HORIZONTALLY, val); |
| 865 |
} |
1667 |
} |
| 866 |
|
1668 |
|
| 867 |
void |
1669 |
void |
| 868 |
gnm_gconf_set_print_center_vertically (gboolean val) |
1670 |
gnm_gconf_set_print_center_vertically (gboolean val) |
| 869 |
{ |
1671 |
{ |
| 870 |
go_conf_set_bool (PRINTSETUP_GCONF_CENTER_VERTICALLY, val); |
1672 |
go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_CENTER_VERTICALLY, val); |
| 871 |
} |
1673 |
} |
| 872 |
|
1674 |
|
| 873 |
void |
1675 |
void |
| 874 |
gnm_gconf_set_print_grid_lines (gboolean val) |
1676 |
gnm_gconf_set_print_grid_lines (gboolean val) |
| 875 |
{ |
1677 |
{ |
| 876 |
go_conf_set_bool (PRINTSETUP_GCONF_PRINT_GRID_LINES, val); |
1678 |
go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_PRINT_GRID_LINES, val); |
| 877 |
} |
1679 |
} |
| 878 |
|
1680 |
|
| 879 |
void |
1681 |
void |
| 880 |
gnm_gconf_set_print_even_if_only_styles (gboolean val) |
1682 |
gnm_gconf_set_print_even_if_only_styles (gboolean val) |
| 881 |
{ |
1683 |
{ |
| 882 |
go_conf_set_bool (PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES, val); |
1684 |
go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES, val); |
| 883 |
} |
1685 |
} |
| 884 |
|
1686 |
|
| 885 |
void |
1687 |
void |
| 886 |
gnm_gconf_set_print_black_and_white (gboolean val) |
1688 |
gnm_gconf_set_print_black_and_white (gboolean val) |
| 887 |
{ |
1689 |
{ |
| 888 |
go_conf_set_bool (PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE, val); |
1690 |
go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE, val); |
| 889 |
} |
1691 |
} |
| 890 |
|
1692 |
|
| 891 |
void |
1693 |
void |
| 892 |
gnm_gconf_set_print_titles (gboolean val) |
1694 |
gnm_gconf_set_print_titles (gboolean val) |
| 893 |
{ |
1695 |
{ |
| 894 |
go_conf_set_bool (PRINTSETUP_GCONF_PRINT_TITLES, val); |
1696 |
go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_PRINT_TITLES, val); |
| 895 |
} |
1697 |
} |
| 896 |
|
1698 |
|
| 897 |
void |
1699 |
void |
| 898 |
gnm_gconf_set_print_order_right_then_down (gboolean val) |
1700 |
gnm_gconf_set_print_order_right_then_down (gboolean val) |
| 899 |
{ |
1701 |
{ |
| 900 |
go_conf_set_bool (PRINTSETUP_GCONF_RIGHT_THEN_DOWN, val); |
1702 |
go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_RIGHT_THEN_DOWN, val); |
| 901 |
} |
1703 |
} |
| 902 |
|
1704 |
|
| 903 |
void |
1705 |
void |
| 904 |
gnm_gconf_set_print_scale_percentage (gboolean val) |
1706 |
gnm_gconf_set_print_scale_percentage (gboolean val) |
| 905 |
{ |
1707 |
{ |
| 906 |
go_conf_set_bool (PRINTSETUP_GCONF_SCALE_PERCENTAGE, val); |
1708 |
go_conf_set_bool ( |
|
|
1709 |
root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_SCALE_PERCENTAGE, val); |
| 907 |
} |
1710 |
} |
| 908 |
|
1711 |
|
| 909 |
void |
1712 |
void |
| 910 |
gnm_gconf_set_print_scale_percentage_value (gnm_float val) |
1713 |
gnm_gconf_set_print_scale_percentage_value (gnm_float val) |
| 911 |
{ |
1714 |
{ |
| 912 |
go_conf_set_double (PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE, val); |
1715 |
go_conf_set_double ( |
|
|
1716 |
root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE, val); |
| 913 |
} |
1717 |
} |
| 914 |
|
1718 |
|
| 915 |
void |
1719 |
void |
|
Lines 917-935
gnm_gconf_set_print_tb_margins (PrintMar
Link Here
|
| 917 |
{ |
1721 |
{ |
| 918 |
/* We are not saving the GnomePrintUnits since they are */ |
1722 |
/* We are not saving the GnomePrintUnits since they are */ |
| 919 |
/* duplicated in the gnomeprintconfig */ |
1723 |
/* duplicated in the gnomeprintconfig */ |
| 920 |
go_conf_set_double (PRINTSETUP_GCONF_MARGIN_TOP, pm->top.points); |
1724 |
go_conf_set_double ( |
| 921 |
go_conf_set_double (PRINTSETUP_GCONF_MARGIN_BOTTOM, pm->bottom.points); |
1725 |
root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_MARGIN_TOP, pm->top.points); |
|
|
1726 |
go_conf_set_double ( |
| 1727 |
root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_MARGIN_BOTTOM, pm->bottom.points); |
| 922 |
} |
1728 |
} |
| 923 |
|
1729 |
|
| 924 |
void |
1730 |
void |
| 925 |
gnm_gconf_set_print_header_formats (GSList *left, GSList *middle, |
1731 |
gnm_gconf_set_print_header_formats (GSList *left, GSList *middle, |
| 926 |
GSList *right) |
1732 |
GSList *right) |
| 927 |
{ |
1733 |
{ |
| 928 |
go_conf_set_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_LEFT, left); |
1734 |
go_conf_set_str_list ( |
|
|
1735 |
root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HEADER_FORMAT_LEFT, left); |
| 929 |
gnm_slist_free_custom (left, g_free); |
1736 |
gnm_slist_free_custom (left, g_free); |
| 930 |
go_conf_set_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE, middle); |
1737 |
go_conf_set_str_list ( |
|
|
1738 |
root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE, middle); |
| 931 |
gnm_slist_free_custom (middle, g_free); |
1739 |
gnm_slist_free_custom (middle, g_free); |
| 932 |
go_conf_set_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT, right); |
1740 |
go_conf_set_str_list ( |
|
|
1741 |
root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT, right); |
| 933 |
gnm_slist_free_custom (right, g_free); |
1742 |
gnm_slist_free_custom (right, g_free); |
| 934 |
} |
1743 |
} |
| 935 |
|
1744 |
|
|
Lines 937-996
void
Link Here
|
| 937 |
gnm_gconf_set_gui_window_x (gnm_float val) |
1746 |
gnm_gconf_set_gui_window_x (gnm_float val) |
| 938 |
{ |
1747 |
{ |
| 939 |
prefs.horizontal_window_fraction = val; |
1748 |
prefs.horizontal_window_fraction = val; |
| 940 |
go_conf_set_double (GNM_CONF_GUI_WINDOW_X, val); |
1749 |
go_conf_set_double ( |
|
|
1750 |
root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_WINDOW_X, val); |
| 941 |
} |
1751 |
} |
| 942 |
|
1752 |
|
| 943 |
void |
1753 |
void |
| 944 |
gnm_gconf_set_gui_window_y (gnm_float val) |
1754 |
gnm_gconf_set_gui_window_y (gnm_float val) |
| 945 |
{ |
1755 |
{ |
| 946 |
prefs.vertical_window_fraction = val; |
1756 |
prefs.vertical_window_fraction = val; |
| 947 |
go_conf_set_double (GNM_CONF_GUI_WINDOW_Y, val); |
1757 |
go_conf_set_double ( |
|
|
1758 |
root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_WINDOW_Y, val); |
| 948 |
} |
1759 |
} |
| 949 |
|
1760 |
|
| 950 |
void |
1761 |
void |
| 951 |
gnm_gconf_set_gui_zoom (gnm_float val) |
1762 |
gnm_gconf_set_gui_zoom (gnm_float val) |
| 952 |
{ |
1763 |
{ |
| 953 |
prefs.zoom = val; |
1764 |
prefs.zoom = val; |
| 954 |
go_conf_set_double (GNM_CONF_GUI_WINDOW_Y, val); |
1765 |
go_conf_set_double ( |
|
|
1766 |
root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_WINDOW_Y, val); |
| 955 |
} |
1767 |
} |
| 956 |
|
1768 |
|
| 957 |
void |
1769 |
void |
| 958 |
gnm_gconf_set_default_font_size (gnm_float val) |
1770 |
gnm_gconf_set_default_font_size (gnm_float val) |
| 959 |
{ |
1771 |
{ |
| 960 |
prefs.default_font.size = val; |
1772 |
prefs.default_font.size = val; |
| 961 |
go_conf_set_double (GNM_CONF_FONT_SIZE, val); |
1773 |
go_conf_set_double ( |
|
|
1774 |
root, GNM_CONF_FONT_DIR "/" GNM_CONF_FONT_SIZE, val); |
| 962 |
} |
1775 |
} |
| 963 |
|
1776 |
|
| 964 |
void |
1777 |
void |
| 965 |
gnm_gconf_set_default_font_name (char const *str) |
1778 |
gnm_gconf_set_default_font_name (char const *str) |
| 966 |
{ |
1779 |
{ |
| 967 |
g_return_if_fail (str != NULL); |
1780 |
go_conf_set_string (root, GNM_CONF_FONT_DIR "/" GNM_CONF_FONT_NAME, str); |
| 968 |
|
1781 |
if (prefs.default_font.name != str) { |
| 969 |
/* the const_casts are ok, the const in the header is just to keep |
1782 |
/* the const in the header is just a safety net */ |
| 970 |
* people for doing stupid things */ |
|
|
| 971 |
if (prefs.default_font.name != NULL) |
| 972 |
g_free ((char *) prefs.default_font.name); |
1783 |
g_free ((char *) prefs.default_font.name); |
| 973 |
prefs.default_font.name = g_strdup (str); |
1784 |
prefs.default_font.name = g_strdup (str); |
| 974 |
go_conf_set_string (GNM_CONF_FONT_NAME, str); |
1785 |
} |
| 975 |
} |
1786 |
} |
| 976 |
|
1787 |
|
| 977 |
void |
1788 |
void |
| 978 |
gnm_gconf_set_default_font_bold (gboolean val) |
1789 |
gnm_gconf_set_default_font_bold (gboolean val) |
| 979 |
{ |
1790 |
{ |
| 980 |
prefs.default_font.is_bold = val; |
1791 |
prefs.default_font.is_bold = val; |
| 981 |
go_conf_set_bool (GNM_CONF_FONT_BOLD, val); |
1792 |
go_conf_set_bool ( |
|
|
1793 |
root, GNM_CONF_FONT_DIR "/" GNM_CONF_FONT_BOLD, val); |
| 982 |
} |
1794 |
} |
| 983 |
|
1795 |
|
| 984 |
void |
1796 |
void |
| 985 |
gnm_gconf_set_default_font_italic (gboolean val) |
1797 |
gnm_gconf_set_default_font_italic (gboolean val) |
| 986 |
{ |
1798 |
{ |
| 987 |
prefs.default_font.is_italic = val; |
1799 |
prefs.default_font.is_italic = val; |
| 988 |
go_conf_set_bool (GNM_CONF_FONT_ITALIC, val); |
1800 |
go_conf_set_bool ( |
|
|
1801 |
root, GNM_CONF_FONT_DIR "/" GNM_CONF_FONT_ITALIC, val); |
| 989 |
} |
1802 |
} |
| 990 |
|
1803 |
|
| 991 |
void |
1804 |
void |
| 992 |
gnm_gconf_set_hf_font (GnmStyle const *mstyle) |
1805 |
gnm_gconf_set_hf_font (GnmStyle const *mstyle) |
| 993 |
{ |
1806 |
{ |
|
|
1807 |
GOConfNode *node; |
| 994 |
GnmStyle *old_style = (prefs.printer_decoration_font != NULL) ? |
1808 |
GnmStyle *old_style = (prefs.printer_decoration_font != NULL) ? |
| 995 |
prefs.printer_decoration_font : |
1809 |
prefs.printer_decoration_font : |
| 996 |
mstyle_new_default (); |
1810 |
mstyle_new_default (); |
|
Lines 998-1015
gnm_gconf_set_hf_font (GnmStyle const *m
Link Here
|
| 998 |
prefs.printer_decoration_font = mstyle_copy_merge (old_style, mstyle); |
1812 |
prefs.printer_decoration_font = mstyle_copy_merge (old_style, mstyle); |
| 999 |
mstyle_unref (old_style); |
1813 |
mstyle_unref (old_style); |
| 1000 |
|
1814 |
|
|
|
1815 |
node = go_conf_get_node (root, PRINTSETUP_GCONF_DIR); |
| 1001 |
if (mstyle_is_element_set (mstyle, MSTYLE_FONT_SIZE)) |
1816 |
if (mstyle_is_element_set (mstyle, MSTYLE_FONT_SIZE)) |
| 1002 |
go_conf_set_double (PRINTSETUP_GCONF_HF_FONT_SIZE, |
1817 |
go_conf_set_double (node, PRINTSETUP_GCONF_HF_FONT_SIZE, |
| 1003 |
mstyle_get_font_size (mstyle)); |
1818 |
mstyle_get_font_size (mstyle)); |
| 1004 |
if (mstyle_is_element_set (mstyle, MSTYLE_FONT_NAME)) |
1819 |
if (mstyle_is_element_set (mstyle, MSTYLE_FONT_NAME)) |
| 1005 |
go_conf_set_string (PRINTSETUP_GCONF_HF_FONT_NAME, |
1820 |
go_conf_set_string (node, PRINTSETUP_GCONF_HF_FONT_NAME, |
| 1006 |
mstyle_get_font_name (mstyle)); |
1821 |
mstyle_get_font_name (mstyle)); |
| 1007 |
if (mstyle_is_element_set (mstyle, MSTYLE_FONT_BOLD)) |
1822 |
if (mstyle_is_element_set (mstyle, MSTYLE_FONT_BOLD)) |
| 1008 |
go_conf_set_bool (PRINTSETUP_GCONF_HF_FONT_BOLD, |
1823 |
go_conf_set_bool (node, PRINTSETUP_GCONF_HF_FONT_BOLD, |
| 1009 |
mstyle_get_font_bold (mstyle)); |
1824 |
mstyle_get_font_bold (mstyle)); |
| 1010 |
if (mstyle_is_element_set (mstyle, MSTYLE_FONT_ITALIC)) |
1825 |
if (mstyle_is_element_set (mstyle, MSTYLE_FONT_ITALIC)) |
| 1011 |
go_conf_set_bool (PRINTSETUP_GCONF_HF_FONT_ITALIC, |
1826 |
go_conf_set_bool (node, PRINTSETUP_GCONF_HF_FONT_ITALIC, |
| 1012 |
mstyle_get_font_italic (mstyle)); |
1827 |
mstyle_get_font_italic (mstyle)); |
|
|
1828 |
go_conf_free_node (node); |
| 1013 |
} |
1829 |
} |
| 1014 |
|
1830 |
|
| 1015 |
|
1831 |
|
|
Lines 1019-1025
gnm_gconf_set_max_descriptor_width (gint
Link Here
|
| 1019 |
if (val < 1) |
1835 |
if (val < 1) |
| 1020 |
val = 1; |
1836 |
val = 1; |
| 1021 |
prefs.max_descriptor_width = val; |
1837 |
prefs.max_descriptor_width = val; |
| 1022 |
go_conf_set_int (GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH, val); |
1838 |
go_conf_set_int ( |
|
|
1839 |
root, GNM_CONF_UNDO_DIR "/" GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH, val); |
| 1023 |
} |
1840 |
} |
| 1024 |
|
1841 |
|
| 1025 |
void |
1842 |
void |
|
Lines 1028-1034
gnm_gconf_set_sort_dialog_max_initial (g
Link Here
|
| 1028 |
if (val < 1) |
1845 |
if (val < 1) |
| 1029 |
val = 1; |
1846 |
val = 1; |
| 1030 |
prefs.sort_max_initial_clauses = val; |
1847 |
prefs.sort_max_initial_clauses = val; |
| 1031 |
go_conf_set_int (GNM_CONF_SORT_DIALOG_MAX_INITIAL, val); |
1848 |
go_conf_set_int ( |
|
|
1849 |
root, GNM_CONF_SORT_DIR "/" GNM_CONF_SORT_DIALOG_MAX_INITIAL, val); |
| 1032 |
} |
1850 |
} |
| 1033 |
|
1851 |
|
| 1034 |
void |
1852 |
void |
|
Lines 1037-1043
gnm_gconf_set_workbook_nsheets (gint val
Link Here
|
| 1037 |
if (val < 1) |
1855 |
if (val < 1) |
| 1038 |
val = 1; |
1856 |
val = 1; |
| 1039 |
prefs.initial_sheet_number = val; |
1857 |
prefs.initial_sheet_number = val; |
| 1040 |
go_conf_set_int (GNM_CONF_WORKBOOK_NSHEETS, val); |
1858 |
go_conf_set_int (root, GNM_CONF_WORKBOOK_NSHEETS, val); |
| 1041 |
} |
1859 |
} |
| 1042 |
|
1860 |
|
| 1043 |
void |
1861 |
void |
|
Lines 1046-1124
gnm_gconf_set_xml_compression (gint val)
Link Here
|
| 1046 |
if (val < 0) |
1864 |
if (val < 0) |
| 1047 |
val = 0; |
1865 |
val = 0; |
| 1048 |
prefs.xml_compression_level = val; |
1866 |
prefs.xml_compression_level = val; |
| 1049 |
go_conf_set_int (GNM_CONF_XML_COMPRESSION, val); |
1867 |
go_conf_set_int (root, GNM_CONF_XML_COMPRESSION, val); |
| 1050 |
} |
1868 |
} |
| 1051 |
|
1869 |
|
| 1052 |
void |
1870 |
void |
| 1053 |
gnm_gconf_set_show_sheet_name (gboolean val) |
1871 |
gnm_gconf_set_show_sheet_name (gboolean val) |
| 1054 |
{ |
1872 |
{ |
| 1055 |
prefs.show_sheet_name = val; |
1873 |
prefs.show_sheet_name = val; |
| 1056 |
go_conf_set_bool( GNM_CONF_UNDO_SHOW_SHEET_NAME, |
1874 |
go_conf_set_bool ( |
| 1057 |
val != FALSE); |
1875 |
root, GNM_CONF_UNDO_DIR "/" GNM_CONF_UNDO_SHOW_SHEET_NAME,val != FALSE); |
| 1058 |
} |
1876 |
} |
| 1059 |
|
1877 |
|
| 1060 |
void |
1878 |
void |
| 1061 |
gnm_gconf_set_latex_use_utf8 (gboolean val) |
1879 |
gnm_gconf_set_latex_use_utf8 (gboolean val) |
| 1062 |
{ |
1880 |
{ |
| 1063 |
prefs.latex_use_utf8 = val; |
1881 |
prefs.latex_use_utf8 = val; |
| 1064 |
go_conf_set_bool( PLUGIN_GCONF_LATEX_USE_UTF8, |
1882 |
go_conf_set_bool ( |
| 1065 |
val != FALSE); |
1883 |
root, PLUGIN_GCONF_LATEX "/" PLUGIN_GCONF_LATEX_USE_UTF8, val != FALSE); |
| 1066 |
} |
1884 |
} |
| 1067 |
|
1885 |
|
| 1068 |
void |
1886 |
void |
| 1069 |
gnm_gconf_set_sort_retain_form (gboolean val) |
1887 |
gnm_gconf_set_sort_retain_form (gboolean val) |
| 1070 |
{ |
1888 |
{ |
| 1071 |
prefs.sort_default_retain_formats = val; |
1889 |
prefs.sort_default_retain_formats = val; |
| 1072 |
go_conf_set_bool( GNM_CONF_SORT_DEFAULT_RETAIN_FORM, |
1890 |
go_conf_set_bool ( |
| 1073 |
val != FALSE); |
1891 |
root, GNM_CONF_SORT_DIR "/" GNM_CONF_SORT_DEFAULT_RETAIN_FORM, val != FALSE); |
| 1074 |
} |
1892 |
} |
| 1075 |
|
1893 |
|
| 1076 |
void |
1894 |
void |
| 1077 |
gnm_gconf_set_sort_by_case (gboolean val) |
1895 |
gnm_gconf_set_sort_by_case (gboolean val) |
| 1078 |
{ |
1896 |
{ |
| 1079 |
prefs.sort_default_by_case = val; |
1897 |
prefs.sort_default_by_case = val; |
| 1080 |
go_conf_set_bool( GNM_CONF_SORT_DEFAULT_BY_CASE, |
1898 |
go_conf_set_bool ( |
| 1081 |
val != FALSE); |
1899 |
root, GNM_CONF_SORT_DIR "/" GNM_CONF_SORT_DEFAULT_BY_CASE, val != FALSE); |
| 1082 |
} |
1900 |
} |
| 1083 |
|
1901 |
|
| 1084 |
void |
1902 |
void |
| 1085 |
gnm_gconf_set_sort_ascending (gboolean val) |
1903 |
gnm_gconf_set_sort_ascending (gboolean val) |
| 1086 |
{ |
1904 |
{ |
| 1087 |
prefs.sort_default_ascending = val; |
1905 |
prefs.sort_default_ascending = val; |
| 1088 |
go_conf_set_bool( GNM_CONF_SORT_DEFAULT_ASCENDING, |
1906 |
go_conf_set_bool ( |
| 1089 |
val != FALSE); |
1907 |
root, GNM_CONF_SORT_DIR "/" GNM_CONF_SORT_DEFAULT_ASCENDING, val != FALSE); |
| 1090 |
} |
1908 |
} |
| 1091 |
|
1909 |
|
| 1092 |
void |
1910 |
void |
| 1093 |
gnm_gconf_set_gui_transition_keys (gboolean val) |
1911 |
gnm_gconf_set_gui_transition_keys (gboolean val) |
| 1094 |
{ |
1912 |
{ |
| 1095 |
prefs.transition_keys = val; |
1913 |
prefs.transition_keys = val; |
| 1096 |
go_conf_set_bool( GNM_CONF_GUI_ED_TRANSITION_KEYS, |
1914 |
go_conf_set_bool ( |
| 1097 |
val != FALSE); |
1915 |
root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_TRANSITION_KEYS, val != FALSE); |
| 1098 |
} |
1916 |
} |
| 1099 |
|
1917 |
|
| 1100 |
void |
1918 |
void |
| 1101 |
gnm_gconf_set_gui_livescrolling (gboolean val) |
1919 |
gnm_gconf_set_gui_livescrolling (gboolean val) |
| 1102 |
{ |
1920 |
{ |
| 1103 |
prefs.live_scrolling = val; |
1921 |
prefs.live_scrolling = val; |
| 1104 |
go_conf_set_bool( GNM_CONF_GUI_ED_LIVESCROLLING, |
1922 |
go_conf_set_bool ( |
| 1105 |
val != FALSE); |
1923 |
root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_LIVESCROLLING, val != FALSE); |
| 1106 |
} |
1924 |
} |
| 1107 |
|
1925 |
|
| 1108 |
void |
1926 |
void |
| 1109 |
gnm_gconf_set_file_overwrite (gboolean val) |
1927 |
gnm_gconf_set_file_overwrite (gboolean val) |
| 1110 |
{ |
1928 |
{ |
| 1111 |
prefs.file_overwrite_default_answer = val; |
1929 |
prefs.file_overwrite_default_answer = val; |
| 1112 |
go_conf_set_bool( GNM_CONF_FILE_OVERWRITE_DEFAULT, |
1930 |
go_conf_set_bool ( |
| 1113 |
val != FALSE); |
1931 |
root, GNM_CONF_FILE_DIR "/" GNM_CONF_FILE_OVERWRITE_DEFAULT, val != FALSE); |
| 1114 |
} |
1932 |
} |
| 1115 |
|
1933 |
|
| 1116 |
void |
1934 |
void |
| 1117 |
gnm_gconf_set_file_single_sheet_save (gboolean val) |
1935 |
gnm_gconf_set_file_single_sheet_save (gboolean val) |
| 1118 |
{ |
1936 |
{ |
| 1119 |
prefs.file_ask_single_sheet_save = val; |
1937 |
prefs.file_ask_single_sheet_save = val; |
| 1120 |
go_conf_set_bool( GNM_CONF_FILE_SINGLE_SHEET_SAVE, |
1938 |
go_conf_set_bool ( |
| 1121 |
val != FALSE); |
1939 |
root, GNM_CONF_FILE_DIR "/" GNM_CONF_FILE_SINGLE_SHEET_SAVE, val != FALSE); |
| 1122 |
} |
1940 |
} |
| 1123 |
|
1941 |
|
| 1124 |
void |
1942 |
void |
|
Lines 1129-1135
gnm_gconf_set_gui_resolution_h (gnm_floa
Link Here
|
| 1129 |
if (val > 250) |
1947 |
if (val > 250) |
| 1130 |
val = 250; |
1948 |
val = 250; |
| 1131 |
prefs.horizontal_dpi = val; |
1949 |
prefs.horizontal_dpi = val; |
| 1132 |
go_conf_set_double (GNM_CONF_GUI_RES_H, val); |
1950 |
go_conf_set_double ( |
|
|
1951 |
root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_RES_H, val); |
| 1133 |
} |
1952 |
} |
| 1134 |
|
1953 |
|
| 1135 |
void |
1954 |
void |
|
Lines 1140-1169
gnm_gconf_set_gui_resolution_v (gnm_floa
Link Here
|
| 1140 |
if (val > 250) |
1959 |
if (val > 250) |
| 1141 |
val = 250; |
1960 |
val = 250; |
| 1142 |
prefs.vertical_dpi = val; |
1961 |
prefs.vertical_dpi = val; |
| 1143 |
go_conf_set_double (GNM_CONF_GUI_RES_V, val); |
1962 |
go_conf_set_double ( |
|
|
1963 |
root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_RES_V, val); |
| 1144 |
} |
1964 |
} |
| 1145 |
|
1965 |
|
| 1146 |
void |
1966 |
void |
| 1147 |
gnm_gconf_set_unfocused_rs (gboolean val) |
1967 |
gnm_gconf_set_unfocused_rs (gboolean val) |
| 1148 |
{ |
1968 |
{ |
| 1149 |
prefs.unfocused_range_selection = val; |
1969 |
prefs.unfocused_range_selection = val; |
| 1150 |
go_conf_set_bool( DIALOGS_GCONF_UNFOCUSED_RS, |
1970 |
go_conf_set_bool ( |
| 1151 |
val != FALSE); |
1971 |
root, DIALOGS_GCONF_DIR "/" DIALOGS_GCONF_UNFOCUSED_RS, val != FALSE); |
| 1152 |
} |
1972 |
} |
| 1153 |
|
1973 |
|
| 1154 |
void |
1974 |
void |
| 1155 |
gnm_gconf_set_autocomplete (gboolean val) |
1975 |
gnm_gconf_set_autocomplete (gboolean val) |
| 1156 |
{ |
1976 |
{ |
| 1157 |
prefs.auto_complete = val; |
1977 |
prefs.auto_complete = val; |
| 1158 |
go_conf_set_bool( GNM_CONF_GUI_ED_AUTOCOMPLETE, |
1978 |
go_conf_set_bool ( |
| 1159 |
val != FALSE); |
1979 |
root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_AUTOCOMPLETE, val != FALSE); |
| 1160 |
} |
1980 |
} |
| 1161 |
|
1981 |
|
| 1162 |
void |
1982 |
void |
| 1163 |
gnm_gconf_set_prefer_clipboard (gboolean val) |
1983 |
gnm_gconf_set_prefer_clipboard (gboolean val) |
| 1164 |
{ |
1984 |
{ |
| 1165 |
prefs.prefer_clipboard_selection = val; |
1985 |
prefs.prefer_clipboard_selection = val; |
| 1166 |
go_conf_set_bool( GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD, |
1986 |
go_conf_set_bool ( |
| 1167 |
val != FALSE); |
1987 |
root, GNM_CONF_CUTANDPASTE_DIR "/" GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD, val != FALSE); |
| 1168 |
} |
1988 |
} |
| 1169 |
|
|
|