]> Dogcows Code - chaz/openbox/blob - openbox/config.c
hardcode the button names for themes
[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 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(xmlDocPtr doc, xmlNodePtr node, void *d)
27 {
28 xmlNodePtr n;
29
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);
40 }
41
42 static void parse_theme(xmlDocPtr doc, xmlNodePtr node, void *d)
43 {
44 xmlNodePtr n;
45
46 if ((n = parse_find_node("theme", node))) {
47 g_free(config_theme);
48 config_theme = parse_string(doc, n);
49 }
50 }
51
52 static void parse_desktops(xmlDocPtr doc, xmlNodePtr node, void *d)
53 {
54 xmlNodePtr n;
55
56 if ((n = parse_find_node("number", node)))
57 config_desktops_num = parse_int(doc, n);
58 if ((n = parse_find_node("names", node))) {
59 GSList *it;
60 xmlNodePtr nname;
61
62 for (it = config_desktops_names; it; it = it->next)
63 g_free(it->data);
64 g_slist_free(config_desktops_names);
65 config_desktops_names = NULL;
66
67 nname = parse_find_node("name", n->xmlChildrenNode);
68 while (nname) {
69 config_desktops_names = g_slist_append(config_desktops_names,
70 parse_string(doc, nname));
71 nname = parse_find_node("name", nname->next);
72 }
73 }
74 }
75
76 static void parse_moveresize(xmlDocPtr doc, xmlNodePtr node, void *d)
77 {
78 xmlNodePtr n;
79
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);
84 }
85
86 static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d)
87 {
88 xmlNodePtr n;
89
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;
109 }
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);
115 }
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;
123 }
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;
129 }
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);
134 }
135
136 void config_startup()
137 {
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;
143
144 parse_register("focus", parse_focus, NULL);
145
146 config_theme = NULL;
147
148 parse_register("theme", parse_theme, NULL);
149
150 config_desktops_num = 4;
151 config_desktops_names = NULL;
152
153 parse_register("desktops", parse_desktops, NULL);
154
155 config_opaque_move = TRUE;
156 config_opaque_resize = TRUE;
157
158 parse_register("moveresize", parse_moveresize, NULL);
159
160 config_dock_layer = Layer_Top;
161 config_dock_pos = DockPos_TopRight;
162 config_dock_x = 0;
163 config_dock_y = 0;
164 config_dock_horz = FALSE;
165 config_dock_hide = FALSE;
166 config_dock_hide_timeout = 3000;
167
168 parse_register("dock", parse_dock, NULL);
169 }
170
171 void config_shutdown()
172 {
173 GSList *it;
174
175 g_free(config_theme);
176
177 for (it = config_desktops_names; it; it = it->next)
178 g_free(it->data);
179 g_slist_free(config_desktops_names);
180 }
This page took 0.047206 seconds and 4 git commands to generate.