1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/* GConf
* Copyright (C) 1999 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gconf-schema.h"
GConfSchema*
gconf_schema_new(void)
{
GConfSchema* sc;
sc = g_new0(GConfSchema, 1);
sc->type = GCONF_VALUE_INVALID;
return sc;
}
void
gconf_schema_destroy(GConfSchema* sc)
{
if (sc->locale)
g_free(sc->locale);
if (sc->short_desc)
g_free(sc->short_desc);
if (sc->long_desc)
g_free(sc->long_desc);
if (sc->owner)
g_free(sc->owner);
if (sc->default_value)
gconf_value_destroy(sc->default_value);
g_free(sc);
}
GConfSchema*
gconf_schema_copy(GConfSchema* sc)
{
GConfSchema* dest;
dest = gconf_schema_new();
dest->type = sc->type;
dest->locale = sc->locale ? g_strdup(sc->locale) : NULL;
dest->short_desc = sc->short_desc ? g_strdup(sc->short_desc) : NULL;
dest->long_desc = sc->long_desc ? g_strdup(sc->long_desc) : NULL;
dest->owner = sc->owner ? g_strdup(sc->owner) : NULL;
dest->default_value = sc->default_value ? gconf_value_copy(sc->default_value) : NULL;
return dest;
}
void
gconf_schema_set_type(GConfSchema* sc, GConfValueType type)
{
sc->type = type;
}
void
gconf_schema_set_locale(GConfSchema* sc, const gchar* locale)
{
if (sc->locale)
g_free(sc->locale);
if (locale)
sc->locale = g_strdup(locale);
else
sc->locale = NULL;
}
void
gconf_schema_set_short_desc(GConfSchema* sc, const gchar* desc)
{
if (sc->short_desc)
g_free(sc->short_desc);
if (desc)
sc->short_desc = g_strdup(desc);
else
sc->short_desc = NULL;
}
void
gconf_schema_set_long_desc(GConfSchema* sc, const gchar* desc)
{
if (sc->long_desc)
g_free(sc->long_desc);
if (desc)
sc->long_desc = g_strdup(desc);
else
sc->long_desc = NULL;
}
void
gconf_schema_set_owner(GConfSchema* sc, const gchar* owner)
{
if (sc->owner)
g_free(sc->owner);
if (owner)
sc->owner = g_strdup(owner);
else
sc->owner = NULL;
}
void
gconf_schema_set_default_value(GConfSchema* sc, GConfValue* val)
{
if (sc->default_value != NULL)
gconf_value_destroy(sc->default_value);
sc->default_value = gconf_value_copy(val);
}
void
gconf_schema_set_default_value_nocopy(GConfSchema* sc, GConfValue* val)
{
if (sc->default_value != NULL)
gconf_value_destroy(sc->default_value);
sc->default_value = val;
}
|