]> Dogcows Code - chaz/openbox/blob - openbox/config.c
prefixing and capitalizing the StackLayer -> ObStackingLayer enum.
[chaz/openbox] / openbox / config.c
1 #include "config.h"
2 #include "parser/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 ObStackingLayer config_dock_layer;
19 gboolean config_dock_floating;
20 ObDirection config_dock_pos;
21 gint config_dock_x;
22 gint config_dock_y;
23 ObOrientation config_dock_orient;
24 gboolean config_dock_hide;
25 guint config_dock_hide_timeout;
26
27 static void parse_focus(xmlDocPtr doc, xmlNodePtr node, void *d)
28 {
29 xmlNodePtr n;
30
31 if ((n = parse_find_node("focusNew", node)))
32 config_focus_new = parse_bool(doc, n);
33 if ((n = parse_find_node("followMouse", node)))
34 config_focus_follow = parse_bool(doc, n);
35 if ((n = parse_find_node("focusLast", node)))
36 config_focus_last = parse_bool(doc, n);
37 if ((n = parse_find_node("focusLastOnDesktop", node)))
38 config_focus_last_on_desktop = parse_bool(doc, n);
39 if ((n = parse_find_node("cyclingDialog", node)))
40 config_focus_popup = parse_bool(doc, n);
41 }
42
43 static void parse_theme(xmlDocPtr doc, xmlNodePtr node, void *d)
44 {
45 xmlNodePtr n;
46
47 if ((n = parse_find_node("theme", node))) {
48 g_free(config_theme);
49 config_theme = parse_string(doc, n);
50 }
51 }
52
53 static void parse_desktops(xmlDocPtr doc, xmlNodePtr node, void *d)
54 {
55 xmlNodePtr n;
56
57 if ((n = parse_find_node("number", node)))
58 config_desktops_num = parse_int(doc, n);
59 if ((n = parse_find_node("names", node))) {
60 GSList *it;
61 xmlNodePtr nname;
62
63 for (it = config_desktops_names; it; it = it->next)
64 g_free(it->data);
65 g_slist_free(config_desktops_names);
66 config_desktops_names = NULL;
67
68 nname = parse_find_node("name", n->xmlChildrenNode);
69 while (nname) {
70 config_desktops_names = g_slist_append(config_desktops_names,
71 parse_string(doc, nname));
72 nname = parse_find_node("name", nname->next);
73 }
74 }
75 }
76
77 static void parse_moveresize(xmlDocPtr doc, xmlNodePtr node, void *d)
78 {
79 xmlNodePtr n;
80
81 if ((n = parse_find_node("opaqueMove", node)))
82 config_opaque_move = parse_bool(doc, n);
83 if ((n = parse_find_node("opaqueResize", node)))
84 config_opaque_resize = parse_bool(doc, n);
85 }
86
87 static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d)
88 {
89 xmlNodePtr n;
90
91 if ((n = parse_find_node("position", node))) {
92 if (parse_contains("TopLeft", doc, n))
93 config_dock_floating = FALSE,
94 config_dock_pos = OB_DIRECTION_NORTHWEST;
95 else if (parse_contains("Top", doc, n))
96 config_dock_floating = FALSE,
97 config_dock_pos = OB_DIRECTION_NORTH;
98 else if (parse_contains("TopRight", doc, n))
99 config_dock_floating = FALSE,
100 config_dock_pos = OB_DIRECTION_NORTHEAST;
101 else if (parse_contains("Right", doc, n))
102 config_dock_floating = FALSE,
103 config_dock_pos = OB_DIRECTION_EAST;
104 else if (parse_contains("BottomRight", doc, n))
105 config_dock_floating = FALSE,
106 config_dock_pos = OB_DIRECTION_SOUTHEAST;
107 else if (parse_contains("Bottom", doc, n))
108 config_dock_floating = FALSE,
109 config_dock_pos = OB_DIRECTION_SOUTH;
110 else if (parse_contains("BottomLeft", doc, n))
111 config_dock_floating = FALSE,
112 config_dock_pos = OB_DIRECTION_SOUTHWEST;
113 else if (parse_contains("Left", doc, n))
114 config_dock_floating = FALSE,
115 config_dock_pos = OB_DIRECTION_WEST;
116 else if (parse_contains("Floating", doc, n))
117 config_dock_floating = TRUE;
118 }
119 if (config_dock_floating) {
120 if ((n = parse_find_node("floatingX", node)))
121 config_dock_x = parse_int(doc, n);
122 if ((n = parse_find_node("floatingY", node)))
123 config_dock_y = parse_int(doc, n);
124 }
125 if ((n = parse_find_node("stacking", node))) {
126 if (parse_contains("top", doc, n))
127 config_dock_layer = OB_STACKING_LAYER_TOP;
128 else if (parse_contains("normal", doc, n))
129 config_dock_layer = OB_STACKING_LAYER_NORMAL;
130 else if (parse_contains("bottom", doc, n))
131 config_dock_layer = OB_STACKING_LAYER_BELOW;
132 }
133 if ((n = parse_find_node("direction", node))) {
134 if (parse_contains("horizontal", doc, n))
135 config_dock_orient = OB_ORIENTATION_HORZ;
136 else if (parse_contains("vertical", doc, n))
137 config_dock_orient = OB_ORIENTATION_VERT;
138 }
139 if ((n = parse_find_node("autoHide", node)))
140 config_dock_hide = parse_bool(doc, n);
141 if ((n = parse_find_node("hideTimeout", node)))
142 config_dock_hide_timeout = parse_int(doc, n);
143 }
144
145 void config_startup()
146 {
147 config_focus_new = TRUE;
148 config_focus_follow = FALSE;
149 config_focus_last = TRUE;
150 config_focus_last_on_desktop = TRUE;
151 config_focus_popup = TRUE;
152
153 parse_register("focus", parse_focus, NULL);
154
155 config_theme = NULL;
156
157 parse_register("theme", parse_theme, NULL);
158
159 config_desktops_num = 4;
160 config_desktops_names = NULL;
161
162 parse_register("desktops", parse_desktops, NULL);
163
164 config_opaque_move = TRUE;
165 config_opaque_resize = TRUE;
166
167 parse_register("moveresize", parse_moveresize, NULL);
168
169 config_dock_layer = OB_STACKING_LAYER_TOP;
170 config_dock_pos = OB_DIRECTION_NORTHEAST;
171 config_dock_floating = FALSE;
172 config_dock_x = 0;
173 config_dock_y = 0;
174 config_dock_orient = OB_ORIENTATION_VERT;
175 config_dock_hide = FALSE;
176 config_dock_hide_timeout = 3000;
177
178 parse_register("dock", parse_dock, NULL);
179 }
180
181 void config_shutdown()
182 {
183 GSList *it;
184
185 g_free(config_theme);
186
187 for (it = config_desktops_names; it; it = it->next)
188 g_free(it->data);
189 g_slist_free(config_desktops_names);
190 }
This page took 0.045155 seconds and 4 git commands to generate.