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 int config_desktops_num;
13 GSList *config_desktops_names;
15 static void parse_focus(char *name, ParseToken *value)
17 if (!g_ascii_strcasecmp(name, "focusnew")) {
18 if (value->type != TOKEN_BOOL)
19 yyerror("invalid value");
21 config_focus_new = value->data.bool;
23 } else if (!g_ascii_strcasecmp(name, "followmouse")) {
24 if (value->type != TOKEN_BOOL)
25 yyerror("invalid value");
27 config_focus_follow = value->data.bool;
29 } else if (!g_ascii_strcasecmp(name, "focuslast")) {
30 if (value->type != TOKEN_BOOL)
31 yyerror("invalid value");
33 config_focus_last = value->data.bool;
35 } else if (!g_ascii_strcasecmp(name, "focuslastondesktop")) {
36 if (value->type != TOKEN_BOOL)
37 yyerror("invalid value");
39 config_focus_last_on_desktop = value->data.bool;
41 } else if (!g_ascii_strcasecmp(name, "cyclingdialog")) {
42 if (value->type != TOKEN_BOOL)
43 yyerror("invalid value");
45 config_focus_popup = value->data.bool;
48 yyerror("invalid option");
49 parse_free_token(value);
52 static void parse_theme(char *name, ParseToken *value)
54 if (!g_ascii_strcasecmp(name, "theme")) {
55 if (value->type != TOKEN_STRING)
56 yyerror("invalid value");
59 config_theme = g_strdup(value->data.string);
62 yyerror("invalid option");
63 parse_free_token(value);
66 static void parse_desktops(char *name, ParseToken *value)
70 if (!g_ascii_strcasecmp(name, "number")) {
71 if (value->type != TOKEN_INTEGER)
72 yyerror("invalid value");
74 config_desktops_num = value->data.integer;
76 } else if (!g_ascii_strcasecmp(name, "names")) {
77 if (value->type == TOKEN_LIST) {
78 for (it = value->data.list; it; it = it->next)
79 if (((ParseToken*)it->data)->type != TOKEN_STRING) break;
81 /* build a string list */
82 g_free(config_desktops_names);
83 for (it = value->data.list; it; it = it->next)
84 config_desktops_names =
85 g_slist_append(config_desktops_names,
87 (((ParseToken*)it->data)->data.string));
89 yyerror("invalid string in names list");
92 yyerror("syntax error (expected list of strings)");
95 yyerror("invalid option");
96 parse_free_token(value);
101 config_focus_new = TRUE;
102 config_focus_follow = FALSE;
103 config_focus_last = TRUE;
104 config_focus_last_on_desktop = TRUE;
105 config_focus_popup = TRUE;
107 parse_reg_section("focus", NULL, parse_focus);
111 parse_reg_section("theme", NULL, parse_theme);
113 config_desktops_num = 4;
114 config_desktops_names = NULL;
116 parse_reg_section("desktops", NULL, parse_desktops);
119 void config_shutdown()
123 g_free(config_theme);
125 for (it = config_desktops_names; it; it = it->next)
127 g_slist_free(config_desktops_names);