Merge lp:~compiz-team/compiz-compizconfig-gsettings/compiz-compizconfig-gsettings.fix_874815 into lp:compiz-compizconfig-gsettings
- compiz-compizconfig-gsettings.fix_874815
- Merge into trunk
Proposed by
Sam Spilsbury
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~compiz-team/compiz-compizconfig-gsettings/compiz-compizconfig-gsettings.fix_874815 | ||||
Merge into: | lp:compiz-compizconfig-gsettings | ||||
Diff against target: |
2275 lines (+2252/-0) (has conflicts) 2 files modified
src/gconf-integration.c (+957/-0) src/gsettings.c (+1295/-0) Text conflict in src/gconf-integration.c Text conflict in src/gsettings.c |
||||
To merge this branch: | bzr merge lp:~compiz-team/compiz-compizconfig-gsettings/compiz-compizconfig-gsettings.fix_874815 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sam Spilsbury | Pending | ||
Review via email: mp+79453@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-10-26.
Commit message
Description of the change
To post a comment you must log in.
- 159. By Sam Spilsbury
-
Fix conflicts
- 160. By Sam Spilsbury
-
Merge in changes from truncation branch
- 161. By Sam Spilsbury
-
More descriptive names
Unmerged revisions
- 161. By Sam Spilsbury
-
More descriptive names
- 160. By Sam Spilsbury
-
Merge in changes from truncation branch
- 159. By Sam Spilsbury
-
Fix conflicts
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/gconf-integration.c' | |||
2 | --- src/gconf-integration.c 2011-07-24 14:28:26 +0000 | |||
3 | +++ src/gconf-integration.c 2011-10-15 07:07:06 +0000 | |||
4 | @@ -1,3 +1,4 @@ | |||
5 | 1 | <<<<<<< TREE | ||
6 | 1 | /** | 2 | /** |
7 | 2 | * | 3 | * |
8 | 3 | * GSettings libccs backend | 4 | * GSettings libccs backend |
9 | @@ -952,3 +953,959 @@ | |||
10 | 952 | g_error_free (err); | 953 | g_error_free (err); |
11 | 953 | } | 954 | } |
12 | 954 | #endif | 955 | #endif |
13 | 956 | ======= | ||
14 | 957 | /** | ||
15 | 958 | * | ||
16 | 959 | * GSettings libccs backend | ||
17 | 960 | * | ||
18 | 961 | * gconf-integration.c | ||
19 | 962 | * | ||
20 | 963 | * Copyright (c) 2011 Canonical Ltd | ||
21 | 964 | * | ||
22 | 965 | * Based on the original compizconfig-backend-gconf | ||
23 | 966 | * | ||
24 | 967 | * Copyright (c) 2007 Danny Baumann <maniac@opencompositing.org> | ||
25 | 968 | * | ||
26 | 969 | * Parts of this code are taken from libberylsettings | ||
27 | 970 | * gconf backend, written by: | ||
28 | 971 | * | ||
29 | 972 | * Copyright (c) 2006 Robert Carr <racarr@opencompositing.org> | ||
30 | 973 | * Copyright (c) 2007 Dennis Kasprzyk <onestone@opencompositing.org> | ||
31 | 974 | * | ||
32 | 975 | * This program is free software; you can redistribute it and/or | ||
33 | 976 | * modify it under the terms of the GNU General Public License | ||
34 | 977 | * as published by the Free Software Foundation; either version 2 | ||
35 | 978 | * of the License, or (at your option) any later version. | ||
36 | 979 | * | ||
37 | 980 | * This program is distributed in the hope that it will be useful, | ||
38 | 981 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
39 | 982 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
40 | 983 | * GNU General Public License for more details. | ||
41 | 984 | * | ||
42 | 985 | * Authored By: | ||
43 | 986 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
44 | 987 | * | ||
45 | 988 | **/ | ||
46 | 989 | |||
47 | 990 | #include "gsettings.h" | ||
48 | 991 | #ifdef USE_GCONF | ||
49 | 992 | GConfClient *client = NULL; | ||
50 | 993 | guint gnomeGConfNotifyIds[NUM_WATCHED_DIRS]; | ||
51 | 994 | |||
52 | 995 | const SpecialOptionGConf specialOptions[] = { | ||
53 | 996 | {"run_key", "gnomecompat", FALSE, | ||
54 | 997 | METACITY "/global_keybindings/panel_run_dialog", OptionKey}, | ||
55 | 998 | {"main_menu_key", "gnomecompat", FALSE, | ||
56 | 999 | METACITY "/global_keybindings/panel_main_menu", OptionKey}, | ||
57 | 1000 | {"run_command_screenshot_key", "gnomecompat", FALSE, | ||
58 | 1001 | METACITY "/global_keybindings/run_command_screenshot", OptionKey}, | ||
59 | 1002 | {"run_command_window_screenshot_key", "gnomecompat", FALSE, | ||
60 | 1003 | METACITY "/global_keybindings/run_command_window_screenshot", OptionKey}, | ||
61 | 1004 | {"run_command_terminal_key", "gnomecompat", FALSE, | ||
62 | 1005 | METACITY "/global_keybindings/run_command_terminal", OptionKey}, | ||
63 | 1006 | |||
64 | 1007 | {"toggle_window_maximized_key", "core", FALSE, | ||
65 | 1008 | METACITY "/window_keybindings/toggle_maximized", OptionKey}, | ||
66 | 1009 | {"minimize_window_key", "core", FALSE, | ||
67 | 1010 | METACITY "/window_keybindings/minimize", OptionKey}, | ||
68 | 1011 | {"maximize_window_key", "core", FALSE, | ||
69 | 1012 | METACITY "/window_keybindings/maximize", OptionKey}, | ||
70 | 1013 | {"unmaximize_window_key", "core", FALSE, | ||
71 | 1014 | METACITY "/window_keybindings/unmaximize", OptionKey}, | ||
72 | 1015 | {"maximize_window_horizontally_key", "core", FALSE, | ||
73 | 1016 | METACITY "/window_keybindings/maximize_horizontally", OptionKey}, | ||
74 | 1017 | {"maximize_window_vertically_key", "core", FALSE, | ||
75 | 1018 | METACITY "/window_keybindings/maximize_vertically", OptionKey}, | ||
76 | 1019 | {"raise_window_key", "core", FALSE, | ||
77 | 1020 | METACITY "/window_keybindings/raise", OptionKey}, | ||
78 | 1021 | {"lower_window_key", "core", FALSE, | ||
79 | 1022 | METACITY "/window_keybindings/lower", OptionKey}, | ||
80 | 1023 | {"close_window_key", "core", FALSE, | ||
81 | 1024 | METACITY "/window_keybindings/close", OptionKey}, | ||
82 | 1025 | {"toggle_window_shaded_key", "core", FALSE, | ||
83 | 1026 | METACITY "/window_keybindings/toggle_shaded", OptionKey}, | ||
84 | 1027 | |||
85 | 1028 | {"show_desktop_key", "core", FALSE, | ||
86 | 1029 | METACITY "/global_keybindings/show_desktop", OptionKey}, | ||
87 | 1030 | |||
88 | 1031 | {"initiate_key", "move", FALSE, | ||
89 | 1032 | METACITY "/window_keybindings/begin_move", OptionKey}, | ||
90 | 1033 | {"initiate_key", "resize", FALSE, | ||
91 | 1034 | METACITY "/window_keybindings/begin_resize", OptionKey}, | ||
92 | 1035 | {"window_menu_key", "core", FALSE, | ||
93 | 1036 | METACITY "/window_keybindings/activate_window_menu", OptionKey}, | ||
94 | 1037 | |||
95 | 1038 | /* integration of Metacity's mouse_button_modifier option */ | ||
96 | 1039 | {"initiate_button", "move", FALSE, | ||
97 | 1040 | METACITY "/window_keybindings/begin_move", OptionSpecial}, | ||
98 | 1041 | {"initiate_button", "resize", FALSE, | ||
99 | 1042 | METACITY "/window_keybindings/begin_resize", OptionSpecial}, | ||
100 | 1043 | {"window_menu_button", "core", FALSE, | ||
101 | 1044 | METACITY "/window_keybindings/activate_window_menu", OptionSpecial}, | ||
102 | 1045 | {"mouse_button_modifier", NULL, FALSE, | ||
103 | 1046 | METACITY "/general/mouse_button_modifier", OptionSpecial}, | ||
104 | 1047 | /* integration of the Metacity's option to swap mouse buttons */ | ||
105 | 1048 | {"resize_with_right_button", NULL, FALSE, | ||
106 | 1049 | METACITY "/general/resize_with_right_button", OptionSpecial}, | ||
107 | 1050 | |||
108 | 1051 | {"visual_bell", "fade", TRUE, | ||
109 | 1052 | METACITY "/general/visual_bell", OptionBool}, | ||
110 | 1053 | {"fullscreen_visual_bell", "fade", TRUE, | ||
111 | 1054 | METACITY "/general/visual_bell_type", OptionSpecial}, | ||
112 | 1055 | |||
113 | 1056 | {"next_key", "staticswitcher", FALSE, | ||
114 | 1057 | METACITY "/global_keybindings/switch_windows", OptionKey}, | ||
115 | 1058 | {"prev_key", "staticswitcher", FALSE, | ||
116 | 1059 | METACITY "/global_keybindings/switch_windows_backward", OptionKey}, | ||
117 | 1060 | |||
118 | 1061 | {"toggle_sticky_key", "extrawm", FALSE, | ||
119 | 1062 | METACITY "/window_keybindings/toggle_on_all_workspaces", OptionKey}, | ||
120 | 1063 | {"toggle_fullscreen_key", "extrawm", FALSE, | ||
121 | 1064 | METACITY "/window_keybindings/toggle_fullscreen", OptionKey}, | ||
122 | 1065 | |||
123 | 1066 | {"command0", "commands", FALSE, | ||
124 | 1067 | METACITY "/keybinding_commands/command_1", OptionString}, | ||
125 | 1068 | {"command1", "commands", FALSE, | ||
126 | 1069 | METACITY "/keybinding_commands/command_2", OptionString}, | ||
127 | 1070 | {"command2", "commands", FALSE, | ||
128 | 1071 | METACITY "/keybinding_commands/command_3", OptionString}, | ||
129 | 1072 | {"command3", "commands", FALSE, | ||
130 | 1073 | METACITY "/keybinding_commands/command_4", OptionString}, | ||
131 | 1074 | {"command4", "commands", FALSE, | ||
132 | 1075 | METACITY "/keybinding_commands/command_5", OptionString}, | ||
133 | 1076 | {"command5", "commands", FALSE, | ||
134 | 1077 | METACITY "/keybinding_commands/command_6", OptionString}, | ||
135 | 1078 | {"command6", "commands", FALSE, | ||
136 | 1079 | METACITY "/keybinding_commands/command_7", OptionString}, | ||
137 | 1080 | {"command7", "commands", FALSE, | ||
138 | 1081 | METACITY "/keybinding_commands/command_8", OptionString}, | ||
139 | 1082 | {"command8", "commands", FALSE, | ||
140 | 1083 | METACITY "/keybinding_commands/command_9", OptionString}, | ||
141 | 1084 | {"command9", "commands", FALSE, | ||
142 | 1085 | METACITY "/keybinding_commands/command_10", OptionString}, | ||
143 | 1086 | {"command10", "commands", FALSE, | ||
144 | 1087 | METACITY "/keybinding_commands/command_11", OptionString}, | ||
145 | 1088 | {"command11", "commands", FALSE, | ||
146 | 1089 | METACITY "/keybinding_commands/command_12", OptionString}, | ||
147 | 1090 | |||
148 | 1091 | {"run_command0_key", "commands", FALSE, | ||
149 | 1092 | METACITY "/global_keybindings/run_command_1", OptionKey}, | ||
150 | 1093 | {"run_command1_key", "commands", FALSE, | ||
151 | 1094 | METACITY "/global_keybindings/run_command_2", OptionKey}, | ||
152 | 1095 | {"run_command2_key", "commands", FALSE, | ||
153 | 1096 | METACITY "/global_keybindings/run_command_3", OptionKey}, | ||
154 | 1097 | {"run_command3_key", "commands", FALSE, | ||
155 | 1098 | METACITY "/global_keybindings/run_command_4", OptionKey}, | ||
156 | 1099 | {"run_command4_key", "commands", FALSE, | ||
157 | 1100 | METACITY "/global_keybindings/run_command_5", OptionKey}, | ||
158 | 1101 | {"run_command5_key", "commands", FALSE, | ||
159 | 1102 | METACITY "/global_keybindings/run_command_6", OptionKey}, | ||
160 | 1103 | {"run_command6_key", "commands", FALSE, | ||
161 | 1104 | METACITY "/global_keybindings/run_command_7", OptionKey}, | ||
162 | 1105 | {"run_command7_key", "commands", FALSE, | ||
163 | 1106 | METACITY "/global_keybindings/run_command_8", OptionKey}, | ||
164 | 1107 | {"run_command8_key", "commands", FALSE, | ||
165 | 1108 | METACITY "/global_keybindings/run_command_9", OptionKey}, | ||
166 | 1109 | {"run_command9_key", "commands", FALSE, | ||
167 | 1110 | METACITY "/global_keybindings/run_command_10", OptionKey}, | ||
168 | 1111 | {"run_command10_key", "commands", FALSE, | ||
169 | 1112 | METACITY "/global_keybindings/run_command_11", OptionKey}, | ||
170 | 1113 | {"run_command11_key", "commands", FALSE, | ||
171 | 1114 | METACITY "/global_keybindings/run_command_12", OptionKey}, | ||
172 | 1115 | |||
173 | 1116 | {"rotate_to_1_key", "rotate", FALSE, | ||
174 | 1117 | METACITY "/global_keybindings/switch_to_workspace_1", OptionKey}, | ||
175 | 1118 | {"rotate_to_2_key", "rotate", FALSE, | ||
176 | 1119 | METACITY "/global_keybindings/switch_to_workspace_2", OptionKey}, | ||
177 | 1120 | {"rotate_to_3_key", "rotate", FALSE, | ||
178 | 1121 | METACITY "/global_keybindings/switch_to_workspace_3", OptionKey}, | ||
179 | 1122 | {"rotate_to_4_key", "rotate", FALSE, | ||
180 | 1123 | METACITY "/global_keybindings/switch_to_workspace_4", OptionKey}, | ||
181 | 1124 | {"rotate_to_5_key", "rotate", FALSE, | ||
182 | 1125 | METACITY "/global_keybindings/switch_to_workspace_5", OptionKey}, | ||
183 | 1126 | {"rotate_to_6_key", "rotate", FALSE, | ||
184 | 1127 | METACITY "/global_keybindings/switch_to_workspace_6", OptionKey}, | ||
185 | 1128 | {"rotate_to_7_key", "rotate", FALSE, | ||
186 | 1129 | METACITY "/global_keybindings/switch_to_workspace_7", OptionKey}, | ||
187 | 1130 | {"rotate_to_8_key", "rotate", FALSE, | ||
188 | 1131 | METACITY "/global_keybindings/switch_to_workspace_8", OptionKey}, | ||
189 | 1132 | {"rotate_to_9_key", "rotate", FALSE, | ||
190 | 1133 | METACITY "/global_keybindings/switch_to_workspace_9", OptionKey}, | ||
191 | 1134 | {"rotate_to_10_key", "rotate", FALSE, | ||
192 | 1135 | METACITY "/global_keybindings/switch_to_workspace_10", OptionKey}, | ||
193 | 1136 | {"rotate_to_11_key", "rotate", FALSE, | ||
194 | 1137 | METACITY "/global_keybindings/switch_to_workspace_11", OptionKey}, | ||
195 | 1138 | {"rotate_to_12_key", "rotate", FALSE, | ||
196 | 1139 | METACITY "/global_keybindings/switch_to_workspace_12", OptionKey}, | ||
197 | 1140 | |||
198 | 1141 | {"rotate_left_key", "rotate", FALSE, | ||
199 | 1142 | METACITY "/global_keybindings/switch_to_workspace_left", OptionKey}, | ||
200 | 1143 | {"rotate_right_key", "rotate", FALSE, | ||
201 | 1144 | METACITY "/global_keybindings/switch_to_workspace_right", OptionKey}, | ||
202 | 1145 | |||
203 | 1146 | {"switch_to_1_key", "vpswitch", FALSE, | ||
204 | 1147 | METACITY "/global_keybindings/switch_to_workspace_1", OptionKey}, | ||
205 | 1148 | {"switch_to_2_key", "vpswitch", FALSE, | ||
206 | 1149 | METACITY "/global_keybindings/switch_to_workspace_2", OptionKey}, | ||
207 | 1150 | {"switch_to_3_key", "vpswitch", FALSE, | ||
208 | 1151 | METACITY "/global_keybindings/switch_to_workspace_3", OptionKey}, | ||
209 | 1152 | {"switch_to_4_key", "vpswitch", FALSE, | ||
210 | 1153 | METACITY "/global_keybindings/switch_to_workspace_4", OptionKey}, | ||
211 | 1154 | {"switch_to_5_key", "vpswitch", FALSE, | ||
212 | 1155 | METACITY "/global_keybindings/switch_to_workspace_5", OptionKey}, | ||
213 | 1156 | {"switch_to_6_key", "vpswitch", FALSE, | ||
214 | 1157 | METACITY "/global_keybindings/switch_to_workspace_6", OptionKey}, | ||
215 | 1158 | {"switch_to_7_key", "vpswitch", FALSE, | ||
216 | 1159 | METACITY "/global_keybindings/switch_to_workspace_7", OptionKey}, | ||
217 | 1160 | {"switch_to_8_key", "vpswitch", FALSE, | ||
218 | 1161 | METACITY "/global_keybindings/switch_to_workspace_8", OptionKey}, | ||
219 | 1162 | {"switch_to_9_key", "vpswitch", FALSE, | ||
220 | 1163 | METACITY "/global_keybindings/switch_to_workspace_9", OptionKey}, | ||
221 | 1164 | {"switch_to_10_key", "vpswitch", FALSE, | ||
222 | 1165 | METACITY "/global_keybindings/switch_to_workspace_10", OptionKey}, | ||
223 | 1166 | {"switch_to_11_key", "vpswitch", FALSE, | ||
224 | 1167 | METACITY "/global_keybindings/switch_to_workspace_11", OptionKey}, | ||
225 | 1168 | {"switch_to_12_key", "vpswitch", FALSE, | ||
226 | 1169 | METACITY "/global_keybindings/switch_to_workspace_12", OptionKey}, | ||
227 | 1170 | |||
228 | 1171 | {"up_key", "wall", FALSE, | ||
229 | 1172 | METACITY "/global_keybindings/switch_to_workspace_up", OptionKey}, | ||
230 | 1173 | {"down_key", "wall", FALSE, | ||
231 | 1174 | METACITY "/global_keybindings/switch_to_workspace_down", OptionKey}, | ||
232 | 1175 | {"left_key", "wall", FALSE, | ||
233 | 1176 | METACITY "/global_keybindings/switch_to_workspace_left", OptionKey}, | ||
234 | 1177 | {"right_key", "wall", FALSE, | ||
235 | 1178 | METACITY "/global_keybindings/switch_to_workspace_right", OptionKey}, | ||
236 | 1179 | {"left_window_key", "wall", FALSE, | ||
237 | 1180 | METACITY "/window_keybindings/move_to_workspace_left", OptionKey}, | ||
238 | 1181 | {"right_window_key", "wall", FALSE, | ||
239 | 1182 | METACITY "/window_keybindings/move_to_workspace_right", OptionKey}, | ||
240 | 1183 | {"up_window_key", "wall", FALSE, | ||
241 | 1184 | METACITY "/window_keybindings/move_to_workspace_up", OptionKey}, | ||
242 | 1185 | {"down_window_key", "wall", FALSE, | ||
243 | 1186 | METACITY "/window_keybindings/move_to_workspace_down", OptionKey}, | ||
244 | 1187 | |||
245 | 1188 | {"put_topleft_key", "put", FALSE, | ||
246 | 1189 | METACITY "/window_keybindings/move_to_corner_nw", OptionKey}, | ||
247 | 1190 | {"put_topright_key", "put", FALSE, | ||
248 | 1191 | METACITY "/window_keybindings/move_to_corner_ne", OptionKey}, | ||
249 | 1192 | {"put_bottomleft_key", "put", FALSE, | ||
250 | 1193 | METACITY "/window_keybindings/move_to_corner_sw", OptionKey}, | ||
251 | 1194 | {"put_bottomright_key", "put", FALSE, | ||
252 | 1195 | METACITY "/window_keybindings/move_to_corner_se", OptionKey}, | ||
253 | 1196 | {"put_left_key", "put", FALSE, | ||
254 | 1197 | METACITY "/window_keybindings/move_to_side_w", OptionKey}, | ||
255 | 1198 | {"put_right_key", "put", FALSE, | ||
256 | 1199 | METACITY "/window_keybindings/move_to_side_e", OptionKey}, | ||
257 | 1200 | {"put_top_key", "put", FALSE, | ||
258 | 1201 | METACITY "/window_keybindings/move_to_side_n", OptionKey}, | ||
259 | 1202 | {"put_bottom_key", "put", FALSE, | ||
260 | 1203 | METACITY "/window_keybindings/move_to_side_s", OptionKey}, | ||
261 | 1204 | |||
262 | 1205 | {"rotate_to_1_window_key", "rotate", FALSE, | ||
263 | 1206 | METACITY "/window_keybindings/move_to_workspace_1", OptionKey}, | ||
264 | 1207 | {"rotate_to_2_window_key", "rotate", FALSE, | ||
265 | 1208 | METACITY "/window_keybindings/move_to_workspace_2", OptionKey}, | ||
266 | 1209 | {"rotate_to_3_window_key", "rotate", FALSE, | ||
267 | 1210 | METACITY "/window_keybindings/move_to_workspace_3", OptionKey}, | ||
268 | 1211 | {"rotate_to_4_window_key", "rotate", FALSE, | ||
269 | 1212 | METACITY "/window_keybindings/move_to_workspace_4", OptionKey}, | ||
270 | 1213 | {"rotate_to_5_window_key", "rotate", FALSE, | ||
271 | 1214 | METACITY "/window_keybindings/move_to_workspace_5", OptionKey}, | ||
272 | 1215 | {"rotate_to_6_window_key", "rotate", FALSE, | ||
273 | 1216 | METACITY "/window_keybindings/move_to_workspace_6", OptionKey}, | ||
274 | 1217 | {"rotate_to_7_window_key", "rotate", FALSE, | ||
275 | 1218 | METACITY "/window_keybindings/move_to_workspace_7", OptionKey}, | ||
276 | 1219 | {"rotate_to_8_window_key", "rotate", FALSE, | ||
277 | 1220 | METACITY "/window_keybindings/move_to_workspace_8", OptionKey}, | ||
278 | 1221 | {"rotate_to_9_window_key", "rotate", FALSE, | ||
279 | 1222 | METACITY "/window_keybindings/move_to_workspace_9", OptionKey}, | ||
280 | 1223 | {"rotate_to_10_window_key", "rotate", FALSE, | ||
281 | 1224 | METACITY "/window_keybindings/move_to_workspace_10", OptionKey}, | ||
282 | 1225 | {"rotate_to_11_window_key", "rotate", FALSE, | ||
283 | 1226 | METACITY "/window_keybindings/move_to_workspace_11", OptionKey}, | ||
284 | 1227 | {"rotate_to_12_window_key", "rotate", FALSE, | ||
285 | 1228 | METACITY "/window_keybindings/move_to_workspace_12", OptionKey}, | ||
286 | 1229 | |||
287 | 1230 | {"rotate_left_window_key", "rotate", FALSE, | ||
288 | 1231 | METACITY "/window_keybindings/move_to_workspace_left", OptionKey}, | ||
289 | 1232 | {"rotate_right_window_key", "rotate", FALSE, | ||
290 | 1233 | METACITY "/window_keybindings/move_to_workspace_right", OptionKey}, | ||
291 | 1234 | |||
292 | 1235 | {"command_screenshot", "gnomecompat", FALSE, | ||
293 | 1236 | METACITY "/keybinding_commands/command_screenshot", OptionString}, | ||
294 | 1237 | {"command_window_screenshot", "gnomecompat", FALSE, | ||
295 | 1238 | METACITY "/keybinding_commands/command_window_screenshot", OptionString}, | ||
296 | 1239 | {"command_terminal", "gnomecompat", FALSE, | ||
297 | 1240 | "/desktop/gnome/applications/terminal/exec", OptionString}, | ||
298 | 1241 | |||
299 | 1242 | {"current_viewport", "thumbnail", TRUE, | ||
300 | 1243 | "/apps/panel/applets/window_list/prefs/display_all_workspaces", | ||
301 | 1244 | OptionSpecial}, | ||
302 | 1245 | |||
303 | 1246 | {"autoraise", "core", FALSE, | ||
304 | 1247 | METACITY "/general/auto_raise", OptionBool}, | ||
305 | 1248 | {"autoraise_delay", "core", FALSE, | ||
306 | 1249 | METACITY "/general/auto_raise_delay", OptionInt}, | ||
307 | 1250 | {"raise_on_click", "core", FALSE, | ||
308 | 1251 | METACITY "/general/raise_on_click", OptionBool}, | ||
309 | 1252 | {"click_to_focus", "core", FALSE, | ||
310 | 1253 | METACITY "/general/focus_mode", OptionSpecial}, | ||
311 | 1254 | |||
312 | 1255 | {"audible_bell", "core", FALSE, | ||
313 | 1256 | METACITY "/general/audible_bell", OptionBool}, | ||
314 | 1257 | /*{"hsize", "core", TRUE, | ||
315 | 1258 | METACITY "/general/num_workspaces", OptionInt},*/ | ||
316 | 1259 | }; | ||
317 | 1260 | |||
318 | 1261 | static const char* watchedGConfGnomeDirectories[] = { | ||
319 | 1262 | METACITY, | ||
320 | 1263 | "/desktop/gnome/applications/terminal", | ||
321 | 1264 | "/apps/panel/applets/window_list/prefs" | ||
322 | 1265 | }; | ||
323 | 1266 | |||
324 | 1267 | #define N_SOPTIONS (sizeof (specialOptions) / sizeof (struct _SpecialOptionGConf)) | ||
325 | 1268 | |||
326 | 1269 | static CCSSetting * | ||
327 | 1270 | findDisplaySettingForPlugin (CCSContext *context, | ||
328 | 1271 | const char *plugin, | ||
329 | 1272 | const char *setting) | ||
330 | 1273 | { | ||
331 | 1274 | CCSPlugin *p; | ||
332 | 1275 | CCSSetting *s; | ||
333 | 1276 | |||
334 | 1277 | p = ccsFindPlugin (context, plugin); | ||
335 | 1278 | if (!p) | ||
336 | 1279 | return NULL; | ||
337 | 1280 | |||
338 | 1281 | s = ccsFindSetting (p, setting); | ||
339 | 1282 | if (!s) | ||
340 | 1283 | return NULL; | ||
341 | 1284 | |||
342 | 1285 | return s; | ||
343 | 1286 | } | ||
344 | 1287 | |||
345 | 1288 | Bool | ||
346 | 1289 | isGConfIntegratedOption (CCSSetting *setting, | ||
347 | 1290 | int *index) | ||
348 | 1291 | { | ||
349 | 1292 | unsigned int i; | ||
350 | 1293 | |||
351 | 1294 | for (i = 0; i < N_SOPTIONS; i++) | ||
352 | 1295 | { | ||
353 | 1296 | const SpecialOptionGConf *opt = &specialOptions[i]; | ||
354 | 1297 | |||
355 | 1298 | if (strcmp (setting->name, opt->settingName) != 0) | ||
356 | 1299 | continue; | ||
357 | 1300 | |||
358 | 1301 | if (setting->parent->name) | ||
359 | 1302 | { | ||
360 | 1303 | if (!opt->pluginName) | ||
361 | 1304 | continue; | ||
362 | 1305 | if (strcmp (setting->parent->name, opt->pluginName) != 0) | ||
363 | 1306 | continue; | ||
364 | 1307 | } | ||
365 | 1308 | else | ||
366 | 1309 | { | ||
367 | 1310 | if (opt->pluginName) | ||
368 | 1311 | continue; | ||
369 | 1312 | } | ||
370 | 1313 | |||
371 | 1314 | if (index) | ||
372 | 1315 | *index = i; | ||
373 | 1316 | |||
374 | 1317 | return TRUE; | ||
375 | 1318 | } | ||
376 | 1319 | |||
377 | 1320 | return FALSE; | ||
378 | 1321 | } | ||
379 | 1322 | |||
380 | 1323 | void | ||
381 | 1324 | gnomeGConfValueChanged (GConfClient *client, | ||
382 | 1325 | guint cnxn_id, | ||
383 | 1326 | GConfEntry *entry, | ||
384 | 1327 | gpointer user_data) | ||
385 | 1328 | { | ||
386 | 1329 | CCSContext *context = (CCSContext *)user_data; | ||
387 | 1330 | char *keyName = (char*) gconf_entry_get_key (entry); | ||
388 | 1331 | int i, last = 0, num = 0; | ||
389 | 1332 | Bool needInit = TRUE; | ||
390 | 1333 | |||
391 | 1334 | if (!ccsGetIntegrationEnabled (context)) | ||
392 | 1335 | return; | ||
393 | 1336 | |||
394 | 1337 | /* we have to loop multiple times here, because one Gnome | ||
395 | 1338 | option may be integrated with multiple Compiz options */ | ||
396 | 1339 | |||
397 | 1340 | while (1) | ||
398 | 1341 | { | ||
399 | 1342 | for (i = last, num = -1; i < N_SOPTIONS; i++) | ||
400 | 1343 | { | ||
401 | 1344 | if (strcmp (specialOptions[i].gnomeName, keyName) == 0) | ||
402 | 1345 | { | ||
403 | 1346 | num = i; | ||
404 | 1347 | last = i + 1; | ||
405 | 1348 | break; | ||
406 | 1349 | } | ||
407 | 1350 | } | ||
408 | 1351 | |||
409 | 1352 | if (num < 0) | ||
410 | 1353 | break; | ||
411 | 1354 | |||
412 | 1355 | if ((strcmp (specialOptions[num].settingName, | ||
413 | 1356 | "mouse_button_modifier") == 0) || | ||
414 | 1357 | (strcmp (specialOptions[num].settingName, | ||
415 | 1358 | "resize_with_right_button") == 0)) | ||
416 | 1359 | { | ||
417 | 1360 | CCSSetting *s; | ||
418 | 1361 | |||
419 | 1362 | if (needInit) | ||
420 | 1363 | { | ||
421 | 1364 | readInit (context); | ||
422 | 1365 | needInit = FALSE; | ||
423 | 1366 | } | ||
424 | 1367 | |||
425 | 1368 | s = findDisplaySettingForPlugin (context, "core", | ||
426 | 1369 | "window_menu_button"); | ||
427 | 1370 | if (s) | ||
428 | 1371 | readSetting (context, s); | ||
429 | 1372 | |||
430 | 1373 | s = findDisplaySettingForPlugin (context, "move", | ||
431 | 1374 | "initiate_button"); | ||
432 | 1375 | if (s) | ||
433 | 1376 | readSetting (context, s); | ||
434 | 1377 | |||
435 | 1378 | s = findDisplaySettingForPlugin (context, "resize", | ||
436 | 1379 | "initiate_button"); | ||
437 | 1380 | if (s) | ||
438 | 1381 | readSetting (context, s); | ||
439 | 1382 | } | ||
440 | 1383 | else | ||
441 | 1384 | { | ||
442 | 1385 | CCSPlugin *plugin = NULL; | ||
443 | 1386 | CCSSetting *setting; | ||
444 | 1387 | SpecialOptionGConf *opt = (SpecialOptionGConf *) &specialOptions[num]; | ||
445 | 1388 | |||
446 | 1389 | plugin = ccsFindPlugin (context, (char*) opt->pluginName); | ||
447 | 1390 | if (plugin) | ||
448 | 1391 | { | ||
449 | 1392 | for (i = 0; i < 1; i++) | ||
450 | 1393 | { | ||
451 | 1394 | setting = ccsFindSetting (plugin, (char*) opt->settingName); | ||
452 | 1395 | |||
453 | 1396 | if (setting) | ||
454 | 1397 | { | ||
455 | 1398 | if (needInit) | ||
456 | 1399 | { | ||
457 | 1400 | readInit (context); | ||
458 | 1401 | needInit = FALSE; | ||
459 | 1402 | } | ||
460 | 1403 | readSetting (context, setting); | ||
461 | 1404 | } | ||
462 | 1405 | |||
463 | 1406 | /* do not read display settings multiple | ||
464 | 1407 | times for multiscreen environments */ | ||
465 | 1408 | } | ||
466 | 1409 | } | ||
467 | 1410 | } | ||
468 | 1411 | } | ||
469 | 1412 | } | ||
470 | 1413 | |||
471 | 1414 | void | ||
472 | 1415 | initGConfClient (CCSContext *context) | ||
473 | 1416 | { | ||
474 | 1417 | int i; | ||
475 | 1418 | |||
476 | 1419 | client = gconf_client_get_default (); | ||
477 | 1420 | |||
478 | 1421 | for (i = 0; i < NUM_WATCHED_DIRS; i++) | ||
479 | 1422 | { | ||
480 | 1423 | gnomeGConfNotifyIds[i] = gconf_client_notify_add (client, | ||
481 | 1424 | watchedGConfGnomeDirectories[i], | ||
482 | 1425 | gnomeGConfValueChanged, context, | ||
483 | 1426 | NULL, NULL); | ||
484 | 1427 | gconf_client_add_dir (client, watchedGConfGnomeDirectories[i], | ||
485 | 1428 | GCONF_CLIENT_PRELOAD_NONE, NULL); | ||
486 | 1429 | } | ||
487 | 1430 | } | ||
488 | 1431 | |||
489 | 1432 | void | ||
490 | 1433 | finiGConfClient (void) | ||
491 | 1434 | { | ||
492 | 1435 | int i; | ||
493 | 1436 | |||
494 | 1437 | for (i = 0; i < NUM_WATCHED_DIRS; i++) | ||
495 | 1438 | { | ||
496 | 1439 | if (gnomeGConfNotifyIds[i]) | ||
497 | 1440 | { | ||
498 | 1441 | gconf_client_notify_remove (client, gnomeGConfNotifyIds[0]); | ||
499 | 1442 | gnomeGConfNotifyIds[i] = 0; | ||
500 | 1443 | } | ||
501 | 1444 | gconf_client_remove_dir (client, watchedGConfGnomeDirectories[i], NULL); | ||
502 | 1445 | } | ||
503 | 1446 | gconf_client_suggest_sync (client, NULL); | ||
504 | 1447 | |||
505 | 1448 | g_object_unref (client); | ||
506 | 1449 | client = NULL; | ||
507 | 1450 | } | ||
508 | 1451 | |||
509 | 1452 | static unsigned int | ||
510 | 1453 | getGnomeMouseButtonModifier(void) | ||
511 | 1454 | { | ||
512 | 1455 | unsigned int modMask = 0; | ||
513 | 1456 | GError *err = NULL; | ||
514 | 1457 | char *value; | ||
515 | 1458 | |||
516 | 1459 | value = gconf_client_get_string (client, | ||
517 | 1460 | METACITY "/general/mouse_button_modifier", | ||
518 | 1461 | &err); | ||
519 | 1462 | |||
520 | 1463 | if (err) | ||
521 | 1464 | { | ||
522 | 1465 | g_error_free (err); | ||
523 | 1466 | return 0; | ||
524 | 1467 | } | ||
525 | 1468 | |||
526 | 1469 | if (!value) | ||
527 | 1470 | return 0; | ||
528 | 1471 | |||
529 | 1472 | modMask = ccsStringToModifiers (value); | ||
530 | 1473 | g_free (value); | ||
531 | 1474 | |||
532 | 1475 | return modMask; | ||
533 | 1476 | } | ||
534 | 1477 | |||
535 | 1478 | static unsigned int | ||
536 | 1479 | getButtonBindingForSetting (CCSContext *context, | ||
537 | 1480 | const char *plugin, | ||
538 | 1481 | const char *setting) | ||
539 | 1482 | { | ||
540 | 1483 | CCSSetting *s; | ||
541 | 1484 | |||
542 | 1485 | s = findDisplaySettingForPlugin (context, plugin, setting); | ||
543 | 1486 | if (!s) | ||
544 | 1487 | return 0; | ||
545 | 1488 | |||
546 | 1489 | if (s->type != TypeButton) | ||
547 | 1490 | return 0; | ||
548 | 1491 | |||
549 | 1492 | return s->value->value.asButton.button; | ||
550 | 1493 | } | ||
551 | 1494 | |||
552 | 1495 | Bool | ||
553 | 1496 | readGConfIntegratedOption (CCSContext *context, | ||
554 | 1497 | CCSSetting *setting, | ||
555 | 1498 | int index) | ||
556 | 1499 | { | ||
557 | 1500 | GConfValue *gconfValue; | ||
558 | 1501 | GError *err = NULL; | ||
559 | 1502 | Bool ret = FALSE; | ||
560 | 1503 | |||
561 | 1504 | ret = readOption (setting); | ||
562 | 1505 | |||
563 | 1506 | gconfValue = gconf_client_get (client, | ||
564 | 1507 | specialOptions[index].gnomeName, | ||
565 | 1508 | &err); | ||
566 | 1509 | |||
567 | 1510 | if (err) | ||
568 | 1511 | { | ||
569 | 1512 | g_error_free (err); | ||
570 | 1513 | return FALSE; | ||
571 | 1514 | } | ||
572 | 1515 | |||
573 | 1516 | if (!gconfValue) | ||
574 | 1517 | return FALSE; | ||
575 | 1518 | |||
576 | 1519 | switch (specialOptions[index].type) { | ||
577 | 1520 | case OptionInt: | ||
578 | 1521 | if (gconfValue->type == GCONF_VALUE_INT) | ||
579 | 1522 | { | ||
580 | 1523 | guint value; | ||
581 | 1524 | |||
582 | 1525 | value = gconf_value_get_int (gconfValue); | ||
583 | 1526 | ccsSetInt (setting, value, TRUE); | ||
584 | 1527 | ret = TRUE; | ||
585 | 1528 | } | ||
586 | 1529 | break; | ||
587 | 1530 | case OptionBool: | ||
588 | 1531 | if (gconfValue->type == GCONF_VALUE_BOOL) | ||
589 | 1532 | { | ||
590 | 1533 | gboolean value; | ||
591 | 1534 | |||
592 | 1535 | value = gconf_value_get_bool (gconfValue); | ||
593 | 1536 | ccsSetBool (setting, value ? TRUE : FALSE, FALSE); | ||
594 | 1537 | ret = TRUE; | ||
595 | 1538 | } | ||
596 | 1539 | break; | ||
597 | 1540 | case OptionString: | ||
598 | 1541 | if (gconfValue->type == GCONF_VALUE_STRING) | ||
599 | 1542 | { | ||
600 | 1543 | const char *value; | ||
601 | 1544 | |||
602 | 1545 | value = gconf_value_get_string (gconfValue); | ||
603 | 1546 | if (value) | ||
604 | 1547 | { | ||
605 | 1548 | ccsSetString (setting, value, FALSE); | ||
606 | 1549 | ret = TRUE; | ||
607 | 1550 | } | ||
608 | 1551 | } | ||
609 | 1552 | break; | ||
610 | 1553 | case OptionKey: | ||
611 | 1554 | if (gconfValue->type == GCONF_VALUE_STRING) | ||
612 | 1555 | { | ||
613 | 1556 | const char *value; | ||
614 | 1557 | |||
615 | 1558 | value = gconf_value_get_string (gconfValue); | ||
616 | 1559 | if (value) | ||
617 | 1560 | { | ||
618 | 1561 | CCSSettingKeyValue key; | ||
619 | 1562 | |||
620 | 1563 | memset (&key, 0, sizeof (CCSSettingKeyValue)); | ||
621 | 1564 | ccsGetKey (setting, &key); | ||
622 | 1565 | if (ccsStringToKeyBinding (value, &key)) | ||
623 | 1566 | { | ||
624 | 1567 | ccsSetKey (setting, key, TRUE); | ||
625 | 1568 | ret = TRUE; | ||
626 | 1569 | } | ||
627 | 1570 | } | ||
628 | 1571 | } | ||
629 | 1572 | break; | ||
630 | 1573 | case OptionSpecial: | ||
631 | 1574 | { | ||
632 | 1575 | const char *settingName = specialOptions[index].settingName; | ||
633 | 1576 | const char *pluginName = specialOptions[index].pluginName; | ||
634 | 1577 | |||
635 | 1578 | if (strcmp (settingName, "current_viewport") == 0) | ||
636 | 1579 | { | ||
637 | 1580 | if (gconfValue->type == GCONF_VALUE_BOOL) | ||
638 | 1581 | { | ||
639 | 1582 | gboolean showAll; | ||
640 | 1583 | |||
641 | 1584 | showAll = gconf_value_get_bool (gconfValue); | ||
642 | 1585 | ccsSetBool (setting, !showAll, FALSE); | ||
643 | 1586 | ret = TRUE; | ||
644 | 1587 | } | ||
645 | 1588 | } | ||
646 | 1589 | else if (strcmp (settingName, "fullscreen_visual_bell") == 0) | ||
647 | 1590 | { | ||
648 | 1591 | if (gconfValue->type == GCONF_VALUE_STRING) | ||
649 | 1592 | { | ||
650 | 1593 | const char *value; | ||
651 | 1594 | |||
652 | 1595 | value = gconf_value_get_string (gconfValue); | ||
653 | 1596 | if (value) | ||
654 | 1597 | { | ||
655 | 1598 | Bool fullscreen; | ||
656 | 1599 | |||
657 | 1600 | fullscreen = strcmp (value, "fullscreen") == 0; | ||
658 | 1601 | ccsSetBool (setting, fullscreen, FALSE); | ||
659 | 1602 | ret = TRUE; | ||
660 | 1603 | } | ||
661 | 1604 | } | ||
662 | 1605 | } | ||
663 | 1606 | else if (strcmp (settingName, "click_to_focus") == 0) | ||
664 | 1607 | { | ||
665 | 1608 | if (gconfValue->type == GCONF_VALUE_STRING) | ||
666 | 1609 | { | ||
667 | 1610 | const char *focusMode; | ||
668 | 1611 | |||
669 | 1612 | focusMode = gconf_value_get_string (gconfValue); | ||
670 | 1613 | |||
671 | 1614 | if (focusMode) | ||
672 | 1615 | { | ||
673 | 1616 | Bool clickToFocus = (strcmp (focusMode, "click") == 0); | ||
674 | 1617 | ccsSetBool (setting, clickToFocus, FALSE); | ||
675 | 1618 | ret = TRUE; | ||
676 | 1619 | } | ||
677 | 1620 | } | ||
678 | 1621 | } | ||
679 | 1622 | else if (((strcmp (settingName, "initiate_button") == 0) && | ||
680 | 1623 | ((strcmp (pluginName, "move") == 0) || | ||
681 | 1624 | (strcmp (pluginName, "resize") == 0))) || | ||
682 | 1625 | ((strcmp (settingName, "window_menu_button") == 0) && | ||
683 | 1626 | (strcmp (pluginName, "core") == 0))) | ||
684 | 1627 | { | ||
685 | 1628 | gboolean resizeWithRightButton; | ||
686 | 1629 | CCSSettingButtonValue button; | ||
687 | 1630 | |||
688 | 1631 | memset (&button, 0, sizeof (CCSSettingButtonValue)); | ||
689 | 1632 | ccsGetButton (setting, &button); | ||
690 | 1633 | |||
691 | 1634 | button.buttonModMask = getGnomeMouseButtonModifier (); | ||
692 | 1635 | |||
693 | 1636 | resizeWithRightButton = | ||
694 | 1637 | gconf_client_get_bool (client, METACITY | ||
695 | 1638 | "/general/resize_with_right_button", | ||
696 | 1639 | &err); | ||
697 | 1640 | |||
698 | 1641 | if (strcmp (settingName, "window_menu_button") == 0) | ||
699 | 1642 | button.button = resizeWithRightButton ? 2 : 3; | ||
700 | 1643 | else if (strcmp (pluginName, "resize") == 0) | ||
701 | 1644 | button.button = resizeWithRightButton ? 3 : 2; | ||
702 | 1645 | else | ||
703 | 1646 | button.button = 1; | ||
704 | 1647 | |||
705 | 1648 | ccsSetButton (setting, button, FALSE); | ||
706 | 1649 | ret = TRUE; | ||
707 | 1650 | } | ||
708 | 1651 | } | ||
709 | 1652 | break; | ||
710 | 1653 | default: | ||
711 | 1654 | break; | ||
712 | 1655 | } | ||
713 | 1656 | |||
714 | 1657 | gconf_value_free (gconfValue); | ||
715 | 1658 | |||
716 | 1659 | return ret; | ||
717 | 1660 | } | ||
718 | 1661 | |||
719 | 1662 | static Bool | ||
720 | 1663 | setGnomeMouseButtonModifier (unsigned int modMask) | ||
721 | 1664 | { | ||
722 | 1665 | char *modifiers, *currentValue; | ||
723 | 1666 | GError *err = NULL; | ||
724 | 1667 | |||
725 | 1668 | modifiers = ccsModifiersToString (modMask); | ||
726 | 1669 | if (!modifiers) | ||
727 | 1670 | return FALSE; | ||
728 | 1671 | |||
729 | 1672 | currentValue = gconf_client_get_string (client, | ||
730 | 1673 | METACITY | ||
731 | 1674 | "/general/mouse_button_modifier", | ||
732 | 1675 | &err); | ||
733 | 1676 | if (err) | ||
734 | 1677 | { | ||
735 | 1678 | free (modifiers); | ||
736 | 1679 | g_error_free (err); | ||
737 | 1680 | return FALSE; | ||
738 | 1681 | } | ||
739 | 1682 | |||
740 | 1683 | if (!currentValue || (strcmp (currentValue, modifiers) != 0)) | ||
741 | 1684 | gconf_client_set_string (client, | ||
742 | 1685 | METACITY "/general/mouse_button_modifier", | ||
743 | 1686 | modifiers, NULL); | ||
744 | 1687 | if (currentValue) | ||
745 | 1688 | g_free (currentValue); | ||
746 | 1689 | |||
747 | 1690 | free (modifiers); | ||
748 | 1691 | |||
749 | 1692 | return TRUE; | ||
750 | 1693 | } | ||
751 | 1694 | |||
752 | 1695 | static void | ||
753 | 1696 | setButtonBindingForSetting (CCSContext *context, | ||
754 | 1697 | const char *plugin, | ||
755 | 1698 | const char *setting, | ||
756 | 1699 | unsigned int button, | ||
757 | 1700 | unsigned int buttonModMask) | ||
758 | 1701 | { | ||
759 | 1702 | CCSSetting *s; | ||
760 | 1703 | CCSSettingButtonValue value; | ||
761 | 1704 | |||
762 | 1705 | s = findDisplaySettingForPlugin (context, plugin, setting); | ||
763 | 1706 | if (!s) | ||
764 | 1707 | return; | ||
765 | 1708 | |||
766 | 1709 | if (s->type != TypeButton) | ||
767 | 1710 | return; | ||
768 | 1711 | |||
769 | 1712 | value = s->value->value.asButton; | ||
770 | 1713 | |||
771 | 1714 | if ((value.button != button) || (value.buttonModMask != buttonModMask)) | ||
772 | 1715 | { | ||
773 | 1716 | value.button = button; | ||
774 | 1717 | value.buttonModMask = buttonModMask; | ||
775 | 1718 | |||
776 | 1719 | ccsSetButton (s, value, FALSE); | ||
777 | 1720 | } | ||
778 | 1721 | } | ||
779 | 1722 | |||
780 | 1723 | void | ||
781 | 1724 | writeGConfIntegratedOption (CCSContext *context, | ||
782 | 1725 | CCSSetting *setting, | ||
783 | 1726 | int index) | ||
784 | 1727 | { | ||
785 | 1728 | GError *err = NULL; | ||
786 | 1729 | const char *optionName = specialOptions[index].gnomeName; | ||
787 | 1730 | |||
788 | 1731 | switch (specialOptions[index].type) | ||
789 | 1732 | { | ||
790 | 1733 | case OptionInt: | ||
791 | 1734 | { | ||
792 | 1735 | int newValue, currentValue; | ||
793 | 1736 | if (!ccsGetInt (setting, &newValue)) | ||
794 | 1737 | break; | ||
795 | 1738 | currentValue = gconf_client_get_int (client, optionName, &err); | ||
796 | 1739 | |||
797 | 1740 | if (!err && (currentValue != newValue)) | ||
798 | 1741 | gconf_client_set_int(client, specialOptions[index].gnomeName, | ||
799 | 1742 | newValue, NULL); | ||
800 | 1743 | } | ||
801 | 1744 | break; | ||
802 | 1745 | case OptionBool: | ||
803 | 1746 | { | ||
804 | 1747 | Bool newValue; | ||
805 | 1748 | gboolean currentValue; | ||
806 | 1749 | if (!ccsGetBool (setting, &newValue)) | ||
807 | 1750 | break; | ||
808 | 1751 | currentValue = gconf_client_get_bool (client, optionName, &err); | ||
809 | 1752 | |||
810 | 1753 | if (!err && ((currentValue && !newValue) || | ||
811 | 1754 | (!currentValue && newValue))) | ||
812 | 1755 | gconf_client_set_bool (client, specialOptions[index].gnomeName, | ||
813 | 1756 | newValue, NULL); | ||
814 | 1757 | } | ||
815 | 1758 | break; | ||
816 | 1759 | case OptionString: | ||
817 | 1760 | { | ||
818 | 1761 | char *newValue; | ||
819 | 1762 | gchar *currentValue; | ||
820 | 1763 | if (!ccsGetString (setting, &newValue)) | ||
821 | 1764 | break; | ||
822 | 1765 | currentValue = gconf_client_get_string (client, optionName, &err); | ||
823 | 1766 | |||
824 | 1767 | if (!err && currentValue) | ||
825 | 1768 | { | ||
826 | 1769 | if (strcmp (currentValue, newValue) != 0) | ||
827 | 1770 | gconf_client_set_string (client, optionName, | ||
828 | 1771 | newValue, NULL); | ||
829 | 1772 | g_free (currentValue); | ||
830 | 1773 | } | ||
831 | 1774 | } | ||
832 | 1775 | break; | ||
833 | 1776 | case OptionKey: | ||
834 | 1777 | { | ||
835 | 1778 | char *newValue; | ||
836 | 1779 | gchar *currentValue; | ||
837 | 1780 | |||
838 | 1781 | newValue = ccsKeyBindingToString (&setting->value->value.asKey); | ||
839 | 1782 | if (newValue) | ||
840 | 1783 | { | ||
841 | 1784 | if (strcmp (newValue, "Disabled") == 0) | ||
842 | 1785 | { | ||
843 | 1786 | /* Metacity doesn't like "Disabled", it wants "disabled" */ | ||
844 | 1787 | newValue[0] = 'd'; | ||
845 | 1788 | } | ||
846 | 1789 | |||
847 | 1790 | currentValue = gconf_client_get_string (client, | ||
848 | 1791 | optionName, &err); | ||
849 | 1792 | |||
850 | 1793 | if (!err && currentValue) | ||
851 | 1794 | { | ||
852 | 1795 | if (strcmp (currentValue, newValue) != 0) | ||
853 | 1796 | gconf_client_set_string (client, optionName, | ||
854 | 1797 | newValue, NULL); | ||
855 | 1798 | g_free (currentValue); | ||
856 | 1799 | } | ||
857 | 1800 | free (newValue); | ||
858 | 1801 | } | ||
859 | 1802 | } | ||
860 | 1803 | break; | ||
861 | 1804 | case OptionSpecial: | ||
862 | 1805 | { | ||
863 | 1806 | const char *settingName = specialOptions[index].settingName; | ||
864 | 1807 | const char *pluginName = specialOptions[index].pluginName; | ||
865 | 1808 | |||
866 | 1809 | if (strcmp (settingName, "current_viewport") == 0) | ||
867 | 1810 | { | ||
868 | 1811 | Bool currentViewport; | ||
869 | 1812 | |||
870 | 1813 | if (!ccsGetBool (setting, ¤tViewport)) | ||
871 | 1814 | break; | ||
872 | 1815 | |||
873 | 1816 | gconf_client_set_bool (client, optionName, | ||
874 | 1817 | !currentViewport, NULL); | ||
875 | 1818 | } | ||
876 | 1819 | else if (strcmp (settingName, "fullscreen_visual_bell") == 0) | ||
877 | 1820 | { | ||
878 | 1821 | Bool fullscreen; | ||
879 | 1822 | gchar *currentValue, *newValue; | ||
880 | 1823 | if (!ccsGetBool (setting, &fullscreen)) | ||
881 | 1824 | break; | ||
882 | 1825 | |||
883 | 1826 | newValue = fullscreen ? "fullscreen" : "frame_flash"; | ||
884 | 1827 | currentValue = gconf_client_get_string (client, | ||
885 | 1828 | optionName, &err); | ||
886 | 1829 | if (!err && currentValue) | ||
887 | 1830 | { | ||
888 | 1831 | if (strcmp (currentValue, newValue) != 0) | ||
889 | 1832 | gconf_client_set_string (client, optionName, | ||
890 | 1833 | newValue, NULL); | ||
891 | 1834 | g_free (currentValue); | ||
892 | 1835 | } | ||
893 | 1836 | } | ||
894 | 1837 | else if (strcmp (settingName, "click_to_focus") == 0) | ||
895 | 1838 | { | ||
896 | 1839 | Bool clickToFocus; | ||
897 | 1840 | gchar *newValue, *currentValue; | ||
898 | 1841 | if (!ccsGetBool (setting, &clickToFocus)) | ||
899 | 1842 | break; | ||
900 | 1843 | |||
901 | 1844 | newValue = clickToFocus ? "click" : "sloppy"; | ||
902 | 1845 | currentValue = gconf_client_get_string (client, | ||
903 | 1846 | optionName, &err); | ||
904 | 1847 | |||
905 | 1848 | if (!err && currentValue) | ||
906 | 1849 | { | ||
907 | 1850 | if (strcmp (currentValue, newValue) != 0) | ||
908 | 1851 | gconf_client_set_string (client, optionName, | ||
909 | 1852 | newValue, NULL); | ||
910 | 1853 | g_free (currentValue); | ||
911 | 1854 | } | ||
912 | 1855 | } | ||
913 | 1856 | else if (((strcmp (settingName, "initiate_button") == 0) && | ||
914 | 1857 | ((strcmp (pluginName, "move") == 0) || | ||
915 | 1858 | (strcmp (pluginName, "resize") == 0))) || | ||
916 | 1859 | ((strcmp (settingName, "window_menu_button") == 0) && | ||
917 | 1860 | (strcmp (pluginName, "core") == 0))) | ||
918 | 1861 | { | ||
919 | 1862 | unsigned int modMask; | ||
920 | 1863 | Bool resizeWithRightButton = FALSE; | ||
921 | 1864 | gboolean currentValue; | ||
922 | 1865 | |||
923 | 1866 | if ((getButtonBindingForSetting (context, "resize", | ||
924 | 1867 | "initiate_button") == 3) || | ||
925 | 1868 | (getButtonBindingForSetting (context, "core", | ||
926 | 1869 | "window_menu_button") == 2)) | ||
927 | 1870 | { | ||
928 | 1871 | resizeWithRightButton = TRUE; | ||
929 | 1872 | } | ||
930 | 1873 | |||
931 | 1874 | currentValue = | ||
932 | 1875 | gconf_client_get_bool (client, METACITY | ||
933 | 1876 | "/general/resize_with_right_button", | ||
934 | 1877 | &err); | ||
935 | 1878 | |||
936 | 1879 | if (!err && ((currentValue && !resizeWithRightButton) || | ||
937 | 1880 | (!currentValue && resizeWithRightButton))) | ||
938 | 1881 | { | ||
939 | 1882 | gconf_client_set_bool (client, | ||
940 | 1883 | METACITY | ||
941 | 1884 | "/general/resize_with_right_button", | ||
942 | 1885 | resizeWithRightButton, NULL); | ||
943 | 1886 | } | ||
944 | 1887 | |||
945 | 1888 | modMask = setting->value->value.asButton.buttonModMask; | ||
946 | 1889 | if (setGnomeMouseButtonModifier (modMask)) | ||
947 | 1890 | { | ||
948 | 1891 | setButtonBindingForSetting (context, "move", | ||
949 | 1892 | "initiate_button", 1, modMask); | ||
950 | 1893 | setButtonBindingForSetting (context, "resize", | ||
951 | 1894 | "initiate_button", | ||
952 | 1895 | resizeWithRightButton ? 3 : 2, | ||
953 | 1896 | modMask); | ||
954 | 1897 | setButtonBindingForSetting (context, "core", | ||
955 | 1898 | "window_menu_button", | ||
956 | 1899 | resizeWithRightButton ? 2 : 3, | ||
957 | 1900 | modMask); | ||
958 | 1901 | } | ||
959 | 1902 | } | ||
960 | 1903 | } | ||
961 | 1904 | break; | ||
962 | 1905 | } | ||
963 | 1906 | |||
964 | 1907 | if (err) | ||
965 | 1908 | g_error_free (err); | ||
966 | 1909 | } | ||
967 | 1910 | #endif | ||
968 | 1911 | >>>>>>> MERGE-SOURCE | ||
969 | 955 | 1912 | ||
970 | === modified file 'src/gsettings.c' | |||
971 | --- src/gsettings.c 2011-07-29 15:41:46 +0000 | |||
972 | +++ src/gsettings.c 2011-10-15 07:07:06 +0000 | |||
973 | @@ -1,3 +1,4 @@ | |||
974 | 1 | <<<<<<< TREE | ||
975 | 1 | /** | 2 | /** |
976 | 2 | * | 3 | * |
977 | 3 | * GSettings libccs backend | 4 | * GSettings libccs backend |
978 | @@ -1255,3 +1256,1297 @@ | |||
979 | 1255 | return &gsettingsVTable; | 1256 | return &gsettingsVTable; |
980 | 1256 | } | 1257 | } |
981 | 1257 | 1258 | ||
982 | 1259 | ======= | ||
983 | 1260 | /** | ||
984 | 1261 | * | ||
985 | 1262 | * GSettings libccs backend | ||
986 | 1263 | * | ||
987 | 1264 | * gsettings.c | ||
988 | 1265 | * | ||
989 | 1266 | * Copyright (c) 2011 Canonical Ltd | ||
990 | 1267 | * | ||
991 | 1268 | * Based on the original compizconfig-backend-gconf | ||
992 | 1269 | * | ||
993 | 1270 | * Copyright (c) 2007 Danny Baumann <maniac@opencompositing.org> | ||
994 | 1271 | * | ||
995 | 1272 | * Parts of this code are taken from libberylsettings | ||
996 | 1273 | * gconf backend, written by: | ||
997 | 1274 | * | ||
998 | 1275 | * Copyright (c) 2006 Robert Carr <racarr@opencompositing.org> | ||
999 | 1276 | * Copyright (c) 2007 Dennis Kasprzyk <onestone@opencompositing.org> | ||
1000 | 1277 | * | ||
1001 | 1278 | * This program is free software; you can redistribute it and/or | ||
1002 | 1279 | * modify it under the terms of the GNU General Public License | ||
1003 | 1280 | * as published by the Free Software Foundation; either version 2 | ||
1004 | 1281 | * of the License, or (at your option) any later version. | ||
1005 | 1282 | * | ||
1006 | 1283 | * This program is distributed in the hope that it will be useful, | ||
1007 | 1284 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1008 | 1285 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1009 | 1286 | * GNU General Public License for more details. | ||
1010 | 1287 | * | ||
1011 | 1288 | * Authored By: | ||
1012 | 1289 | * Sam Spilsbury <sam.spilsbury@canonical.com> | ||
1013 | 1290 | * | ||
1014 | 1291 | **/ | ||
1015 | 1292 | |||
1016 | 1293 | #include "gsettings.h" | ||
1017 | 1294 | |||
1018 | 1295 | static void | ||
1019 | 1296 | valueChanged (GSettings *settings, | ||
1020 | 1297 | gchar *keyname, | ||
1021 | 1298 | gpointer user_data); | ||
1022 | 1299 | |||
1023 | 1300 | static void | ||
1024 | 1301 | gnomeValueChanged (GSettings *settings, | ||
1025 | 1302 | gchar *keyname, | ||
1026 | 1303 | gpointer user_data); | ||
1027 | 1304 | |||
1028 | 1305 | static GList *settingsList = NULL; | ||
1029 | 1306 | static GSettings *compizconfigSettings = NULL; | ||
1030 | 1307 | static GSettings *currentProfileSettings = NULL; | ||
1031 | 1308 | static GList *watchedGnomeSettings = NULL; | ||
1032 | 1309 | |||
1033 | 1310 | char *currentProfile = NULL; | ||
1034 | 1311 | |||
1035 | 1312 | /* some forward declarations */ | ||
1036 | 1313 | static void writeIntegratedOption (CCSContext *context, | ||
1037 | 1314 | CCSSetting *setting, | ||
1038 | 1315 | int index); | ||
1039 | 1316 | |||
1040 | 1317 | typedef struct _SpecialOptionGSettings { | ||
1041 | 1318 | const char* settingName; | ||
1042 | 1319 | const char* pluginName; | ||
1043 | 1320 | const char* schemaName; | ||
1044 | 1321 | const char* keyName; | ||
1045 | 1322 | const char* type; | ||
1046 | 1323 | } SpecialOption; | ||
1047 | 1324 | |||
1048 | 1325 | static gchar * | ||
1049 | 1326 | getSchemaNameForPlugin (const char *plugin) | ||
1050 | 1327 | { | ||
1051 | 1328 | gchar *schemaName = NULL; | ||
1052 | 1329 | |||
1053 | 1330 | schemaName = g_strconcat (COMPIZ_SCHEMA_ID, ".", plugin, NULL); | ||
1054 | 1331 | |||
1055 | 1332 | return schemaName; | ||
1056 | 1333 | } | ||
1057 | 1334 | |||
1058 | 1335 | static inline gchar * | ||
1059 | 1336 | translateKeyForGSettings (char *gsettingName) | ||
1060 | 1337 | { | ||
1061 | 1338 | gchar *clean = NULL; | ||
1062 | 1339 | gchar **delimited = NULL; | ||
1063 | 1340 | guint i = 0; | ||
1064 | 1341 | |||
1065 | 1342 | /* Replace underscores with dashes */ | ||
1066 | 1343 | delimited = g_strsplit (gsettingName, "_", 0); | ||
1067 | 1344 | |||
1068 | 1345 | clean = g_strjoinv ("-", delimited); | ||
1069 | 1346 | |||
1070 | 1347 | /* It can't be more than 32 chars, warn if that's the case */ | ||
1071 | 1348 | gchar *ret = g_strndup (clean, 31); | ||
1072 | 1349 | |||
1073 | 1350 | if (strlen (clean) > 31) | ||
1074 | 1351 | printf ("GSettings Backend: Warning: key name %s is not valid in GSettings, it was changed to %s, this may cause problems!\n", clean, ret); | ||
1075 | 1352 | |||
1076 | 1353 | /* Everything must be lowercase */ | ||
1077 | 1354 | for (; i < strlen (ret); i++) | ||
1078 | 1355 | ret[i] = g_ascii_tolower (ret[i]); | ||
1079 | 1356 | |||
1080 | 1357 | g_free (clean); | ||
1081 | 1358 | g_strfreev (delimited); | ||
1082 | 1359 | |||
1083 | 1360 | return ret; | ||
1084 | 1361 | } | ||
1085 | 1362 | |||
1086 | 1363 | static inline gchar * | ||
1087 | 1364 | translateKeyForCCS (char *gsettingName) | ||
1088 | 1365 | { | ||
1089 | 1366 | gchar *clean = NULL; | ||
1090 | 1367 | gchar **delimited = NULL; | ||
1091 | 1368 | |||
1092 | 1369 | /* Replace dashes with underscores */ | ||
1093 | 1370 | delimited = g_strsplit (gsettingName, "-", 0); | ||
1094 | 1371 | |||
1095 | 1372 | clean = g_strjoinv ("_", delimited); | ||
1096 | 1373 | |||
1097 | 1374 | /* FIXME: Truncated and lowercased settings aren't going to work */ | ||
1098 | 1375 | |||
1099 | 1376 | g_strfreev (delimited); | ||
1100 | 1377 | |||
1101 | 1378 | return clean; | ||
1102 | 1379 | } | ||
1103 | 1380 | |||
1104 | 1381 | static GSettings * | ||
1105 | 1382 | getSettingsObjectForPluginWithPath (const char *plugin, | ||
1106 | 1383 | const char *path, | ||
1107 | 1384 | CCSContext *context) | ||
1108 | 1385 | { | ||
1109 | 1386 | GSettings *settingsObj = NULL; | ||
1110 | 1387 | GList *l = settingsList; | ||
1111 | 1388 | gchar *schemaName = getSchemaNameForPlugin (plugin); | ||
1112 | 1389 | GVariant *writtenPlugins; | ||
1113 | 1390 | char *plug; | ||
1114 | 1391 | GVariant *newWrittenPlugins; | ||
1115 | 1392 | GVariantBuilder *newWrittenPluginsBuilder; | ||
1116 | 1393 | GVariantIter *iter; | ||
1117 | 1394 | gboolean found = FALSE; | ||
1118 | 1395 | |||
1119 | 1396 | while (l) | ||
1120 | 1397 | { | ||
1121 | 1398 | settingsObj = (GSettings *) l->data; | ||
1122 | 1399 | gchar *name = NULL; | ||
1123 | 1400 | |||
1124 | 1401 | g_object_get (G_OBJECT (settingsObj), | ||
1125 | 1402 | "schema", | ||
1126 | 1403 | &name, NULL); | ||
1127 | 1404 | if (g_strcmp0 (name, schemaName) == 0) | ||
1128 | 1405 | { | ||
1129 | 1406 | g_free (name); | ||
1130 | 1407 | g_free (schemaName); | ||
1131 | 1408 | |||
1132 | 1409 | return settingsObj; | ||
1133 | 1410 | } | ||
1134 | 1411 | |||
1135 | 1412 | l = g_list_next (l); | ||
1136 | 1413 | } | ||
1137 | 1414 | |||
1138 | 1415 | /* No existing settings object found for this schema, create one */ | ||
1139 | 1416 | |||
1140 | 1417 | settingsObj = g_settings_new_with_path (schemaName, path); | ||
1141 | 1418 | |||
1142 | 1419 | g_signal_connect (G_OBJECT (settingsObj), "changed", (GCallback) valueChanged, (gpointer) context); | ||
1143 | 1420 | |||
1144 | 1421 | settingsList = g_list_append (settingsList, (void *) settingsObj); | ||
1145 | 1422 | |||
1146 | 1423 | /* Also write the plugin name to the list of modified plugins so | ||
1147 | 1424 | * that when we delete the profile the keys for that profile are also | ||
1148 | 1425 | * unset FIXME: This could be a little more efficient, like we could | ||
1149 | 1426 | * store keys that have changed from their defaults ... though | ||
1150 | 1427 | * gsettings doesn't seem to give you a way to get all of the schemas */ | ||
1151 | 1428 | |||
1152 | 1429 | writtenPlugins = g_settings_get_value (currentProfileSettings, "plugins-with-set-keys"); | ||
1153 | 1430 | |||
1154 | 1431 | newWrittenPluginsBuilder = g_variant_builder_new (G_VARIANT_TYPE ("as")); | ||
1155 | 1432 | |||
1156 | 1433 | iter = g_variant_iter_new (writtenPlugins); | ||
1157 | 1434 | while (g_variant_iter_next (iter, "s", &plug)) | ||
1158 | 1435 | { | ||
1159 | 1436 | g_variant_builder_add (newWrittenPluginsBuilder, "s", plug); | ||
1160 | 1437 | |||
1161 | 1438 | if (!found) | ||
1162 | 1439 | found = (g_strcmp0 (plug, plugin) == 0); | ||
1163 | 1440 | |||
1164 | 1441 | g_free (plug); | ||
1165 | 1442 | } | ||
1166 | 1443 | |||
1167 | 1444 | if (!found) | ||
1168 | 1445 | g_variant_builder_add (newWrittenPluginsBuilder, "s", plugin); | ||
1169 | 1446 | |||
1170 | 1447 | newWrittenPlugins = g_variant_new ("as", newWrittenPluginsBuilder); | ||
1171 | 1448 | g_settings_set_value (currentProfileSettings, "plugins-with-set-keys", newWrittenPlugins); | ||
1172 | 1449 | |||
1173 | 1450 | g_variant_iter_free (iter); | ||
1174 | 1451 | g_variant_unref (newWrittenPlugins); | ||
1175 | 1452 | g_variant_builder_unref (newWrittenPluginsBuilder); | ||
1176 | 1453 | |||
1177 | 1454 | return settingsObj; | ||
1178 | 1455 | } | ||
1179 | 1456 | |||
1180 | 1457 | static GSettings * | ||
1181 | 1458 | getSettingsObjectForCCSSetting (CCSSetting *setting) | ||
1182 | 1459 | { | ||
1183 | 1460 | KEYNAME(setting->parent->context->screenNum); | ||
1184 | 1461 | PATHNAME (setting->parent->name, keyName); | ||
1185 | 1462 | |||
1186 | 1463 | return getSettingsObjectForPluginWithPath (setting->parent->name, pathName, setting->parent->context); | ||
1187 | 1464 | } | ||
1188 | 1465 | |||
1189 | 1466 | static Bool | ||
1190 | 1467 | isIntegratedOption (CCSSetting *setting, | ||
1191 | 1468 | int *index) | ||
1192 | 1469 | { | ||
1193 | 1470 | #ifdef USE_GCONF | ||
1194 | 1471 | return isGConfIntegratedOption (setting, index); | ||
1195 | 1472 | #else | ||
1196 | 1473 | return FALSE; | ||
1197 | 1474 | #endif | ||
1198 | 1475 | } | ||
1199 | 1476 | |||
1200 | 1477 | static void | ||
1201 | 1478 | gnomeValueChanged (GSettings *settings, | ||
1202 | 1479 | gchar *keyName, | ||
1203 | 1480 | gpointer user_data) | ||
1204 | 1481 | { | ||
1205 | 1482 | } | ||
1206 | 1483 | |||
1207 | 1484 | static void | ||
1208 | 1485 | valueChanged (GSettings *settings, | ||
1209 | 1486 | gchar *keyName, | ||
1210 | 1487 | gpointer user_data) | ||
1211 | 1488 | { | ||
1212 | 1489 | CCSContext *context = (CCSContext *)user_data; | ||
1213 | 1490 | char *uncleanKeyName; | ||
1214 | 1491 | char *path; | ||
1215 | 1492 | char *token; | ||
1216 | 1493 | int index; | ||
1217 | 1494 | unsigned int screenNum; | ||
1218 | 1495 | CCSPlugin *plugin; | ||
1219 | 1496 | CCSSetting *setting; | ||
1220 | 1497 | |||
1221 | 1498 | g_object_get (G_OBJECT (settings), "path", &path, NULL); | ||
1222 | 1499 | |||
1223 | 1500 | path += strlen (COMPIZ) + 1; | ||
1224 | 1501 | |||
1225 | 1502 | token = strsep (&path, "/"); /* Profile name */ | ||
1226 | 1503 | if (!token) | ||
1227 | 1504 | return; | ||
1228 | 1505 | |||
1229 | 1506 | token = strsep (&path, "/"); /* plugins */ | ||
1230 | 1507 | if (!token) | ||
1231 | 1508 | return; | ||
1232 | 1509 | |||
1233 | 1510 | token = strsep (&path, "/"); /* plugin */ | ||
1234 | 1511 | if (!token) | ||
1235 | 1512 | return; | ||
1236 | 1513 | |||
1237 | 1514 | plugin = ccsFindPlugin (context, token); | ||
1238 | 1515 | if (!plugin) | ||
1239 | 1516 | return; | ||
1240 | 1517 | |||
1241 | 1518 | token = strsep (&path, "/"); /* screen%i */ | ||
1242 | 1519 | if (!token) | ||
1243 | 1520 | return; | ||
1244 | 1521 | |||
1245 | 1522 | sscanf (token, "screen%d", &screenNum); | ||
1246 | 1523 | |||
1247 | 1524 | uncleanKeyName = translateKeyForCCS (keyName); | ||
1248 | 1525 | |||
1249 | 1526 | setting = ccsFindSetting (plugin, uncleanKeyName); | ||
1250 | 1527 | |||
1251 | 1528 | /* Try again, this time truncating the settings themselves */ | ||
1252 | 1529 | if (!setting) | ||
1253 | 1530 | { | ||
1254 | 1531 | char *cleanKeyName; | ||
1255 | 1532 | CCSSettingList it = ccsGetPluginSettings (plugin); | ||
1256 | 1533 | |||
1257 | 1534 | while (it) | ||
1258 | 1535 | { | ||
1259 | 1536 | cleanKeyName = translateKeyForGSettings (((CCSSetting *) it->data)->name); | ||
1260 | 1537 | |||
1261 | 1538 | if (g_strcmp0 (cleanKeyName, keyName) == 0) | ||
1262 | 1539 | { | ||
1263 | 1540 | free (cleanKeyName); | ||
1264 | 1541 | setting = it->data; | ||
1265 | 1542 | break; | ||
1266 | 1543 | } | ||
1267 | 1544 | |||
1268 | 1545 | free (cleanKeyName); | ||
1269 | 1546 | |||
1270 | 1547 | it = it->next; | ||
1271 | 1548 | } | ||
1272 | 1549 | } | ||
1273 | 1550 | |||
1274 | 1551 | if (!setting) | ||
1275 | 1552 | { | ||
1276 | 1553 | printf ("GSettings Backend: unable to find setting %s, for path %s\n", uncleanKeyName, path); | ||
1277 | 1554 | free (uncleanKeyName); | ||
1278 | 1555 | return; | ||
1279 | 1556 | } | ||
1280 | 1557 | |||
1281 | 1558 | readInit (context); | ||
1282 | 1559 | if (!readOption (setting)) | ||
1283 | 1560 | { | ||
1284 | 1561 | ccsResetToDefault (setting, TRUE); | ||
1285 | 1562 | } | ||
1286 | 1563 | |||
1287 | 1564 | if (ccsGetIntegrationEnabled (context) && | ||
1288 | 1565 | isIntegratedOption (setting, &index)) | ||
1289 | 1566 | { | ||
1290 | 1567 | writeInit (context); | ||
1291 | 1568 | writeIntegratedOption (context, setting, index); | ||
1292 | 1569 | } | ||
1293 | 1570 | |||
1294 | 1571 | free (uncleanKeyName); | ||
1295 | 1572 | } | ||
1296 | 1573 | |||
1297 | 1574 | static Bool | ||
1298 | 1575 | readListValue (CCSSetting *setting) | ||
1299 | 1576 | { | ||
1300 | 1577 | GSettings *settings = getSettingsObjectForCCSSetting (setting); | ||
1301 | 1578 | gchar *variantType; | ||
1302 | 1579 | unsigned int nItems, i = 0; | ||
1303 | 1580 | CCSSettingValueList list = NULL; | ||
1304 | 1581 | GVariant *value; | ||
1305 | 1582 | GVariantIter *iter; | ||
1306 | 1583 | |||
1307 | 1584 | char *cleanSettingName = translateKeyForGSettings (setting->name); | ||
1308 | 1585 | |||
1309 | 1586 | switch (setting->info.forList.listType) | ||
1310 | 1587 | { | ||
1311 | 1588 | case TypeString: | ||
1312 | 1589 | case TypeMatch: | ||
1313 | 1590 | case TypeColor: | ||
1314 | 1591 | variantType = g_strdup ("s"); | ||
1315 | 1592 | break; | ||
1316 | 1593 | case TypeBool: | ||
1317 | 1594 | variantType = g_strdup ("b"); | ||
1318 | 1595 | break; | ||
1319 | 1596 | case TypeInt: | ||
1320 | 1597 | variantType = g_strdup ("i"); | ||
1321 | 1598 | break; | ||
1322 | 1599 | case TypeFloat: | ||
1323 | 1600 | variantType = g_strdup ("d"); | ||
1324 | 1601 | break; | ||
1325 | 1602 | default: | ||
1326 | 1603 | variantType = NULL; | ||
1327 | 1604 | break; | ||
1328 | 1605 | } | ||
1329 | 1606 | |||
1330 | 1607 | if (!variantType) | ||
1331 | 1608 | return FALSE; | ||
1332 | 1609 | |||
1333 | 1610 | value = g_settings_get_value (settings, cleanSettingName); | ||
1334 | 1611 | if (!value) | ||
1335 | 1612 | { | ||
1336 | 1613 | ccsResetToDefault (setting, TRUE); | ||
1337 | 1614 | return TRUE; | ||
1338 | 1615 | } | ||
1339 | 1616 | |||
1340 | 1617 | iter = g_variant_iter_new (value); | ||
1341 | 1618 | nItems = g_variant_iter_n_children (iter); | ||
1342 | 1619 | |||
1343 | 1620 | if (nItems) | ||
1344 | 1621 | { | ||
1345 | 1622 | switch (setting->info.forList.listType) | ||
1346 | 1623 | { | ||
1347 | 1624 | case TypeBool: | ||
1348 | 1625 | { | ||
1349 | 1626 | Bool *array = malloc (nItems * sizeof (Bool)); | ||
1350 | 1627 | Bool *arrayCounter = array; | ||
1351 | 1628 | gboolean v; | ||
1352 | 1629 | |||
1353 | 1630 | if (!array) | ||
1354 | 1631 | break; | ||
1355 | 1632 | |||
1356 | 1633 | /* Reads each item from the variant into the position pointed | ||
1357 | 1634 | * at by arrayCounter */ | ||
1358 | 1635 | while (g_variant_iter_next (iter, variantType, &v)) | ||
1359 | 1636 | { | ||
1360 | 1637 | *arrayCounter++ = v; | ||
1361 | 1638 | } | ||
1362 | 1639 | |||
1363 | 1640 | list = ccsGetValueListFromBoolArray (array, nItems, setting); | ||
1364 | 1641 | free (array); | ||
1365 | 1642 | } | ||
1366 | 1643 | break; | ||
1367 | 1644 | case TypeInt: | ||
1368 | 1645 | { | ||
1369 | 1646 | int *array = malloc (nItems * sizeof (int)); | ||
1370 | 1647 | int *arrayCounter = array; | ||
1371 | 1648 | |||
1372 | 1649 | if (!array) | ||
1373 | 1650 | break; | ||
1374 | 1651 | |||
1375 | 1652 | /* Reads each item from the variant into the position pointed | ||
1376 | 1653 | * at by arrayCounter */ | ||
1377 | 1654 | while (g_variant_iter_next (iter, variantType, arrayCounter++)); | ||
1378 | 1655 | |||
1379 | 1656 | list = ccsGetValueListFromIntArray (array, nItems, setting); | ||
1380 | 1657 | free (array); | ||
1381 | 1658 | } | ||
1382 | 1659 | break; | ||
1383 | 1660 | case TypeFloat: | ||
1384 | 1661 | { | ||
1385 | 1662 | double *array = malloc (nItems * sizeof (double)); | ||
1386 | 1663 | double *arrayCounter = array; | ||
1387 | 1664 | |||
1388 | 1665 | if (!array) | ||
1389 | 1666 | break; | ||
1390 | 1667 | |||
1391 | 1668 | /* Reads each item from the variant into the position pointed | ||
1392 | 1669 | * at by arrayCounter */ | ||
1393 | 1670 | while (g_variant_iter_next (iter, variantType, arrayCounter++)); | ||
1394 | 1671 | |||
1395 | 1672 | list = ccsGetValueListFromFloatArray ((float *) array, nItems, setting); | ||
1396 | 1673 | free (array); | ||
1397 | 1674 | } | ||
1398 | 1675 | break; | ||
1399 | 1676 | case TypeString: | ||
1400 | 1677 | case TypeMatch: | ||
1401 | 1678 | { | ||
1402 | 1679 | char **array = calloc (1, (nItems + 1) * sizeof (char *)); | ||
1403 | 1680 | char **arrayCounter = array; | ||
1404 | 1681 | |||
1405 | 1682 | if (!array) | ||
1406 | 1683 | { | ||
1407 | 1684 | break; | ||
1408 | 1685 | } | ||
1409 | 1686 | |||
1410 | 1687 | /* Reads each item from the variant into the position pointed | ||
1411 | 1688 | * at by arrayCounter */ | ||
1412 | 1689 | while (g_variant_iter_next (iter, variantType, arrayCounter++)); | ||
1413 | 1690 | |||
1414 | 1691 | list = ccsGetValueListFromStringArray (array, nItems, setting); | ||
1415 | 1692 | for (i = 0; i < nItems; i++) | ||
1416 | 1693 | if (array[i]) | ||
1417 | 1694 | free (array[i]); | ||
1418 | 1695 | free (array); | ||
1419 | 1696 | } | ||
1420 | 1697 | break; | ||
1421 | 1698 | case TypeColor: | ||
1422 | 1699 | { | ||
1423 | 1700 | CCSSettingColorValue *array; | ||
1424 | 1701 | char *colorValue; | ||
1425 | 1702 | array = malloc (nItems * sizeof (CCSSettingColorValue)); | ||
1426 | 1703 | if (!array) | ||
1427 | 1704 | break; | ||
1428 | 1705 | |||
1429 | 1706 | while (g_variant_iter_next (iter, variantType, &colorValue)) | ||
1430 | 1707 | { | ||
1431 | 1708 | memset (&array[i], 0, sizeof (CCSSettingColorValue)); | ||
1432 | 1709 | ccsStringToColor (colorValue, | ||
1433 | 1710 | &array[i]); | ||
1434 | 1711 | } | ||
1435 | 1712 | list = ccsGetValueListFromColorArray (array, nItems, setting); | ||
1436 | 1713 | free (array); | ||
1437 | 1714 | } | ||
1438 | 1715 | break; | ||
1439 | 1716 | default: | ||
1440 | 1717 | break; | ||
1441 | 1718 | } | ||
1442 | 1719 | } | ||
1443 | 1720 | |||
1444 | 1721 | free (cleanSettingName); | ||
1445 | 1722 | free (variantType); | ||
1446 | 1723 | |||
1447 | 1724 | if (list) | ||
1448 | 1725 | { | ||
1449 | 1726 | ccsSetList (setting, list, TRUE); | ||
1450 | 1727 | ccsSettingValueListFree (list, TRUE); | ||
1451 | 1728 | return TRUE; | ||
1452 | 1729 | } | ||
1453 | 1730 | else | ||
1454 | 1731 | ccsResetToDefault (setting, TRUE); | ||
1455 | 1732 | |||
1456 | 1733 | return FALSE; | ||
1457 | 1734 | } | ||
1458 | 1735 | |||
1459 | 1736 | static Bool | ||
1460 | 1737 | readIntegratedOption (CCSContext *context, | ||
1461 | 1738 | CCSSetting *setting, | ||
1462 | 1739 | int index) | ||
1463 | 1740 | { | ||
1464 | 1741 | #ifdef USE_GCONF | ||
1465 | 1742 | return readGConfIntegratedOption (context, setting, index); | ||
1466 | 1743 | #else | ||
1467 | 1744 | return FALSE; | ||
1468 | 1745 | #endif | ||
1469 | 1746 | } | ||
1470 | 1747 | |||
1471 | 1748 | Bool | ||
1472 | 1749 | readOption (CCSSetting * setting) | ||
1473 | 1750 | { | ||
1474 | 1751 | GSettings *settings = getSettingsObjectForCCSSetting (setting); | ||
1475 | 1752 | GVariant *gsettingsValue = NULL; | ||
1476 | 1753 | Bool ret = FALSE; | ||
1477 | 1754 | Bool valid = TRUE; | ||
1478 | 1755 | |||
1479 | 1756 | /* It is impossible for certain settings to have a schema, | ||
1480 | 1757 | * such as actions and read only settings, so in that case | ||
1481 | 1758 | * just return FALSE since compizconfig doesn't expect us | ||
1482 | 1759 | * to read them anyways */ | ||
1483 | 1760 | |||
1484 | 1761 | if (setting->type == TypeAction || | ||
1485 | 1762 | ccsSettingIsReadOnly (setting)) | ||
1486 | 1763 | { | ||
1487 | 1764 | return FALSE; | ||
1488 | 1765 | } | ||
1489 | 1766 | |||
1490 | 1767 | char *cleanSettingName = translateKeyForGSettings (setting->name); | ||
1491 | 1768 | KEYNAME(setting->parent->context->screenNum); | ||
1492 | 1769 | PATHNAME (setting->parent->name, keyName); | ||
1493 | 1770 | |||
1494 | 1771 | /* first check if the key is set */ | ||
1495 | 1772 | gsettingsValue = g_settings_get_value (settings, cleanSettingName); | ||
1496 | 1773 | |||
1497 | 1774 | switch (setting->type) | ||
1498 | 1775 | { | ||
1499 | 1776 | case TypeString: | ||
1500 | 1777 | case TypeMatch: | ||
1501 | 1778 | case TypeColor: | ||
1502 | 1779 | case TypeKey: | ||
1503 | 1780 | case TypeButton: | ||
1504 | 1781 | case TypeEdge: | ||
1505 | 1782 | valid = (g_variant_type_is_subtype_of (G_VARIANT_TYPE_STRING, g_variant_get_type (gsettingsValue))); | ||
1506 | 1783 | break; | ||
1507 | 1784 | case TypeInt: | ||
1508 | 1785 | valid = (g_variant_type_is_subtype_of (G_VARIANT_TYPE_INT32, g_variant_get_type (gsettingsValue))); | ||
1509 | 1786 | break; | ||
1510 | 1787 | case TypeBool: | ||
1511 | 1788 | case TypeBell: | ||
1512 | 1789 | valid = (g_variant_type_is_subtype_of (G_VARIANT_TYPE_BOOLEAN, g_variant_get_type (gsettingsValue))); | ||
1513 | 1790 | break; | ||
1514 | 1791 | case TypeFloat: | ||
1515 | 1792 | valid = (g_variant_type_is_subtype_of (G_VARIANT_TYPE_DOUBLE, g_variant_get_type (gsettingsValue))); | ||
1516 | 1793 | break; | ||
1517 | 1794 | case TypeList: | ||
1518 | 1795 | valid = (g_variant_type_is_array (g_variant_get_type (gsettingsValue))); | ||
1519 | 1796 | break; | ||
1520 | 1797 | default: | ||
1521 | 1798 | break; | ||
1522 | 1799 | } | ||
1523 | 1800 | |||
1524 | 1801 | if (!valid) | ||
1525 | 1802 | { | ||
1526 | 1803 | printf ("GSettings backend: There is an unsupported value at path %s. " | ||
1527 | 1804 | "Settings from this path won't be read. Try to remove " | ||
1528 | 1805 | "that value so that operation can continue properly.\n", | ||
1529 | 1806 | pathName); | ||
1530 | 1807 | free (cleanSettingName); | ||
1531 | 1808 | g_variant_unref (gsettingsValue); | ||
1532 | 1809 | return FALSE; | ||
1533 | 1810 | } | ||
1534 | 1811 | |||
1535 | 1812 | switch (setting->type) | ||
1536 | 1813 | { | ||
1537 | 1814 | case TypeString: | ||
1538 | 1815 | { | ||
1539 | 1816 | const char *value; | ||
1540 | 1817 | value = g_variant_get_string (gsettingsValue, NULL); | ||
1541 | 1818 | if (value) | ||
1542 | 1819 | { | ||
1543 | 1820 | ccsSetString (setting, value, FALSE); | ||
1544 | 1821 | ret = TRUE; | ||
1545 | 1822 | } | ||
1546 | 1823 | } | ||
1547 | 1824 | break; | ||
1548 | 1825 | case TypeMatch: | ||
1549 | 1826 | { | ||
1550 | 1827 | const char * value; | ||
1551 | 1828 | value = g_variant_get_string (gsettingsValue, NULL); | ||
1552 | 1829 | if (value) | ||
1553 | 1830 | { | ||
1554 | 1831 | ccsSetMatch (setting, value, FALSE); | ||
1555 | 1832 | ret = TRUE; | ||
1556 | 1833 | } | ||
1557 | 1834 | } | ||
1558 | 1835 | break; | ||
1559 | 1836 | case TypeInt: | ||
1560 | 1837 | { | ||
1561 | 1838 | int value; | ||
1562 | 1839 | value = g_variant_get_int32 (gsettingsValue); | ||
1563 | 1840 | |||
1564 | 1841 | ccsSetInt (setting, value, FALSE); | ||
1565 | 1842 | ret = TRUE; | ||
1566 | 1843 | } | ||
1567 | 1844 | break; | ||
1568 | 1845 | case TypeBool: | ||
1569 | 1846 | { | ||
1570 | 1847 | gboolean value; | ||
1571 | 1848 | value = g_variant_get_boolean (gsettingsValue); | ||
1572 | 1849 | |||
1573 | 1850 | ccsSetBool (setting, value ? TRUE : FALSE, FALSE); | ||
1574 | 1851 | ret = TRUE; | ||
1575 | 1852 | } | ||
1576 | 1853 | break; | ||
1577 | 1854 | case TypeFloat: | ||
1578 | 1855 | { | ||
1579 | 1856 | double value; | ||
1580 | 1857 | value = g_variant_get_double (gsettingsValue); | ||
1581 | 1858 | |||
1582 | 1859 | ccsSetFloat (setting, (float)value, FALSE); | ||
1583 | 1860 | ret = TRUE; | ||
1584 | 1861 | } | ||
1585 | 1862 | break; | ||
1586 | 1863 | case TypeColor: | ||
1587 | 1864 | { | ||
1588 | 1865 | const char *value; | ||
1589 | 1866 | CCSSettingColorValue color; | ||
1590 | 1867 | value = g_variant_get_string (gsettingsValue, NULL); | ||
1591 | 1868 | |||
1592 | 1869 | if (value && ccsStringToColor (value, &color)) | ||
1593 | 1870 | { | ||
1594 | 1871 | ccsSetColor (setting, color, FALSE); | ||
1595 | 1872 | ret = TRUE; | ||
1596 | 1873 | } | ||
1597 | 1874 | } | ||
1598 | 1875 | break; | ||
1599 | 1876 | case TypeKey: | ||
1600 | 1877 | { | ||
1601 | 1878 | const char *value; | ||
1602 | 1879 | CCSSettingKeyValue key; | ||
1603 | 1880 | value = g_variant_get_string (gsettingsValue, NULL); | ||
1604 | 1881 | |||
1605 | 1882 | if (value && ccsStringToKeyBinding (value, &key)) | ||
1606 | 1883 | { | ||
1607 | 1884 | ccsSetKey (setting, key, FALSE); | ||
1608 | 1885 | ret = TRUE; | ||
1609 | 1886 | } | ||
1610 | 1887 | } | ||
1611 | 1888 | break; | ||
1612 | 1889 | case TypeButton: | ||
1613 | 1890 | { | ||
1614 | 1891 | const char *value; | ||
1615 | 1892 | CCSSettingButtonValue button; | ||
1616 | 1893 | value = g_variant_get_string (gsettingsValue, NULL); | ||
1617 | 1894 | |||
1618 | 1895 | if (value && ccsStringToButtonBinding (value, &button)) | ||
1619 | 1896 | { | ||
1620 | 1897 | ccsSetButton (setting, button, FALSE); | ||
1621 | 1898 | ret = TRUE; | ||
1622 | 1899 | } | ||
1623 | 1900 | } | ||
1624 | 1901 | break; | ||
1625 | 1902 | case TypeEdge: | ||
1626 | 1903 | { | ||
1627 | 1904 | const char *value; | ||
1628 | 1905 | value = g_variant_get_string (gsettingsValue, NULL); | ||
1629 | 1906 | |||
1630 | 1907 | if (value) | ||
1631 | 1908 | { | ||
1632 | 1909 | unsigned int edges; | ||
1633 | 1910 | edges = ccsStringToEdges (value); | ||
1634 | 1911 | ccsSetEdge (setting, edges, FALSE); | ||
1635 | 1912 | ret = TRUE; | ||
1636 | 1913 | } | ||
1637 | 1914 | } | ||
1638 | 1915 | break; | ||
1639 | 1916 | case TypeBell: | ||
1640 | 1917 | { | ||
1641 | 1918 | gboolean value; | ||
1642 | 1919 | value = g_variant_get_boolean (gsettingsValue); | ||
1643 | 1920 | |||
1644 | 1921 | ccsSetBell (setting, value ? TRUE : FALSE, FALSE); | ||
1645 | 1922 | ret = TRUE; | ||
1646 | 1923 | } | ||
1647 | 1924 | break; | ||
1648 | 1925 | case TypeList: | ||
1649 | 1926 | ret = readListValue (setting); | ||
1650 | 1927 | break; | ||
1651 | 1928 | default: | ||
1652 | 1929 | printf("GSettings backend: attempt to read unsupported setting type %d!\n", | ||
1653 | 1930 | setting->type); | ||
1654 | 1931 | break; | ||
1655 | 1932 | } | ||
1656 | 1933 | |||
1657 | 1934 | free (cleanSettingName); | ||
1658 | 1935 | g_variant_unref (gsettingsValue); | ||
1659 | 1936 | |||
1660 | 1937 | return ret; | ||
1661 | 1938 | } | ||
1662 | 1939 | |||
1663 | 1940 | static void | ||
1664 | 1941 | writeListValue (CCSSetting *setting, | ||
1665 | 1942 | char *pathName) | ||
1666 | 1943 | { | ||
1667 | 1944 | GSettings *settings = getSettingsObjectForCCSSetting (setting); | ||
1668 | 1945 | GVariant *value; | ||
1669 | 1946 | gchar *variantType = NULL; | ||
1670 | 1947 | CCSSettingValueList list; | ||
1671 | 1948 | |||
1672 | 1949 | char *cleanSettingName = translateKeyForGSettings (setting->name); | ||
1673 | 1950 | |||
1674 | 1951 | if (!ccsGetList (setting, &list)) | ||
1675 | 1952 | return; | ||
1676 | 1953 | |||
1677 | 1954 | switch (setting->info.forList.listType) | ||
1678 | 1955 | { | ||
1679 | 1956 | case TypeBool: | ||
1680 | 1957 | { | ||
1681 | 1958 | variantType = "ab"; | ||
1682 | 1959 | GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE ("ab")); | ||
1683 | 1960 | while (list) | ||
1684 | 1961 | { | ||
1685 | 1962 | g_variant_builder_add (builder, "b", list->data->value.asBool); | ||
1686 | 1963 | list = list->next; | ||
1687 | 1964 | } | ||
1688 | 1965 | value = g_variant_new ("ab", builder); | ||
1689 | 1966 | g_variant_builder_unref (builder); | ||
1690 | 1967 | } | ||
1691 | 1968 | break; | ||
1692 | 1969 | case TypeInt: | ||
1693 | 1970 | { | ||
1694 | 1971 | variantType = "ai"; | ||
1695 | 1972 | GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE ("ai")); | ||
1696 | 1973 | while (list) | ||
1697 | 1974 | { | ||
1698 | 1975 | g_variant_builder_add (builder, "i", list->data->value.asInt); | ||
1699 | 1976 | list = list->next; | ||
1700 | 1977 | } | ||
1701 | 1978 | value = g_variant_new ("ai", builder); | ||
1702 | 1979 | g_variant_builder_unref (builder); | ||
1703 | 1980 | } | ||
1704 | 1981 | break; | ||
1705 | 1982 | case TypeFloat: | ||
1706 | 1983 | { | ||
1707 | 1984 | variantType = "ad"; | ||
1708 | 1985 | GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE ("ad")); | ||
1709 | 1986 | while (list) | ||
1710 | 1987 | { | ||
1711 | 1988 | g_variant_builder_add (builder, "d", (gdouble) list->data->value.asFloat); | ||
1712 | 1989 | list = list->next; | ||
1713 | 1990 | } | ||
1714 | 1991 | value = g_variant_new ("ad", builder); | ||
1715 | 1992 | g_variant_builder_unref (builder); | ||
1716 | 1993 | } | ||
1717 | 1994 | break; | ||
1718 | 1995 | case TypeString: | ||
1719 | 1996 | { | ||
1720 | 1997 | variantType = "as"; | ||
1721 | 1998 | GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); | ||
1722 | 1999 | while (list) | ||
1723 | 2000 | { | ||
1724 | 2001 | g_variant_builder_add (builder, "s", list->data->value.asString); | ||
1725 | 2002 | list = list->next; | ||
1726 | 2003 | } | ||
1727 | 2004 | value = g_variant_new ("as", builder); | ||
1728 | 2005 | g_variant_builder_unref (builder); | ||
1729 | 2006 | } | ||
1730 | 2007 | break; | ||
1731 | 2008 | case TypeMatch: | ||
1732 | 2009 | { | ||
1733 | 2010 | variantType = "as"; | ||
1734 | 2011 | GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); | ||
1735 | 2012 | while (list) | ||
1736 | 2013 | { | ||
1737 | 2014 | g_variant_builder_add (builder, "s", list->data->value.asMatch); | ||
1738 | 2015 | list = list->next; | ||
1739 | 2016 | } | ||
1740 | 2017 | value = g_variant_new ("as", builder); | ||
1741 | 2018 | g_variant_builder_unref (builder); | ||
1742 | 2019 | } | ||
1743 | 2020 | break; | ||
1744 | 2021 | case TypeColor: | ||
1745 | 2022 | { | ||
1746 | 2023 | variantType = "as"; | ||
1747 | 2024 | GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); | ||
1748 | 2025 | char *item; | ||
1749 | 2026 | while (list) | ||
1750 | 2027 | { | ||
1751 | 2028 | item = ccsColorToString (&list->data->value.asColor); | ||
1752 | 2029 | g_variant_builder_add (builder, "s", item); | ||
1753 | 2030 | list = list->next; | ||
1754 | 2031 | } | ||
1755 | 2032 | value = g_variant_new ("as", builder); | ||
1756 | 2033 | g_variant_builder_unref (builder); | ||
1757 | 2034 | } | ||
1758 | 2035 | break; | ||
1759 | 2036 | default: | ||
1760 | 2037 | printf("GSettings backend: attempt to write unsupported list type %d!\n", | ||
1761 | 2038 | setting->info.forList.listType); | ||
1762 | 2039 | variantType = NULL; | ||
1763 | 2040 | break; | ||
1764 | 2041 | } | ||
1765 | 2042 | |||
1766 | 2043 | if (variantType != NULL) | ||
1767 | 2044 | { | ||
1768 | 2045 | g_settings_set_value (settings, cleanSettingName, value); | ||
1769 | 2046 | g_variant_unref (value); | ||
1770 | 2047 | } | ||
1771 | 2048 | |||
1772 | 2049 | free (cleanSettingName); | ||
1773 | 2050 | } | ||
1774 | 2051 | |||
1775 | 2052 | static void | ||
1776 | 2053 | writeIntegratedOption (CCSContext *context, | ||
1777 | 2054 | CCSSetting *setting, | ||
1778 | 2055 | int index) | ||
1779 | 2056 | { | ||
1780 | 2057 | #ifdef USE_GCONF | ||
1781 | 2058 | writeGConfIntegratedOption (context, setting, index); | ||
1782 | 2059 | #endif | ||
1783 | 2060 | |||
1784 | 2061 | return; | ||
1785 | 2062 | } | ||
1786 | 2063 | |||
1787 | 2064 | static void | ||
1788 | 2065 | resetOptionToDefault (CCSSetting * setting) | ||
1789 | 2066 | { | ||
1790 | 2067 | GSettings *settings = getSettingsObjectForCCSSetting (setting); | ||
1791 | 2068 | |||
1792 | 2069 | char *cleanSettingName = translateKeyForGSettings (setting->name); | ||
1793 | 2070 | KEYNAME (setting->parent->context->screenNum); | ||
1794 | 2071 | PATHNAME (setting->parent->name, keyName); | ||
1795 | 2072 | |||
1796 | 2073 | g_settings_reset (settings, cleanSettingName); | ||
1797 | 2074 | |||
1798 | 2075 | free (cleanSettingName); | ||
1799 | 2076 | } | ||
1800 | 2077 | |||
1801 | 2078 | void | ||
1802 | 2079 | writeOption (CCSSetting * setting) | ||
1803 | 2080 | { | ||
1804 | 2081 | GSettings *settings = getSettingsObjectForCCSSetting (setting); | ||
1805 | 2082 | char *cleanSettingName = translateKeyForGSettings (setting->name); | ||
1806 | 2083 | KEYNAME (setting->parent->context->screenNum); | ||
1807 | 2084 | PATHNAME (setting->parent->name, keyName); | ||
1808 | 2085 | |||
1809 | 2086 | switch (setting->type) | ||
1810 | 2087 | { | ||
1811 | 2088 | case TypeString: | ||
1812 | 2089 | { | ||
1813 | 2090 | char *value; | ||
1814 | 2091 | if (ccsGetString (setting, &value)) | ||
1815 | 2092 | { | ||
1816 | 2093 | g_settings_set (settings, cleanSettingName, "s", value, NULL); | ||
1817 | 2094 | } | ||
1818 | 2095 | } | ||
1819 | 2096 | break; | ||
1820 | 2097 | case TypeMatch: | ||
1821 | 2098 | { | ||
1822 | 2099 | char *value; | ||
1823 | 2100 | if (ccsGetMatch (setting, &value)) | ||
1824 | 2101 | { | ||
1825 | 2102 | g_settings_set (settings, cleanSettingName, "s", value, NULL); | ||
1826 | 2103 | } | ||
1827 | 2104 | } | ||
1828 | 2105 | case TypeFloat: | ||
1829 | 2106 | { | ||
1830 | 2107 | float value; | ||
1831 | 2108 | if (ccsGetFloat (setting, &value)) | ||
1832 | 2109 | { | ||
1833 | 2110 | g_settings_set (settings, cleanSettingName, "d", (double) value, NULL); | ||
1834 | 2111 | } | ||
1835 | 2112 | } | ||
1836 | 2113 | break; | ||
1837 | 2114 | case TypeInt: | ||
1838 | 2115 | { | ||
1839 | 2116 | int value; | ||
1840 | 2117 | if (ccsGetInt (setting, &value)) | ||
1841 | 2118 | { | ||
1842 | 2119 | g_settings_set (settings, cleanSettingName, "i", value, NULL); | ||
1843 | 2120 | } | ||
1844 | 2121 | } | ||
1845 | 2122 | break; | ||
1846 | 2123 | case TypeBool: | ||
1847 | 2124 | { | ||
1848 | 2125 | Bool value; | ||
1849 | 2126 | if (ccsGetBool (setting, &value)) | ||
1850 | 2127 | { | ||
1851 | 2128 | g_settings_set (settings, cleanSettingName, "b", value, NULL); | ||
1852 | 2129 | } | ||
1853 | 2130 | } | ||
1854 | 2131 | break; | ||
1855 | 2132 | case TypeColor: | ||
1856 | 2133 | { | ||
1857 | 2134 | CCSSettingColorValue value; | ||
1858 | 2135 | char *colString; | ||
1859 | 2136 | |||
1860 | 2137 | if (!ccsGetColor (setting, &value)) | ||
1861 | 2138 | break; | ||
1862 | 2139 | |||
1863 | 2140 | colString = ccsColorToString (&value); | ||
1864 | 2141 | if (!colString) | ||
1865 | 2142 | break; | ||
1866 | 2143 | |||
1867 | 2144 | g_settings_set (settings, cleanSettingName, "s", colString, NULL); | ||
1868 | 2145 | free (colString); | ||
1869 | 2146 | } | ||
1870 | 2147 | break; | ||
1871 | 2148 | case TypeKey: | ||
1872 | 2149 | { | ||
1873 | 2150 | CCSSettingKeyValue key; | ||
1874 | 2151 | char *keyString; | ||
1875 | 2152 | |||
1876 | 2153 | if (!ccsGetKey (setting, &key)) | ||
1877 | 2154 | break; | ||
1878 | 2155 | |||
1879 | 2156 | keyString = ccsKeyBindingToString (&key); | ||
1880 | 2157 | if (!keyString) | ||
1881 | 2158 | break; | ||
1882 | 2159 | |||
1883 | 2160 | g_settings_set (settings, cleanSettingName, "s", keyString, NULL); | ||
1884 | 2161 | free (keyString); | ||
1885 | 2162 | } | ||
1886 | 2163 | break; | ||
1887 | 2164 | case TypeButton: | ||
1888 | 2165 | { | ||
1889 | 2166 | CCSSettingButtonValue button; | ||
1890 | 2167 | char *buttonString; | ||
1891 | 2168 | |||
1892 | 2169 | if (!ccsGetButton (setting, &button)) | ||
1893 | 2170 | break; | ||
1894 | 2171 | |||
1895 | 2172 | buttonString = ccsButtonBindingToString (&button); | ||
1896 | 2173 | if (!buttonString) | ||
1897 | 2174 | break; | ||
1898 | 2175 | |||
1899 | 2176 | g_settings_set (settings, cleanSettingName, "s", buttonString, NULL); | ||
1900 | 2177 | free (buttonString); | ||
1901 | 2178 | } | ||
1902 | 2179 | break; | ||
1903 | 2180 | case TypeEdge: | ||
1904 | 2181 | { | ||
1905 | 2182 | unsigned int edges; | ||
1906 | 2183 | char *edgeString; | ||
1907 | 2184 | |||
1908 | 2185 | if (!ccsGetEdge (setting, &edges)) | ||
1909 | 2186 | break; | ||
1910 | 2187 | |||
1911 | 2188 | edgeString = ccsEdgesToString (edges); | ||
1912 | 2189 | if (!edgeString) | ||
1913 | 2190 | break; | ||
1914 | 2191 | |||
1915 | 2192 | g_settings_set (settings, cleanSettingName, "s", edgeString, NULL); | ||
1916 | 2193 | free (edgeString); | ||
1917 | 2194 | } | ||
1918 | 2195 | break; | ||
1919 | 2196 | case TypeBell: | ||
1920 | 2197 | { | ||
1921 | 2198 | Bool value; | ||
1922 | 2199 | if (ccsGetBell (setting, &value)) | ||
1923 | 2200 | { | ||
1924 | 2201 | g_settings_set (settings, cleanSettingName, "s", value, NULL); | ||
1925 | 2202 | } | ||
1926 | 2203 | } | ||
1927 | 2204 | break; | ||
1928 | 2205 | case TypeList: | ||
1929 | 2206 | writeListValue (setting, pathName); | ||
1930 | 2207 | break; | ||
1931 | 2208 | default: | ||
1932 | 2209 | printf("GSettings backend: attempt to write unsupported setting type %d\n", | ||
1933 | 2210 | setting->type); | ||
1934 | 2211 | break; | ||
1935 | 2212 | } | ||
1936 | 2213 | |||
1937 | 2214 | free (cleanSettingName); | ||
1938 | 2215 | } | ||
1939 | 2216 | |||
1940 | 2217 | static void | ||
1941 | 2218 | updateCurrentProfileName (char *profile) | ||
1942 | 2219 | { | ||
1943 | 2220 | GVariant *profiles; | ||
1944 | 2221 | char *prof; | ||
1945 | 2222 | char *profilePath = COMPIZ_PROFILEPATH; | ||
1946 | 2223 | char *currentProfilePath; | ||
1947 | 2224 | GVariant *newProfiles; | ||
1948 | 2225 | GVariantBuilder *newProfilesBuilder; | ||
1949 | 2226 | GVariantIter *iter; | ||
1950 | 2227 | gboolean found = FALSE; | ||
1951 | 2228 | |||
1952 | 2229 | profiles = g_settings_get_value (compizconfigSettings, "existing-profiles"); | ||
1953 | 2230 | |||
1954 | 2231 | newProfilesBuilder = g_variant_builder_new (G_VARIANT_TYPE ("as")); | ||
1955 | 2232 | |||
1956 | 2233 | iter = g_variant_iter_new (profiles); | ||
1957 | 2234 | while (g_variant_iter_next (iter, "s", &prof)) | ||
1958 | 2235 | { | ||
1959 | 2236 | g_variant_builder_add (newProfilesBuilder, "s", prof); | ||
1960 | 2237 | |||
1961 | 2238 | if (!found) | ||
1962 | 2239 | found = (g_strcmp0 (prof, profile) == 0); | ||
1963 | 2240 | } | ||
1964 | 2241 | |||
1965 | 2242 | if (!found) | ||
1966 | 2243 | g_variant_builder_add (newProfilesBuilder, "s", profile); | ||
1967 | 2244 | |||
1968 | 2245 | newProfiles = g_variant_new ("as", newProfilesBuilder); | ||
1969 | 2246 | g_settings_set_value (compizconfigSettings, "existing-profiles", newProfiles); | ||
1970 | 2247 | |||
1971 | 2248 | g_variant_iter_free (iter); | ||
1972 | 2249 | g_variant_unref (newProfiles); | ||
1973 | 2250 | g_variant_builder_unref (newProfilesBuilder); | ||
1974 | 2251 | |||
1975 | 2252 | /* Change the current profile and current profile settings */ | ||
1976 | 2253 | free (currentProfile); | ||
1977 | 2254 | |||
1978 | 2255 | currentProfile = strdup (profile); | ||
1979 | 2256 | currentProfilePath = g_strconcat (profilePath, profile, "/", NULL); | ||
1980 | 2257 | currentProfileSettings = g_settings_new_with_path (PROFILE_SCHEMA_ID, profilePath); | ||
1981 | 2258 | |||
1982 | 2259 | g_free (currentProfilePath); | ||
1983 | 2260 | |||
1984 | 2261 | g_settings_set (compizconfigSettings, "current-profile", "s", profile, NULL); | ||
1985 | 2262 | } | ||
1986 | 2263 | |||
1987 | 2264 | static gboolean | ||
1988 | 2265 | updateProfile (CCSContext *context) | ||
1989 | 2266 | { | ||
1990 | 2267 | char *profile = strdup (ccsGetProfile (context)); | ||
1991 | 2268 | |||
1992 | 2269 | if (!profile || !strlen (profile)) | ||
1993 | 2270 | profile = strdup (DEFAULTPROF); | ||
1994 | 2271 | |||
1995 | 2272 | if (g_strcmp0 (profile, currentProfile)) | ||
1996 | 2273 | updateCurrentProfileName (profile); | ||
1997 | 2274 | |||
1998 | 2275 | free (profile); | ||
1999 | 2276 | |||
2000 | 2277 | return TRUE; | ||
2001 | 2278 | } | ||
2002 | 2279 | |||
2003 | 2280 | static char* | ||
2004 | 2281 | getCurrentProfileName (void) | ||
2005 | 2282 | { | ||
2006 | 2283 | GVariant *value; | ||
2007 | 2284 | char *ret = NULL; | ||
2008 | 2285 | |||
2009 | 2286 | value = g_settings_get_value (compizconfigSettings, "current-profile"); | ||
2010 | 2287 | |||
2011 | 2288 | if (value) | ||
2012 | 2289 | ret = strdup (g_variant_get_string (value, NULL)); | ||
2013 | 2290 | else | ||
2014 | 2291 | ret = strdup (DEFAULTPROF); | ||
2015 | 2292 | |||
2016 | 2293 | return ret; | ||
2017 | 2294 | } | ||
2018 | 2295 | |||
2019 | 2296 | static void | ||
2020 | 2297 | processEvents (unsigned int flags) | ||
2021 | 2298 | { | ||
2022 | 2299 | if (!(flags & ProcessEventsNoGlibMainLoopMask)) | ||
2023 | 2300 | { | ||
2024 | 2301 | while (g_main_context_pending(NULL)) | ||
2025 | 2302 | g_main_context_iteration(NULL, FALSE); | ||
2026 | 2303 | } | ||
2027 | 2304 | } | ||
2028 | 2305 | |||
2029 | 2306 | static Bool | ||
2030 | 2307 | initBackend (CCSContext * context) | ||
2031 | 2308 | { | ||
2032 | 2309 | const char *profilePath = PROFILEPATH; | ||
2033 | 2310 | char *currentProfilePath; | ||
2034 | 2311 | |||
2035 | 2312 | g_type_init (); | ||
2036 | 2313 | |||
2037 | 2314 | compizconfigSettings = g_settings_new (COMPIZCONFIG_SCHEMA_ID); | ||
2038 | 2315 | |||
2039 | 2316 | #ifdef USE_GCONF | ||
2040 | 2317 | initGConfClient (context); | ||
2041 | 2318 | #endif | ||
2042 | 2319 | |||
2043 | 2320 | currentProfile = getCurrentProfileName (); | ||
2044 | 2321 | currentProfilePath = g_strconcat (profilePath, currentProfile, "/", NULL); | ||
2045 | 2322 | currentProfileSettings = g_settings_new_with_path (PROFILE_SCHEMA_ID, currentProfilePath); | ||
2046 | 2323 | |||
2047 | 2324 | g_free (currentProfilePath); | ||
2048 | 2325 | |||
2049 | 2326 | return TRUE; | ||
2050 | 2327 | } | ||
2051 | 2328 | |||
2052 | 2329 | static Bool | ||
2053 | 2330 | finiBackend (CCSContext * context) | ||
2054 | 2331 | { | ||
2055 | 2332 | GList *l = settingsList; | ||
2056 | 2333 | |||
2057 | 2334 | processEvents (0); | ||
2058 | 2335 | |||
2059 | 2336 | #ifdef USE_GCONF | ||
2060 | 2337 | gconf_client_clear_cache (client); | ||
2061 | 2338 | finiGConfClient (); | ||
2062 | 2339 | #endif | ||
2063 | 2340 | |||
2064 | 2341 | if (currentProfile) | ||
2065 | 2342 | { | ||
2066 | 2343 | free (currentProfile); | ||
2067 | 2344 | currentProfile = NULL; | ||
2068 | 2345 | } | ||
2069 | 2346 | |||
2070 | 2347 | while (l) | ||
2071 | 2348 | { | ||
2072 | 2349 | g_object_unref (G_OBJECT (l->data)); | ||
2073 | 2350 | l = g_list_next (l); | ||
2074 | 2351 | } | ||
2075 | 2352 | |||
2076 | 2353 | g_object_unref (G_OBJECT (compizconfigSettings)); | ||
2077 | 2354 | |||
2078 | 2355 | processEvents (0); | ||
2079 | 2356 | return TRUE; | ||
2080 | 2357 | } | ||
2081 | 2358 | |||
2082 | 2359 | Bool | ||
2083 | 2360 | readInit (CCSContext * context) | ||
2084 | 2361 | { | ||
2085 | 2362 | return updateProfile (context); | ||
2086 | 2363 | } | ||
2087 | 2364 | |||
2088 | 2365 | void | ||
2089 | 2366 | readSetting (CCSContext *context, | ||
2090 | 2367 | CCSSetting *setting) | ||
2091 | 2368 | { | ||
2092 | 2369 | Bool status; | ||
2093 | 2370 | int index; | ||
2094 | 2371 | |||
2095 | 2372 | if (ccsGetIntegrationEnabled (context) && | ||
2096 | 2373 | isIntegratedOption (setting, &index)) | ||
2097 | 2374 | { | ||
2098 | 2375 | status = readIntegratedOption (context, setting, index); | ||
2099 | 2376 | } | ||
2100 | 2377 | else | ||
2101 | 2378 | status = readOption (setting); | ||
2102 | 2379 | |||
2103 | 2380 | if (!status) | ||
2104 | 2381 | ccsResetToDefault (setting, TRUE); | ||
2105 | 2382 | } | ||
2106 | 2383 | |||
2107 | 2384 | Bool | ||
2108 | 2385 | writeInit (CCSContext * context) | ||
2109 | 2386 | { | ||
2110 | 2387 | return updateProfile (context); | ||
2111 | 2388 | } | ||
2112 | 2389 | |||
2113 | 2390 | void | ||
2114 | 2391 | writeSetting (CCSContext *context, | ||
2115 | 2392 | CCSSetting *setting) | ||
2116 | 2393 | { | ||
2117 | 2394 | int index; | ||
2118 | 2395 | |||
2119 | 2396 | if (ccsGetIntegrationEnabled (context) && | ||
2120 | 2397 | isIntegratedOption (setting, &index)) | ||
2121 | 2398 | { | ||
2122 | 2399 | writeIntegratedOption (context, setting, index); | ||
2123 | 2400 | } | ||
2124 | 2401 | else if (setting->isDefault) | ||
2125 | 2402 | { | ||
2126 | 2403 | resetOptionToDefault (setting); | ||
2127 | 2404 | } | ||
2128 | 2405 | else | ||
2129 | 2406 | writeOption (setting); | ||
2130 | 2407 | |||
2131 | 2408 | } | ||
2132 | 2409 | |||
2133 | 2410 | static Bool | ||
2134 | 2411 | getSettingIsIntegrated (CCSSetting * setting) | ||
2135 | 2412 | { | ||
2136 | 2413 | if (!ccsGetIntegrationEnabled (setting->parent->context)) | ||
2137 | 2414 | return FALSE; | ||
2138 | 2415 | |||
2139 | 2416 | if (!isIntegratedOption (setting, NULL)) | ||
2140 | 2417 | return FALSE; | ||
2141 | 2418 | |||
2142 | 2419 | return TRUE; | ||
2143 | 2420 | } | ||
2144 | 2421 | |||
2145 | 2422 | static Bool | ||
2146 | 2423 | getSettingIsReadOnly (CCSSetting * setting) | ||
2147 | 2424 | { | ||
2148 | 2425 | /* FIXME */ | ||
2149 | 2426 | return FALSE; | ||
2150 | 2427 | } | ||
2151 | 2428 | |||
2152 | 2429 | static CCSStringList | ||
2153 | 2430 | getExistingProfiles (CCSContext *context) | ||
2154 | 2431 | { | ||
2155 | 2432 | GVariant *value; | ||
2156 | 2433 | char *profile; | ||
2157 | 2434 | GVariantIter iter; | ||
2158 | 2435 | CCSStringList ret = NULL; | ||
2159 | 2436 | |||
2160 | 2437 | value = g_settings_get_value (compizconfigSettings, "existing-profiles"); | ||
2161 | 2438 | g_variant_iter_init (&iter, value); | ||
2162 | 2439 | while (g_variant_iter_next (&iter, "s", &profile)) | ||
2163 | 2440 | { | ||
2164 | 2441 | CCSString *str = malloc (sizeof (CCSString)); | ||
2165 | 2442 | |||
2166 | 2443 | str->value = profile; | ||
2167 | 2444 | |||
2168 | 2445 | ret = ccsStringListAppend (ret, str); | ||
2169 | 2446 | } | ||
2170 | 2447 | |||
2171 | 2448 | g_variant_unref (value); | ||
2172 | 2449 | |||
2173 | 2450 | return ret; | ||
2174 | 2451 | } | ||
2175 | 2452 | |||
2176 | 2453 | static Bool | ||
2177 | 2454 | deleteProfile (CCSContext *context, | ||
2178 | 2455 | char *profile) | ||
2179 | 2456 | { | ||
2180 | 2457 | GVariant *plugins; | ||
2181 | 2458 | GVariant *profiles; | ||
2182 | 2459 | GVariant *newProfiles; | ||
2183 | 2460 | GVariantBuilder *newProfilesBuilder; | ||
2184 | 2461 | char *plugin, *prof; | ||
2185 | 2462 | GVariantIter *iter; | ||
2186 | 2463 | char *profileSettingsPath = g_strconcat (PROFILEPATH, profile, "/", NULL); | ||
2187 | 2464 | GSettings *profileSettings = g_settings_new_with_path (PROFILE_SCHEMA_ID, profileSettingsPath); | ||
2188 | 2465 | |||
2189 | 2466 | plugins = g_settings_get_value (currentProfileSettings, "plugins-with-set-keys"); | ||
2190 | 2467 | profiles = g_settings_get_value (compizconfigSettings, "existing-profiles"); | ||
2191 | 2468 | |||
2192 | 2469 | iter = g_variant_iter_new (plugins); | ||
2193 | 2470 | while (g_variant_iter_next (iter, "s", &plugin)) | ||
2194 | 2471 | { | ||
2195 | 2472 | GSettings *settings; | ||
2196 | 2473 | |||
2197 | 2474 | KEYNAME (context->screenNum); | ||
2198 | 2475 | PATHNAME (plugin, keyName); | ||
2199 | 2476 | |||
2200 | 2477 | settings = getSettingsObjectForPluginWithPath (plugin, pathName, context); | ||
2201 | 2478 | |||
2202 | 2479 | /* The GSettings documentation says not to use this API | ||
2203 | 2480 | * because we should know our own schema ... though really | ||
2204 | 2481 | * we don't because we autogenerate schemas ... */ | ||
2205 | 2482 | if (settings) | ||
2206 | 2483 | { | ||
2207 | 2484 | char **keys = g_settings_list_keys (settings); | ||
2208 | 2485 | char **key_ptr; | ||
2209 | 2486 | |||
2210 | 2487 | /* Unset all the keys */ | ||
2211 | 2488 | for (key_ptr = keys; *key_ptr; key_ptr++) | ||
2212 | 2489 | g_settings_reset (settings, *key_ptr); | ||
2213 | 2490 | |||
2214 | 2491 | g_strfreev (keys); | ||
2215 | 2492 | } | ||
2216 | 2493 | |||
2217 | 2494 | g_free (plugin); | ||
2218 | 2495 | } | ||
2219 | 2496 | |||
2220 | 2497 | /* Remove the profile from existing-profiles */ | ||
2221 | 2498 | g_variant_iter_free (iter); | ||
2222 | 2499 | g_settings_reset (profileSettings, "plugins-with-set-values"); | ||
2223 | 2500 | |||
2224 | 2501 | iter = g_variant_iter_new (profiles); | ||
2225 | 2502 | newProfilesBuilder = g_variant_builder_new (G_VARIANT_TYPE ("as")); | ||
2226 | 2503 | |||
2227 | 2504 | while (g_variant_iter_next (iter, "s", &prof)) | ||
2228 | 2505 | { | ||
2229 | 2506 | if (g_strcmp0 (prof, profile)) | ||
2230 | 2507 | g_variant_builder_add (newProfilesBuilder, "s", prof); | ||
2231 | 2508 | |||
2232 | 2509 | g_free (prof); | ||
2233 | 2510 | } | ||
2234 | 2511 | |||
2235 | 2512 | newProfiles = g_variant_new ("as", newProfilesBuilder); | ||
2236 | 2513 | g_settings_set_value (compizconfigSettings, "existing-profiles", newProfiles); | ||
2237 | 2514 | |||
2238 | 2515 | g_variant_unref (newProfiles); | ||
2239 | 2516 | g_variant_builder_unref (newProfilesBuilder); | ||
2240 | 2517 | |||
2241 | 2518 | free (profileSettingsPath); | ||
2242 | 2519 | |||
2243 | 2520 | updateProfile (context); | ||
2244 | 2521 | |||
2245 | 2522 | return TRUE; | ||
2246 | 2523 | } | ||
2247 | 2524 | |||
2248 | 2525 | static CCSBackendVTable gsettingsVTable = { | ||
2249 | 2526 | "gsettings", | ||
2250 | 2527 | "GSettings Configuration Backend", | ||
2251 | 2528 | "GSettings Configuration Backend for libccs", | ||
2252 | 2529 | TRUE, | ||
2253 | 2530 | TRUE, | ||
2254 | 2531 | processEvents, | ||
2255 | 2532 | initBackend, | ||
2256 | 2533 | finiBackend, | ||
2257 | 2534 | readInit, | ||
2258 | 2535 | readSetting, | ||
2259 | 2536 | 0, | ||
2260 | 2537 | writeInit, | ||
2261 | 2538 | writeSetting, | ||
2262 | 2539 | 0, | ||
2263 | 2540 | getSettingIsIntegrated, | ||
2264 | 2541 | getSettingIsReadOnly, | ||
2265 | 2542 | getExistingProfiles, | ||
2266 | 2543 | deleteProfile | ||
2267 | 2544 | }; | ||
2268 | 2545 | |||
2269 | 2546 | CCSBackendVTable * | ||
2270 | 2547 | getBackendInfo (void) | ||
2271 | 2548 | { | ||
2272 | 2549 | return &gsettingsVTable; | ||
2273 | 2550 | } | ||
2274 | 2551 | |||
2275 | 2552 | >>>>>>> MERGE-SOURCE |