4 gboolean config_focus_new;
5 gboolean config_focus_follow;
6 gboolean config_focus_last;
7 gboolean config_focus_last_on_desktop;
11 int config_desktops_num;
12 GSList *config_desktops_names;
14 static void parse_focus(char *name, ParseToken *value)
16 if (!g_ascii_strcasecmp(name, "focusnew")) {
17 if (value->type != TOKEN_BOOL)
18 yyerror("invalid value");
20 config_focus_new = value->data.bool;
22 } else if (!g_ascii_strcasecmp(name, "followmouse")) {
23 if (value->type != TOKEN_BOOL)
24 yyerror("invalid value");
26 config_focus_follow = value->data.bool;
28 } else if (!g_ascii_strcasecmp(name, "focuslast")) {
29 if (value->type != TOKEN_BOOL)
30 yyerror("invalid value");
32 config_focus_last = value->data.bool;
34 } else if (!g_ascii_strcasecmp(name, "focuslastondesktop")) {
35 if (value->type != TOKEN_BOOL)
36 yyerror("invalid value");
38 config_focus_last_on_desktop = value->data.bool;
41 yyerror("invalid option");
42 parse_free_token(value);
45 static void parse_theme(char *name, ParseToken *value)
47 if (!g_ascii_strcasecmp(name, "theme")) {
48 if (value->type != TOKEN_STRING)
49 yyerror("invalid value");
52 config_theme = g_strdup(value->data.string);
55 yyerror("invalid option");
56 parse_free_token(value);
59 static void parse_desktops(char *name, ParseToken *value)
63 if (!g_ascii_strcasecmp(name, "number")) {
64 if (value->type != TOKEN_INTEGER)
65 yyerror("invalid value");
67 config_desktops_num = value->data.integer;
69 } else if (!g_ascii_strcasecmp(name, "names")) {
70 if (value->type == TOKEN_LIST) {
71 for (it = value->data.list; it; it = it->next)
72 if (((ParseToken*)it->data)->type != TOKEN_STRING) break;
74 /* build a string list */
75 g_free(config_desktops_names);
76 for (it = value->data.list; it; it = it->next)
77 config_desktops_names =
78 g_slist_append(config_desktops_names,
80 (((ParseToken*)it->data)->data.string));
82 yyerror("invalid string in names list");
85 yyerror("syntax error (expected list of strings)");
88 yyerror("invalid option");
89 parse_free_token(value);
94 config_focus_new = TRUE;
95 config_focus_follow = FALSE;
96 config_focus_last = TRUE;
97 config_focus_last_on_desktop = TRUE;
99 parse_reg_section("focus", NULL, parse_focus);
103 parse_reg_section("theme", NULL, parse_theme);
105 config_desktops_num = 4;
106 config_desktops_names = NULL;
108 parse_reg_section("desktops", NULL, parse_desktops);
111 void config_shutdown()
115 g_free(config_theme);
117 for (it = config_desktops_names; it; it = it->next)
119 g_slist_free(config_desktops_names);