mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-20 08:11:56 +00:00
work around fatal API flaw in gconf, so we can detect whether ints/bools are set before we substitute default values
This commit is contained in:
parent
855a3a8d2f
commit
a66f4e1157
|
@ -1,3 +1,11 @@
|
||||||
|
2000-09-07 Robey Pointer <robey@eazel.com>
|
||||||
|
|
||||||
|
* components/services/install/lib/eazel-install-metadata.c:
|
||||||
|
(get_conf_string), (get_conf_int), (get_conf_boolean):
|
||||||
|
|
||||||
|
Work around fatal API flaw in gconf, so we can detect whether
|
||||||
|
ints/bools are set before we substitute default values.
|
||||||
|
|
||||||
2000-09-07 Andy Hertzfeld <andy@eazel.com>
|
2000-09-07 Andy Hertzfeld <andy@eazel.com>
|
||||||
|
|
||||||
* libnautilus-extensions/nautilus-icon-dnd.c:
|
* libnautilus-extensions/nautilus-icon-dnd.c:
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#define INSTALL_GCONF_PATH "/apps/eazel-trilobite/install"
|
#define INSTALL_GCONF_PATH "/apps/eazel-trilobite/install"
|
||||||
|
|
||||||
/* these are NOT reasonable defaults. */
|
/* these are NOT reasonable defaults. */
|
||||||
#define DEFAULT_SERVER "ham.eazel.com"
|
#define DEFAULT_SERVER "services.eazel.com"
|
||||||
#define DEFAULT_PORT 8888
|
#define DEFAULT_PORT 8888
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,6 +78,8 @@ get_conf_string (const char *key, const char *default_value)
|
||||||
value = gconf_get_string (conf_engine, full_key, NULL);
|
value = gconf_get_string (conf_engine, full_key, NULL);
|
||||||
if ((value == NULL) && (default_value != NULL)) {
|
if ((value == NULL) && (default_value != NULL)) {
|
||||||
value = g_strdup (default_value);
|
value = g_strdup (default_value);
|
||||||
|
/* write default value to gconf */
|
||||||
|
gconf_set_string (conf_engine, full_key, default_value, NULL);
|
||||||
}
|
}
|
||||||
g_free (full_key);
|
g_free (full_key);
|
||||||
return value;
|
return value;
|
||||||
|
@ -87,14 +89,21 @@ static int
|
||||||
get_conf_int (const char *key, int default_value)
|
get_conf_int (const char *key, int default_value)
|
||||||
{
|
{
|
||||||
char *full_key;
|
char *full_key;
|
||||||
int value;
|
GConfValue *value;
|
||||||
GConfError *error = NULL;
|
int out;
|
||||||
|
|
||||||
full_key = g_strdup_printf ("%s/%s", INSTALL_GCONF_PATH, key);
|
full_key = g_strdup_printf ("%s/%s", INSTALL_GCONF_PATH, key);
|
||||||
value = gconf_get_int (conf_engine, full_key, &error);
|
value = gconf_get (conf_engine, full_key, NULL);
|
||||||
if (error != NULL) {
|
if (value && (value->type == GCONF_VALUE_INT)) {
|
||||||
value = default_value;
|
out = gconf_value_int (value);
|
||||||
gconf_error_destroy (error);
|
gconf_value_destroy (value);
|
||||||
|
} else {
|
||||||
|
if (value) {
|
||||||
|
gconf_value_destroy (value);
|
||||||
|
}
|
||||||
|
out = default_value;
|
||||||
|
/* write default value to gconf */
|
||||||
|
gconf_set_int (conf_engine, full_key, default_value, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (full_key);
|
g_free (full_key);
|
||||||
|
@ -105,18 +114,26 @@ static gboolean
|
||||||
get_conf_boolean (const char *key, gboolean default_value)
|
get_conf_boolean (const char *key, gboolean default_value)
|
||||||
{
|
{
|
||||||
char *full_key;
|
char *full_key;
|
||||||
gboolean value;
|
GConfValue *value;
|
||||||
GConfError *error = NULL;
|
gboolean out;
|
||||||
|
|
||||||
full_key = g_strdup_printf ("%s/%s", INSTALL_GCONF_PATH, key);
|
full_key = g_strdup_printf ("%s/%s", INSTALL_GCONF_PATH, key);
|
||||||
value = gconf_get_bool (conf_engine, full_key, &error);
|
/* gconf API is so crappy that we can't use gconf_get_bool or anything nice */
|
||||||
if (error != NULL) {
|
value = gconf_get (conf_engine, full_key, NULL);
|
||||||
value = default_value;
|
if (value && (value->type == GCONF_VALUE_BOOL)) {
|
||||||
gconf_error_destroy (error);
|
out = gconf_value_bool (value);
|
||||||
|
gconf_value_destroy (value);
|
||||||
|
} else {
|
||||||
|
if (value) {
|
||||||
|
gconf_value_destroy (value);
|
||||||
|
}
|
||||||
|
out = default_value;
|
||||||
|
/* write default value to gconf */
|
||||||
|
gconf_set_bool (conf_engine, full_key, default_value, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (full_key);
|
g_free (full_key);
|
||||||
return value;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static URLType
|
static URLType
|
||||||
|
|
Loading…
Reference in a new issue