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 gboolean config_opaque_move;
16 gboolean config_opaque_resize;
18 static void parse_focus(char *name, ParseToken *value)
20 if (!g_ascii_strcasecmp(name, "focusnew")) {
21 if (value->type != TOKEN_BOOL)
22 yyerror("invalid value");
24 config_focus_new = value->data.bool;
26 } else if (!g_ascii_strcasecmp(name, "followmouse")) {
27 if (value->type != TOKEN_BOOL)
28 yyerror("invalid value");
30 config_focus_follow = value->data.bool;
32 } else if (!g_ascii_strcasecmp(name, "focuslast")) {
33 if (value->type != TOKEN_BOOL)
34 yyerror("invalid value");
36 config_focus_last = value->data.bool;
38 } else if (!g_ascii_strcasecmp(name, "focuslastondesktop")) {
39 if (value->type != TOKEN_BOOL)
40 yyerror("invalid value");
42 config_focus_last_on_desktop = value->data.bool;
44 } else if (!g_ascii_strcasecmp(name, "cyclingdialog")) {
45 if (value->type != TOKEN_BOOL)
46 yyerror("invalid value");
48 config_focus_popup = value->data.bool;
51 yyerror("invalid option");
52 parse_free_token(value);
55 static void parse_theme(char *name, ParseToken *value)
57 if (!g_ascii_strcasecmp(name, "theme")) {
58 if (value->type != TOKEN_STRING)
59 yyerror("invalid value");
62 config_theme = g_strdup(value->data.string);
65 yyerror("invalid option");
66 parse_free_token(value);
69 static void parse_desktops(char *name, ParseToken *value)
73 if (!g_ascii_strcasecmp(name, "number")) {
74 if (value->type != TOKEN_INTEGER)
75 yyerror("invalid value");
77 config_desktops_num = value->data.integer;
79 } else if (!g_ascii_strcasecmp(name, "names")) {
80 if (value->type == TOKEN_LIST) {
81 for (it = value->data.list; it; it = it->next)
82 if (((ParseToken*)it->data)->type != TOKEN_STRING) break;
84 /* build a string list */
85 g_free(config_desktops_names);
86 for (it = value->data.list; it; it = it->next)
87 config_desktops_names =
88 g_slist_append(config_desktops_names,
90 (((ParseToken*)it->data)->data.string));
92 yyerror("invalid string in names list");
95 yyerror("syntax error (expected list of strings)");
98 yyerror("invalid option");
99 parse_free_token(value);
102 static void parse_moveresize(char *name, ParseToken *value)
104 if (!g_ascii_strcasecmp(name, "opaque_move")) {
105 if (value->type != TOKEN_BOOL)
106 yyerror("invalid value");
108 config_opaque_move = value->data.integer;
110 } else if (!g_ascii_strcasecmp(name, "opaque_resize")) {
111 if (value->type != TOKEN_BOOL)
112 yyerror("invalid value");
114 config_opaque_resize = value->data.integer;
117 yyerror("invalid option");
118 parse_free_token(value);
121 void config_startup()
123 config_focus_new = TRUE;
124 config_focus_follow = FALSE;
125 config_focus_last = TRUE;
126 config_focus_last_on_desktop = TRUE;
127 config_focus_popup = TRUE;
129 parse_reg_section("focus", NULL, parse_focus);
133 parse_reg_section("theme", NULL, parse_theme);
135 config_desktops_num = 4;
136 config_desktops_names = NULL;
138 parse_reg_section("desktops", NULL, parse_desktops);
140 config_opaque_move = TRUE;
141 config_opaque_resize = TRUE;
143 parse_reg_section("moveresize", NULL, parse_moveresize);
146 void config_shutdown()
150 g_free(config_theme);
152 for (it = config_desktops_names; it; it = it->next)
154 g_slist_free(config_desktops_names);