2 #include "parser/parse.h"
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
;
12 int config_desktops_num
;
13 GSList
*config_desktops_names
;
15 gboolean config_opaque_move
;
16 gboolean config_opaque_resize
;
18 StackLayer config_dock_layer
;
19 DockPosition config_dock_pos
;
22 gboolean config_dock_horz
;
23 gboolean config_dock_hide
;
24 guint config_dock_hide_timeout
;
26 static void parse_focus(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
30 if ((n
= parse_find_node("focusNew", node
)))
31 config_focus_new
= parse_bool(doc
, n
);
32 if ((n
= parse_find_node("followMouse", node
)))
33 config_focus_follow
= parse_bool(doc
, n
);
34 if ((n
= parse_find_node("focusLast", node
)))
35 config_focus_last
= parse_bool(doc
, n
);
36 if ((n
= parse_find_node("focusLastOnDesktop", node
)))
37 config_focus_last_on_desktop
= parse_bool(doc
, n
);
38 if ((n
= parse_find_node("cyclingDialog", node
)))
39 config_focus_popup
= parse_bool(doc
, n
);
42 static void parse_theme(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
46 if ((n
= parse_find_node("theme", node
))) {
48 config_theme
= parse_string(doc
, n
);
52 static void parse_desktops(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
56 if ((n
= parse_find_node("number", node
)))
57 config_desktops_num
= parse_int(doc
, n
);
58 if ((n
= parse_find_node("names", node
))) {
62 for (it
= config_desktops_names
; it
; it
= it
->next
)
64 g_slist_free(config_desktops_names
);
65 config_desktops_names
= NULL
;
67 nname
= parse_find_node("name", n
->xmlChildrenNode
);
69 config_desktops_names
= g_slist_append(config_desktops_names
,
70 parse_string(doc
, nname
));
71 nname
= parse_find_node("name", nname
->next
);
76 static void parse_moveresize(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
80 if ((n
= parse_find_node("opaqueMove", node
)))
81 config_opaque_move
= parse_bool(doc
, n
);
82 if ((n
= parse_find_node("opaqueResize", node
)))
83 config_opaque_resize
= parse_bool(doc
, n
);
86 static void parse_dock(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
90 if ((n
= parse_find_node("position", node
))) {
91 if (parse_contains("TopLeft", doc
, n
))
92 config_dock_pos
= DockPos_TopLeft
;
93 else if (parse_contains("Top", doc
, n
))
94 config_dock_pos
= DockPos_Top
;
95 else if (parse_contains("TopRight", doc
, n
))
96 config_dock_pos
= DockPos_TopRight
;
97 else if (parse_contains("Right", doc
, n
))
98 config_dock_pos
= DockPos_Right
;
99 else if (parse_contains("BottomRight", doc
, n
))
100 config_dock_pos
= DockPos_BottomRight
;
101 else if (parse_contains("Bottom", doc
, n
))
102 config_dock_pos
= DockPos_Bottom
;
103 else if (parse_contains("BottomLeft", doc
, n
))
104 config_dock_pos
= DockPos_BottomLeft
;
105 else if (parse_contains("Left", doc
, n
))
106 config_dock_pos
= DockPos_Left
;
107 else if (parse_contains("Floating", doc
, n
))
108 config_dock_pos
= DockPos_Floating
;
110 if (config_dock_pos
== DockPos_Floating
) {
111 if ((n
= parse_find_node("floatingX", node
)))
112 config_dock_x
= parse_int(doc
, n
);
113 if ((n
= parse_find_node("floatingY", node
)))
114 config_dock_y
= parse_int(doc
, n
);
116 if ((n
= parse_find_node("stacking", node
))) {
117 if (parse_contains("top", doc
, n
))
118 config_dock_layer
= Layer_Top
;
119 else if (parse_contains("normal", doc
, n
))
120 config_dock_layer
= Layer_Normal
;
121 else if (parse_contains("bottom", doc
, n
))
122 config_dock_layer
= Layer_Below
;
124 if ((n
= parse_find_node("direction", node
))) {
125 if (parse_contains("horizontal", doc
, n
))
126 config_dock_horz
= TRUE
;
127 else if (parse_contains("vertical", doc
, n
))
128 config_dock_horz
= FALSE
;
130 if ((n
= parse_find_node("autoHide", node
)))
131 config_dock_hide
= parse_bool(doc
, n
);
132 if ((n
= parse_find_node("hideTimeout", node
)))
133 config_dock_hide_timeout
= parse_int(doc
, n
);
136 void config_startup()
138 config_focus_new
= TRUE
;
139 config_focus_follow
= FALSE
;
140 config_focus_last
= TRUE
;
141 config_focus_last_on_desktop
= TRUE
;
142 config_focus_popup
= TRUE
;
144 parse_register("focus", parse_focus
, NULL
);
148 parse_register("theme", parse_theme
, NULL
);
150 config_desktops_num
= 4;
151 config_desktops_names
= NULL
;
153 parse_register("desktops", parse_desktops
, NULL
);
155 config_opaque_move
= TRUE
;
156 config_opaque_resize
= TRUE
;
158 parse_register("moveresize", parse_moveresize
, NULL
);
160 config_dock_layer
= Layer_Top
;
161 config_dock_pos
= DockPos_TopRight
;
164 config_dock_horz
= FALSE
;
165 config_dock_hide
= FALSE
;
166 config_dock_hide_timeout
= 3000;
168 parse_register("dock", parse_dock
, NULL
);
171 void config_shutdown()
175 g_free(config_theme
);
177 for (it
= config_desktops_names
; it
; it
= it
->next
)
179 g_slist_free(config_desktops_names
);