6 #include "parser/parse.h"
8 gboolean config_focus_new
;
9 gboolean config_focus_follow
;
10 gboolean config_focus_last
;
11 gboolean config_focus_last_on_desktop
;
12 gboolean config_focus_popup
;
13 gboolean config_desktop_popup
;
17 gchar
*config_title_layout
;
19 int config_desktops_num
;
20 GSList
*config_desktops_names
;
22 gboolean config_redraw_resize
;
24 ObStackingLayer config_dock_layer
;
25 gboolean config_dock_floating
;
26 ObDirection config_dock_pos
;
29 ObOrientation config_dock_orient
;
30 gboolean config_dock_hide
;
31 guint config_dock_hide_timeout
;
33 guint config_keyboard_reset_keycode
;
34 guint config_keyboard_reset_state
;
36 gint config_mouse_threshold
;
37 gint config_mouse_dclicktime
;
39 gchar
*config_menu_path
;
41 gchar
*expand_tilde(const gchar
*f
)
48 return g_strconcat(g_get_home_dir(), f
+1, NULL
);
54 <action name="ChangeDesktop">
61 static void parse_key(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
69 if ((n
= parse_find_node("chainQuitKey", node
))) {
70 key
= parse_string(doc
, n
);
71 translate_key(key
, &config_keyboard_reset_state
,
72 &config_keyboard_reset_keycode
);
76 n
= parse_find_node("keybind", node
);
78 if (parse_attr_string("key", n
, &key
)) {
79 keylist
= g_list_append(keylist
, key
);
81 parse_key(i
, doc
, n
->xmlChildrenNode
, keylist
);
83 it
= g_list_last(keylist
);
85 keylist
= g_list_delete_link(keylist
, it
);
87 n
= parse_find_node("keybind", n
->next
);
90 nact
= parse_find_node("action", node
);
92 if ((action
= action_parse(doc
, nact
))) {
93 /* validate that its okay for a key binding */
94 if (action
->func
== action_moveresize
&&
95 action
->data
.moveresize
.corner
!=
96 prop_atoms
.net_wm_moveresize_move_keyboard
&&
97 action
->data
.moveresize
.corner
!=
98 prop_atoms
.net_wm_moveresize_size_keyboard
) {
104 keyboard_bind(keylist
, action
);
106 nact
= parse_find_node("action", nact
->next
);
111 static void parse_keyboard(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
114 parse_key(i
, doc
, node
->xmlChildrenNode
, NULL
);
119 <context name="Titlebar">
120 <mousebind button="Left" action="Press">
121 <action name="Raise"></action>
127 static void parse_mouse(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
130 xmlNodePtr n
, nbut
, nact
;
136 node
= node
->xmlChildrenNode
;
138 if ((n
= parse_find_node("dragThreshold", node
)))
139 config_mouse_threshold
= parse_int(doc
, n
);
140 if ((n
= parse_find_node("doubleClickTime", node
)))
141 config_mouse_dclicktime
= parse_int(doc
, n
);
143 n
= parse_find_node("context", node
);
145 if (!parse_attr_string("name", n
, &contextstr
))
147 nbut
= parse_find_node("mousebind", n
->xmlChildrenNode
);
149 if (!parse_attr_string("button", nbut
, &buttonstr
))
151 if (parse_attr_contains("press", nbut
, "action"))
152 mact
= OB_MOUSE_ACTION_PRESS
;
153 else if (parse_attr_contains("release", nbut
, "action"))
154 mact
= OB_MOUSE_ACTION_RELEASE
;
155 else if (parse_attr_contains("click", nbut
, "action"))
156 mact
= OB_MOUSE_ACTION_CLICK
;
157 else if (parse_attr_contains("doubleclick", nbut
,"action"))
158 mact
= OB_MOUSE_ACTION_DOUBLE_CLICK
;
159 else if (parse_attr_contains("drag", nbut
, "action"))
160 mact
= OB_MOUSE_ACTION_MOTION
;
163 nact
= parse_find_node("action", nbut
->xmlChildrenNode
);
165 if ((action
= action_parse(doc
, nact
))) {
166 /* validate that its okay for a mouse binding*/
167 if (mact
== OB_MOUSE_ACTION_MOTION
) {
168 if (action
->func
!= action_moveresize
||
169 action
->data
.moveresize
.corner
==
170 prop_atoms
.net_wm_moveresize_move_keyboard
||
171 action
->data
.moveresize
.corner
==
172 prop_atoms
.net_wm_moveresize_size_keyboard
) {
177 if (action
->func
== action_moveresize
&&
178 action
->data
.moveresize
.corner
!=
179 prop_atoms
.net_wm_moveresize_move_keyboard
&&
180 action
->data
.moveresize
.corner
!=
181 prop_atoms
.net_wm_moveresize_size_keyboard
) {
187 mouse_bind(buttonstr
, contextstr
, mact
, action
);
189 nact
= parse_find_node("action", nact
->next
);
193 nbut
= parse_find_node("mousebind", nbut
->next
);
197 n
= parse_find_node("context", n
->next
);
201 static void parse_focus(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
206 node
= node
->xmlChildrenNode
;
208 if ((n
= parse_find_node("focusNew", node
)))
209 config_focus_new
= parse_bool(doc
, n
);
210 if ((n
= parse_find_node("followMouse", node
)))
211 config_focus_follow
= parse_bool(doc
, n
);
212 if ((n
= parse_find_node("focusLast", node
)))
213 config_focus_last
= parse_bool(doc
, n
);
214 if ((n
= parse_find_node("focusLastOnDesktop", node
)))
215 config_focus_last_on_desktop
= parse_bool(doc
, n
);
216 if ((n
= parse_find_node("cyclingDialog", node
)))
217 config_focus_popup
= parse_bool(doc
, n
);
220 static void parse_theme(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
225 node
= node
->xmlChildrenNode
;
227 if ((n
= parse_find_node("theme", node
))) {
228 g_free(config_theme
);
229 config_theme
= parse_string(doc
, n
);
231 if ((n
= parse_find_node("titlelayout", node
))) {
232 g_free(config_title_layout
);
233 config_title_layout
= parse_string(doc
, n
);
237 static void parse_desktops(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
242 node
= node
->xmlChildrenNode
;
244 if ((n
= parse_find_node("number", node
)))
245 config_desktops_num
= parse_int(doc
, n
);
246 if ((n
= parse_find_node("names", node
))) {
250 for (it
= config_desktops_names
; it
; it
= it
->next
)
252 g_slist_free(config_desktops_names
);
253 config_desktops_names
= NULL
;
255 nname
= parse_find_node("name", n
->xmlChildrenNode
);
257 config_desktops_names
= g_slist_append(config_desktops_names
,
258 parse_string(doc
, nname
));
259 nname
= parse_find_node("name", nname
->next
);
262 if ((n
= parse_find_node("cyclingDialog", node
)))
263 config_desktop_popup
= parse_bool(doc
, n
);
266 static void parse_resize(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
271 node
= node
->xmlChildrenNode
;
273 if ((n
= parse_find_node("drawContents", node
)))
274 config_redraw_resize
= parse_bool(doc
, n
);
277 static void parse_dock(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
, void *d
)
281 node
= node
->xmlChildrenNode
;
283 if ((n
= parse_find_node("position", node
))) {
284 if (parse_contains("TopLeft", doc
, n
))
285 config_dock_floating
= FALSE
,
286 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
287 else if (parse_contains("Top", doc
, n
))
288 config_dock_floating
= FALSE
,
289 config_dock_pos
= OB_DIRECTION_NORTH
;
290 else if (parse_contains("TopRight", doc
, n
))
291 config_dock_floating
= FALSE
,
292 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
293 else if (parse_contains("Right", doc
, n
))
294 config_dock_floating
= FALSE
,
295 config_dock_pos
= OB_DIRECTION_EAST
;
296 else if (parse_contains("BottomRight", doc
, n
))
297 config_dock_floating
= FALSE
,
298 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
299 else if (parse_contains("Bottom", doc
, n
))
300 config_dock_floating
= FALSE
,
301 config_dock_pos
= OB_DIRECTION_SOUTH
;
302 else if (parse_contains("BottomLeft", doc
, n
))
303 config_dock_floating
= FALSE
,
304 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
305 else if (parse_contains("Left", doc
, n
))
306 config_dock_floating
= FALSE
,
307 config_dock_pos
= OB_DIRECTION_WEST
;
308 else if (parse_contains("Floating", doc
, n
))
309 config_dock_floating
= TRUE
;
311 if (config_dock_floating
) {
312 if ((n
= parse_find_node("floatingX", node
)))
313 config_dock_x
= parse_int(doc
, n
);
314 if ((n
= parse_find_node("floatingY", node
)))
315 config_dock_y
= parse_int(doc
, n
);
317 if ((n
= parse_find_node("stacking", node
))) {
318 if (parse_contains("top", doc
, n
))
319 config_dock_layer
= OB_STACKING_LAYER_TOP
;
320 else if (parse_contains("normal", doc
, n
))
321 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
322 else if (parse_contains("bottom", doc
, n
))
323 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
325 if ((n
= parse_find_node("direction", node
))) {
326 if (parse_contains("horizontal", doc
, n
))
327 config_dock_orient
= OB_ORIENTATION_HORZ
;
328 else if (parse_contains("vertical", doc
, n
))
329 config_dock_orient
= OB_ORIENTATION_VERT
;
331 if ((n
= parse_find_node("autoHide", node
)))
332 config_dock_hide
= parse_bool(doc
, n
);
333 if ((n
= parse_find_node("hideTimeout", node
)))
334 config_dock_hide_timeout
= parse_int(doc
, n
);
337 static void parse_menu(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
, void *d
)
341 node
= node
->xmlChildrenNode
;
342 if ((n
= parse_find_node("location", node
))) {
345 c
= parse_string(doc
, n
);
346 config_menu_path
= expand_tilde(c
);
351 void config_startup(ObParseInst
*i
)
353 config_focus_new
= TRUE
;
354 config_focus_follow
= FALSE
;
355 config_focus_last
= TRUE
;
356 config_focus_last_on_desktop
= TRUE
;
357 config_focus_popup
= TRUE
;
359 parse_register(i
, "focus", parse_focus
, NULL
);
363 config_title_layout
= g_strdup("NLIMC");
365 parse_register(i
, "theme", parse_theme
, NULL
);
367 config_desktops_num
= 4;
368 config_desktops_names
= NULL
;
369 config_desktop_popup
= TRUE
;
371 parse_register(i
, "desktops", parse_desktops
, NULL
);
373 config_redraw_resize
= TRUE
;
375 parse_register(i
, "resize", parse_resize
, NULL
);
377 config_dock_layer
= OB_STACKING_LAYER_TOP
;
378 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
379 config_dock_floating
= FALSE
;
382 config_dock_orient
= OB_ORIENTATION_VERT
;
383 config_dock_hide
= FALSE
;
384 config_dock_hide_timeout
= 3000;
386 parse_register(i
, "dock", parse_dock
, NULL
);
388 translate_key("C-g", &config_keyboard_reset_state
,
389 &config_keyboard_reset_keycode
);
391 parse_register(i
, "keyboard", parse_keyboard
, NULL
);
393 config_mouse_threshold
= 3;
394 config_mouse_dclicktime
= 200;
396 parse_register(i
, "mouse", parse_mouse
, NULL
);
398 config_menu_path
= NULL
;
400 parse_register(i
, "menu", parse_menu
, NULL
);
403 void config_shutdown()
407 g_free(config_theme
);
409 for (it
= config_desktops_names
; it
; it
= it
->next
)
411 g_slist_free(config_desktops_names
);