]>
Dogcows Code - chaz/openbox/blob - openbox/config.c
7 static void config_free_entry(ConfigEntry
*entry
);
8 static void config_set_entry(char *name
, ConfigValueType type
,
10 static void config_def_free(ConfigDefEntry
*entry
);
12 static GData
*config
= NULL
;
13 static GData
*config_def
= NULL
;
15 /* provided by cparse.l */
16 void cparse_go(char *filename
, FILE *);
23 /* set up options exported by the kernel */
24 config_def_set(config_def_new("engine", Config_String
,
26 "The name of the theming engine to be used "
27 "to decorate windows."));
29 config_def_set(config_def_new("theme", Config_String
,
31 "The name of the theme to load with the "
34 config_def_set(config_def_new("font", Config_String
,
36 "The fontstring specifying the font to "
37 "be used in window titlebars."));
38 val
.string
= "Sans-7";
39 config_set("font", Config_String
, val
);
41 config_def_set(config_def_new("font.shadow", Config_Bool
,
42 "Titlebar Font Shadow",
43 "Whether or not the text in the window "
44 "titlebars gets a drop shadow."));
46 config_set("font.shadow", Config_Bool
, val
);
48 config_def_set(config_def_new("font.shadow.offset", Config_Integer
,
49 "Titlebar Font Shadow Offset",
50 "The offset of the drop shadow for text "
51 "in the window titlebars."));
53 config_set("font.shadow.offset", Config_Integer
, val
);
55 config_def_set(config_def_new("font.shadow.tint", Config_Integer
,
56 "Titlebar Font Shadow Tint",
57 "The percentage of tint/opacity to give the "
58 "the shadow(from -100(white) to "
61 config_set("font.shadow.tint", Config_Integer
, val
);
63 config_def_set(config_def_new("titlebar.layout", Config_String
,
65 "The ordering of the elements in the "
66 "window titlebars."));
67 val
.string
= "NDSLIMC";
68 config_set("titlebar.layout", Config_String
, val
);
70 config_def_set(config_def_new("focusNew", Config_Bool
,
72 "Focus windows when they first appear."));
74 config_set("focusNew", Config_Bool
, val
);
76 config_def_set(config_def_new("focusFollowsMouse", Config_Bool
,
77 "Focus Follows Mouse",
78 "Focus windows when the mouse pointer "
81 config_set("focusFollowsMouse", Config_Bool
, val
);
84 void config_shutdown()
86 g_datalist_clear(&config
);
87 g_datalist_clear(&config_def
);
90 gboolean
config_set(char *name
, ConfigValueType type
, ConfigValue value
)
95 name
= g_ascii_strdown(name
, -1);
97 def
= g_datalist_get_data(&config_def
, name
);
100 g_warning("Invalid config option '%s'", name
);
103 gboolean found
= FALSE
;
107 g_assert(it
!= NULL
);
109 if (g_ascii_strcasecmp(it
->data
, value
.string
) == 0) {
113 } while ((it
= it
->next
));
116 g_warning("Invalid value '%s' for config option '%s'",
120 } else if (type
!= def
->type
) {
121 g_warning("Incorrect type of value for config option '%s'", name
);
128 config_set_entry(name
, type
, value
);
135 gboolean
config_get(char *name
, ConfigValueType type
, ConfigValue
*value
)
138 gboolean ret
= FALSE
;
140 name
= g_ascii_strdown(name
, -1);
141 entry
= g_datalist_get_data(&config
, name
);
142 if (entry
!= NULL
&& entry
->type
== type
) {
143 *value
= entry
->value
;
150 static void config_set_entry(char *name
, ConfigValueType type
,
153 ConfigEntry
*entry
= NULL
;
155 entry
= g_new(ConfigEntry
, 1);
158 if (type
== Config_String
)
159 entry
->value
.string
= g_strdup(value
.string
);
161 entry
->value
= value
;
163 g_datalist_set_data_full(&config
, name
, entry
,
164 (GDestroyNotify
)config_free_entry
);
167 static void config_free_entry(ConfigEntry
*entry
)
171 if(entry
->type
== Config_String
) {
172 g_free(entry
->value
.string
);
173 entry
->value
.string
= NULL
;
178 ConfigDefEntry
*config_def_new(char *name
, ConfigValueType type
,
179 char *descriptive_name
, char *long_description
)
181 ConfigDefEntry
*entry
;
183 entry
= g_new(ConfigDefEntry
, 1);
184 entry
->name
= g_ascii_strdown(name
, -1);
185 entry
->descriptive_name
= g_strdup(descriptive_name
);
186 entry
->long_description
= g_strdup(long_description
);
187 entry
->hasList
= FALSE
;
189 entry
->values
= NULL
;
193 static void config_def_free(ConfigDefEntry
*entry
)
198 g_free(entry
->descriptive_name
);
199 g_free(entry
->long_description
);
200 if (entry
->hasList
) {
201 for (it
= entry
->values
; it
!= NULL
; it
= it
->next
)
203 g_slist_free(entry
->values
);
208 gboolean
config_def_add_value(ConfigDefEntry
*entry
, char *value
)
210 if (entry
->type
!= Config_String
) {
211 g_warning("Tried adding value to non-string config definition");
215 entry
->hasList
= TRUE
;
216 entry
->values
= g_slist_append(entry
->values
, g_ascii_strdown(value
, -1));
220 gboolean
config_def_set(ConfigDefEntry
*entry
)
222 gboolean ret
= FALSE
;
225 if ((def
= g_datalist_get_data(&config_def
, entry
->name
))) {
226 g_assert(def
!= entry
); /* adding it twice!? */
227 g_warning("Definition already set for config option '%s'. ",
229 config_def_free(entry
);
231 g_datalist_set_data_full(&config_def
, entry
->name
, entry
,
232 (GDestroyNotify
)config_def_free
);
This page took 0.042248 seconds and 4 git commands to generate.