2 * Copyright (C) 2001, 2002 Anders Carlsson <andersca@gnu.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "gconf-util.h"
31 gconf_value_get_type (void)
33 static GType type = 0;
36 type = g_boxed_type_register_static ("GConfValue",
37 (GBoxedCopyFunc)gconf_value_copy,
38 (GBoxedFreeFunc)gconf_value_free);
45 gconf_get_key_name_from_path (const gchar *path)
49 /* FIXME: VALIDATE KEY */
51 ptr = path + strlen (path);
53 while (ptr[-1] != '/')
56 return g_strdup (ptr);
60 gconf_value_type_to_string (GConfValueType value_type)
63 case GCONF_VALUE_STRING:
64 return g_strdup ("String");
67 return g_strdup ("Integer");
69 case GCONF_VALUE_BOOL:
70 return g_strdup ("Boolean");
72 case GCONF_VALUE_LIST:
73 return g_strdup ("List");
76 return g_strdup_printf ("UNKNOWN, %d", value_type);
81 gconf_client_get_schema_for_key (GConfClient *client, const char *key)
84 const char *schema_name;
85 GConfSchema *schema = NULL;
87 entry = gconf_client_get_entry (client, key, NULL, TRUE, NULL);
88 schema_name = gconf_entry_get_schema_name (entry);
90 if (schema_name == NULL)
93 schema = gconf_client_get_schema (client, schema_name, NULL);
97 gconf_entry_free (entry);
103 can_edit_source (const char *source)
111 if (!(engine = gconf_engine_get_for_address (source, NULL)))
115 client = gconf_client_get_for_engine (engine);
116 entry = gconf_client_get_entry (client,
117 "/apps/gconf-editor/can_edit_source",
122 g_assert (entry == NULL);
123 g_error_free (error);
124 g_object_unref (client);
125 gconf_engine_unref (engine);
129 g_assert (entry != NULL);
131 retval = gconf_entry_get_is_writable (entry);
133 gconf_entry_unref (entry);
134 g_object_unref (client);
135 gconf_engine_unref (engine);
141 gconf_util_can_edit_defaults (void)
143 static int can_edit_defaults = GCONF_NOT_SET;
145 if (can_edit_defaults == GCONF_NOT_SET)
146 can_edit_defaults = can_edit_source (GCONF_DEFAULTS_SOURCE);
148 return can_edit_defaults;
152 gconf_util_can_edit_mandatory (void)
154 static int can_edit_mandatory = GCONF_NOT_SET;
156 if (can_edit_mandatory == GCONF_NOT_SET)
157 can_edit_mandatory = can_edit_source (GCONF_MANDATORY_SOURCE);
159 return can_edit_mandatory;