]> Dogcows Code - chaz/openbox/blob - openbox/config.c
rename "Slit" to "Dock".
[chaz/openbox] / openbox / config.c
1 #include "config.h"
2 #include "parse.h"
3
4 gboolean config_focus_new;
5 gboolean config_focus_follow;
6 gboolean config_focus_last;
7 gboolean config_focus_last_on_desktop;
8 gboolean config_focus_popup;
9
10 char *config_theme;
11
12 int config_desktops_num;
13 GSList *config_desktops_names;
14
15 gboolean config_opaque_move;
16 gboolean config_opaque_resize;
17
18 StackLayer config_dock_layer;
19 DockPosition config_dock_pos;
20 int config_dock_x;
21 int config_dock_y;
22 gboolean config_dock_horz;
23 gboolean config_dock_hide;
24 guint config_dock_hide_timeout;
25
26 static void parse_focus(char *name, ParseToken *value)
27 {
28 if (!g_ascii_strcasecmp(name, "focusnew")) {
29 if (value->type != TOKEN_BOOL)
30 yyerror("invalid value");
31 else {
32 config_focus_new = value->data.bool;
33 }
34 } else if (!g_ascii_strcasecmp(name, "followmouse")) {
35 if (value->type != TOKEN_BOOL)
36 yyerror("invalid value");
37 else {
38 config_focus_follow = value->data.bool;
39 }
40 } else if (!g_ascii_strcasecmp(name, "focuslast")) {
41 if (value->type != TOKEN_BOOL)
42 yyerror("invalid value");
43 else {
44 config_focus_last = value->data.bool;
45 }
46 } else if (!g_ascii_strcasecmp(name, "focuslastondesktop")) {
47 if (value->type != TOKEN_BOOL)
48 yyerror("invalid value");
49 else {
50 config_focus_last_on_desktop = value->data.bool;
51 }
52 } else if (!g_ascii_strcasecmp(name, "cyclingdialog")) {
53 if (value->type != TOKEN_BOOL)
54 yyerror("invalid value");
55 else {
56 config_focus_popup = value->data.bool;
57 }
58 } else
59 yyerror("invalid option");
60 parse_free_token(value);
61 }
62
63 static void parse_theme(char *name, ParseToken *value)
64 {
65 if (!g_ascii_strcasecmp(name, "theme")) {
66 if (value->type != TOKEN_STRING)
67 yyerror("invalid value");
68 else {
69 g_free(config_theme);
70 config_theme = g_strdup(value->data.string);
71 }
72 } else
73 yyerror("invalid option");
74 parse_free_token(value);
75 }
76
77 static void parse_desktops(char *name, ParseToken *value)
78 {
79 GList *it;
80
81 if (!g_ascii_strcasecmp(name, "number")) {
82 if (value->type != TOKEN_INTEGER)
83 yyerror("invalid value");
84 else {
85 config_desktops_num = value->data.integer;
86 }
87 } else if (!g_ascii_strcasecmp(name, "names")) {
88 if (value->type == TOKEN_LIST) {
89 for (it = value->data.list; it; it = it->next)
90 if (((ParseToken*)it->data)->type != TOKEN_STRING) break;
91 if (it == NULL) {
92 /* build a string list */
93 g_free(config_desktops_names);
94 for (it = value->data.list; it; it = it->next)
95 config_desktops_names =
96 g_slist_append(config_desktops_names,
97 g_strdup
98 (((ParseToken*)it->data)->data.string));
99 } else {
100 yyerror("invalid string in names list");
101 }
102 } else {
103 yyerror("syntax error (expected list of strings)");
104 }
105 } else
106 yyerror("invalid option");
107 parse_free_token(value);
108 }
109
110 static void parse_moveresize(char *name, ParseToken *value)
111 {
112 if (!g_ascii_strcasecmp(name, "opaque_move")) {
113 if (value->type != TOKEN_BOOL)
114 yyerror("invalid value");
115 else {
116 config_opaque_move = value->data.integer;
117 }
118 } else if (!g_ascii_strcasecmp(name, "opaque_resize")) {
119 if (value->type != TOKEN_BOOL)
120 yyerror("invalid value");
121 else {
122 config_opaque_resize = value->data.integer;
123 }
124 } else
125 yyerror("invalid option");
126 parse_free_token(value);
127 }
128
129 static void parse_dock(char *name, ParseToken *value)
130 {
131 if (!g_ascii_strcasecmp(name, "stacking")) {
132 if (value->type != TOKEN_STRING)
133 yyerror("invalid value");
134 else {
135 if (!g_ascii_strcasecmp(value->data.string, "bottom"))
136 config_dock_layer = Layer_Below;
137 else if (!g_ascii_strcasecmp(value->data.string, "normal"))
138 config_dock_layer = Layer_Normal;
139 else if (!g_ascii_strcasecmp(value->data.string, "top"))
140 config_dock_layer = Layer_Top;
141 else
142 yyerror("invalid layer");
143 }
144 } else if (!g_ascii_strcasecmp(name, "position")) {
145 if (value->type != TOKEN_STRING)
146 yyerror("invalid value");
147 else {
148 if (!g_ascii_strcasecmp(value->data.string, "topleft"))
149 config_dock_pos = DockPos_TopLeft;
150 else if (!g_ascii_strcasecmp(value->data.string, "top"))
151 config_dock_pos = DockPos_Top;
152 else if (!g_ascii_strcasecmp(value->data.string, "topright"))
153 config_dock_pos = DockPos_TopRight;
154 else if (!g_ascii_strcasecmp(value->data.string, "right"))
155 config_dock_pos = DockPos_Right;
156 else if (!g_ascii_strcasecmp(value->data.string, "bottomright"))
157 config_dock_pos = DockPos_BottomRight;
158 else if (!g_ascii_strcasecmp(value->data.string, "bottom"))
159 config_dock_pos = DockPos_Bottom;
160 else if (!g_ascii_strcasecmp(value->data.string, "bottomleft"))
161 config_dock_pos = DockPos_BottomLeft;
162 else if (!g_ascii_strcasecmp(value->data.string, "left"))
163 config_dock_pos = DockPos_Left;
164 else if (!g_ascii_strcasecmp(value->data.string, "floating"))
165 config_dock_pos = DockPos_Floating;
166 else
167 yyerror("invalid position");
168 }
169 } else if (!g_ascii_strcasecmp(name, "floatingx")) {
170 if (value->type != TOKEN_INTEGER)
171 yyerror("invalid value");
172 else {
173 config_dock_x = value->data.integer;
174 }
175 } else if (!g_ascii_strcasecmp(name, "floatingy")) {
176 if (value->type != TOKEN_INTEGER)
177 yyerror("invalid value");
178 else {
179 config_dock_y = value->data.integer;
180 }
181 } else if (!g_ascii_strcasecmp(name, "horizontal")) {
182 if (value->type != TOKEN_BOOL)
183 yyerror("invalid value");
184 else {
185 config_dock_horz = value->data.bool;
186 }
187 } else if (!g_ascii_strcasecmp(name, "autohide")) {
188 if (value->type != TOKEN_BOOL)
189 yyerror("invalid value");
190 else {
191 config_dock_hide = value->data.bool;
192 }
193 } else if (!g_ascii_strcasecmp(name, "hidetimeout")) {
194 if (value->type != TOKEN_INTEGER)
195 yyerror("invalid value");
196 else {
197 config_dock_hide_timeout = value->data.integer;
198 }
199 } else
200 yyerror("invalid option");
201 parse_free_token(value);
202 }
203
204 void config_startup()
205 {
206 config_focus_new = TRUE;
207 config_focus_follow = FALSE;
208 config_focus_last = TRUE;
209 config_focus_last_on_desktop = TRUE;
210 config_focus_popup = TRUE;
211
212 parse_reg_section("focus", NULL, parse_focus);
213
214 config_theme = NULL;
215
216 parse_reg_section("theme", NULL, parse_theme);
217
218 config_desktops_num = 4;
219 config_desktops_names = NULL;
220
221 parse_reg_section("desktops", NULL, parse_desktops);
222
223 config_opaque_move = TRUE;
224 config_opaque_resize = TRUE;
225
226 parse_reg_section("moveresize", NULL, parse_moveresize);
227
228 config_dock_layer = Layer_Top;
229 config_dock_pos = DockPos_TopRight;
230 config_dock_x = 0;
231 config_dock_y = 0;
232 config_dock_horz = FALSE;
233 config_dock_hide = FALSE;
234 config_dock_hide_timeout = 3000;
235
236 parse_reg_section("dock", NULL, parse_dock);
237 }
238
239 void config_shutdown()
240 {
241 GSList *it;
242
243 g_free(config_theme);
244
245 for (it = config_desktops_names; it; it = it->next)
246 g_free(it->data);
247 g_slist_free(config_desktops_names);
248 }
This page took 0.0444020000000001 seconds and 4 git commands to generate.