4 gboolean config_focus_new;
5 gboolean config_focus_follow;
6 gboolean config_focus_last;
7 gboolean config_focus_last_on_desktop;
9 char *config_engine_name;
10 char *config_engine_theme;
11 char *config_engine_layout;
12 char *config_engine_font;
13 gboolean config_engine_shadow;
14 int config_engine_shadow_offset;
15 int config_engine_shadow_tint;
17 int config_desktops_num;
18 GSList *config_desktops_names;
20 static void parse_focus(char *name, ParseToken *value)
22 if (!g_ascii_strcasecmp(name, "focusnew")) {
23 if (value->type != TOKEN_BOOL)
24 yyerror("invalid value");
26 config_focus_new = value->data.bool;
28 } else if (!g_ascii_strcasecmp(name, "followmouse")) {
29 if (value->type != TOKEN_BOOL)
30 yyerror("invalid value");
32 config_focus_follow = value->data.bool;
34 } else if (!g_ascii_strcasecmp(name, "focuslast")) {
35 if (value->type != TOKEN_BOOL)
36 yyerror("invalid value");
38 config_focus_last = value->data.bool;
40 } else if (!g_ascii_strcasecmp(name, "focuslastondesktop")) {
41 if (value->type != TOKEN_BOOL)
42 yyerror("invalid value");
44 config_focus_last_on_desktop = value->data.bool;
47 yyerror("invalid option");
48 parse_free_token(value);
51 static void parse_engine(char *name, ParseToken *value)
53 if (!g_ascii_strcasecmp(name, "engine")) {
54 if (value->type != TOKEN_STRING)
55 yyerror("invalid value");
57 g_free(config_engine_name);
58 config_engine_name = g_strdup(value->data.string);
60 } else if (!g_ascii_strcasecmp(name, "theme")) {
61 if (value->type != TOKEN_STRING)
62 yyerror("invalid value");
64 g_free(config_engine_theme);
65 config_engine_theme = g_strdup(value->data.string);
67 } else if (!g_ascii_strcasecmp(name, "titlebarlayout")) {
68 if (value->type != TOKEN_STRING)
69 yyerror("invalid value");
71 g_free(config_engine_layout);
72 config_engine_layout = g_strdup(value->data.string);
74 } else if (!g_ascii_strcasecmp(name, "font.title")) {
75 if (value->type != TOKEN_STRING)
76 yyerror("invalid value");
78 g_free(config_engine_font);
79 config_engine_font = g_strdup(value->data.string);
81 } else if (!g_ascii_strcasecmp(name, "font.title.shadow")) {
82 if (value->type != TOKEN_BOOL)
83 yyerror("invalid value");
85 config_engine_shadow = value->data.bool;
87 } else if (!g_ascii_strcasecmp(name, "font.title.shadow.offset")) {
88 if (value->type != TOKEN_INTEGER)
89 yyerror("invalid value");
91 config_engine_shadow_offset = value->data.integer;
93 } else if (!g_ascii_strcasecmp(name, "font.title.shadow.tint")) {
94 if (value->type != TOKEN_INTEGER)
95 yyerror("invalid value");
97 config_engine_shadow_tint = value->data.integer;
98 if (config_engine_shadow_tint < -100)
99 config_engine_shadow_tint = -100;
100 else if (config_engine_shadow_tint > 100)
101 config_engine_shadow_tint = 100;
104 yyerror("invalid option");
105 parse_free_token(value);
108 static void parse_desktops(char *name, ParseToken *value)
112 if (!g_ascii_strcasecmp(name, "number")) {
113 if (value->type != TOKEN_INTEGER)
114 yyerror("invalid value");
116 config_desktops_num = value->data.integer;
118 } else if (!g_ascii_strcasecmp(name, "names")) {
119 if (value->type == TOKEN_LIST) {
120 for (it = value->data.list; it; it = it->next)
121 if (((ParseToken*)it->data)->type != TOKEN_STRING) break;
123 /* build a string list */
124 g_free(config_desktops_names);
125 for (it = value->data.list; it; it = it->next)
126 config_desktops_names =
127 g_slist_append(config_desktops_names,
129 (((ParseToken*)it->data)->data.string));
131 yyerror("invalid string in names list");
134 yyerror("syntax error (expected list of strings)");
137 yyerror("invalid option");
138 parse_free_token(value);
141 void config_startup()
143 config_focus_new = TRUE;
144 config_focus_follow = FALSE;
145 config_focus_last = TRUE;
146 config_focus_last_on_desktop = TRUE;
148 parse_reg_section("focus", NULL, parse_focus);
150 config_engine_name = g_strdup(DEFAULT_ENGINE);
151 config_engine_theme = NULL;
152 config_engine_layout = g_strdup("NLIMC");
153 config_engine_font = g_strdup("Sans-7");
154 config_engine_shadow = FALSE;
155 config_engine_shadow_offset = 1;
156 config_engine_shadow_tint = 25;
158 parse_reg_section("engine", NULL, parse_engine);
160 config_desktops_num = 4;
161 config_desktops_names = NULL;
163 parse_reg_section("desktops", NULL, parse_desktops);
166 void config_shutdown()
170 g_free(config_engine_name);
171 g_free(config_engine_layout);
172 g_free(config_engine_font);
174 for (it = config_desktops_names; it; it = it->next)
176 g_slist_free(config_desktops_names);