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 gchar
*config_title_layout
;
14 int config_desktops_num
;
15 GSList
*config_desktops_names
;
17 gboolean config_redraw_resize
;
19 ObStackingLayer config_dock_layer
;
20 gboolean config_dock_floating
;
21 ObDirection config_dock_pos
;
24 ObOrientation config_dock_orient
;
25 gboolean config_dock_hide
;
26 guint config_dock_hide_timeout
;
28 static void parse_focus(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
32 node
= node
->xmlChildrenNode
;
34 if ((n
= parse_find_node("focusNew", node
)))
35 config_focus_new
= parse_bool(doc
, n
);
36 if ((n
= parse_find_node("followMouse", node
)))
37 config_focus_follow
= parse_bool(doc
, n
);
38 if ((n
= parse_find_node("focusLast", node
)))
39 config_focus_last
= parse_bool(doc
, n
);
40 if ((n
= parse_find_node("focusLastOnDesktop", node
)))
41 config_focus_last_on_desktop
= parse_bool(doc
, n
);
42 if ((n
= parse_find_node("cyclingDialog", node
)))
43 config_focus_popup
= parse_bool(doc
, n
);
46 static void parse_theme(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
50 node
= node
->xmlChildrenNode
;
52 if ((n
= parse_find_node("theme", node
))) {
54 config_theme
= parse_string(doc
, n
);
56 if ((n
= parse_find_node("titlelayout", node
))) {
57 g_free(config_title_layout
);
58 config_title_layout
= parse_string(doc
, n
);
62 static void parse_desktops(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
66 node
= node
->xmlChildrenNode
;
68 if ((n
= parse_find_node("number", node
)))
69 config_desktops_num
= parse_int(doc
, n
);
70 if ((n
= parse_find_node("names", node
))) {
74 for (it
= config_desktops_names
; it
; it
= it
->next
)
76 g_slist_free(config_desktops_names
);
77 config_desktops_names
= NULL
;
79 nname
= parse_find_node("name", n
->xmlChildrenNode
);
81 config_desktops_names
= g_slist_append(config_desktops_names
,
82 parse_string(doc
, nname
));
83 nname
= parse_find_node("name", nname
->next
);
88 static void parse_resize(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
92 node
= node
->xmlChildrenNode
;
94 if ((n
= parse_find_node("drawContents", node
)))
95 config_redraw_resize
= parse_bool(doc
, n
);
98 static void parse_dock(xmlDocPtr doc
, xmlNodePtr node
, void *d
)
102 node
= node
->xmlChildrenNode
;
104 if ((n
= parse_find_node("position", node
))) {
105 if (parse_contains("TopLeft", doc
, n
))
106 config_dock_floating
= FALSE
,
107 config_dock_pos
= OB_DIRECTION_NORTHWEST
;
108 else if (parse_contains("Top", doc
, n
))
109 config_dock_floating
= FALSE
,
110 config_dock_pos
= OB_DIRECTION_NORTH
;
111 else if (parse_contains("TopRight", doc
, n
))
112 config_dock_floating
= FALSE
,
113 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
114 else if (parse_contains("Right", doc
, n
))
115 config_dock_floating
= FALSE
,
116 config_dock_pos
= OB_DIRECTION_EAST
;
117 else if (parse_contains("BottomRight", doc
, n
))
118 config_dock_floating
= FALSE
,
119 config_dock_pos
= OB_DIRECTION_SOUTHEAST
;
120 else if (parse_contains("Bottom", doc
, n
))
121 config_dock_floating
= FALSE
,
122 config_dock_pos
= OB_DIRECTION_SOUTH
;
123 else if (parse_contains("BottomLeft", doc
, n
))
124 config_dock_floating
= FALSE
,
125 config_dock_pos
= OB_DIRECTION_SOUTHWEST
;
126 else if (parse_contains("Left", doc
, n
))
127 config_dock_floating
= FALSE
,
128 config_dock_pos
= OB_DIRECTION_WEST
;
129 else if (parse_contains("Floating", doc
, n
))
130 config_dock_floating
= TRUE
;
132 if (config_dock_floating
) {
133 if ((n
= parse_find_node("floatingX", node
)))
134 config_dock_x
= parse_int(doc
, n
);
135 if ((n
= parse_find_node("floatingY", node
)))
136 config_dock_y
= parse_int(doc
, n
);
138 if ((n
= parse_find_node("stacking", node
))) {
139 if (parse_contains("top", doc
, n
))
140 config_dock_layer
= OB_STACKING_LAYER_TOP
;
141 else if (parse_contains("normal", doc
, n
))
142 config_dock_layer
= OB_STACKING_LAYER_NORMAL
;
143 else if (parse_contains("bottom", doc
, n
))
144 config_dock_layer
= OB_STACKING_LAYER_BELOW
;
146 if ((n
= parse_find_node("direction", node
))) {
147 if (parse_contains("horizontal", doc
, n
))
148 config_dock_orient
= OB_ORIENTATION_HORZ
;
149 else if (parse_contains("vertical", doc
, n
))
150 config_dock_orient
= OB_ORIENTATION_VERT
;
152 if ((n
= parse_find_node("autoHide", node
)))
153 config_dock_hide
= parse_bool(doc
, n
);
154 if ((n
= parse_find_node("hideTimeout", node
)))
155 config_dock_hide_timeout
= parse_int(doc
, n
);
158 void config_startup()
160 config_focus_new
= TRUE
;
161 config_focus_follow
= FALSE
;
162 config_focus_last
= TRUE
;
163 config_focus_last_on_desktop
= TRUE
;
164 config_focus_popup
= TRUE
;
166 parse_register("focus", parse_focus
, NULL
);
170 config_title_layout
= g_strdup("NLIMC");
172 parse_register("theme", parse_theme
, NULL
);
174 config_desktops_num
= 4;
175 config_desktops_names
= NULL
;
177 parse_register("desktops", parse_desktops
, NULL
);
179 config_redraw_resize
= TRUE
;
181 parse_register("resize", parse_resize
, NULL
);
183 config_dock_layer
= OB_STACKING_LAYER_TOP
;
184 config_dock_pos
= OB_DIRECTION_NORTHEAST
;
185 config_dock_floating
= FALSE
;
188 config_dock_orient
= OB_ORIENTATION_VERT
;
189 config_dock_hide
= FALSE
;
190 config_dock_hide_timeout
= 3000;
192 parse_register("dock", parse_dock
, NULL
);
195 void config_shutdown()
199 g_free(config_theme
);
201 for (it
= config_desktops_names
; it
; it
= it
->next
)
203 g_slist_free(config_desktops_names
);