Merge lp:~compiz-team/compiz/compiz.ccs_test_990690 into lp:compiz/0.9.8
- compiz.ccs_test_990690
- Merge into 0.9.8
Status: | Merged |
---|---|
Merged at revision: | 3266 |
Proposed branch: | lp:~compiz-team/compiz/compiz.ccs_test_990690 |
Merge into: | lp:compiz/0.9.8 |
Diff against target: |
8584 lines (+4686/-1148) 25 files modified
compizconfig/cmake/exec_setup_py_with_destdir.cmake (+0/-2) compizconfig/compizconfig-python/src/compizconfig.pyx (+123/-103) compizconfig/gconf/src/gconf.c (+27/-27) compizconfig/gsettings/src/gconf-integration.c (+9/-9) compizconfig/gsettings/src/gsettings.c (+29/-27) compizconfig/libcompizconfig/CMakeLists.txt (+1/-0) compizconfig/libcompizconfig/backend/src/ini.c (+31/-31) compizconfig/libcompizconfig/include/ccs.h (+466/-141) compizconfig/libcompizconfig/src/CMakeLists.txt (+3/-0) compizconfig/libcompizconfig/src/ccs-private.h (+68/-3) compizconfig/libcompizconfig/src/compiz.cpp (+241/-164) compizconfig/libcompizconfig/src/ini.c (+1/-1) compizconfig/libcompizconfig/src/main.c (+1869/-614) compizconfig/libcompizconfig/tests/CMakeLists.txt (+100/-0) compizconfig/libcompizconfig/tests/context-mock.cpp (+76/-0) compizconfig/libcompizconfig/tests/mock-context.h (+338/-0) compizconfig/libcompizconfig/tests/mock-plugin.h (+166/-0) compizconfig/libcompizconfig/tests/mock-setting.h (+353/-0) compizconfig/libcompizconfig/tests/plugin-mock.cpp (+61/-0) compizconfig/libcompizconfig/tests/setting-mock.cpp (+82/-0) compizconfig/libcompizconfig/tests/test-ccs-object.cpp (+356/-0) compizconfig/libcompizconfig/tests/test-context.cpp (+94/-0) compizconfig/libcompizconfig/tests/test-plugin.cpp (+60/-0) compizconfig/libcompizconfig/tests/test-setting.cpp (+109/-0) plugins/ccp/src/ccp.cpp (+23/-26) |
To merge this branch: | bzr merge lp:~compiz-team/compiz/compiz.ccs_test_990690 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sam Spilsbury | Needs Fixing | ||
Daniel van Vugt | Approve | ||
Review via email: mp+112091@code.launchpad.net |
Commit message
Description of the change
Do the initial work to get libcompizconfig under test. (LP: #990690)
libcompizconfig underwent some fairly large refactorings so that we could
get it under test. This includes moving all of the public data in the public
API structs into private structs and creating accessor functions for all of
that data. The accessor functions are wrappers around interface structures which
can be replaced at runtime for testing purposes.
A C based object system was added to make this possible:
This branch introduces some preliminary work in a series of branches to get libcompizconfig under test. In order to test the objects properly, we need to abstract away their interfaces$
This would be awkward to do correctly if we didn't have a suitable object system to handle interface implementation, referencing, private storage etc.
As such, a new struct CCSObject is introduced. It is similar in design to GObject, but with a much smaller feature set centered mostly around the handling of interfaces and composition$
Tests are included.
Basic mock classes for all of the public API were added for testing.
The gconf backend and compizconfig-python were adapted as necessary.
Merge in the following branches manually:
lp:~smspillaz/compiz-compizconfig-python/compiz-compizconfig-python.context-api ⇒ lp:compiz-compizconfig-python
lp:~smspillaz/compiz-compizconfig-python/compiz-compizconfig-python.plugin-api ⇒ lp:compiz-compizconfig-python
lp:~smspillaz/compiz-compizconfig-python/compiz-compizconfig-python.setting-api ⇒ lp:compiz-compizconfig-python
lp:~smspillaz/compiz-compizconfig-gconf/compiz-compizconfig-gconf.adapt-to-new-interfaces ⇒ lp:compiz-compizconfig-gconf
lp:~smspillaz/compiz-libcompizconfig/refactor-setting ⇒ lp:compiz-libcompizconfig
lp:~smspillaz/compiz-libcompizconfig/setting-funcs-behind-interface ⇒ lp:compiz-libcompizconfig
lp:~smspillaz/compiz-libcompizconfig/context-mock ⇒ lp:compiz-libcompizconfig
lp:~smspillaz/compiz-libcompizconfig/plugin-mock ⇒ lp:compiz-libcompizconfig
lp:~smspillaz/compiz-libcompizconfig/setting-mock ⇒ lp:compiz-libcompizconfig
lp:~smspillaz/compiz-libcompizconfig/refactor-context ⇒ lp:compiz-libcompizconfig
lp:~smspillaz/compiz-libcompizconfig/ccs-object ⇒ lp:compiz-libcompizconfig
lp:~smspillaz/compiz-libcompizconfig/refactor-plugin ⇒ lp:compiz-libcompizconfig
lp:~smspillaz/compiz-libcompizconfig/context-funcs-behind-interface ⇒ lp:compiz-libcompizconfig
lp:~smspillaz/compiz-libcompizconfig/plugin-funcs-behind-interface ⇒ lp:compiz-libcompizconfig
All of the above branches have been reviewed by ~alan-griffiths, All of the libcompizconfig ones have been approved, asides from setting-mock and plugin-mock, and those two concerns have now been addressed.
Daniel van Vugt (vanvugt) wrote : | # |
Daniel van Vugt (vanvugt) wrote : | # |
CCSM segfaults on startup using this branch. object_interfaces is NULL at compizconfig/
Using trunk, CCSM does not segfault on startup and is mostly usable. At least until you click on things and run into a crash caused by bug 1018730 (which has a fix).
Though, this might be my fault for using an old version of:
/usr/
(gdb) bt
#0 0x00007f09e45ab317 in ccsEmptyContextNew (screenNum=0,
object_
at /home/dan/
#1 0x00007f09e45abe6b in ccsContextNew (screenNum=
iface=
at /home/dan/
#2 0x00007f09e47c7c2f in ?? ()
from /usr/lib/
#3 0x00000000004c71c8 in ?? ()
#4 0x00000000004c7c76 in PyObject_Call ()
#5 0x000000000042aa4a in PyEval_EvalFrameEx ()
#6 0x00000000004317f2 in PyEval_EvalCodeEx ()
#7 0x000000000054b171 in PyRun_FileExFlags ()
#8 0x000000000054b7d8 in PyRun_SimpleFil
#9 0x000000000054c5d6 in Py_Main ()
#10 0x00007f09f001b76d in __libc_start_main (main=0x41b900 <main>, argc=2,
ubp_
rtld_
#11 0x000000000041b931 in _start ()
Daniel van Vugt (vanvugt) wrote : | # |
I will have to delve into re-compiling and testing compizconfig-python another day :(
Sam Spilsbury (smspillaz) wrote : | # |
Right, there's a problem with the ccsm installation process. I'll propose the merge for that now, didn't get around to doing it yesterday.
Sam Spilsbury (smspillaz) wrote : | # |
Daniel van Vugt (vanvugt) wrote : | # |
Manual regression testing, including under valgrind, all seems OK.
However, I think it's a terrible idea to make an 8584 line proposal. There will almost certainly be regressions neither of us have found yet.
I also think it's a bad idea to rewrite a large chunk of (mature-ish) code from procedural to object-oriented, just to use Google Test/Mock. But I also won't block this proposal because I'm not about to invest the time to prototype a better alternative. And I don't have enough understanding of compizconfig to know where to begin.
Sam Spilsbury (smspillaz) wrote : | # |
FYI, the merges in smaller chunks that alan and I worked on can be found here:
http://
I have noticed that there's some weird feedback with gconf just on the hsize setting that causes it to get reset, so I'm going to tentatively mark this needs fixing and have a look into it.
Preview Diff
1 | === modified file 'compizconfig/cmake/exec_setup_py_with_destdir.cmake' |
2 | --- compizconfig/cmake/exec_setup_py_with_destdir.cmake 2012-05-27 14:25:30 +0000 |
3 | +++ compizconfig/cmake/exec_setup_py_with_destdir.cmake 2012-06-27 07:01:20 +0000 |
4 | @@ -15,8 +15,6 @@ |
5 | |
6 | cmake_policy (SET CMP0012 NEW) |
7 | |
8 | -message (${BUILD_DEB}) |
9 | - |
10 | if (BUILD_DEB) |
11 | message ("Installing Debian Format") |
12 | set (EXTRAARGS "--install-layout=deb") |
13 | |
14 | === modified file 'compizconfig/compizconfig-python/src/compizconfig.pyx' |
15 | --- compizconfig/compizconfig-python/src/compizconfig.pyx 2012-05-23 06:44:28 +0000 |
16 | +++ compizconfig/compizconfig-python/src/compizconfig.pyx 2012-06-27 07:01:20 +0000 |
17 | @@ -25,6 +25,11 @@ |
18 | |
19 | ctypedef unsigned int Bool |
20 | |
21 | +cdef struct CCSInterfaceTable: |
22 | + void *contextInterface |
23 | + |
24 | +cdef extern CCSInterfaceTable ccsDefaultInterfaceTable |
25 | + |
26 | cdef enum CCSSettingType: |
27 | TypeBool |
28 | TypeInt |
29 | @@ -194,37 +199,11 @@ |
30 | char * longDesc |
31 | CCSStringList * plugins |
32 | |
33 | -cdef struct CCSContext: |
34 | - CCSPluginList * plugins |
35 | - CCSPluginCategory * categories |
36 | - |
37 | - void * priv |
38 | - void * ccsPrivate |
39 | - |
40 | - CCSSettingList * changedSettings |
41 | - unsigned int screenNum |
42 | +cdef struct CCSContext |
43 | |
44 | cdef struct CCSPlugin |
45 | |
46 | -cdef struct CCSSetting: |
47 | - char * name |
48 | - char * shortDesc |
49 | - char * longDesc |
50 | - |
51 | - CCSSettingType type |
52 | - |
53 | - CCSSettingInfo info |
54 | - char * group |
55 | - char * subGroup |
56 | - char * hints |
57 | - |
58 | - CCSSettingValue defaultValue |
59 | - CCSSettingValue * value |
60 | - Bool isDefault |
61 | - |
62 | - CCSPlugin * parent |
63 | - void * priv |
64 | - unsigned int refCount |
65 | +cdef struct CCSSetting |
66 | |
67 | cdef struct CCSStrExtension: |
68 | char * basePlugin |
69 | @@ -233,22 +212,7 @@ |
70 | unsigned int refCount |
71 | |
72 | cdef struct CCSPlugin: |
73 | - char * name |
74 | - char * shortDesc |
75 | - char * longDesc |
76 | - char * hints |
77 | - char * category |
78 | - |
79 | - CCSStringList * loadAfter |
80 | - CCSStringList * loadBefore |
81 | - CCSStringList * requiresPlugin |
82 | - CCSStringList * conflictPlugin |
83 | - CCSStringList * conflictFeature |
84 | - CCSStringList * providesFeature |
85 | - CCSStringList * requiresFeature |
86 | - |
87 | - void * priv |
88 | - CCSContext * context |
89 | + |
90 | void * ccsPrivate |
91 | unsigned int refCount |
92 | |
93 | @@ -264,9 +228,22 @@ |
94 | |
95 | '''Context functions''' |
96 | cdef extern void ccsSetBasicMetadata (Bool value) |
97 | -cdef extern CCSContext * ccsContextNew (unsigned int screenNum) |
98 | -cdef extern CCSContext * ccsEmptyContextNew (unsigned int screenNum) |
99 | +cdef extern CCSContext * ccsContextNew (unsigned int screenNum, CCSInterfaceTable *) |
100 | +cdef extern CCSContext * ccsEmptyContextNew (unsigned int screenNum, CCSInterfaceTable *) |
101 | cdef extern void ccsContextDestroy (CCSContext * context) |
102 | +cdef extern CCSPluginList ccsContextGetPlugins (CCSContext *context) |
103 | +cdef extern CCSPluginCategory * ccsContextGetCategories (CCSContext *context) |
104 | +cdef extern CCSSettingList ccsContextGetChangedSettings (CCSContext *context) |
105 | +cdef extern unsigned int ccsContextGetScreenNum (CCSContext *context) |
106 | +cdef extern Bool ccsContextAddChangedSetting (CCSContext *context, CCSSetting *setting) |
107 | +cdef extern Bool ccsContextClearChangedSettings (CCSContext *context) |
108 | +cdef extern CCSSettingList ccsContextStealChangedSettings (CCSContext *context) |
109 | +cdef extern void * ccsContextGetPrivatePtr (CCSContext *context) |
110 | +cdef extern void ccsContextSetPrivatePtr (CCSContext *context, void *) |
111 | + |
112 | +cdef extern void * ccsContextGetPluginsBindable (CCSContext *context) |
113 | +cdef extern void * ccsContextStealChangedSettingsBindable (CCSContext *context) |
114 | +cdef extern void * ccsContextGetChangedSettingsBindable (CCSContext *context) |
115 | |
116 | '''Plugin functions''' |
117 | cdef extern Bool ccsLoadPlugin (CCSContext * context, char * name) |
118 | @@ -276,6 +253,26 @@ |
119 | cdef extern CCSSettingList * ccsGetPluginSettings (CCSPlugin * plugin) |
120 | cdef extern CCSGroupList * ccsGetPluginGroups (CCSPlugin * plugin) |
121 | |
122 | +cdef extern char * ccsPluginGetName (CCSPlugin *plugin) |
123 | +cdef extern char * ccsPluginGetShortDesc (CCSPlugin *plugin) |
124 | +cdef extern char * ccsPluginGetLongDesc (CCSPlugin *plugin) |
125 | +cdef extern char * ccsPluginGetHints (CCSPlugin *plugin) |
126 | +cdef extern char * ccsPluginGetCategory (CCSPlugin *plugin) |
127 | + |
128 | +cdef extern CCSStringList ccsPluginGetLoadAfter (CCSPlugin *plugin) |
129 | +cdef extern CCSStringList ccsPluginGetLoadBefore (CCSPlugin *plugin) |
130 | +cdef extern CCSStringList ccsPluginGetRequiresPlugins (CCSPlugin *plugin) |
131 | +cdef extern CCSStringList ccsPluginGetConflictPlugins (CCSPlugin *plugin) |
132 | +cdef extern CCSStringList ccsPluginGetProvidesFeatures (CCSPlugin *plugin) |
133 | +cdef extern CCSStringList ccsPluginGetRequiresFeatures (CCSPlugin *plugin) |
134 | + |
135 | +cdef extern void * ccsPluginGetProvidesFeaturesBindable (CCSPlugin *plugin) |
136 | + |
137 | +cdef extern void * ccsPluginGetPrivatePtr (CCSPlugin *plugin) |
138 | +cdef extern void ccsPluginSetPrivatePtr (CCSPlugin *plugin, void *ptr) |
139 | + |
140 | +cdef extern CCSContext * ccsPluginGetContext (CCSPlugin *plugin) |
141 | + |
142 | '''Action => String''' |
143 | cdef extern char * ccsModifiersToString (unsigned int modMask) |
144 | cdef extern char * ccsEdgesToString (unsigned int edge) |
145 | @@ -349,6 +346,20 @@ |
146 | '''Misc. Plugin/Setting utils''' |
147 | cdef extern Bool ccsSettingIsReadOnly (CCSSetting * setting) |
148 | cdef extern Bool ccsSettingIsIntegrated (CCSSetting * setting) |
149 | +cdef extern char * ccsSettingGetName (CCSSetting *) |
150 | +cdef extern char * ccsSettingGetShortDesc (CCSSetting *) |
151 | +cdef extern char * ccsSettingGetLongDesc (CCSSetting *) |
152 | +cdef extern CCSSettingType ccsSettingGetType (CCSSetting *) |
153 | +cdef extern CCSSettingInfo * ccsSettingGetInfo (CCSSetting *) |
154 | +cdef extern char * ccsSettingGetGroup (CCSSetting *) |
155 | +cdef extern char * ccsSettingGetSubGroup (CCSSetting *) |
156 | +cdef extern char * ccsSettingGetHints (CCSSetting *) |
157 | +cdef extern CCSSettingValue * ccsSettingGetDefaultValue (CCSSetting *) |
158 | +cdef extern CCSSettingValue *ccsSettingGetValue (CCSSetting *) |
159 | +cdef extern Bool ccsSettingGetIsDefault (CCSSetting *) |
160 | +cdef extern CCSPlugin * ccsSettingGetParent (CCSSetting *) |
161 | +cdef extern void * ccsSettingGetPrivatePtr (CCSSetting *) |
162 | +cdef extern void ccsSettingSetPrivatePtr (CCSSetting *, void *) |
163 | |
164 | cdef extern void ccsPluginConflictListFree (CCSPluginConflictList * l, |
165 | Bool freeObj) |
166 | @@ -368,9 +379,9 @@ |
167 | |
168 | cdef CCSSettingType GetType (CCSSettingValue * value): |
169 | if value.isListChild: |
170 | - return (<CCSSetting *> value.parent).info.forList.listType |
171 | + return ccsSettingGetInfo ((<CCSSetting *> value.parent)).forList.listType |
172 | else: |
173 | - return (<CCSSetting *> value.parent).type |
174 | + return ccsSettingGetType ((<CCSSetting *> value.parent)) |
175 | |
176 | cdef CCSStringList * ListToStringList (object list): |
177 | if len (list) <= 0: |
178 | @@ -445,8 +456,8 @@ |
179 | while settingList: |
180 | ccsSetting = <CCSSetting *> settingList.data |
181 | setting = None |
182 | - plugin = context.Plugins[ccsSetting.parent.name] |
183 | - setting = plugin.Screen[ccsSetting.name] |
184 | + plugin = context.Plugins[ccsPluginGetName (ccsSettingGetParent (ccsSetting))] |
185 | + setting = plugin.Screen[ccsSettingGetName (ccsSetting)] |
186 | list.append (setting) |
187 | settingList = settingList.next |
188 | |
189 | @@ -484,9 +495,9 @@ |
190 | bv.isListChild = isListChild |
191 | bv.parent = setting |
192 | if isListChild: |
193 | - t = setting.info.forList.listType |
194 | + t = ccsSettingGetInfo (setting).forList.listType |
195 | else: |
196 | - t = setting.type |
197 | + t = ccsSettingGetType (setting) |
198 | if t == TypeString: |
199 | bv.value.asString = strdup (data) |
200 | elif t == TypeMatch: |
201 | @@ -607,11 +618,11 @@ |
202 | self.extendedStrRestrictions = None |
203 | self.baseStrRestrictions = None |
204 | info = () |
205 | - t = self.ccsSetting.type |
206 | - i = &self.ccsSetting.info |
207 | + t = ccsSettingGetType (self.ccsSetting) |
208 | + i = ccsSettingGetInfo (self.ccsSetting) |
209 | if t == TypeList: |
210 | - t = self.ccsSetting.info.forList.listType |
211 | - i = <CCSSettingInfo *> self.ccsSetting.info.forList.listInfo |
212 | + t = ccsSettingGetInfo (self.ccsSetting).forList.listType |
213 | + i = <CCSSettingInfo *> ccsSettingGetInfo (self.ccsSetting).forList.listInfo |
214 | if t == TypeInt: |
215 | desc = IntDescListToDict (i.forInt.desc) |
216 | info = (i.forInt.min, i.forInt.max, desc) |
217 | @@ -625,7 +636,7 @@ |
218 | self.extendedStrRestrictions = {} |
219 | elif t in (TypeKey, TypeButton, TypeEdge, TypeBell): |
220 | info = (bool (i.forAction.internal),) |
221 | - if self.ccsSetting.type == TypeList: |
222 | + if ccsSettingGetType (self.ccsSetting) == TypeList: |
223 | info = (SettingTypeString[t], info) |
224 | self.info = info |
225 | |
226 | @@ -638,27 +649,27 @@ |
227 | |
228 | property Name: |
229 | def __get__ (self): |
230 | - return self.ccsSetting.name |
231 | + return ccsSettingGetName (self.ccsSetting) |
232 | |
233 | property ShortDesc: |
234 | def __get__ (self): |
235 | - return self.ccsSetting.shortDesc |
236 | + return ccsSettingGetShortDesc (self.ccsSetting) |
237 | |
238 | property LongDesc: |
239 | def __get__ (self): |
240 | - return self.ccsSetting.longDesc |
241 | + return ccsSettingGetLongDesc (self.ccsSetting) |
242 | |
243 | property Group: |
244 | def __get__ (self): |
245 | - return self.ccsSetting.group |
246 | + return ccsSettingGetGroup (self.ccsSetting) |
247 | |
248 | property SubGroup: |
249 | def __get__ (self): |
250 | - return self.ccsSetting.subGroup |
251 | + return ccsSettingGetSubGroup (self.ccsSetting) |
252 | |
253 | property Type: |
254 | def __get__ (self): |
255 | - return SettingTypeString[self.ccsSetting.type] |
256 | + return SettingTypeString[ccsSettingGetType (self.ccsSetting)] |
257 | |
258 | property Info: |
259 | def __get__ (self): |
260 | @@ -666,24 +677,24 @@ |
261 | |
262 | property Hints: |
263 | def __get__ (self): |
264 | - if not self.ccsSetting.hints: |
265 | + if not ccsSettingGetHints (self.ccsSetting): |
266 | return [] |
267 | else: |
268 | - return str (self.ccsSetting.hints).split (";")[:-1] |
269 | + return str (ccsSettingGetHints (self.ccsSetting)).split (";")[:-1] |
270 | |
271 | property IsDefault: |
272 | def __get__ (self): |
273 | - if self.ccsSetting.isDefault: |
274 | + if ccsSettingGetIsDefault (self.ccsSetting): |
275 | return True |
276 | return False |
277 | |
278 | property DefaultValue: |
279 | def __get__ (self): |
280 | - return DecodeValue (&self.ccsSetting.defaultValue) |
281 | + return DecodeValue (ccsSettingGetDefaultValue (self.ccsSetting)) |
282 | |
283 | property Value: |
284 | def __get__ (self): |
285 | - return DecodeValue (self.ccsSetting.value) |
286 | + return DecodeValue (ccsSettingGetValue (self.ccsSetting)) |
287 | def __set__ (self, value): |
288 | cdef CCSSettingValue * sv |
289 | sv = EncodeValue (value, self.ccsSetting, 0) |
290 | @@ -760,22 +771,22 @@ |
291 | while setlist != NULL: |
292 | sett = <CCSSetting *> setlist.data |
293 | |
294 | - subgroup = self.groups[sett.group][1][sett.subGroup][1] |
295 | - |
296 | - setting = Setting (self, sett.name) |
297 | - self.screen[sett.name] = setting |
298 | - subgroup.Screen[sett.name] = setting |
299 | - |
300 | - t = sett.type |
301 | - i = &sett.info |
302 | + subgroup = self.groups[ccsSettingGetGroup (sett)][1][ccsSettingGetSubGroup (sett)][1] |
303 | + |
304 | + setting = Setting (self, ccsSettingGetName (sett)) |
305 | + self.screen[ccsSettingGetName (sett)] = setting |
306 | + subgroup.Screen[ccsSettingGetName (sett)] = setting |
307 | + |
308 | + t = ccsSettingGetType (sett) |
309 | + i = ccsSettingGetInfo (sett) |
310 | if t == TypeList: |
311 | t = i.forList.listType |
312 | i = <CCSSettingInfo *> i.forList.listInfo |
313 | if t == TypeString and i.forString.extensible: |
314 | self.hasExtendedString = True |
315 | |
316 | - if not self.ranking.has_key (sett.name): |
317 | - self.ranking[sett.name] = rank |
318 | + if not self.ranking.has_key (ccsSettingGetName (sett)): |
319 | + self.ranking[ccsSettingGetName (sett)] = rank |
320 | rank = rank + 1 |
321 | |
322 | setlist = setlist.next |
323 | @@ -793,8 +804,8 @@ |
324 | cdef CCSSettingType t |
325 | cdef CCSSettingInfo * i |
326 | |
327 | - t = setting.ccsSetting.type |
328 | - i = &setting.ccsSetting.info |
329 | + t = ccsSettingGetType (setting.ccsSetting) |
330 | + i = ccsSettingGetInfo (setting.ccsSetting) |
331 | if t == TypeList: |
332 | t = i.forList.listType |
333 | i = <CCSSettingInfo *> i.forList.listInfo |
334 | @@ -834,7 +845,7 @@ |
335 | itemsByValue[value] = (name, index) |
336 | |
337 | # Insert itemsByName and sortedItems into setting.info |
338 | - if setting.ccsSetting.type == TypeList: |
339 | + if ccsSettingGetType (setting.ccsSetting) == TypeList: |
340 | setting.info = (setting.info[0], (itemsByName, |
341 | itemsByValue, |
342 | sortedItems)) |
343 | @@ -875,8 +886,8 @@ |
344 | |
345 | for settingItem in settings: |
346 | setting = settingItem |
347 | - t = setting.ccsSetting.type |
348 | - i = &setting.ccsSetting.info |
349 | + t = ccsSettingGetType (setting.ccsSetting) |
350 | + i = ccsSettingGetInfo (setting.ccsSetting) |
351 | if t == TypeList: |
352 | t = i.forList.listType |
353 | i = <CCSSettingInfo *> i.forList.listInfo |
354 | @@ -939,23 +950,23 @@ |
355 | |
356 | property Name: |
357 | def __get__ (self): |
358 | - return self.ccsPlugin.name |
359 | + return ccsPluginGetName (self.ccsPlugin) |
360 | |
361 | property ShortDesc: |
362 | def __get__ (self): |
363 | - return self.ccsPlugin.shortDesc |
364 | + return ccsPluginGetShortDesc (self.ccsPlugin) |
365 | |
366 | property LongDesc: |
367 | def __get__ (self): |
368 | - return self.ccsPlugin.longDesc |
369 | + return ccsPluginGetLongDesc (self.ccsPlugin) |
370 | |
371 | property Category: |
372 | def __get__ (self): |
373 | - return self.ccsPlugin.category |
374 | + return ccsPluginGetCategory (self.ccsPlugin) |
375 | |
376 | property Features: |
377 | def __get__ (self): |
378 | - features = StringListToList (self.ccsPlugin.providesFeature) |
379 | + features = StringListToList (<CCSList *> ccsPluginGetProvidesFeaturesBindable (self.ccsPlugin)) |
380 | return features |
381 | |
382 | property Initialized: |
383 | @@ -965,7 +976,7 @@ |
384 | property Enabled: |
385 | def __get__ (self): |
386 | return bool (ccsPluginIsActive (self.context.ccsContext, |
387 | - self.ccsPlugin.name)) |
388 | + ccsPluginGetName (self.ccsPlugin))) |
389 | def __set__ (self, val): |
390 | if val: |
391 | if len (self.EnableConflicts): |
392 | @@ -996,7 +1007,7 @@ |
393 | ppl = pc.plugins |
394 | while ppl != NULL: |
395 | plg = <CCSPlugin *> ppl.data |
396 | - rpl.append (self.context.Plugins[plg.name]) |
397 | + rpl.append (self.context.Plugins[ccsPluginGetName (plg)]) |
398 | ppl = ppl.next |
399 | ret.append ((ConflictTypeString[pc.type], pc.value, rpl)) |
400 | pls = pls.next |
401 | @@ -1024,7 +1035,7 @@ |
402 | ppl = pc.plugins |
403 | while ppl != NULL: |
404 | plg = <CCSPlugin *> ppl.data |
405 | - rpl.append (self.context.Plugins[plg.name]) |
406 | + rpl.append (self.context.Plugins[ccsPluginGetName (plg)]) |
407 | ppl = ppl.next |
408 | ret.append ((ConflictTypeString[pc.type], pc.value, rpl)) |
409 | pls = pls.next |
410 | @@ -1108,26 +1119,26 @@ |
411 | ccsSetBasicMetadata (True) |
412 | self.plugins = {} |
413 | if not len (plugins): |
414 | - self.ccsContext = ccsContextNew (screenNum) |
415 | + self.ccsContext = ccsContextNew (screenNum, &ccsDefaultInterfaceTable) |
416 | else: |
417 | - self.ccsContext = ccsEmptyContextNew (screenNum) |
418 | + self.ccsContext = ccsEmptyContextNew (screenNum, &ccsDefaultInterfaceTable) |
419 | |
420 | for plugin in plugins: |
421 | self.LoadPlugin (plugin) |
422 | |
423 | ccsReadSettings (self.ccsContext) |
424 | - pll = self.ccsContext.plugins |
425 | + pll = <CCSList *> ccsContextGetPluginsBindable (self.ccsContext) |
426 | self.categories = {} |
427 | while pll != NULL: |
428 | pl = <CCSPlugin *> pll.data |
429 | - self.plugins[pl.name] = Plugin (self, pl.name) |
430 | - if pl.category == NULL: |
431 | + self.plugins[ccsPluginGetName (pl)] = Plugin (self, ccsPluginGetName (pl)) |
432 | + if ccsPluginGetCategory (pl) == NULL: |
433 | cat = '' |
434 | else: |
435 | - cat = pl.category |
436 | + cat = ccsPluginGetCategory (pl) |
437 | if not self.categories.has_key (cat): |
438 | self.categories[cat] = [] |
439 | - self.categories[cat].append (self.plugins[pl.name]) |
440 | + self.categories[cat].append (self.plugins[ccsPluginGetName (pl)]) |
441 | pll = pll.next |
442 | |
443 | self.integration = ccsGetIntegrationEnabled (self.ccsContext) |
444 | @@ -1252,15 +1263,24 @@ |
445 | |
446 | property ChangedSettings: |
447 | def __get__ (self): |
448 | - return SettingListToList (self, self.ccsContext.changedSettings) |
449 | + return SettingListToList (self, <CCSList *> ccsContextGetChangedSettingsBindable (self.ccsContext)) |
450 | def __set__ (self, value): |
451 | cdef CCSSettingList * settingList |
452 | - if self.ccsContext.changedSettings != NULL: |
453 | - self.ccsContext.changedSettings = \ |
454 | - ccsSettingListFree (self.ccsContext.changedSettings, False) |
455 | + cdef CCSSettingList * l |
456 | + cdef CCSSetting * setting |
457 | + |
458 | + ccsContextClearChangedSettings (self.ccsContext) |
459 | if value != None and len (value) != 0: |
460 | settingList = ListToSettingList (value) |
461 | - self.ccsContext.changedSettings = settingList |
462 | + |
463 | + l = settingList |
464 | + |
465 | + while l: |
466 | + setting = <CCSSetting *> l.data |
467 | + ccsContextAddChangedSetting (self.ccsContext, setting) |
468 | + l = l.next |
469 | + |
470 | + ccsSettingListFree (settingList, False) |
471 | |
472 | property AutoSort: |
473 | def __get__ (self): |
474 | |
475 | === modified file 'compizconfig/gconf/src/gconf.c' |
476 | --- compizconfig/gconf/src/gconf.c 2012-05-21 15:30:41 +0000 |
477 | +++ compizconfig/gconf/src/gconf.c 2012-06-27 07:01:20 +0000 |
478 | @@ -63,15 +63,15 @@ |
479 | snprintf (keyName, BUFSIZE, "screen%i", sn); |
480 | |
481 | #define PATHNAME char pathName[BUFSIZE]; \ |
482 | - if (!setting->parent->name || \ |
483 | - strcmp (setting->parent->name, "core") == 0) \ |
484 | + if (!ccsPluginGetName (ccsSettingGetParent (setting)) || \ |
485 | + strcmp (ccsPluginGetName (ccsSettingGetParent (setting)), "core") == 0) \ |
486 | snprintf (pathName, BUFSIZE, \ |
487 | "%s/general/%s/options/%s", COMPIZ, \ |
488 | - keyName, setting->name); \ |
489 | + keyName, ccsSettingGetName (setting)); \ |
490 | else \ |
491 | snprintf(pathName, BUFSIZE, \ |
492 | "%s/plugins/%s/%s/options/%s", COMPIZ, \ |
493 | - setting->parent->name, keyName, setting->name); |
494 | + ccsPluginGetName (ccsSettingGetParent (setting)), keyName, ccsSettingGetName (setting)); |
495 | |
496 | static const char* watchedGnomeDirectories[] = { |
497 | METACITY, |
498 | @@ -408,14 +408,14 @@ |
499 | { |
500 | const SpecialOption *opt = &specialOptions[i]; |
501 | |
502 | - if (strcmp (setting->name, opt->settingName) != 0) |
503 | + if (strcmp (ccsSettingGetName (setting), opt->settingName) != 0) |
504 | continue; |
505 | |
506 | - if (setting->parent->name) |
507 | + if (ccsPluginGetName (ccsSettingGetParent (setting))) |
508 | { |
509 | if (!opt->pluginName) |
510 | continue; |
511 | - if (strcmp (setting->parent->name, opt->pluginName) != 0) |
512 | + if (strcmp (ccsPluginGetName (ccsSettingGetParent (setting)), opt->pluginName) != 0) |
513 | continue; |
514 | } |
515 | else |
516 | @@ -788,7 +788,7 @@ |
517 | CCSSettingValueList list = NULL; |
518 | GSList *valueList = NULL; |
519 | |
520 | - switch (setting->info.forList.listType) |
521 | + switch (ccsSettingGetInfo (setting)->forList.listType) |
522 | { |
523 | case TypeString: |
524 | case TypeMatch: |
525 | @@ -824,7 +824,7 @@ |
526 | |
527 | nItems = g_slist_length (valueList); |
528 | |
529 | - switch (setting->info.forList.listType) |
530 | + switch (ccsSettingGetInfo (setting)->forList.listType) |
531 | { |
532 | case TypeBool: |
533 | { |
534 | @@ -947,10 +947,10 @@ |
535 | if (!s) |
536 | return 0; |
537 | |
538 | - if (s->type != TypeButton) |
539 | + if (ccsSettingGetType (s) != TypeButton) |
540 | return 0; |
541 | |
542 | - return s->value->value.asButton.button; |
543 | + return ccsSettingGetValue (s)->value.asButton.button; |
544 | } |
545 | |
546 | |
547 | @@ -1138,7 +1138,7 @@ |
548 | Bool ret = FALSE; |
549 | Bool valid = TRUE; |
550 | |
551 | - KEYNAME(setting->parent->context->screenNum); |
552 | + KEYNAME (ccsContextGetScreenNum (ccsPluginGetContext (ccsSettingGetParent (setting)))); |
553 | PATHNAME; |
554 | |
555 | /* first check if the key is set */ |
556 | @@ -1153,7 +1153,7 @@ |
557 | return FALSE; |
558 | |
559 | /* setting type sanity check */ |
560 | - switch (setting->type) |
561 | + switch (ccsSettingGetType (setting)) |
562 | { |
563 | case TypeString: |
564 | case TypeMatch: |
565 | @@ -1188,7 +1188,7 @@ |
566 | return FALSE; |
567 | } |
568 | |
569 | - switch (setting->type) |
570 | + switch (ccsSettingGetType (setting)) |
571 | { |
572 | case TypeString: |
573 | { |
574 | @@ -1306,7 +1306,7 @@ |
575 | break; |
576 | default: |
577 | printf("GConf backend: attempt to read unsupported setting type %d from path %s!\n", |
578 | - setting->type, pathName); |
579 | + ccsSettingGetType (setting), pathName); |
580 | break; |
581 | } |
582 | |
583 | @@ -1329,7 +1329,7 @@ |
584 | if (!ccsGetList (setting, &list)) |
585 | return; |
586 | |
587 | - switch (setting->info.forList.listType) |
588 | + switch (ccsSettingGetInfo (setting)->forList.listType) |
589 | { |
590 | case TypeBool: |
591 | { |
592 | @@ -1407,7 +1407,7 @@ |
593 | break; |
594 | default: |
595 | printf("GConf backend: attempt to write unsupported list type %d at path %s!\n", |
596 | - setting->info.forList.listType, pathName); |
597 | + ccsSettingGetInfo (setting)->forList.listType, pathName); |
598 | valueType = GCONF_VALUE_INVALID; |
599 | break; |
600 | } |
601 | @@ -1475,10 +1475,10 @@ |
602 | if (!s) |
603 | return; |
604 | |
605 | - if (s->type != TypeButton) |
606 | + if (ccsSettingGetType (s) != TypeButton) |
607 | return; |
608 | |
609 | - value = s->value->value.asButton; |
610 | + value = ccsSettingGetValue (s)->value.asButton; |
611 | |
612 | if ((value.button != button) || (value.buttonModMask != buttonModMask)) |
613 | { |
614 | @@ -1561,7 +1561,7 @@ |
615 | char *newValue; |
616 | gchar *currentValue; |
617 | |
618 | - newValue = ccsKeyBindingToString (&setting->value->value.asKey); |
619 | + newValue = ccsKeyBindingToString (&ccsSettingGetValue (setting)->value.asKey); |
620 | if (newValue) |
621 | { |
622 | if (strcmp (newValue, "Disabled") == 0) |
623 | @@ -1668,7 +1668,7 @@ |
624 | resizeWithRightButton, NULL); |
625 | } |
626 | |
627 | - modMask = setting->value->value.asButton.buttonModMask; |
628 | + modMask = ccsSettingGetValue (setting)->value.asButton.buttonModMask; |
629 | if (setGnomeMouseButtonModifier (modMask)) |
630 | { |
631 | setButtonBindingForSetting (context, "move", |
632 | @@ -1694,7 +1694,7 @@ |
633 | static void |
634 | resetOptionToDefault (CCSSetting * setting) |
635 | { |
636 | - KEYNAME (setting->parent->context->screenNum); |
637 | + KEYNAME (ccsContextGetScreenNum (ccsPluginGetContext (ccsSettingGetParent (setting)))); |
638 | PATHNAME; |
639 | |
640 | gconf_client_recursive_unset (client, pathName, 0, NULL); |
641 | @@ -1704,10 +1704,10 @@ |
642 | static void |
643 | writeOption (CCSSetting * setting) |
644 | { |
645 | - KEYNAME (setting->parent->context->screenNum); |
646 | + KEYNAME (ccsContextGetScreenNum (ccsPluginGetContext (ccsSettingGetParent (setting)))); |
647 | PATHNAME; |
648 | |
649 | - switch (setting->type) |
650 | + switch (ccsSettingGetType (setting)) |
651 | { |
652 | case TypeString: |
653 | { |
654 | @@ -1819,7 +1819,7 @@ |
655 | break; |
656 | default: |
657 | printf("GConf backend: attempt to write unsupported setting type %d\n", |
658 | - setting->type); |
659 | + ccsSettingGetType (setting)); |
660 | break; |
661 | } |
662 | } |
663 | @@ -2021,7 +2021,7 @@ |
664 | { |
665 | writeIntegratedOption (context, setting, index); |
666 | } |
667 | - else if (setting->isDefault) |
668 | + else if (ccsSettingGetIsDefault (setting)) |
669 | { |
670 | resetOptionToDefault (setting); |
671 | } |
672 | @@ -2033,7 +2033,7 @@ |
673 | static Bool |
674 | getSettingIsIntegrated (CCSSetting * setting) |
675 | { |
676 | - if (!ccsGetIntegrationEnabled (setting->parent->context)) |
677 | + if (!ccsGetIntegrationEnabled (ccsPluginGetContext (ccsSettingGetParent (setting)))) |
678 | return FALSE; |
679 | |
680 | if (!isIntegratedOption (setting, NULL)) |
681 | |
682 | === modified file 'compizconfig/gsettings/src/gconf-integration.c' |
683 | --- compizconfig/gsettings/src/gconf-integration.c 2011-07-29 15:41:46 +0000 |
684 | +++ compizconfig/gsettings/src/gconf-integration.c 2012-06-27 07:01:20 +0000 |
685 | @@ -339,14 +339,14 @@ |
686 | { |
687 | const SpecialOptionGConf *opt = &specialOptions[i]; |
688 | |
689 | - if (strcmp (setting->name, opt->settingName) != 0) |
690 | + if (strcmp (ccsSettingGetName (setting), opt->settingName) != 0) |
691 | continue; |
692 | |
693 | - if (setting->parent->name) |
694 | + if (ccsPluginGetName (ccsSettingGetParent (setting))) |
695 | { |
696 | if (!opt->pluginName) |
697 | continue; |
698 | - if (strcmp (setting->parent->name, opt->pluginName) != 0) |
699 | + if (strcmp (ccsPluginGetName (ccsSettingGetParent (setting)), opt->pluginName) != 0) |
700 | continue; |
701 | } |
702 | else |
703 | @@ -530,10 +530,10 @@ |
704 | if (!s) |
705 | return 0; |
706 | |
707 | - if (s->type != TypeButton) |
708 | + if (ccsSettingGetType (s) != TypeButton) |
709 | return 0; |
710 | |
711 | - return s->value->value.asButton.button; |
712 | + return ccsSettingGetValue (s)->value.asButton.button; |
713 | } |
714 | |
715 | Bool |
716 | @@ -750,10 +750,10 @@ |
717 | if (!s) |
718 | return; |
719 | |
720 | - if (s->type != TypeButton) |
721 | + if (ccsSettingGetType (s) != TypeButton) |
722 | return; |
723 | |
724 | - value = s->value->value.asButton; |
725 | + value = ccsSettingGetValue (s)->value.asButton; |
726 | |
727 | if ((value.button != button) || (value.buttonModMask != buttonModMask)) |
728 | { |
729 | @@ -822,7 +822,7 @@ |
730 | char *newValue; |
731 | gchar *currentValue; |
732 | |
733 | - newValue = ccsKeyBindingToString (&setting->value->value.asKey); |
734 | + newValue = ccsKeyBindingToString (&(ccsSettingGetValue (setting)->value.asKey)); |
735 | if (newValue) |
736 | { |
737 | if (strcmp (newValue, "Disabled") == 0) |
738 | @@ -929,7 +929,7 @@ |
739 | resizeWithRightButton, NULL); |
740 | } |
741 | |
742 | - modMask = setting->value->value.asButton.buttonModMask; |
743 | + modMask = ccsSettingGetValue (setting)->value.asButton.buttonModMask; |
744 | if (setGnomeMouseButtonModifier (modMask)) |
745 | { |
746 | setButtonBindingForSetting (context, "move", |
747 | |
748 | === modified file 'compizconfig/gsettings/src/gsettings.c' |
749 | --- compizconfig/gsettings/src/gsettings.c 2012-05-21 15:37:47 +0000 |
750 | +++ compizconfig/gsettings/src/gsettings.c 2012-06-27 07:01:20 +0000 |
751 | @@ -190,10 +190,12 @@ |
752 | static GSettings * |
753 | getSettingsObjectForCCSSetting (CCSSetting *setting) |
754 | { |
755 | - KEYNAME(setting->parent->context->screenNum); |
756 | - PATHNAME (setting->parent->name, keyName); |
757 | + KEYNAME (ccsContextGetScreenNum (ccsPluginGetContext (ccsSettingGetParent (setting)))); |
758 | + PATHNAME (ccsPluginGetName (ccsSettingGetParent (setting)), keyName); |
759 | |
760 | - return getSettingsObjectForPluginWithPath (setting->parent->name, pathName, setting->parent->context); |
761 | + return getSettingsObjectForPluginWithPath (ccsPluginGetName (ccsSettingGetParent (setting)), |
762 | + pathName, |
763 | + ccsPluginGetContext (ccsSettingGetParent (setting))); |
764 | } |
765 | |
766 | static Bool |
767 | @@ -283,9 +285,9 @@ |
768 | GVariant *value; |
769 | GVariantIter *iter; |
770 | |
771 | - char *cleanSettingName = translateKeyForGSettings (setting->name); |
772 | + char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting)); |
773 | |
774 | - switch (setting->info.forList.listType) |
775 | + switch (ccsSettingGetInfo (setting)->forList.listType) |
776 | { |
777 | case TypeString: |
778 | case TypeMatch: |
779 | @@ -319,7 +321,7 @@ |
780 | iter = g_variant_iter_new (value); |
781 | nItems = g_variant_iter_n_children (iter); |
782 | |
783 | - switch (setting->info.forList.listType) |
784 | + switch (ccsSettingGetInfo (setting)->forList.listType) |
785 | { |
786 | case TypeBool: |
787 | { |
788 | @@ -455,20 +457,20 @@ |
789 | * just return FALSE since compizconfig doesn't expect us |
790 | * to read them anyways */ |
791 | |
792 | - if (setting->type == TypeAction || |
793 | + if (ccsSettingGetType (setting) == TypeAction || |
794 | ccsSettingIsReadOnly (setting)) |
795 | { |
796 | return FALSE; |
797 | } |
798 | |
799 | - char *cleanSettingName = translateKeyForGSettings (setting->name); |
800 | - KEYNAME(setting->parent->context->screenNum); |
801 | - PATHNAME (setting->parent->name, keyName); |
802 | + char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting)); |
803 | + KEYNAME(ccsContextGetScreenNum (ccsPluginGetContext (ccsSettingGetParent (setting)))); |
804 | + PATHNAME (ccsPluginGetName (ccsSettingGetParent (setting)), keyName); |
805 | |
806 | /* first check if the key is set */ |
807 | gsettingsValue = g_settings_get_value (settings, cleanSettingName); |
808 | |
809 | - switch (setting->type) |
810 | + switch (ccsSettingGetType (setting)) |
811 | { |
812 | case TypeString: |
813 | case TypeMatch: |
814 | @@ -506,7 +508,7 @@ |
815 | return FALSE; |
816 | } |
817 | |
818 | - switch (setting->type) |
819 | + switch (ccsSettingGetType (setting)) |
820 | { |
821 | case TypeString: |
822 | { |
823 | @@ -624,7 +626,7 @@ |
824 | break; |
825 | default: |
826 | printf("GSettings backend: attempt to read unsupported setting type %d!\n", |
827 | - setting->type); |
828 | + ccsSettingGetType (setting)); |
829 | break; |
830 | } |
831 | |
832 | @@ -643,12 +645,12 @@ |
833 | gchar *variantType = NULL; |
834 | CCSSettingValueList list; |
835 | |
836 | - char *cleanSettingName = translateKeyForGSettings (setting->name); |
837 | + char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting)); |
838 | |
839 | if (!ccsGetList (setting, &list)) |
840 | return; |
841 | |
842 | - switch (setting->info.forList.listType) |
843 | + switch (ccsSettingGetInfo (setting)->forList.listType) |
844 | { |
845 | case TypeBool: |
846 | { |
847 | @@ -732,7 +734,7 @@ |
848 | break; |
849 | default: |
850 | printf("GSettings backend: attempt to write unsupported list type %d!\n", |
851 | - setting->info.forList.listType); |
852 | + ccsSettingGetInfo (setting)->forList.listType); |
853 | variantType = NULL; |
854 | break; |
855 | } |
856 | @@ -763,9 +765,9 @@ |
857 | { |
858 | GSettings *settings = getSettingsObjectForCCSSetting (setting); |
859 | |
860 | - char *cleanSettingName = translateKeyForGSettings (setting->name); |
861 | - KEYNAME (setting->parent->context->screenNum); |
862 | - PATHNAME (setting->parent->name, keyName); |
863 | + char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting)); |
864 | + KEYNAME(ccsContextGetScreenNum (ccsPluginGetContext (ccsSettingGetParent (setting)))); |
865 | + PATHNAME (ccsPluginGetName (ccsSettingGetParent (setting)), keyName); |
866 | |
867 | g_settings_reset (settings, cleanSettingName); |
868 | |
869 | @@ -776,11 +778,11 @@ |
870 | writeOption (CCSSetting * setting) |
871 | { |
872 | GSettings *settings = getSettingsObjectForCCSSetting (setting); |
873 | - char *cleanSettingName = translateKeyForGSettings (setting->name); |
874 | - KEYNAME (setting->parent->context->screenNum); |
875 | - PATHNAME (setting->parent->name, keyName); |
876 | + char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting)); |
877 | + KEYNAME(ccsContextGetScreenNum (ccsPluginGetContext (ccsSettingGetParent (setting)))); |
878 | + PATHNAME (ccsPluginGetName (ccsSettingGetParent (setting)), keyName); |
879 | |
880 | - switch (setting->type) |
881 | + switch (ccsSettingGetType (setting)) |
882 | { |
883 | case TypeString: |
884 | { |
885 | @@ -904,7 +906,7 @@ |
886 | break; |
887 | default: |
888 | printf("GSettings backend: attempt to write unsupported setting type %d\n", |
889 | - setting->type); |
890 | + ccsSettingGetType (setting)); |
891 | break; |
892 | } |
893 | |
894 | @@ -1095,7 +1097,7 @@ |
895 | { |
896 | writeIntegratedOption (context, setting, index); |
897 | } |
898 | - else if (setting->isDefault) |
899 | + else if (ccsSettingGetIsDefault (setting)) |
900 | { |
901 | resetOptionToDefault (setting); |
902 | } |
903 | @@ -1107,7 +1109,7 @@ |
904 | static Bool |
905 | getSettingIsIntegrated (CCSSetting * setting) |
906 | { |
907 | - if (!ccsGetIntegrationEnabled (setting->parent->context)) |
908 | + if (!ccsGetIntegrationEnabled (ccsPluginGetContext (ccsSettingGetParent (setting)))) |
909 | return FALSE; |
910 | |
911 | if (!isIntegratedOption (setting, NULL)) |
912 | @@ -1168,7 +1170,7 @@ |
913 | { |
914 | GSettings *settings; |
915 | |
916 | - KEYNAME (context->screenNum); |
917 | + KEYNAME (ccsContextGetScreenNum (context)); |
918 | PATHNAME (plugin, keyName); |
919 | |
920 | settings = getSettingsObjectForPluginWithPath (plugin, pathName, context); |
921 | |
922 | === modified file 'compizconfig/libcompizconfig/CMakeLists.txt' |
923 | --- compizconfig/libcompizconfig/CMakeLists.txt 2012-05-24 06:30:07 +0000 |
924 | +++ compizconfig/libcompizconfig/CMakeLists.txt 2012-06-27 07:01:20 +0000 |
925 | @@ -149,3 +149,4 @@ |
926 | add_subdirectory (src) |
927 | add_subdirectory (include) |
928 | add_subdirectory (cmake) |
929 | +add_subdirectory (tests) |
930 | |
931 | === modified file 'compizconfig/libcompizconfig/backend/src/ini.c' |
932 | --- compizconfig/libcompizconfig/backend/src/ini.c 2012-05-21 09:36:37 +0000 |
933 | +++ compizconfig/libcompizconfig/backend/src/ini.c 2012-06-27 07:01:20 +0000 |
934 | @@ -269,16 +269,16 @@ |
935 | if (!data) |
936 | return; |
937 | |
938 | - if (asprintf (&keyName, "s%d_%s", context->screenNum, setting->name) == -1) |
939 | + if (asprintf (&keyName, "s%d_%s", ccsContextGetScreenNum (context), ccsSettingGetName (setting)) == -1) |
940 | return; |
941 | |
942 | - switch (setting->type) |
943 | + switch (ccsSettingGetType (setting)) |
944 | { |
945 | case TypeString: |
946 | { |
947 | char *value; |
948 | - if (ccsIniGetString (data->iniFile, setting->parent->name, |
949 | - keyName, &value)) |
950 | + if (ccsIniGetString (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
951 | + keyName, &value)) |
952 | { |
953 | ccsSetString (setting, value, TRUE); |
954 | free (value); |
955 | @@ -289,7 +289,7 @@ |
956 | case TypeMatch: |
957 | { |
958 | char *value; |
959 | - if (ccsIniGetString (data->iniFile, setting->parent->name, |
960 | + if (ccsIniGetString (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
961 | keyName, &value)) |
962 | { |
963 | ccsSetMatch (setting, value, TRUE); |
964 | @@ -301,7 +301,7 @@ |
965 | case TypeInt: |
966 | { |
967 | int value; |
968 | - if (ccsIniGetInt (data->iniFile, setting->parent->name, |
969 | + if (ccsIniGetInt (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
970 | keyName, &value)) |
971 | { |
972 | ccsSetInt (setting, value, TRUE); |
973 | @@ -312,7 +312,7 @@ |
974 | case TypeBool: |
975 | { |
976 | Bool value; |
977 | - if (ccsIniGetBool (data->iniFile, setting->parent->name, |
978 | + if (ccsIniGetBool (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
979 | keyName, &value)) |
980 | { |
981 | ccsSetBool (setting, (value != 0), TRUE); |
982 | @@ -323,7 +323,7 @@ |
983 | case TypeFloat: |
984 | { |
985 | float value; |
986 | - if (ccsIniGetFloat (data->iniFile, setting->parent->name, |
987 | + if (ccsIniGetFloat (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
988 | keyName, &value)) |
989 | { |
990 | ccsSetFloat (setting, value, TRUE); |
991 | @@ -335,7 +335,7 @@ |
992 | { |
993 | CCSSettingColorValue color; |
994 | |
995 | - if (ccsIniGetColor (data->iniFile, setting->parent->name, |
996 | + if (ccsIniGetColor (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
997 | keyName, &color)) |
998 | { |
999 | ccsSetColor (setting, color, TRUE); |
1000 | @@ -346,7 +346,7 @@ |
1001 | case TypeKey: |
1002 | { |
1003 | CCSSettingKeyValue key; |
1004 | - if (ccsIniGetKey (data->iniFile, setting->parent->name, |
1005 | + if (ccsIniGetKey (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1006 | keyName, &key)) |
1007 | { |
1008 | ccsSetKey (setting, key, TRUE); |
1009 | @@ -357,7 +357,7 @@ |
1010 | case TypeButton: |
1011 | { |
1012 | CCSSettingButtonValue button; |
1013 | - if (ccsIniGetButton (data->iniFile, setting->parent->name, |
1014 | + if (ccsIniGetButton (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1015 | keyName, &button)) |
1016 | { |
1017 | ccsSetButton (setting, button, TRUE); |
1018 | @@ -368,7 +368,7 @@ |
1019 | case TypeEdge: |
1020 | { |
1021 | unsigned int edges; |
1022 | - if (ccsIniGetEdge (data->iniFile, setting->parent->name, |
1023 | + if (ccsIniGetEdge (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1024 | keyName, &edges)) |
1025 | { |
1026 | ccsSetEdge (setting, edges, TRUE); |
1027 | @@ -379,7 +379,7 @@ |
1028 | case TypeBell: |
1029 | { |
1030 | Bool bell; |
1031 | - if (ccsIniGetBell (data->iniFile, setting->parent->name, |
1032 | + if (ccsIniGetBell (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1033 | keyName, &bell)) |
1034 | { |
1035 | ccsSetBell (setting, bell, TRUE); |
1036 | @@ -390,7 +390,7 @@ |
1037 | case TypeList: |
1038 | { |
1039 | CCSSettingValueList value; |
1040 | - if (ccsIniGetList (data->iniFile, setting->parent->name, |
1041 | + if (ccsIniGetList (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1042 | keyName, &value, setting)) |
1043 | { |
1044 | ccsSetList (setting, value, TRUE); |
1045 | @@ -460,31 +460,31 @@ |
1046 | if (!data) |
1047 | return; |
1048 | |
1049 | - if (asprintf (&keyName, "s%d_%s", context->screenNum, setting->name) == -1) |
1050 | + if (asprintf (&keyName, "s%d_%s", ccsContextGetScreenNum (context), ccsSettingGetName (setting)) == -1) |
1051 | return; |
1052 | |
1053 | - if (setting->isDefault) |
1054 | + if (ccsSettingGetIsDefault (setting)) |
1055 | { |
1056 | - ccsIniRemoveEntry (data->iniFile, setting->parent->name, keyName); |
1057 | + ccsIniRemoveEntry (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName); |
1058 | free (keyName); |
1059 | return; |
1060 | } |
1061 | |
1062 | - switch (setting->type) |
1063 | + switch (ccsSettingGetType (setting)) |
1064 | { |
1065 | case TypeString: |
1066 | { |
1067 | char *value; |
1068 | if (ccsGetString (setting, &value)) |
1069 | - ccsIniSetString (data->iniFile, setting->parent->name, |
1070 | - keyName, value); |
1071 | + ccsIniSetString (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1072 | + keyName, value); |
1073 | } |
1074 | break; |
1075 | case TypeMatch: |
1076 | { |
1077 | char *value; |
1078 | if (ccsGetMatch (setting, &value)) |
1079 | - ccsIniSetString (data->iniFile, setting->parent->name, |
1080 | + ccsIniSetString (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1081 | keyName, value); |
1082 | } |
1083 | break; |
1084 | @@ -492,7 +492,7 @@ |
1085 | { |
1086 | int value; |
1087 | if (ccsGetInt (setting, &value)) |
1088 | - ccsIniSetInt (data->iniFile, setting->parent->name, |
1089 | + ccsIniSetInt (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1090 | keyName, value); |
1091 | } |
1092 | break; |
1093 | @@ -500,7 +500,7 @@ |
1094 | { |
1095 | float value; |
1096 | if (ccsGetFloat (setting, &value)) |
1097 | - ccsIniSetFloat (data->iniFile, setting->parent->name, |
1098 | + ccsIniSetFloat (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1099 | keyName, value); |
1100 | } |
1101 | break; |
1102 | @@ -508,7 +508,7 @@ |
1103 | { |
1104 | Bool value; |
1105 | if (ccsGetBool (setting, &value)) |
1106 | - ccsIniSetBool (data->iniFile, setting->parent->name, |
1107 | + ccsIniSetBool (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1108 | keyName, value); |
1109 | } |
1110 | break; |
1111 | @@ -516,7 +516,7 @@ |
1112 | { |
1113 | CCSSettingColorValue value; |
1114 | if (ccsGetColor (setting, &value)) |
1115 | - ccsIniSetColor (data->iniFile, setting->parent->name, |
1116 | + ccsIniSetColor (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1117 | keyName, value); |
1118 | } |
1119 | break; |
1120 | @@ -524,7 +524,7 @@ |
1121 | { |
1122 | CCSSettingKeyValue value; |
1123 | if (ccsGetKey (setting, &value)) |
1124 | - ccsIniSetKey (data->iniFile, setting->parent->name, |
1125 | + ccsIniSetKey (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1126 | keyName, value); |
1127 | } |
1128 | break; |
1129 | @@ -532,7 +532,7 @@ |
1130 | { |
1131 | CCSSettingButtonValue value; |
1132 | if (ccsGetButton (setting, &value)) |
1133 | - ccsIniSetButton (data->iniFile, setting->parent->name, |
1134 | + ccsIniSetButton (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1135 | keyName, value); |
1136 | } |
1137 | break; |
1138 | @@ -540,7 +540,7 @@ |
1139 | { |
1140 | unsigned int value; |
1141 | if (ccsGetEdge (setting, &value)) |
1142 | - ccsIniSetEdge (data->iniFile, setting->parent->name, |
1143 | + ccsIniSetEdge (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1144 | keyName, value); |
1145 | } |
1146 | break; |
1147 | @@ -548,7 +548,7 @@ |
1148 | { |
1149 | Bool value; |
1150 | if (ccsGetBell (setting, &value)) |
1151 | - ccsIniSetBell (data->iniFile, setting->parent->name, |
1152 | + ccsIniSetBell (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1153 | keyName, value); |
1154 | } |
1155 | break; |
1156 | @@ -556,8 +556,8 @@ |
1157 | { |
1158 | CCSSettingValueList value; |
1159 | if (ccsGetList (setting, &value)) |
1160 | - ccsIniSetList (data->iniFile, setting->parent->name, |
1161 | - keyName, value, setting->info.forList.listType); |
1162 | + ccsIniSetList (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), |
1163 | + keyName, value, ccsSettingGetInfo (setting)->forList.listType); |
1164 | } |
1165 | break; |
1166 | default: |
1167 | |
1168 | === modified file 'compizconfig/libcompizconfig/include/ccs.h' |
1169 | --- compizconfig/libcompizconfig/include/ccs.h 2011-08-20 19:03:37 +0000 |
1170 | +++ compizconfig/libcompizconfig/include/ccs.h 2012-06-27 07:01:20 +0000 |
1171 | @@ -19,10 +19,14 @@ |
1172 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1173 | */ |
1174 | |
1175 | - |
1176 | #ifndef _CSS_H |
1177 | #define _CSS_H |
1178 | |
1179 | +#ifdef __cplusplus |
1180 | +extern "C" |
1181 | +{ |
1182 | +#endif |
1183 | + |
1184 | #define D_NONE 0 |
1185 | #define D_NORMAL 1 |
1186 | #define D_FULL 2 |
1187 | @@ -124,6 +128,103 @@ |
1188 | CCSLIST_HDR (StrRestriction, CCSStrRestriction) |
1189 | CCSLIST_HDR (StrExtension, CCSStrExtension) |
1190 | |
1191 | +typedef struct _CCSInterface CCSInterface; /* Dummy typedef */ |
1192 | +typedef struct _CCSPrivate CCSPrivate; /* Dummy typedef */ |
1193 | +typedef struct _CCSObject CCSObject; |
1194 | + |
1195 | +typedef void * (*reallocObjectProc) (void *, void *, size_t); |
1196 | +typedef void * (*mallocObjectProc) (void *, size_t); |
1197 | +typedef void * (*callocObjectProc) (void *, size_t, size_t); |
1198 | +typedef void (*freeObjectProc) (void *, void *); |
1199 | + |
1200 | +typedef struct _CCSObjectAllocationInterface |
1201 | +{ |
1202 | + reallocObjectProc realloc_; |
1203 | + mallocObjectProc malloc_; |
1204 | + callocObjectProc calloc_; |
1205 | + freeObjectProc free_; |
1206 | + void *allocator; |
1207 | +} CCSObjectAllocationInterface; |
1208 | + |
1209 | +extern CCSObjectAllocationInterface ccsDefaultObjectAllocator; |
1210 | + |
1211 | +struct _CCSObject |
1212 | +{ |
1213 | + CCSPrivate *priv; /* Private pointer for object storage */ |
1214 | + |
1215 | + const CCSInterface **interfaces; /* An array of interfaces that this object implements */ |
1216 | + int *interface_types; /* An array of interface types */ |
1217 | + unsigned int n_interfaces; |
1218 | + unsigned int n_allocated_interfaces; |
1219 | + |
1220 | + CCSObjectAllocationInterface *object_allocation; |
1221 | + |
1222 | + unsigned int refcnt; /* Reference count of this object */ |
1223 | +}; |
1224 | + |
1225 | +Bool |
1226 | +ccsObjectInit_ (CCSObject *object, CCSObjectAllocationInterface *interface); |
1227 | + |
1228 | +#define ccsObjectInit(o, interface) (ccsObjectInit_) (&(o)->object, interface) |
1229 | + |
1230 | +Bool |
1231 | +ccsObjectAddInterface_ (CCSObject *object, const CCSInterface *interface, int interface_type); |
1232 | + |
1233 | +#define ccsObjectAddInterface(o, interface, type) (ccsObjectAddInterface_) (&(o)->object, interface, type); |
1234 | + |
1235 | +Bool |
1236 | +ccsObjectRemoveInterface_ (CCSObject *object, int interface_type); |
1237 | + |
1238 | +#define ccsObjectRemoveInterface(o, interface_type) (ccsObjectRemoveInterface_) (&(o)->object, interface_type); |
1239 | + |
1240 | +const CCSInterface * ccsObjectGetInterface_ (CCSObject *object, int interface_type); |
1241 | + |
1242 | +#define ccsObjectGetInterface(o, interface_type) (ccsObjectGetInterface_) (&(o)->object, interface_type) |
1243 | + |
1244 | +#define ccsObjectRef(o) \ |
1245 | + do { ((o)->object).refcnt++; } while (FALSE) |
1246 | + |
1247 | +#define ccsObjectUnref(o, freeFunc) \ |
1248 | + do \ |
1249 | + { \ |
1250 | + ((o)->object).refcnt--; \ |
1251 | + if (!((o)->object).refcnt) \ |
1252 | + freeFunc (o); \ |
1253 | + } while (FALSE) |
1254 | + |
1255 | +CCSPrivate * |
1256 | +ccsObjectGetPrivate_ (CCSObject *object); |
1257 | + |
1258 | +#define ccsObjectGetPrivate(o) (ccsObjectGetPrivate_) (&(o)->object) |
1259 | + |
1260 | +void |
1261 | +ccsObjectSetPrivate_ (CCSObject *object, CCSPrivate *priv); |
1262 | + |
1263 | +#define ccsObjectSetPrivate(o, priv) (ccsObjectSetPrivate_) (&(o)->object, priv) |
1264 | + |
1265 | +void |
1266 | +ccsObjectFinalize_ (CCSObject *object); |
1267 | + |
1268 | +#define ccsObjectFinalize(o) (ccsObjectFinalize_) (&(o)->object) |
1269 | + |
1270 | +unsigned int |
1271 | +ccsAllocateType (); |
1272 | + |
1273 | +#define GET_INTERFACE_TYPE(Interface) \ |
1274 | + ccs##Interface##GetType () |
1275 | + |
1276 | +#define INTERFACE_TYPE(Interface) \ |
1277 | + unsigned int ccs##Interface##GetType () \ |
1278 | + { \ |
1279 | + static unsigned int type_id = 0; \ |
1280 | + if (!type_id) \ |
1281 | + type_id = ccsAllocateType (); \ |
1282 | + \ |
1283 | + return type_id; \ |
1284 | + } |
1285 | + |
1286 | +#define GET_INTERFACE(CType, o) (CType *) ccsObjectGetInterface (o, GET_INTERFACE_TYPE(CType)) |
1287 | + |
1288 | /** |
1289 | * reference counting |
1290 | * |
1291 | @@ -154,20 +255,115 @@ |
1292 | CCSREF_HDR (StrRestriction, CCSStrRestriction) |
1293 | CCSREF_HDR (StrExtension, CCSStrExtension) |
1294 | |
1295 | +typedef struct _CCSInterfaceTable CCSInterfaceTable; |
1296 | +typedef struct _CCSContextInterface CCSContextInterface; |
1297 | +typedef struct _CCSPluginInterface CCSPluginInterface; |
1298 | +typedef struct _CCSSettingInterface CCSSettingInterface; |
1299 | + |
1300 | +struct _CCSInterfaceTable |
1301 | +{ |
1302 | + const CCSContextInterface *contextInterface; |
1303 | + const CCSPluginInterface *pluginInterface; |
1304 | + const CCSSettingInterface *settingInterface; |
1305 | +}; |
1306 | + |
1307 | +extern const CCSInterfaceTable ccsDefaultInterfaceTable; |
1308 | + |
1309 | +/* CCSContext interface */ |
1310 | +typedef CCSPluginList (*CCSContextGetPluginsProc) (CCSContext *context); |
1311 | +typedef CCSPluginCategory * (*CCSContextGetCategories) (CCSContext *context); |
1312 | +typedef CCSSettingList (*CCSContextGetChangedSettings) (CCSContext *context); |
1313 | +typedef unsigned int (*CCSContextGetScreenNum) (CCSContext *context); |
1314 | +typedef Bool (*CCSContextAddChangedSetting) (CCSContext *context, CCSSetting *setting); |
1315 | +typedef Bool (*CCSContextClearChangedSettings) (CCSContext *context); |
1316 | +typedef CCSSettingList (*CCSContextStealChangedSettings) (CCSContext *context); |
1317 | +typedef void * (*CCSContextGetPrivatePtr) (CCSContext *context); |
1318 | +typedef void (*CCSContextSetPrivatePtr) (CCSContext *context, void *ptr); |
1319 | +typedef Bool (*CCSContextLoadPlugin) (CCSContext *context, char *name); |
1320 | +typedef CCSPlugin * (*CCSContextFindPlugin) (CCSContext *context, const char *name); |
1321 | +typedef Bool (*CCSContextPluginIsActive) (CCSContext *context, char *name); |
1322 | +typedef CCSPluginList (*CCSContextGetActivePluginList) (CCSContext *context); |
1323 | +typedef CCSStringList (*CCSContextGetSortedPluginStringList) (CCSContext *context); |
1324 | +typedef Bool (*CCSContextSetBackend) (CCSContext *context, char *name); |
1325 | +typedef char * (*CCSContextGetBackend) (CCSContext *context); |
1326 | +typedef void (*CCSContextSetIntegrationEnabled) (CCSContext *context, Bool value); |
1327 | +typedef void (*CCSContextSetProfile) (CCSContext *context, char *name); |
1328 | +typedef void (*CCSContextSetPluginListAutoSort) (CCSContext *context, Bool value); |
1329 | +typedef char * (*CCSContextGetProfile) (CCSContext *context); |
1330 | +typedef Bool (*CCSContextGetIntegrationEnabled) (CCSContext *context); |
1331 | +typedef Bool (*CCSContextGetPluginListAutoSort) (CCSContext *context); |
1332 | +typedef void (*CCSContextProcessEvents) (CCSContext *context, unsigned int flags); |
1333 | +typedef void (*CCSContextReadSettings) (CCSContext *context); |
1334 | +typedef void (*CCSContextWriteSettings) (CCSContext *context); |
1335 | +typedef void (*CCSContextWriteChangedSettings) (CCSContext *context); |
1336 | +typedef Bool (*CCSContextExportToFile) (CCSContext *context, const char *fileName, Bool skipDefaults); |
1337 | +typedef Bool (*CCSContextImportFromFile) (CCSContext *context, const char *fileName, Bool overwriteNonDefault); |
1338 | +typedef CCSPluginConflictList (*CCSContextCanEnablePlugin) (CCSContext *context, CCSPlugin *plugin); |
1339 | +typedef CCSPluginConflictList (*CCSContextCanDisablePlugin) (CCSContext *context, CCSPlugin *plugin); |
1340 | +typedef CCSStringList (*CCSContextGetExistingProfiles) (CCSContext *context); |
1341 | +typedef void (*CCSContextDeleteProfile) (CCSContext *context, char *name); |
1342 | +typedef Bool (*CCSContextCheckForSettingsUpgrade) (CCSContext *context); |
1343 | +typedef void (*CCSContextLoadPlugins) (CCSContext *context); |
1344 | + |
1345 | +struct _CCSContextInterface |
1346 | +{ |
1347 | + CCSContextGetPluginsProc contextGetPlugins; |
1348 | + CCSContextGetCategories contextGetCategories; |
1349 | + CCSContextGetChangedSettings contextGetChangedSettings; |
1350 | + CCSContextGetScreenNum contextGetScreenNum; |
1351 | + CCSContextAddChangedSetting contextAddChangedSetting; |
1352 | + CCSContextClearChangedSettings contextClearChangedSettings; |
1353 | + CCSContextStealChangedSettings contextStealChangedSettings; |
1354 | + CCSContextGetPrivatePtr contextGetPrivatePtr; |
1355 | + CCSContextSetPrivatePtr contextSetPrivatePtr; |
1356 | + CCSContextLoadPlugin contextLoadPlugin; |
1357 | + CCSContextFindPlugin contextFindPlugin; |
1358 | + CCSContextPluginIsActive contextPluginIsActive; |
1359 | + CCSContextGetActivePluginList contextGetActivePluginList; |
1360 | + CCSContextGetSortedPluginStringList contextGetSortedPluginStringList; |
1361 | + CCSContextSetBackend contextSetBackend; |
1362 | + CCSContextGetBackend contextGetBackend; |
1363 | + CCSContextSetIntegrationEnabled contextSetIntegrationEnabled; |
1364 | + CCSContextSetProfile contextSetProfile; |
1365 | + CCSContextSetPluginListAutoSort contextSetPluginListAutoSort; |
1366 | + CCSContextGetProfile contextGetProfile; |
1367 | + CCSContextGetIntegrationEnabled contextGetIntegrationEnabled; |
1368 | + CCSContextGetPluginListAutoSort contextGetPluginListAutoSort; |
1369 | + CCSContextProcessEvents contextProcessEvents; |
1370 | + CCSContextReadSettings contextReadSettings; |
1371 | + CCSContextWriteSettings contextWriteSettings; |
1372 | + CCSContextWriteChangedSettings contextWriteChangedSettings; |
1373 | + CCSContextExportToFile contextExportToFile; |
1374 | + CCSContextImportFromFile contextImportFromFile; |
1375 | + CCSContextCanEnablePlugin contextCanEnablePlugin; |
1376 | + CCSContextCanDisablePlugin contextCanDisablePlugin; |
1377 | + CCSContextGetExistingProfiles contextGetExistingProfiles; |
1378 | + CCSContextDeleteProfile contextDeleteProfile; |
1379 | + CCSContextCheckForSettingsUpgrade contextCheckForSettingsUpgrade; |
1380 | + CCSContextLoadPlugins contextLoadPlugins; |
1381 | +}; |
1382 | + |
1383 | +unsigned int ccsCCSContextInterfaceGetType (); |
1384 | + |
1385 | +/* CCSContext accessor functions */ |
1386 | +CCSPluginList ccsContextGetPlugins (CCSContext *); |
1387 | +CCSPluginCategory * ccsContextGetCategories (CCSContext *); |
1388 | +CCSSettingList ccsContextGetChangedSettings (CCSContext *); |
1389 | +unsigned int ccsContextGetScreenNum (CCSContext *); |
1390 | +Bool ccsContextAddChangedSetting (CCSContext *context, CCSSetting *setting); |
1391 | +Bool ccsContextClearChangedSettings (CCSContext *context); |
1392 | +CCSSettingList ccsContextStealChangedSettings (CCSContext *context); |
1393 | +void * ccsContextGetPrivatePtr (CCSContext *context); |
1394 | +void ccsContextSetPrivatePtr (CCSContext *context, void *ptr); |
1395 | + |
1396 | +/* only for bindings */ |
1397 | +void * ccsContextGetPluginsBindable (CCSContext *context); |
1398 | +void * ccsContextStealChangedSettingsBindable (CCSContext *context); |
1399 | +void * ccsContextGetChangedSettingsBindable (CCSContext *context); |
1400 | + |
1401 | struct _CCSContext |
1402 | { |
1403 | - CCSPluginList plugins; /* list of plugins settings |
1404 | - were loaded for */ |
1405 | - CCSPluginCategory *categories; /* list of plugin categories */ |
1406 | - void *privatePtr; /* private pointer that can be used |
1407 | - by the caller */ |
1408 | - void *ccsPrivate; /* private pointer for compizconfig |
1409 | - internal usage */ |
1410 | - |
1411 | - CCSSettingList changedSettings; /* list of settings changed since last |
1412 | - settings write */ |
1413 | - |
1414 | - unsigned int screenNum; /* screen number this context is assigned to */ |
1415 | + CCSObject object; |
1416 | }; |
1417 | |
1418 | struct _CCSBackendInfo |
1419 | @@ -180,36 +376,80 @@ |
1420 | unsigned int refCount; /* reference count */ |
1421 | }; |
1422 | |
1423 | +/* CCSPluginInterface */ |
1424 | +typedef char * (*CCSPluginGetName) (CCSPlugin *plugin); |
1425 | +typedef char * (*CCSPluginGetShortDesc) (CCSPlugin *plugin); |
1426 | +typedef char * (*CCSPluginGetLongDesc) (CCSPlugin *plugin); |
1427 | +typedef char * (*CCSPluginGetHints) (CCSPlugin *plugin); |
1428 | +typedef char * (*CCSPluginGetCategory) (CCSPlugin *plugin); |
1429 | + |
1430 | +typedef CCSStringList (*CCSPluginGetLoadAfter) (CCSPlugin *plugin); |
1431 | +typedef CCSStringList (*CCSPluginGetLoadBefore) (CCSPlugin *plugin); |
1432 | +typedef CCSStringList (*CCSPluginGetRequiresPlugins) (CCSPlugin *plugin); |
1433 | +typedef CCSStringList (*CCSPluginGetConflictPlugins) (CCSPlugin *plugin); |
1434 | +typedef CCSStringList (*CCSPluginGetProvidesFeatures) (CCSPlugin *plugin); |
1435 | +typedef CCSStringList (*CCSPluginGetRequiresFeatures) (CCSPlugin *plugin); |
1436 | + |
1437 | +typedef void * (*CCSPluginGetPrivatePtr) (CCSPlugin *plugin); |
1438 | +typedef void (*CCSPluginSetPrivatePtr) (CCSPlugin *plugin, void *); |
1439 | + |
1440 | +typedef CCSContext * (*CCSPluginGetContext) (CCSPlugin *plugin); |
1441 | + |
1442 | +typedef CCSSetting * (*CCSPluginFindSetting) (CCSPlugin *plugin, const char *name); |
1443 | +typedef CCSSettingList (*CCSPluginGetPluginSettings) (CCSPlugin *plugin); |
1444 | +typedef CCSGroupList (*CCSPluginGetPluginGroups) (CCSPlugin *plugin); |
1445 | +typedef void (*CCSPluginReadPluginSettings) (CCSPlugin *plugin); |
1446 | +typedef CCSStrExtensionList (*CCSPluginGetPluginStrExtensions) (CCSPlugin *plugin); |
1447 | + |
1448 | +unsigned int ccsCCSPluginInterfaceGetType (); |
1449 | + |
1450 | +struct _CCSPluginInterface |
1451 | +{ |
1452 | + CCSPluginGetName pluginGetName; |
1453 | + CCSPluginGetShortDesc pluginGetShortDesc; |
1454 | + CCSPluginGetLongDesc pluginGetLongDesc; |
1455 | + CCSPluginGetHints pluginGetHints; |
1456 | + CCSPluginGetCategory pluginGetCategory; |
1457 | + CCSPluginGetLoadAfter pluginGetLoadAfter; |
1458 | + CCSPluginGetLoadBefore pluginGetLoadBefore; |
1459 | + CCSPluginGetRequiresPlugins pluginGetRequiresPlugins; |
1460 | + CCSPluginGetConflictPlugins pluginGetConflictPlugins; |
1461 | + CCSPluginGetProvidesFeatures pluginGetProvidesFeatures; |
1462 | + CCSPluginGetRequiresFeatures pluginGetRequiresFeatures; |
1463 | + CCSPluginGetPrivatePtr pluginGetPrivatePtr; |
1464 | + CCSPluginSetPrivatePtr pluginSetPrivatePtr; |
1465 | + CCSPluginGetContext pluginGetContext; |
1466 | + CCSPluginFindSetting pluginFindSetting; |
1467 | + CCSPluginGetPluginSettings pluginGetPluginSettings; |
1468 | + CCSPluginGetPluginGroups pluginGetPluginGroups; |
1469 | + CCSPluginReadPluginSettings pluginReadPluginSettings; |
1470 | + CCSPluginGetPluginStrExtensions pluginGetPluginStrExtensions; |
1471 | +}; |
1472 | + |
1473 | +/* CCSPlugin accessor functions */ |
1474 | +char * ccsPluginGetName (CCSPlugin *plugin); |
1475 | +char * ccsPluginGetShortDesc (CCSPlugin *plugin); |
1476 | +char * ccsPluginGetLongDesc (CCSPlugin *plugin); |
1477 | +char * ccsPluginGetHints (CCSPlugin *plugin); |
1478 | +char * ccsPluginGetCategory (CCSPlugin *plugin); |
1479 | + |
1480 | +CCSStringList ccsPluginGetLoadAfter (CCSPlugin *plugin); |
1481 | +CCSStringList ccsPluginGetLoadBefore (CCSPlugin *plugin); |
1482 | +CCSStringList ccsPluginGetRequiresPlugins (CCSPlugin *plugin); |
1483 | +CCSStringList ccsPluginGetConflictPlugins (CCSPlugin *plugin); |
1484 | +CCSStringList ccsPluginGetProvidesFeatures (CCSPlugin *plugin); |
1485 | +CCSStringList ccsPluginGetRequiresFeatures (CCSPlugin *plugin); |
1486 | + |
1487 | +void * ccsPluginGetPrivatePtr (CCSPlugin *plugin); |
1488 | +void ccsPluginSetPrivatePtr (CCSPlugin *plugin, void *ptr); |
1489 | + |
1490 | +CCSContext * ccsPluginGetContext (CCSPlugin *plugin); |
1491 | + |
1492 | +void * ccsPluginGetProvidesFeaturesBindable (CCSPlugin *plugin); |
1493 | + |
1494 | struct _CCSPlugin |
1495 | { |
1496 | - char *name; /* plugin name */ |
1497 | - char *shortDesc; /* plugin short description */ |
1498 | - char *longDesc; /* plugin long description */ |
1499 | - char *hints; /* currently unused */ |
1500 | - char *category; /* plugin category name */ |
1501 | - |
1502 | - CCSStringList loadAfter; /* list of plugin names this plugin needs to |
1503 | - be loaded after */ |
1504 | - CCSStringList loadBefore; /* list of plugin names this plugin needs to |
1505 | - be loaded before */ |
1506 | - CCSStringList requiresPlugin; /* list of plugin names this plugin |
1507 | - requires */ |
1508 | - CCSStringList conflictPlugin; /* list of plugin names this plugin |
1509 | - conflicts with */ |
1510 | - CCSStringList conflictFeature; /* list of feature names this plugin |
1511 | - conflicts with */ |
1512 | - CCSStringList providesFeature; /* list of feature names this plugin |
1513 | - provides */ |
1514 | - CCSStringList requiresFeature; /* list of feature names this plugin |
1515 | - requires */ |
1516 | - |
1517 | - void *privatePtr; /* private pointer that can be used |
1518 | - by the caller */ |
1519 | - CCSContext *context; /* context this plugin belongs to */ |
1520 | - |
1521 | - void *ccsPrivate; /* private pointer for compizconfig |
1522 | - internal usage */ |
1523 | - unsigned int refCount; /* reference count */ |
1524 | + CCSObject object; |
1525 | }; |
1526 | |
1527 | typedef enum _CCSSettingType |
1528 | @@ -399,30 +639,187 @@ |
1529 | unsigned int refCount; /* reference count */ |
1530 | }; |
1531 | |
1532 | +/* Interface for CCSSetting */ |
1533 | +char * ccsSettingGetName (CCSSetting *setting); |
1534 | +char * ccsSettingGetShortDesc (CCSSetting *setting); |
1535 | +char * ccsSettingGetLongDesc (CCSSetting *setting); |
1536 | +CCSSettingType ccsSettingGetType (CCSSetting *setting); |
1537 | +CCSSettingInfo * ccsSettingGetInfo (CCSSetting *setting); |
1538 | +char * ccsSettingGetGroup (CCSSetting *setting); |
1539 | +char * ccsSettingGetSubGroup (CCSSetting *setting); |
1540 | +char * ccsSettingGetHints (CCSSetting *setting); |
1541 | +CCSSettingValue * ccsSettingGetDefaultValue (CCSSetting *setting); |
1542 | +CCSSettingValue *ccsSettingGetValue (CCSSetting *setting); |
1543 | +Bool ccsSettingGetIsDefault (CCSSetting *setting); |
1544 | +CCSPlugin * ccsSettingGetParent (CCSSetting *setting); |
1545 | +void * ccsSettingGetPrivatePtr (CCSSetting *setting); |
1546 | +void ccsSettingSetPrivatePtr (CCSSetting *setting, void *ptr); |
1547 | + |
1548 | +/* Setting getters. Returns TRUE if the setting value was successfully |
1549 | + copied into <data>, FALSE otherwise. */ |
1550 | +Bool ccsGetInt (CCSSetting *setting, |
1551 | + int *data); |
1552 | +Bool ccsGetFloat (CCSSetting *setting, |
1553 | + float *data); |
1554 | +Bool ccsGetBool (CCSSetting *setting, |
1555 | + Bool *data); |
1556 | +Bool ccsGetString (CCSSetting *setting, |
1557 | + char **data); |
1558 | +Bool ccsGetColor (CCSSetting *setting, |
1559 | + CCSSettingColorValue *data); |
1560 | +Bool ccsGetMatch (CCSSetting *setting, |
1561 | + char **data); |
1562 | +Bool ccsGetKey (CCSSetting *setting, |
1563 | + CCSSettingKeyValue *data); |
1564 | +Bool ccsGetButton (CCSSetting *setting, |
1565 | + CCSSettingButtonValue *data); |
1566 | +Bool ccsGetEdge (CCSSetting *setting, |
1567 | + unsigned int *data); |
1568 | +Bool ccsGetBell (CCSSetting *setting, |
1569 | + Bool *data); |
1570 | +Bool ccsGetList (CCSSetting *setting, |
1571 | + CCSSettingValueList *data); |
1572 | + |
1573 | +/* Setting setters. Set <setting> to value <data>. Return TRUE if new value |
1574 | + matches data. If the new value doesn't match the old value, the setting |
1575 | + is added to the context's changedSettings list. */ |
1576 | +Bool ccsSetInt (CCSSetting *setting, |
1577 | + int data, |
1578 | + Bool processChanged); |
1579 | +Bool ccsSetFloat (CCSSetting *setting, |
1580 | + float data, |
1581 | + Bool processChanged); |
1582 | +Bool ccsSetBool (CCSSetting *setting, |
1583 | + Bool data, |
1584 | + Bool processChanged); |
1585 | +Bool ccsSetString (CCSSetting *setting, |
1586 | + const char *data, |
1587 | + Bool processChanged); |
1588 | +Bool ccsSetColor (CCSSetting *setting, |
1589 | + CCSSettingColorValue data, |
1590 | + Bool processChanged); |
1591 | +Bool ccsSetMatch (CCSSetting *setting, |
1592 | + const char *data, |
1593 | + Bool processChanged); |
1594 | +Bool ccsSetKey (CCSSetting *setting, |
1595 | + CCSSettingKeyValue data, |
1596 | + Bool processChanged); |
1597 | +Bool ccsSetButton (CCSSetting *setting, |
1598 | + CCSSettingButtonValue data, |
1599 | + Bool processChanged); |
1600 | +Bool ccsSetEdge (CCSSetting *setting, |
1601 | + unsigned int data, |
1602 | + Bool processChanged); |
1603 | +Bool ccsSetBell (CCSSetting *setting, |
1604 | + Bool data, |
1605 | + Bool processChanged); |
1606 | +Bool ccsSetList (CCSSetting *setting, |
1607 | + CCSSettingValueList data, |
1608 | + Bool processChanged); |
1609 | +Bool ccsSetValue (CCSSetting *setting, |
1610 | + CCSSettingValue *data, |
1611 | + Bool processChanged); |
1612 | + |
1613 | +/* Reset all settings to defaults. Settings that were non-default |
1614 | + previously are added to the changedSettings list of the context. */ |
1615 | +void ccsResetToDefault (CCSSetting * setting, Bool processChanged); |
1616 | + |
1617 | +/* Checks if a given setting is integrated in the desktop environment. */ |
1618 | +Bool ccsSettingIsIntegrated (CCSSetting *setting); |
1619 | + |
1620 | +/* Checks if a given setting is read-only. */ |
1621 | +Bool ccsSettingIsReadOnly (CCSSetting *setting); |
1622 | + |
1623 | +typedef char * (*CCSSettingGetName) (CCSSetting *); |
1624 | +typedef char * (*CCSSettingGetShortDesc) (CCSSetting *); |
1625 | +typedef char * (*CCSSettingGetLongDesc) (CCSSetting *); |
1626 | +typedef CCSSettingType (*CCSSettingGetType) (CCSSetting *); |
1627 | +typedef CCSSettingInfo * (*CCSSettingGetInfo) (CCSSetting *); |
1628 | +typedef char * (*CCSSettingGetGroup) (CCSSetting *); |
1629 | +typedef char * (*CCSSettingGetSubGroup) (CCSSetting *); |
1630 | +typedef char * (*CCSSettingGetHints) (CCSSetting *); |
1631 | +typedef CCSSettingValue * (*CCSSettingGetDefaultValue) (CCSSetting *setting); |
1632 | +typedef CCSSettingValue * (*CCSSettingGetValue) (CCSSetting *setting); |
1633 | +typedef Bool (*CCSSettingGetIsDefault) (CCSSetting *); |
1634 | +typedef CCSPlugin * (*CCSSettingGetParent) (CCSSetting *); |
1635 | +typedef void * (*CCSSettingGetPrivatePtr) (CCSSetting *); |
1636 | +typedef void (*CCSSettingSetPrivatePtr) (CCSSetting *, void *); |
1637 | +typedef Bool (*CCSSettingSetInt) (CCSSetting *setting, int data, Bool processChanged); |
1638 | +typedef Bool (*CCSSettingSetFloat) (CCSSetting *setting, float data, Bool processChanged); |
1639 | +typedef Bool (*CCSSettingSetBool) (CCSSetting *setting, Bool data, Bool processChanged); |
1640 | +typedef Bool (*CCSSettingSetString) (CCSSetting *setting, const char * data, Bool processChanged); |
1641 | +typedef Bool (*CCSSettingSetColor) (CCSSetting *setting, CCSSettingColorValue data, Bool processChanged); |
1642 | +typedef Bool (*CCSSettingSetMatch) (CCSSetting *setting, const char * data, Bool processChanged); |
1643 | +typedef Bool (*CCSSettingSetKey) (CCSSetting *setting, CCSSettingKeyValue data, Bool processChanged); |
1644 | +typedef Bool (*CCSSettingSetButton) (CCSSetting *setting, CCSSettingButtonValue data, Bool processChanged); |
1645 | +typedef Bool (*CCSSettingSetEdge) (CCSSetting *setting, unsigned int data, Bool processChanged); |
1646 | +typedef Bool (*CCSSettingSetBell) (CCSSetting *setting, Bool data, Bool processChanged); |
1647 | +typedef Bool (*CCSSettingSetList) (CCSSetting *setting, CCSSettingValueList data, Bool processChanged); |
1648 | +typedef Bool (*CCSSettingSetValue) (CCSSetting *setting, CCSSettingValue *data, Bool processChanged); |
1649 | +typedef Bool (*CCSSettingGetInt) (CCSSetting *setting, int *data); |
1650 | +typedef Bool (*CCSSettingGetFloat) (CCSSetting *setting, float *data); |
1651 | +typedef Bool (*CCSSettingGetBool) (CCSSetting *setting, Bool *data); |
1652 | +typedef Bool (*CCSSettingGetString) (CCSSetting *setting, char **data); |
1653 | +typedef Bool (*CCSSettingGetColor) (CCSSetting *setting, CCSSettingColorValue *data); |
1654 | +typedef Bool (*CCSSettingGetMatch) (CCSSetting *setting, char **data); |
1655 | +typedef Bool (*CCSSettingGetKey) (CCSSetting *setting, CCSSettingKeyValue *data); |
1656 | +typedef Bool (*CCSSettingGetButton) (CCSSetting *setting, CCSSettingButtonValue *data); |
1657 | +typedef Bool (*CCSSettingGetEdge) (CCSSetting *setting, unsigned int *data); |
1658 | +typedef Bool (*CCSSettingGetBell) (CCSSetting *setting, Bool *data); |
1659 | +typedef Bool (*CCSSettingGetList) (CCSSetting *setting, CCSSettingValueList *data); |
1660 | +typedef void (*CCSSettingResetToDefault) (CCSSetting *setting, Bool processChanged); |
1661 | +typedef Bool (*CCSSettingIsIntegrated) (CCSSetting *setting); |
1662 | +typedef Bool (*CCSSettingIsReadOnly) (CCSSetting *setting); |
1663 | + |
1664 | +unsigned int ccsCCSSettingInterfaceGetType (); |
1665 | + |
1666 | +struct _CCSSettingInterface |
1667 | +{ |
1668 | + CCSSettingGetName settingGetName; |
1669 | + CCSSettingGetShortDesc settingGetShortDesc; |
1670 | + CCSSettingGetLongDesc settingGetLongDesc; |
1671 | + CCSSettingGetType settingGetType; |
1672 | + CCSSettingGetInfo settingGetInfo; |
1673 | + CCSSettingGetGroup settingGetGroup; |
1674 | + CCSSettingGetSubGroup settingGetSubGroup; |
1675 | + CCSSettingGetHints settingGetHints; |
1676 | + CCSSettingGetDefaultValue settingGetDefaultValue; |
1677 | + CCSSettingGetValue settingGetValue; |
1678 | + CCSSettingGetIsDefault settingGetIsDefault; |
1679 | + CCSSettingGetParent settingGetParent; |
1680 | + CCSSettingGetPrivatePtr settingGetPrivatePtr; |
1681 | + CCSSettingSetPrivatePtr settingSetPrivatePtr; |
1682 | + CCSSettingSetInt settingSetInt; |
1683 | + CCSSettingSetFloat settingSetFloat; |
1684 | + CCSSettingSetBool settingSetBool; |
1685 | + CCSSettingSetString settingSetString; |
1686 | + CCSSettingSetColor settingSetColor; |
1687 | + CCSSettingSetMatch settingSetMatch; |
1688 | + CCSSettingSetKey settingSetKey; |
1689 | + CCSSettingSetButton settingSetButton; |
1690 | + CCSSettingSetEdge settingSetEdge; |
1691 | + CCSSettingSetBell settingSetBell; |
1692 | + CCSSettingSetList settingSetList; |
1693 | + CCSSettingSetValue settingSetValue; |
1694 | + CCSSettingGetInt settingGetInt; |
1695 | + CCSSettingGetFloat settingGetFloat; |
1696 | + CCSSettingGetBool settingGetBool; |
1697 | + CCSSettingGetString settingGetString; |
1698 | + CCSSettingGetColor settingGetColor; |
1699 | + CCSSettingGetMatch settingGetMatch; |
1700 | + CCSSettingGetKey settingGetKey; |
1701 | + CCSSettingGetButton settingGetButton; |
1702 | + CCSSettingGetEdge settingGetEdge; |
1703 | + CCSSettingGetBell settingGetBell; |
1704 | + CCSSettingGetList settingGetList; |
1705 | + CCSSettingResetToDefault settingResetToDefault; |
1706 | + CCSSettingIsIntegrated settingIsIntegrated; |
1707 | + CCSSettingIsReadOnly settingIsReadOnly; |
1708 | +}; |
1709 | + |
1710 | struct _CCSSetting |
1711 | { |
1712 | - char *name; /* setting name */ |
1713 | - char *shortDesc; /* setting short description in current locale */ |
1714 | - char *longDesc; /* setting long description in current locale */ |
1715 | - |
1716 | - CCSSettingType type; /* setting type */ |
1717 | - |
1718 | - CCSSettingInfo info; /* information assigned to this setting, |
1719 | - valid if the setting is an int, float, string |
1720 | - or list setting */ |
1721 | - |
1722 | - char *group; /* group name in current locale */ |
1723 | - char *subGroup; /* sub group name in current locale */ |
1724 | - char *hints; /* hints in current locale */ |
1725 | - |
1726 | - CCSSettingValue defaultValue; /* default value of this setting */ |
1727 | - CCSSettingValue *value; /* actual value of this setting */ |
1728 | - Bool isDefault; /* does the actual value match the default |
1729 | - value? */ |
1730 | - |
1731 | - CCSPlugin *parent; /* plugin this setting belongs to */ |
1732 | - void *privatePtr; /* private pointer for usage by the caller */ |
1733 | - unsigned int refCount; /* reference count */ |
1734 | + CCSObject object; |
1735 | }; |
1736 | |
1737 | struct _CCSPluginCategory |
1738 | @@ -441,11 +838,11 @@ |
1739 | |
1740 | /* Creates a new context for the given screen. |
1741 | All plugin settings are automatically enumerated. */ |
1742 | -CCSContext* ccsContextNew (unsigned int screenNum); |
1743 | +CCSContext* ccsContextNew (unsigned int screenNum, const CCSInterfaceTable *); |
1744 | |
1745 | /* Creates a new context without auto-enumerating any plugin or setting. |
1746 | Behaves otherwise exactly like ccsContextNew. */ |
1747 | -CCSContext* ccsEmptyContextNew (unsigned int screenNum); |
1748 | +CCSContext* ccsEmptyContextNew (unsigned int screenNum, const CCSInterfaceTable *); |
1749 | |
1750 | /* Destroys the allocated context. */ |
1751 | void ccsContextDestroy (CCSContext * context); |
1752 | @@ -484,45 +881,7 @@ |
1753 | void ccsFreeStrExtension (CCSStrExtension *extension); |
1754 | void ccsFreeString (CCSString *str); |
1755 | |
1756 | -/* Setting setters. Set <setting> to value <data>. Return TRUE if new value |
1757 | - matches data. If the new value doesn't match the old value, the setting |
1758 | - is added to the context's changedSettings list. */ |
1759 | -Bool ccsSetInt (CCSSetting *setting, |
1760 | - int data, |
1761 | - Bool processChanged); |
1762 | -Bool ccsSetFloat (CCSSetting *setting, |
1763 | - float data, |
1764 | - Bool processChanged); |
1765 | -Bool ccsSetBool (CCSSetting *setting, |
1766 | - Bool data, |
1767 | - Bool processChanged); |
1768 | -Bool ccsSetString (CCSSetting *setting, |
1769 | - const char *data, |
1770 | - Bool processChanged); |
1771 | -Bool ccsSetColor (CCSSetting *setting, |
1772 | - CCSSettingColorValue data, |
1773 | - Bool processChanged); |
1774 | -Bool ccsSetMatch (CCSSetting *setting, |
1775 | - const char *data, |
1776 | - Bool processChanged); |
1777 | -Bool ccsSetKey (CCSSetting *setting, |
1778 | - CCSSettingKeyValue data, |
1779 | - Bool processChanged); |
1780 | -Bool ccsSetButton (CCSSetting *setting, |
1781 | - CCSSettingButtonValue data, |
1782 | - Bool processChanged); |
1783 | -Bool ccsSetEdge (CCSSetting *setting, |
1784 | - unsigned int data, |
1785 | - Bool processChanged); |
1786 | -Bool ccsSetBell (CCSSetting *setting, |
1787 | - Bool data, |
1788 | - Bool processChanged); |
1789 | -Bool ccsSetList (CCSSetting *setting, |
1790 | - CCSSettingValueList data, |
1791 | - Bool processChanged); |
1792 | -Bool ccsSetValue (CCSSetting *setting, |
1793 | - CCSSettingValue *data, |
1794 | - Bool processChanged); |
1795 | + |
1796 | |
1797 | /* Compares two setting values. Returns TRUE if values match, |
1798 | FALSE otherwise. */ |
1799 | @@ -533,31 +892,6 @@ |
1800 | Bool ccsIsEqualButton (CCSSettingButtonValue c1, |
1801 | CCSSettingButtonValue c2); |
1802 | |
1803 | -/* Setting getters. Returns TRUE if the setting value was successfully |
1804 | - copied into <data>, FALSE otherwise. */ |
1805 | -Bool ccsGetInt (CCSSetting *setting, |
1806 | - int *data); |
1807 | -Bool ccsGetFloat (CCSSetting *setting, |
1808 | - float *data); |
1809 | -Bool ccsGetBool (CCSSetting *setting, |
1810 | - Bool *data); |
1811 | -Bool ccsGetString (CCSSetting *setting, |
1812 | - char **data); |
1813 | -Bool ccsGetColor (CCSSetting *setting, |
1814 | - CCSSettingColorValue *data); |
1815 | -Bool ccsGetMatch (CCSSetting *setting, |
1816 | - char **data); |
1817 | -Bool ccsGetKey (CCSSetting *setting, |
1818 | - CCSSettingKeyValue *data); |
1819 | -Bool ccsGetButton (CCSSetting *setting, |
1820 | - CCSSettingButtonValue *data); |
1821 | -Bool ccsGetEdge (CCSSetting *setting, |
1822 | - unsigned int *data); |
1823 | -Bool ccsGetBell (CCSSetting *setting, |
1824 | - Bool *data); |
1825 | -Bool ccsGetList (CCSSetting *setting, |
1826 | - CCSSettingValueList *data); |
1827 | - |
1828 | /* Retrieves a list of settings in a plugin */ |
1829 | CCSSettingList ccsGetPluginSettings (CCSPlugin *plugin); |
1830 | |
1831 | @@ -709,10 +1043,6 @@ |
1832 | /* Write changed settings to disk */ |
1833 | void ccsWriteChangedSettings (CCSContext *context); |
1834 | |
1835 | -/* Reset all settings to defaults. Settings that were non-default |
1836 | - previously are added to the changedSettings list of the context. */ |
1837 | -void ccsResetToDefault (CCSSetting * setting, Bool processChanged); |
1838 | - |
1839 | /* Exports a profile to a file. If skipDefaults is TRUE, only exports |
1840 | non-default settings. Returns TRUE on successful export, FALSE otherwise. */ |
1841 | Bool ccsExportToFile (CCSContext *context, |
1842 | @@ -902,15 +1232,10 @@ |
1843 | /* Enumerates the available backends. */ |
1844 | CCSBackendInfoList ccsGetExistingBackends (void); |
1845 | |
1846 | -/* Checks if a given setting is integrated in the desktop environment. */ |
1847 | -Bool ccsSettingIsIntegrated (CCSSetting *setting); |
1848 | - |
1849 | -/* Checks if a given setting is read-only. */ |
1850 | -Bool ccsSettingIsReadOnly (CCSSetting *setting); |
1851 | - |
1852 | CCSStrExtensionList ccsGetPluginStrExtensions (CCSPlugin *plugin); |
1853 | |
1854 | -/* Checks if settings need to be constrained */ |
1855 | -Bool ccsContextNeedsConstraining (CCSContext *context); |
1856 | +#ifdef __cplusplus |
1857 | +} |
1858 | +#endif |
1859 | |
1860 | #endif |
1861 | |
1862 | === modified file 'compizconfig/libcompizconfig/src/CMakeLists.txt' |
1863 | --- compizconfig/libcompizconfig/src/CMakeLists.txt 2012-05-27 14:28:20 +0000 |
1864 | +++ compizconfig/libcompizconfig/src/CMakeLists.txt 2012-06-27 07:01:20 +0000 |
1865 | @@ -35,6 +35,9 @@ |
1866 | ${LIBCOMPIZCONFIG_FILES} |
1867 | ${CMAKE_CURRENT_BINARY_DIR}/compizconfig.pb.cc |
1868 | ) |
1869 | + set (LIBCOMPIZCONFIG_LIBRARIES |
1870 | + ${LIBCOMPIZCONFIG_LIBRARIES} |
1871 | + protobuf) |
1872 | add_definitions ( |
1873 | -DUSE_PROTOBUF |
1874 | ) |
1875 | |
1876 | === modified file 'compizconfig/libcompizconfig/src/ccs-private.h' |
1877 | --- compizconfig/libcompizconfig/src/ccs-private.h 2011-08-20 19:03:37 +0000 |
1878 | +++ compizconfig/libcompizconfig/src/ccs-private.h 2012-06-27 07:01:20 +0000 |
1879 | @@ -26,25 +26,62 @@ |
1880 | #include <ccs-backend.h> |
1881 | |
1882 | #define CONTEXT_PRIV(c) \ |
1883 | - CCSContextPrivate *cPrivate = (CCSContextPrivate *) c->ccsPrivate; |
1884 | + CCSContextPrivate *cPrivate = (CCSContextPrivate *) ccsObjectGetPrivate (c); |
1885 | #define PLUGIN_PRIV(p) \ |
1886 | - CCSPluginPrivate *pPrivate = (CCSPluginPrivate *) p->ccsPrivate; |
1887 | + CCSPluginPrivate *pPrivate = (CCSPluginPrivate *) ccsObjectGetPrivate (p); |
1888 | +#define SETTING_PRIV(s) \ |
1889 | + CCSSettingPrivate *sPrivate = (CCSSettingPrivate *) ccsObjectGetPrivate (s); |
1890 | |
1891 | extern Bool basicMetadata; |
1892 | |
1893 | typedef struct _CCSContextPrivate |
1894 | { |
1895 | CCSBackend *backend; |
1896 | - |
1897 | + CCSPluginList plugins; /* list of plugins settings |
1898 | + were loaded for */ |
1899 | + CCSPluginCategory *categories; /* list of plugin categories */ |
1900 | + void *privatePtr; /* private pointer that can be used |
1901 | + by the caller */ |
1902 | char *profile; |
1903 | Bool deIntegration; |
1904 | Bool pluginListAutoSort; |
1905 | |
1906 | unsigned int configWatchId; |
1907 | + |
1908 | + CCSSettingList changedSettings; /* list of settings changed since last |
1909 | + settings write */ |
1910 | + |
1911 | + unsigned int screenNum; /* screen number this context is assigned to */ |
1912 | + const CCSInterfaceTable *object_interfaces; |
1913 | } CCSContextPrivate; |
1914 | |
1915 | typedef struct _CCSPluginPrivate |
1916 | { |
1917 | + char *name; /* plugin name */ |
1918 | + char *shortDesc; /* plugin short description */ |
1919 | + char *longDesc; /* plugin long description */ |
1920 | + char *hints; /* currently unused */ |
1921 | + char *category; /* plugin category name */ |
1922 | + |
1923 | + CCSStringList loadAfter; /* list of plugin names this plugin needs to |
1924 | + be loaded after */ |
1925 | + CCSStringList loadBefore; /* list of plugin names this plugin needs to |
1926 | + be loaded before */ |
1927 | + CCSStringList requiresPlugin; /* list of plugin names this plugin |
1928 | + requires */ |
1929 | + CCSStringList conflictPlugin; /* list of plugin names this plugin |
1930 | + conflicts with */ |
1931 | + CCSStringList conflictFeature; /* list of feature names this plugin |
1932 | + conflicts with */ |
1933 | + CCSStringList providesFeature; /* list of feature names this plugin |
1934 | + provides */ |
1935 | + CCSStringList requiresFeature; /* list of feature names this plugin |
1936 | + requires */ |
1937 | + |
1938 | + void *privatePtr; /* private pointer that can be used |
1939 | + by the caller */ |
1940 | + CCSContext *context; /* context this plugin belongs to */ |
1941 | + |
1942 | CCSSettingList settings; |
1943 | CCSGroupList groups; |
1944 | Bool loaded; |
1945 | @@ -58,6 +95,31 @@ |
1946 | CCSStrExtensionList stringExtensions; |
1947 | } CCSPluginPrivate; |
1948 | |
1949 | +typedef struct _CCSSettingPrivate |
1950 | +{ |
1951 | + char *name; /* setting name */ |
1952 | + char *shortDesc; /* setting short description in current locale */ |
1953 | + char *longDesc; /* setting long description in current locale */ |
1954 | + |
1955 | + CCSSettingType type; /* setting type */ |
1956 | + |
1957 | + CCSSettingInfo info; /* information assigned to this setting, |
1958 | + valid if the setting is an int, float, string |
1959 | + or list setting */ |
1960 | + |
1961 | + char *group; /* group name in current locale */ |
1962 | + char *subGroup; /* sub group name in current locale */ |
1963 | + char *hints; /* hints in current locale */ |
1964 | + |
1965 | + CCSSettingValue defaultValue; /* default value of this setting */ |
1966 | + CCSSettingValue *value; /* actual value of this setting */ |
1967 | + Bool isDefault; /* does the actual value match the default |
1968 | + value? */ |
1969 | + |
1970 | + CCSPlugin *parent; /* plugin this setting belongs to */ |
1971 | + void *privatePtr; /* private pointer for usage by the caller */ |
1972 | +} CCSSettingPrivate; |
1973 | + |
1974 | typedef struct _CCSSettingsUpgrade |
1975 | { |
1976 | char *profile; |
1977 | @@ -78,6 +140,9 @@ |
1978 | void ccsLoadPluginSettings (CCSPlugin * plugin); |
1979 | void collateGroups (CCSPluginPrivate * p); |
1980 | |
1981 | +Bool ccsLoadPluginDefault (CCSContext *context, char *name); |
1982 | +void ccsLoadPluginsDefault (CCSContext *context); |
1983 | + |
1984 | void ccsCheckFileWatches (void); |
1985 | |
1986 | typedef enum { |
1987 | |
1988 | === modified file 'compizconfig/libcompizconfig/src/compiz.cpp' |
1989 | --- compizconfig/libcompizconfig/src/compiz.cpp 2012-05-23 10:07:03 +0000 |
1990 | +++ compizconfig/libcompizconfig/src/compiz.cpp 2012-06-27 07:01:20 +0000 |
1991 | @@ -562,69 +562,87 @@ |
1992 | return; |
1993 | } |
1994 | |
1995 | + CONTEXT_PRIV (ccsPluginGetContext (plugin)); |
1996 | + |
1997 | setting = (CCSSetting *) calloc (1, sizeof (CCSSetting)); |
1998 | + |
1999 | if (!setting) |
2000 | return; |
2001 | |
2002 | - setting->parent = plugin; |
2003 | - setting->isDefault = TRUE; |
2004 | - setting->name = strdup (name); |
2005 | - setting->refCount = 1; |
2006 | + ccsObjectInit (setting, &ccsDefaultObjectAllocator); |
2007 | + |
2008 | + CCSSettingPrivate *ccsPrivate = (CCSSettingPrivate *) calloc (1, sizeof (CCSSettingPrivate)); |
2009 | + |
2010 | + if (!ccsPrivate) |
2011 | + { |
2012 | + free (setting); |
2013 | + return; |
2014 | + } |
2015 | + |
2016 | + ccsObjectSetPrivate (setting, (CCSPrivate *) ccsPrivate); |
2017 | + ccsObjectAddInterface (setting, (CCSInterface *) cPrivate->object_interfaces->settingInterface, GET_INTERFACE_TYPE (CCSSettingInterface)); |
2018 | + ccsSettingRef (setting); |
2019 | + |
2020 | + SETTING_PRIV (setting); |
2021 | + |
2022 | + sPrivate->parent = plugin; |
2023 | + sPrivate->isDefault = TRUE; |
2024 | + sPrivate->name = strdup (name); |
2025 | |
2026 | if (!basicMetadata) |
2027 | { |
2028 | - setting->shortDesc = |
2029 | + sPrivate->shortDesc = |
2030 | strdup (option.has_short_desc () ? |
2031 | option.short_desc ().c_str () : |
2032 | name); |
2033 | - setting->longDesc = |
2034 | + sPrivate->longDesc = |
2035 | strdup (option.has_long_desc () ? |
2036 | option.long_desc ().c_str () : |
2037 | name); |
2038 | - setting->hints = strdup (option.has_hints () ? |
2039 | + sPrivate->hints = strdup (option.has_hints () ? |
2040 | option.hints ().c_str () : |
2041 | name); |
2042 | - setting->group = |
2043 | + sPrivate->group = |
2044 | strdup (option.group_id () >= 0 ? |
2045 | groups.Get (option.group_id ()).c_str () : |
2046 | ""); |
2047 | - setting->subGroup = |
2048 | + sPrivate->subGroup = |
2049 | strdup (option.subgroup_id () >= 0 ? |
2050 | subgroups.Get (option.subgroup_id ()).c_str () : |
2051 | ""); |
2052 | } |
2053 | else |
2054 | { |
2055 | - setting->shortDesc = strdup (name); |
2056 | - setting->longDesc = strdup (""); |
2057 | - setting->hints = strdup (""); |
2058 | - setting->group = strdup (""); |
2059 | - setting->subGroup = strdup (""); |
2060 | + sPrivate->shortDesc = strdup (name); |
2061 | + sPrivate->longDesc = strdup (""); |
2062 | + sPrivate->hints = strdup (""); |
2063 | + sPrivate->group = strdup (""); |
2064 | + sPrivate->subGroup = strdup (""); |
2065 | } |
2066 | |
2067 | - setting->type = (CCSSettingType) option.type (); |
2068 | - setting->value = &setting->defaultValue; |
2069 | - setting->defaultValue.parent = setting; |
2070 | + sPrivate->type = (CCSSettingType) option.type (); |
2071 | + sPrivate->value = &sPrivate->defaultValue; |
2072 | + sPrivate->defaultValue.parent = setting; |
2073 | |
2074 | - switch (setting->type) |
2075 | + switch (sPrivate->type) |
2076 | { |
2077 | case TypeInt: |
2078 | - initIntInfoPB (&setting->info, option); |
2079 | + initIntInfoPB (&sPrivate->info, option); |
2080 | break; |
2081 | case TypeFloat: |
2082 | - initFloatInfoPB (&setting->info, option); |
2083 | + initFloatInfoPB (&sPrivate->info, option); |
2084 | break; |
2085 | case TypeString: |
2086 | - initStringInfoPB (&setting->info, option); |
2087 | + initStringInfoPB (&sPrivate->info, option); |
2088 | break; |
2089 | case TypeList: |
2090 | - initListInfoPB (&setting->info, option); |
2091 | + initListInfoPB (&sPrivate->info, option); |
2092 | break; |
2093 | case TypeKey: |
2094 | case TypeButton: |
2095 | case TypeEdge: |
2096 | case TypeBell: |
2097 | - initActionInfoPB (&setting->info, option); |
2098 | + initActionInfoPB (&sPrivate->info, option); |
2099 | break; |
2100 | case TypeAction: // do nothing and fall through |
2101 | default: |
2102 | @@ -633,48 +651,48 @@ |
2103 | |
2104 | if (option.default_value_size () > 0) |
2105 | { |
2106 | - switch (setting->type) |
2107 | + switch (sPrivate->type) |
2108 | { |
2109 | case TypeInt: |
2110 | - initIntValuePB (&setting->defaultValue, &setting->info, |
2111 | + initIntValuePB (&sPrivate->defaultValue, &sPrivate->info, |
2112 | option.default_value (0)); |
2113 | break; |
2114 | case TypeBool: |
2115 | - initBoolValuePB (&setting->defaultValue, option.default_value (0)); |
2116 | + initBoolValuePB (&sPrivate->defaultValue, option.default_value (0)); |
2117 | break; |
2118 | case TypeFloat: |
2119 | - initFloatValuePB (&setting->defaultValue, &setting->info, |
2120 | + initFloatValuePB (&sPrivate->defaultValue, &sPrivate->info, |
2121 | option.default_value (0)); |
2122 | break; |
2123 | case TypeString: |
2124 | - initStringValuePB (&setting->defaultValue, &setting->info, |
2125 | + initStringValuePB (&sPrivate->defaultValue, &sPrivate->info, |
2126 | option.default_value (0)); |
2127 | break; |
2128 | case TypeColor: |
2129 | - initColorValuePB (&setting->defaultValue, option.default_value (0)); |
2130 | + initColorValuePB (&sPrivate->defaultValue, option.default_value (0)); |
2131 | break; |
2132 | case TypeKey: |
2133 | - initKeyValuePB (&setting->defaultValue, &setting->info, |
2134 | + initKeyValuePB (&sPrivate->defaultValue, &sPrivate->info, |
2135 | option.default_value (0)); |
2136 | break; |
2137 | case TypeButton: |
2138 | - initButtonValuePB (&setting->defaultValue, &setting->info, |
2139 | + initButtonValuePB (&sPrivate->defaultValue, &sPrivate->info, |
2140 | option.default_value (0)); |
2141 | break; |
2142 | case TypeEdge: |
2143 | - initEdgeValuePB (&setting->defaultValue, &setting->info, |
2144 | + initEdgeValuePB (&sPrivate->defaultValue, &sPrivate->info, |
2145 | option.default_value (0)); |
2146 | break; |
2147 | case TypeBell: |
2148 | - initBellValuePB (&setting->defaultValue, &setting->info, |
2149 | + initBellValuePB (&sPrivate->defaultValue, &sPrivate->info, |
2150 | option.default_value (0)); |
2151 | break; |
2152 | case TypeMatch: |
2153 | - initMatchValuePB (&setting->defaultValue, |
2154 | + initMatchValuePB (&sPrivate->defaultValue, |
2155 | option.default_value (0)); |
2156 | break; |
2157 | case TypeList: |
2158 | - initListValuePB (&setting->defaultValue, &setting->info, |
2159 | + initListValuePB (&sPrivate->defaultValue, &sPrivate->info, |
2160 | option); |
2161 | break; |
2162 | case TypeAction: // do nothing and fall through |
2163 | @@ -686,13 +704,13 @@ |
2164 | { |
2165 | /* if we have no set defaults, we have at least to set |
2166 | the string defaults to empty strings */ |
2167 | - switch (setting->type) |
2168 | + switch (sPrivate->type) |
2169 | { |
2170 | case TypeString: |
2171 | - setting->defaultValue.value.asString = strdup (""); |
2172 | + sPrivate->defaultValue.value.asString = strdup (""); |
2173 | break; |
2174 | case TypeMatch: |
2175 | - setting->defaultValue.value.asMatch = strdup (""); |
2176 | + sPrivate->defaultValue.value.asMatch = strdup (""); |
2177 | break; |
2178 | default: |
2179 | break; |
2180 | @@ -823,19 +841,21 @@ |
2181 | static void |
2182 | initRulesFromPB (CCSPlugin * plugin, const PluginInfoMetadata & pluginInfoPB) |
2183 | { |
2184 | - addStringsFromPB (&plugin->providesFeature, pluginInfoPB.feature ()); |
2185 | + PLUGIN_PRIV (plugin) |
2186 | + |
2187 | + addStringsFromPB (&pPrivate->providesFeature, pluginInfoPB.feature ()); |
2188 | |
2189 | if (!pluginInfoPB.has_deps ()) |
2190 | return; |
2191 | |
2192 | const DependenciesMetadata & deps = pluginInfoPB.deps (); |
2193 | |
2194 | - addStringsFromPB (&plugin->loadAfter, deps.after_plugin ()); |
2195 | - addStringsFromPB (&plugin->loadBefore, deps.before_plugin ()); |
2196 | - addStringsFromPB (&plugin->requiresPlugin, deps.require_plugin ()); |
2197 | - addStringsFromPB (&plugin->requiresFeature, deps.require_feature ()); |
2198 | - addStringsFromPB (&plugin->conflictPlugin, deps.conflict_plugin ()); |
2199 | - addStringsFromPB (&plugin->conflictFeature, deps.conflict_feature ()); |
2200 | + addStringsFromPB (&pPrivate->loadAfter, deps.after_plugin ()); |
2201 | + addStringsFromPB (&pPrivate->loadBefore, deps.before_plugin ()); |
2202 | + addStringsFromPB (&pPrivate->requiresPlugin, deps.require_plugin ()); |
2203 | + addStringsFromPB (&pPrivate->requiresFeature, deps.require_feature ()); |
2204 | + addStringsFromPB (&pPrivate->conflictPlugin, deps.conflict_plugin ()); |
2205 | + addStringsFromPB (&pPrivate->conflictFeature, deps.conflict_feature ()); |
2206 | } |
2207 | |
2208 | static void |
2209 | @@ -848,6 +868,8 @@ |
2210 | CCSPlugin *plugin; |
2211 | CCSPluginPrivate *pPrivate; |
2212 | |
2213 | + CONTEXT_PRIV (context); |
2214 | + |
2215 | name = pluginInfoPB.name ().c_str (); |
2216 | |
2217 | if (!strlen (name)) |
2218 | @@ -861,10 +883,12 @@ |
2219 | return; |
2220 | |
2221 | plugin = (CCSPlugin *) calloc (1, sizeof (CCSPlugin)); |
2222 | + |
2223 | if (!plugin) |
2224 | return; |
2225 | |
2226 | - plugin->refCount = 1; |
2227 | + ccsObjectInit (plugin, &ccsDefaultObjectAllocator); |
2228 | + ccsPluginRef (plugin); |
2229 | |
2230 | pPrivate = (CCSPluginPrivate *) calloc (1, sizeof (CCSPluginPrivate)); |
2231 | if (!pPrivate) |
2232 | @@ -874,7 +898,8 @@ |
2233 | } |
2234 | pPrivate->loaded = FALSE; |
2235 | |
2236 | - plugin->ccsPrivate = (void *) pPrivate; |
2237 | + ccsObjectSetPrivate (plugin, (CCSPrivate *) pPrivate); |
2238 | + ccsObjectAddInterface (plugin, (CCSInterface *) cPrivate->object_interfaces->pluginInterface, GET_INTERFACE_TYPE (CCSPluginInterface)); |
2239 | |
2240 | if (file) |
2241 | pPrivate->pbFilePath = strdup (file); |
2242 | @@ -886,33 +911,33 @@ |
2243 | pPrivate->xmlPath = NULL; |
2244 | } |
2245 | |
2246 | - plugin->context = context; |
2247 | - plugin->name = strdup (name); |
2248 | + pPrivate->context = context; |
2249 | + pPrivate->name = strdup (name); |
2250 | |
2251 | if (!basicMetadata) |
2252 | { |
2253 | - plugin->shortDesc = |
2254 | + pPrivate->shortDesc = |
2255 | strdup (pluginInfoPB.has_short_desc () ? |
2256 | pluginInfoPB.short_desc ().c_str () : |
2257 | name); |
2258 | - plugin->longDesc = |
2259 | + pPrivate->longDesc = |
2260 | strdup (pluginInfoPB.has_long_desc () ? |
2261 | pluginInfoPB.long_desc ().c_str () : |
2262 | name); |
2263 | - plugin->category = strdup (pluginInfoPB.has_category () ? |
2264 | + pPrivate->category = strdup (pluginInfoPB.has_category () ? |
2265 | pluginInfoPB.category ().c_str () : |
2266 | ""); |
2267 | } |
2268 | else |
2269 | { |
2270 | - plugin->shortDesc = strdup (name); |
2271 | - plugin->longDesc = strdup (name); |
2272 | - plugin->category = strdup (""); |
2273 | + pPrivate->shortDesc = strdup (name); |
2274 | + pPrivate->longDesc = strdup (name); |
2275 | + pPrivate->category = strdup (""); |
2276 | } |
2277 | |
2278 | initRulesFromPB (plugin, pluginInfoPB); |
2279 | |
2280 | - context->plugins = ccsPluginListAppend (context->plugins, plugin); |
2281 | + cPrivate->plugins = ccsPluginListAppend (cPrivate->plugins, plugin); |
2282 | } |
2283 | |
2284 | static void |
2285 | @@ -927,11 +952,15 @@ |
2286 | if (ccsFindPlugin (context, "core")) |
2287 | return; |
2288 | |
2289 | + CONTEXT_PRIV (context); |
2290 | + |
2291 | plugin = (CCSPlugin*) calloc (1, sizeof (CCSPlugin)); |
2292 | + |
2293 | if (!plugin) |
2294 | return; |
2295 | |
2296 | - plugin->refCount = 1; |
2297 | + ccsObjectInit (plugin, &ccsDefaultObjectAllocator); |
2298 | + ccsPluginRef (plugin); |
2299 | |
2300 | pPrivate = (CCSPluginPrivate *) calloc (1, sizeof (CCSPluginPrivate)); |
2301 | if (!pPrivate) |
2302 | @@ -940,7 +969,8 @@ |
2303 | return; |
2304 | } |
2305 | |
2306 | - plugin->ccsPrivate = (void *) pPrivate; |
2307 | + ccsObjectSetPrivate (plugin, (CCSPrivate *) pPrivate); |
2308 | + ccsObjectAddInterface (plugin, (CCSInterface *) cPrivate->object_interfaces->pluginInterface, GET_INTERFACE_TYPE (CCSPluginInterface)); |
2309 | |
2310 | if (file) |
2311 | pPrivate->pbFilePath = strdup (file); |
2312 | @@ -951,30 +981,30 @@ |
2313 | pPrivate->xmlPath = strdup ("/compiz/core"); |
2314 | } |
2315 | |
2316 | - plugin->context = context; |
2317 | - plugin->name = strdup ("core"); |
2318 | - plugin->category = strdup ("General"); |
2319 | + pPrivate->context = context; |
2320 | + pPrivate->name = strdup ("core"); |
2321 | + pPrivate->category = strdup ("General"); |
2322 | |
2323 | if (!basicMetadata) |
2324 | { |
2325 | - plugin->shortDesc = |
2326 | + pPrivate->shortDesc = |
2327 | strdup (pluginInfoPB.has_short_desc () ? |
2328 | pluginInfoPB.short_desc ().c_str () : |
2329 | "General Options"); |
2330 | |
2331 | - plugin->longDesc = |
2332 | + pPrivate->longDesc = |
2333 | strdup (pluginInfoPB.has_long_desc () ? |
2334 | pluginInfoPB.long_desc ().c_str () : |
2335 | "General Compiz Options"); |
2336 | } |
2337 | else |
2338 | { |
2339 | - plugin->shortDesc = strdup ("General Options"); |
2340 | - plugin->longDesc = strdup ("General Compiz Options"); |
2341 | + pPrivate->shortDesc = strdup ("General Options"); |
2342 | + pPrivate->longDesc = strdup ("General Compiz Options"); |
2343 | } |
2344 | |
2345 | initRulesFromPB (plugin, pluginInfoPB); |
2346 | - context->plugins = ccsPluginListAppend (context->plugins, plugin); |
2347 | + cPrivate->plugins = ccsPluginListAppend (cPrivate->plugins, plugin); |
2348 | } |
2349 | |
2350 | #endif |
2351 | @@ -1991,39 +2021,57 @@ |
2352 | if (getOptionType (type) == TypeNum) |
2353 | return; |
2354 | |
2355 | + CONTEXT_PRIV (ccsPluginGetContext (plugin)); |
2356 | + |
2357 | setting = (CCSSetting *) calloc (1, sizeof (CCSSetting)); |
2358 | + |
2359 | if (!setting) |
2360 | return; |
2361 | |
2362 | - setting->parent = plugin; |
2363 | - setting->isDefault = TRUE; |
2364 | - setting->name = strdup (name); |
2365 | - setting->refCount = 1; |
2366 | + ccsObjectInit (setting, &ccsDefaultObjectAllocator); |
2367 | + |
2368 | + CCSSettingPrivate *ccsPrivate = (CCSSettingPrivate *) calloc (1, sizeof (CCSSettingPrivate)); |
2369 | + |
2370 | + if (!ccsPrivate) |
2371 | + { |
2372 | + free (setting); |
2373 | + return; |
2374 | + } |
2375 | + |
2376 | + ccsObjectSetPrivate (setting, (CCSPrivate *) ccsPrivate); |
2377 | + ccsObjectAddInterface (setting, (CCSInterface *) cPrivate->object_interfaces->settingInterface, GET_INTERFACE_TYPE (CCSSettingInterface)); |
2378 | + ccsSettingRef (setting); |
2379 | + |
2380 | + SETTING_PRIV (setting) |
2381 | + |
2382 | + sPrivate->parent = plugin; |
2383 | + sPrivate->isDefault = TRUE; |
2384 | + sPrivate->name = strdup (name); |
2385 | |
2386 | if (!basicMetadata) |
2387 | { |
2388 | - setting->shortDesc = |
2389 | + sPrivate->shortDesc = |
2390 | stringFromNodeDefTrans (node, "short/child::text()", name); |
2391 | - setting->longDesc = |
2392 | + sPrivate->longDesc = |
2393 | stringFromNodeDefTrans (node, "long/child::text()", ""); |
2394 | - setting->hints = stringFromNodeDef (node, "hints/child::text()", ""); |
2395 | - setting->group = |
2396 | + sPrivate->hints = stringFromNodeDef (node, "hints/child::text()", ""); |
2397 | + sPrivate->group = |
2398 | stringFromNodeDefTrans (node, "ancestor::group/short/child::text()", |
2399 | ""); |
2400 | - setting->subGroup = |
2401 | + sPrivate->subGroup = |
2402 | stringFromNodeDefTrans (node, |
2403 | "ancestor::subgroup/short/child::text()", |
2404 | ""); |
2405 | } |
2406 | else |
2407 | { |
2408 | - setting->shortDesc = strdup (name); |
2409 | - setting->longDesc = strdup (""); |
2410 | - setting->hints = strdup (""); |
2411 | - setting->group = strdup (""); |
2412 | - setting->subGroup = strdup (""); |
2413 | + sPrivate->shortDesc = strdup (name); |
2414 | + sPrivate->longDesc = strdup (""); |
2415 | + sPrivate->hints = strdup (""); |
2416 | + sPrivate->group = strdup (""); |
2417 | + sPrivate->subGroup = strdup (""); |
2418 | } |
2419 | - setting->type = getOptionType (type); |
2420 | + sPrivate->type = getOptionType (type); |
2421 | |
2422 | #ifdef USE_PROTOBUF |
2423 | OptionMetadata *optPB = NULL; |
2424 | @@ -2033,46 +2081,46 @@ |
2425 | optPB = (OptionMetadata *) optionPBv; |
2426 | |
2427 | optPB->set_name (name); |
2428 | - optPB->set_type ((OptionMetadata::Type) setting->type); |
2429 | + optPB->set_type ((OptionMetadata::Type) sPrivate->type); |
2430 | if (isReadonly) |
2431 | optPB->set_read_only (isReadonly); |
2432 | |
2433 | - optPB->set_short_desc (setting->shortDesc); |
2434 | - optPB->set_long_desc (setting->longDesc); |
2435 | - |
2436 | - if (strlen (setting->hints) > 0) |
2437 | - optPB->set_hints (setting->hints); |
2438 | - |
2439 | - if (groupListPBv && strlen (setting->group) > 0) |
2440 | + optPB->set_short_desc (sPrivate->shortDesc); |
2441 | + optPB->set_long_desc (sPrivate->longDesc); |
2442 | + |
2443 | + if (strlen (sPrivate->hints) > 0) |
2444 | + optPB->set_hints (sPrivate->hints); |
2445 | + |
2446 | + if (groupListPBv && strlen (sPrivate->group) > 0) |
2447 | checkAddGroupSubgroup (optPB, (StringList *) groupListPBv, |
2448 | - setting->group, TRUE); |
2449 | - if (subgroupListPBv && strlen (setting->subGroup) > 0) |
2450 | + sPrivate->group, TRUE); |
2451 | + if (subgroupListPBv && strlen (sPrivate->subGroup) > 0) |
2452 | checkAddGroupSubgroup (optPB, (StringList *) subgroupListPBv, |
2453 | - setting->subGroup, FALSE); |
2454 | + sPrivate->subGroup, FALSE); |
2455 | } |
2456 | #endif |
2457 | - setting->value = &setting->defaultValue; |
2458 | - setting->defaultValue.parent = setting; |
2459 | + sPrivate->value = &sPrivate->defaultValue; |
2460 | + sPrivate->defaultValue.parent = setting; |
2461 | |
2462 | - switch (setting->type) |
2463 | + switch (sPrivate->type) |
2464 | { |
2465 | case TypeInt: |
2466 | - initIntInfo (&setting->info, node, optionPBv); |
2467 | + initIntInfo (&sPrivate->info, node, optionPBv); |
2468 | break; |
2469 | case TypeFloat: |
2470 | - initFloatInfo (&setting->info, node, optionPBv); |
2471 | + initFloatInfo (&sPrivate->info, node, optionPBv); |
2472 | break; |
2473 | case TypeString: |
2474 | - initStringInfo (&setting->info, node, optionPBv); |
2475 | + initStringInfo (&sPrivate->info, node, optionPBv); |
2476 | break; |
2477 | case TypeList: |
2478 | - initListInfo (&setting->info, node, optionPBv); |
2479 | + initListInfo (&sPrivate->info, node, optionPBv); |
2480 | break; |
2481 | case TypeKey: |
2482 | case TypeButton: |
2483 | case TypeEdge: |
2484 | case TypeBell: |
2485 | - initActionInfo (&setting->info, node, optionPBv); |
2486 | + initActionInfo (&sPrivate->info, node, optionPBv); |
2487 | break; |
2488 | default: |
2489 | break; |
2490 | @@ -2083,52 +2131,52 @@ |
2491 | { |
2492 | void * valuePBv = NULL; |
2493 | #ifdef USE_PROTOBUF |
2494 | - if (optPB && setting->type != TypeList) |
2495 | + if (optPB && sPrivate->type != TypeList) |
2496 | valuePBv = optPB->add_default_value (); |
2497 | #endif |
2498 | - switch (setting->type) |
2499 | + switch (sPrivate->type) |
2500 | { |
2501 | case TypeInt: |
2502 | - initIntValue (&setting->defaultValue, &setting->info, nodes[0], |
2503 | + initIntValue (&sPrivate->defaultValue, &sPrivate->info, nodes[0], |
2504 | valuePBv); |
2505 | break; |
2506 | case TypeBool: |
2507 | - initBoolValue (&setting->defaultValue, nodes[0], |
2508 | + initBoolValue (&sPrivate->defaultValue, nodes[0], |
2509 | valuePBv); |
2510 | break; |
2511 | case TypeFloat: |
2512 | - initFloatValue (&setting->defaultValue, &setting->info, nodes[0], |
2513 | + initFloatValue (&sPrivate->defaultValue, &sPrivate->info, nodes[0], |
2514 | valuePBv); |
2515 | break; |
2516 | case TypeString: |
2517 | - initStringValue (&setting->defaultValue, &setting->info, nodes[0], |
2518 | + initStringValue (&sPrivate->defaultValue, &sPrivate->info, nodes[0], |
2519 | valuePBv); |
2520 | break; |
2521 | case TypeColor: |
2522 | - initColorValue (&setting->defaultValue, nodes[0], valuePBv); |
2523 | + initColorValue (&sPrivate->defaultValue, nodes[0], valuePBv); |
2524 | break; |
2525 | case TypeKey: |
2526 | - initKeyValue (&setting->defaultValue, &setting->info, nodes[0], |
2527 | + initKeyValue (&sPrivate->defaultValue, &sPrivate->info, nodes[0], |
2528 | valuePBv); |
2529 | break; |
2530 | case TypeButton: |
2531 | - initButtonValue (&setting->defaultValue, &setting->info, nodes[0], |
2532 | + initButtonValue (&sPrivate->defaultValue, &sPrivate->info, nodes[0], |
2533 | valuePBv); |
2534 | break; |
2535 | case TypeEdge: |
2536 | - initEdgeValue (&setting->defaultValue, &setting->info, nodes[0], |
2537 | + initEdgeValue (&sPrivate->defaultValue, &sPrivate->info, nodes[0], |
2538 | valuePBv); |
2539 | break; |
2540 | case TypeBell: |
2541 | - initBellValue (&setting->defaultValue, &setting->info, nodes[0], |
2542 | + initBellValue (&sPrivate->defaultValue, &sPrivate->info, nodes[0], |
2543 | valuePBv); |
2544 | break; |
2545 | case TypeMatch: |
2546 | - initMatchValue (&setting->defaultValue, nodes[0], |
2547 | + initMatchValue (&sPrivate->defaultValue, nodes[0], |
2548 | valuePBv); |
2549 | break; |
2550 | case TypeList: |
2551 | - initListValue (&setting->defaultValue, &setting->info, nodes[0], |
2552 | + initListValue (&sPrivate->defaultValue, &sPrivate->info, nodes[0], |
2553 | optionPBv); |
2554 | break; |
2555 | default: |
2556 | @@ -2139,13 +2187,13 @@ |
2557 | { |
2558 | /* if we have no set defaults, we have at least to set |
2559 | the string defaults to empty strings */ |
2560 | - switch (setting->type) |
2561 | + switch (sPrivate->type) |
2562 | { |
2563 | case TypeString: |
2564 | - setting->defaultValue.value.asString = strdup (""); |
2565 | + sPrivate->defaultValue.value.asString = strdup (""); |
2566 | break; |
2567 | case TypeMatch: |
2568 | - setting->defaultValue.value.asMatch = strdup (""); |
2569 | + sPrivate->defaultValue.value.asMatch = strdup (""); |
2570 | break; |
2571 | default: |
2572 | break; |
2573 | @@ -2433,22 +2481,24 @@ |
2574 | } |
2575 | #endif |
2576 | |
2577 | - addStringsFromPath (&plugin->providesFeature, "feature", node, |
2578 | + PLUGIN_PRIV (plugin); |
2579 | + |
2580 | + addStringsFromPath (&pPrivate->providesFeature, "feature", node, |
2581 | featureListPBv); |
2582 | |
2583 | - addStringsFromPath (&plugin->loadAfter, |
2584 | + addStringsFromPath (&pPrivate->loadAfter, |
2585 | "deps/relation[@type = 'after']/plugin", node, |
2586 | pluginAfterListPBv); |
2587 | - addStringsFromPath (&plugin->loadBefore, |
2588 | + addStringsFromPath (&pPrivate->loadBefore, |
2589 | "deps/relation[@type = 'before']/plugin", node, |
2590 | pluginBeforeListPBv); |
2591 | - addStringsFromPath (&plugin->requiresPlugin, |
2592 | + addStringsFromPath (&pPrivate->requiresPlugin, |
2593 | "deps/requirement/plugin", node, requirePluginListPBv); |
2594 | - addStringsFromPath (&plugin->requiresFeature, |
2595 | + addStringsFromPath (&pPrivate->requiresFeature, |
2596 | "deps/requirement/feature", node, requireFeatureListPBv); |
2597 | - addStringsFromPath (&plugin->conflictPlugin, |
2598 | + addStringsFromPath (&pPrivate->conflictPlugin, |
2599 | "deps/conflict/plugin", node, conflictPluginListPBv); |
2600 | - addStringsFromPath (&plugin->conflictFeature, |
2601 | + addStringsFromPath (&pPrivate->conflictFeature, |
2602 | "deps/conflict/feature", node, conflictFeatureListPBv); |
2603 | } |
2604 | |
2605 | @@ -2459,10 +2509,10 @@ |
2606 | if (!pluginInfoPB) |
2607 | return; |
2608 | |
2609 | - pluginInfoPB->set_name (plugin->name); |
2610 | - pluginInfoPB->set_short_desc (plugin->shortDesc); |
2611 | - pluginInfoPB->set_long_desc (plugin->longDesc); |
2612 | - pluginInfoPB->set_category (plugin->category); |
2613 | + pluginInfoPB->set_name (ccsPluginGetName (plugin)); |
2614 | + pluginInfoPB->set_short_desc (ccsPluginGetShortDesc (plugin)); |
2615 | + pluginInfoPB->set_long_desc (ccsPluginGetLongDesc (plugin)); |
2616 | + pluginInfoPB->set_category (ccsPluginGetCategory (plugin)); |
2617 | } |
2618 | #endif |
2619 | |
2620 | @@ -2477,6 +2527,8 @@ |
2621 | CCSPlugin *plugin; |
2622 | CCSPluginPrivate *pPrivate; |
2623 | |
2624 | + CONTEXT_PRIV (context); |
2625 | + |
2626 | if (!node) |
2627 | return FALSE; |
2628 | |
2629 | @@ -2503,10 +2555,12 @@ |
2630 | } |
2631 | |
2632 | plugin = (CCSPlugin *) calloc (1, sizeof (CCSPlugin)); |
2633 | + |
2634 | if (!plugin) |
2635 | return FALSE; |
2636 | |
2637 | - plugin->refCount = 1; |
2638 | + ccsObjectInit (plugin, &ccsDefaultObjectAllocator); |
2639 | + ccsPluginRef (plugin); |
2640 | |
2641 | pPrivate = (CCSPluginPrivate *) calloc (1, sizeof (CCSPluginPrivate)); |
2642 | if (!pPrivate) |
2643 | @@ -2515,7 +2569,8 @@ |
2644 | return FALSE; |
2645 | } |
2646 | |
2647 | - plugin->ccsPrivate = (void *) pPrivate; |
2648 | + ccsObjectSetPrivate (plugin, (CCSPrivate *) pPrivate); |
2649 | + ccsObjectAddInterface (plugin, (CCSInterface *) cPrivate->object_interfaces->pluginInterface, GET_INTERFACE_TYPE (CCSPluginInterface)); |
2650 | |
2651 | if (file) |
2652 | pPrivate->xmlFile = strdup (file); |
2653 | @@ -2523,23 +2578,23 @@ |
2654 | if (asprintf (&pPrivate->xmlPath, "/compiz/plugin[@name = '%s']", name) == -1) |
2655 | pPrivate->xmlPath = NULL; |
2656 | |
2657 | - plugin->context = context; |
2658 | - plugin->name = strdup (name); |
2659 | + pPrivate->context = context; |
2660 | + pPrivate->name = strdup (name); |
2661 | |
2662 | if (!basicMetadata) |
2663 | { |
2664 | - plugin->shortDesc = |
2665 | + pPrivate->shortDesc = |
2666 | stringFromNodeDefTrans (node, "short/child::text()", name); |
2667 | - plugin->longDesc = |
2668 | + pPrivate->longDesc = |
2669 | stringFromNodeDefTrans (node, "long/child::text()", name); |
2670 | - plugin->category = |
2671 | + pPrivate->category = |
2672 | stringFromNodeDef (node, "category/child::text()", ""); |
2673 | } |
2674 | else |
2675 | { |
2676 | - plugin->shortDesc = strdup (name); |
2677 | - plugin->longDesc = strdup (name); |
2678 | - plugin->category = strdup (""); |
2679 | + pPrivate->shortDesc = strdup (name); |
2680 | + pPrivate->longDesc = strdup (name); |
2681 | + pPrivate->category = strdup (""); |
2682 | } |
2683 | #ifdef USE_PROTOBUF |
2684 | fillBasicInfoIntoPB (plugin, (PluginInfoMetadata *) pluginInfoPBv); |
2685 | @@ -2547,7 +2602,7 @@ |
2686 | |
2687 | initRulesFromRootNode (plugin, node, pluginInfoPBv); |
2688 | |
2689 | - context->plugins = ccsPluginListAppend (context->plugins, plugin); |
2690 | + cPrivate->plugins = ccsPluginListAppend (cPrivate->plugins, plugin); |
2691 | free (name); |
2692 | |
2693 | return TRUE; |
2694 | @@ -2563,6 +2618,8 @@ |
2695 | CCSPlugin *plugin; |
2696 | CCSPluginPrivate *pPrivate; |
2697 | |
2698 | + CONTEXT_PRIV (context); |
2699 | + |
2700 | if (!node) |
2701 | return FALSE; |
2702 | |
2703 | @@ -2570,10 +2627,12 @@ |
2704 | return FALSE; |
2705 | |
2706 | plugin = (CCSPlugin *) calloc (1, sizeof (CCSPlugin)); |
2707 | + |
2708 | if (!plugin) |
2709 | return FALSE; |
2710 | |
2711 | - plugin->refCount = 1; |
2712 | + ccsObjectInit (plugin, &ccsDefaultObjectAllocator); |
2713 | + ccsPluginRef (plugin); |
2714 | |
2715 | pPrivate = (CCSPluginPrivate *) calloc (1, sizeof (CCSPluginPrivate)); |
2716 | if (!pPrivate) |
2717 | @@ -2582,36 +2641,37 @@ |
2718 | return FALSE; |
2719 | } |
2720 | |
2721 | - plugin->ccsPrivate = (void *) pPrivate; |
2722 | + ccsObjectSetPrivate (plugin, (CCSPrivate *) pPrivate); |
2723 | + ccsObjectAddInterface (plugin, (CCSInterface *) cPrivate->object_interfaces->pluginInterface, GET_INTERFACE_TYPE (CCSPluginInterface)); |
2724 | |
2725 | if (file) |
2726 | pPrivate->xmlFile = strdup (file); |
2727 | |
2728 | pPrivate->xmlPath = strdup ("/compiz/plugin[@name='core']"); |
2729 | - plugin->context = context; |
2730 | - plugin->name = strdup ("core"); |
2731 | - plugin->category = strdup ("General"); |
2732 | + pPrivate->context = context; |
2733 | + pPrivate->name = strdup ("core"); |
2734 | + pPrivate->category = strdup ("General"); |
2735 | |
2736 | if (!basicMetadata) |
2737 | { |
2738 | - plugin->shortDesc = |
2739 | + pPrivate->shortDesc = |
2740 | stringFromNodeDefTrans (node, "short/child::text()", |
2741 | "General Options"); |
2742 | - plugin->longDesc = |
2743 | + pPrivate->longDesc = |
2744 | stringFromNodeDefTrans (node, "long/child::text()", |
2745 | "General Compiz Options"); |
2746 | } |
2747 | else |
2748 | { |
2749 | - plugin->shortDesc = strdup ("General Options"); |
2750 | - plugin->longDesc = strdup ("General Compiz Options"); |
2751 | + pPrivate->shortDesc = strdup ("General Options"); |
2752 | + pPrivate->longDesc = strdup ("General Compiz Options"); |
2753 | } |
2754 | #ifdef USE_PROTOBUF |
2755 | fillBasicInfoIntoPB (plugin, (PluginInfoMetadata *) pluginInfoPBv); |
2756 | #endif |
2757 | |
2758 | initRulesFromRootNode (plugin, node, pluginInfoPBv); |
2759 | - context->plugins = ccsPluginListAppend (context->plugins, plugin); |
2760 | + cPrivate->plugins = ccsPluginListAppend (cPrivate->plugins, plugin); |
2761 | |
2762 | return TRUE; |
2763 | } |
2764 | @@ -2916,6 +2976,8 @@ |
2765 | CCSPlugin *plugin; |
2766 | CCSPluginPrivate *pPrivate; |
2767 | |
2768 | + CONTEXT_PRIV (context); |
2769 | + |
2770 | if (ccsFindPlugin (context, name)) |
2771 | return; |
2772 | |
2773 | @@ -2924,10 +2986,12 @@ |
2774 | return; |
2775 | |
2776 | plugin = (CCSPlugin *) calloc (1, sizeof (CCSPlugin)); |
2777 | + |
2778 | if (!plugin) |
2779 | return; |
2780 | |
2781 | - plugin->refCount = 1; |
2782 | + ccsObjectInit (plugin, &ccsDefaultObjectAllocator); |
2783 | + ccsPluginRef (plugin); |
2784 | |
2785 | pPrivate = (CCSPluginPrivate *) calloc (1, sizeof (CCSPluginPrivate)); |
2786 | if (!pPrivate) |
2787 | @@ -2936,21 +3000,22 @@ |
2788 | return; |
2789 | } |
2790 | |
2791 | - plugin->ccsPrivate = (void *) pPrivate; |
2792 | - |
2793 | - plugin->context = context; |
2794 | - plugin->name = strdup (name); |
2795 | - |
2796 | - if (!plugin->shortDesc) |
2797 | - plugin->shortDesc = strdup (name); |
2798 | - if (!plugin->longDesc) |
2799 | - plugin->longDesc = strdup (name); |
2800 | - if (!plugin->category) |
2801 | - plugin->category = strdup (""); |
2802 | + ccsObjectSetPrivate (plugin, (CCSPrivate *) pPrivate); |
2803 | + ccsObjectAddInterface (plugin, (CCSInterface *) cPrivate->object_interfaces->pluginInterface, GET_INTERFACE_TYPE (CCSPluginInterface)); |
2804 | + |
2805 | + pPrivate->context = context; |
2806 | + pPrivate->name = strdup (name); |
2807 | + |
2808 | + if (!pPrivate->shortDesc) |
2809 | + pPrivate->shortDesc = strdup (name); |
2810 | + if (!pPrivate->longDesc) |
2811 | + pPrivate->longDesc = strdup (name); |
2812 | + if (!pPrivate->category) |
2813 | + pPrivate->category = strdup (""); |
2814 | |
2815 | pPrivate->loaded = TRUE; |
2816 | collateGroups (pPrivate); |
2817 | - context->plugins = ccsPluginListAppend (context->plugins, plugin); |
2818 | + cPrivate->plugins = ccsPluginListAppend (cPrivate->plugins, plugin); |
2819 | } |
2820 | |
2821 | static void |
2822 | @@ -2998,7 +3063,7 @@ |
2823 | #endif |
2824 | |
2825 | Bool |
2826 | -ccsLoadPlugin (CCSContext * context, char *name) |
2827 | +ccsLoadPluginDefault (CCSContext * context, char *name) |
2828 | { |
2829 | #ifdef USE_PROTOBUF |
2830 | initPBLoading (); |
2831 | @@ -3031,8 +3096,14 @@ |
2832 | return (ccsFindPlugin (context, name) != NULL); |
2833 | } |
2834 | |
2835 | +Bool |
2836 | +ccsLoadPlugin (CCSContext *context, char *name) |
2837 | +{ |
2838 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextLoadPlugin) (context, name); |
2839 | +} |
2840 | + |
2841 | void |
2842 | -ccsLoadPlugins (CCSContext * context) |
2843 | +ccsLoadPluginsDefault (CCSContext * context) |
2844 | { |
2845 | D (D_FULL, "Adding plugins\n"); |
2846 | |
2847 | @@ -3085,6 +3156,12 @@ |
2848 | loadPluginsFromName (context, (char *)PLUGINDIR); |
2849 | } |
2850 | |
2851 | +void |
2852 | +ccsLoadPlugins (CCSContext *context) |
2853 | +{ |
2854 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextLoadPlugins) (context); |
2855 | +} |
2856 | + |
2857 | static void |
2858 | loadOptionsStringExtensionsFromXML (CCSPlugin * plugin, |
2859 | void * pluginPBv, |
2860 | @@ -3135,7 +3212,7 @@ |
2861 | return; |
2862 | |
2863 | pPrivate->loaded = TRUE; |
2864 | - D (D_FULL, "Initializing %s options...", plugin->name); |
2865 | + D (D_FULL, "Initializing %s options...", pPrivate->name); |
2866 | |
2867 | #ifdef USE_PROTOBUF |
2868 | if (usingProtobuf && pPrivate->pbFilePath) |
2869 | |
2870 | === modified file 'compizconfig/libcompizconfig/src/ini.c' |
2871 | --- compizconfig/libcompizconfig/src/ini.c 2012-05-21 09:36:37 +0000 |
2872 | +++ compizconfig/libcompizconfig/src/ini.c 2012-06-27 07:01:20 +0000 |
2873 | @@ -382,7 +382,7 @@ |
2874 | } |
2875 | |
2876 | token = strsep (&valueString, ";"); |
2877 | - switch (parent->info.forList.listType) |
2878 | + switch (ccsSettingGetInfo (parent)->forList.listType) |
2879 | { |
2880 | case TypeString: |
2881 | case TypeMatch: |
2882 | |
2883 | === modified file 'compizconfig/libcompizconfig/src/main.c' |
2884 | --- compizconfig/libcompizconfig/src/main.c 2012-05-23 08:15:54 +0000 |
2885 | +++ compizconfig/libcompizconfig/src/main.c 2012-06-27 07:01:20 +0000 |
2886 | @@ -39,6 +39,199 @@ |
2887 | #include "ccs-private.h" |
2888 | #include "iniparser.h" |
2889 | |
2890 | +static void * wrapRealloc (void *o, void *a , size_t b) |
2891 | +{ |
2892 | + return realloc (a, b); |
2893 | +} |
2894 | + |
2895 | +static void * wrapMalloc (void *o, size_t a) |
2896 | +{ |
2897 | + return malloc (a); |
2898 | +} |
2899 | + |
2900 | +static void * wrapCalloc (void *o, size_t a, size_t b) |
2901 | +{ |
2902 | + return calloc (a, b); |
2903 | +} |
2904 | + |
2905 | +static void wrapFree (void *o, void *a) |
2906 | +{ |
2907 | + free (a); |
2908 | +} |
2909 | + |
2910 | +CCSObjectAllocationInterface ccsDefaultObjectAllocator = |
2911 | +{ |
2912 | + wrapRealloc, |
2913 | + wrapMalloc, |
2914 | + wrapCalloc, |
2915 | + wrapFree, |
2916 | + NULL |
2917 | +}; |
2918 | + |
2919 | +/* CCSObject stuff */ |
2920 | +Bool |
2921 | +ccsObjectInit_(CCSObject *object, CCSObjectAllocationInterface *object_allocation) |
2922 | +{ |
2923 | + object->priv = NULL; |
2924 | + object->n_interfaces = 0; |
2925 | + object->n_allocated_interfaces = 0; |
2926 | + object->interfaces = NULL; |
2927 | + object->interface_types = NULL; |
2928 | + object->object_allocation = object_allocation; |
2929 | + object->refcnt = 0; |
2930 | + |
2931 | + return TRUE; |
2932 | +} |
2933 | + |
2934 | +Bool |
2935 | +ccsObjectAddInterface_(CCSObject *object, const CCSInterface *interface, int interface_type) |
2936 | +{ |
2937 | + object->n_interfaces++; |
2938 | + |
2939 | + if (object->n_allocated_interfaces < object->n_interfaces) |
2940 | + { |
2941 | + unsigned int old_allocated_interfaces = object->n_allocated_interfaces; |
2942 | + object->n_allocated_interfaces = object->n_interfaces; |
2943 | + CCSInterface **ifaces = (*object->object_allocation->realloc_) (object->object_allocation->allocator, object->interfaces, object->n_allocated_interfaces * sizeof (CCSInterface *)); |
2944 | + int *iface_types = (*object->object_allocation->realloc_) (object->object_allocation->allocator, object->interface_types, object->n_allocated_interfaces * sizeof (int)); |
2945 | + |
2946 | + if (!ifaces || !iface_types) |
2947 | + { |
2948 | + if (ifaces) |
2949 | + (*object->object_allocation->free_) (object->object_allocation->allocator, ifaces); |
2950 | + |
2951 | + if (iface_types) |
2952 | + (*object->object_allocation->free_) (object->object_allocation->allocator, iface_types); |
2953 | + |
2954 | + object->n_interfaces--; |
2955 | + object->n_allocated_interfaces = old_allocated_interfaces; |
2956 | + return FALSE; |
2957 | + } |
2958 | + else |
2959 | + { |
2960 | + object->interfaces = (const CCSInterface **) ifaces; |
2961 | + object->interface_types = iface_types; |
2962 | + } |
2963 | + } |
2964 | + |
2965 | + object->interfaces[object->n_interfaces - 1] = interface; |
2966 | + object->interface_types[object->n_interfaces - 1] = interface_type; |
2967 | + |
2968 | + return TRUE; |
2969 | +} |
2970 | + |
2971 | +Bool |
2972 | +ccsObjectRemoveInterface_(CCSObject *object, int interface_type) |
2973 | +{ |
2974 | + unsigned int i = 0; |
2975 | + |
2976 | + if (!object->n_interfaces) |
2977 | + return FALSE; |
2978 | + |
2979 | + const CCSInterface **o = object->interfaces; |
2980 | + int *type = object->interface_types; |
2981 | + |
2982 | + for (; i < object->n_interfaces; i++, o++, type++) |
2983 | + { |
2984 | + if (object->interface_types[i] == interface_type) |
2985 | + break; |
2986 | + } |
2987 | + |
2988 | + if (i >= object->n_interfaces) |
2989 | + return FALSE; |
2990 | + |
2991 | + /* Now clear this section and move everything back */ |
2992 | + object->interfaces[i] = NULL; |
2993 | + |
2994 | + i++; |
2995 | + |
2996 | + const CCSInterface **oLast = o; |
2997 | + int *typeLast = type; |
2998 | + |
2999 | + o++; |
3000 | + type++; |
3001 | + |
3002 | + memmove ((void *) oLast, (void *)o, (object->n_interfaces - i) * sizeof (CCSInterface *)); |
3003 | + memmove ((void *) typeLast, (void *) type, (object->n_interfaces - i) * sizeof (int)); |
3004 | + |
3005 | + object->n_interfaces--; |
3006 | + |
3007 | + if (!object->n_interfaces) |
3008 | + { |
3009 | + free (object->interfaces); |
3010 | + free (object->interface_types); |
3011 | + object->interfaces = NULL; |
3012 | + object->interface_types = NULL; |
3013 | + object->n_allocated_interfaces = 0; |
3014 | + } |
3015 | + |
3016 | + return TRUE; |
3017 | +} |
3018 | + |
3019 | +const CCSInterface * |
3020 | +ccsObjectGetInterface_(CCSObject *object, int interface_type) |
3021 | +{ |
3022 | + unsigned int i = 0; |
3023 | + |
3024 | + for (; i < object->n_interfaces; i++) |
3025 | + { |
3026 | + if (object->interface_types[i] == interface_type) |
3027 | + return object->interfaces[i]; |
3028 | + } |
3029 | + |
3030 | + return NULL; |
3031 | +} |
3032 | + |
3033 | +CCSPrivate * |
3034 | +ccsObjectGetPrivate_(CCSObject *object) |
3035 | +{ |
3036 | + return object->priv; |
3037 | +} |
3038 | + |
3039 | +void |
3040 | +ccsObjectSetPrivate_(CCSObject *object, CCSPrivate *priv) |
3041 | +{ |
3042 | + object->priv = priv; |
3043 | +} |
3044 | + |
3045 | +void |
3046 | +ccsObjectFinalize_(CCSObject *object) |
3047 | +{ |
3048 | + if (object->priv) |
3049 | + { |
3050 | + (*object->object_allocation->free_) (object->object_allocation->allocator, object->priv); |
3051 | + object->priv = NULL; |
3052 | + } |
3053 | + |
3054 | + if (object->interfaces) |
3055 | + { |
3056 | + (*object->object_allocation->free_) (object->object_allocation->allocator, object->interfaces); |
3057 | + object->interfaces = NULL; |
3058 | + } |
3059 | + |
3060 | + if (object->interface_types) |
3061 | + { |
3062 | + (*object->object_allocation->free_) (object->object_allocation->allocator, object->interface_types); |
3063 | + object->interface_types = NULL; |
3064 | + } |
3065 | + |
3066 | + object->n_interfaces = 0; |
3067 | +} |
3068 | + |
3069 | +unsigned int |
3070 | +ccsAllocateType () |
3071 | +{ |
3072 | + static unsigned int start = 0; |
3073 | + |
3074 | + start++; |
3075 | + |
3076 | + return start; |
3077 | +} |
3078 | + |
3079 | +INTERFACE_TYPE (CCSContextInterface) |
3080 | +INTERFACE_TYPE (CCSPluginInterface) |
3081 | +INTERFACE_TYPE (CCSSettingInterface) |
3082 | + |
3083 | Bool basicMetadata = FALSE; |
3084 | |
3085 | void |
3086 | @@ -95,24 +288,32 @@ |
3087 | } |
3088 | |
3089 | CCSContext * |
3090 | -ccsEmptyContextNew (unsigned int screenNum) |
3091 | +ccsEmptyContextNew (unsigned int screenNum, const CCSInterfaceTable *object_interfaces) |
3092 | { |
3093 | CCSContext *context; |
3094 | |
3095 | context = calloc (1, sizeof (CCSContext)); |
3096 | + |
3097 | if (!context) |
3098 | return NULL; |
3099 | |
3100 | - context->ccsPrivate = calloc (1, sizeof (CCSContextPrivate)); |
3101 | - if (!context->ccsPrivate) |
3102 | + ccsObjectInit (context, &ccsDefaultObjectAllocator); |
3103 | + |
3104 | + CCSContextPrivate *ccsPrivate = calloc (1, sizeof (CCSContextPrivate)); |
3105 | + if (!ccsPrivate) |
3106 | { |
3107 | free (context); |
3108 | return NULL; |
3109 | } |
3110 | |
3111 | + ccsObjectSetPrivate (context, (CCSPrivate *) ccsPrivate); |
3112 | + |
3113 | CONTEXT_PRIV (context); |
3114 | |
3115 | - context->screenNum = screenNum; |
3116 | + cPrivate->object_interfaces = object_interfaces; |
3117 | + cPrivate->screenNum = screenNum; |
3118 | + |
3119 | + ccsObjectAddInterface (context, (CCSInterface *) object_interfaces->contextInterface, GET_INTERFACE_TYPE (CCSContextInterface)); |
3120 | |
3121 | initGeneralOptions (context); |
3122 | cPrivate->configWatchId = ccsAddConfigWatch (context, configChangeNotify); |
3123 | @@ -127,13 +328,167 @@ |
3124 | return context; |
3125 | } |
3126 | |
3127 | +static void * |
3128 | +ccsContextGetPrivatePtrDefault (CCSContext *context) |
3129 | +{ |
3130 | + CONTEXT_PRIV (context); |
3131 | + |
3132 | + return cPrivate->privatePtr; |
3133 | +} |
3134 | + |
3135 | +static void |
3136 | +ccsContextSetPrivatePtrDefault (CCSContext *context, void *ptr) |
3137 | +{ |
3138 | + CONTEXT_PRIV (context); |
3139 | + |
3140 | + cPrivate->privatePtr = ptr; |
3141 | +} |
3142 | + |
3143 | +static CCSPluginList |
3144 | +ccsContextGetPluginsDefault (CCSContext *context) |
3145 | +{ |
3146 | + CONTEXT_PRIV (context); |
3147 | + |
3148 | + return cPrivate->plugins; |
3149 | +} |
3150 | + |
3151 | +static CCSPluginCategory * |
3152 | +ccsContextGetCategoriesDefault (CCSContext *context) |
3153 | +{ |
3154 | + CONTEXT_PRIV (context); |
3155 | + |
3156 | + return cPrivate->categories; |
3157 | +} |
3158 | + |
3159 | +static CCSSettingList |
3160 | +ccsContextGetChangedSettingsDefault (CCSContext *context) |
3161 | +{ |
3162 | + CONTEXT_PRIV (context); |
3163 | + |
3164 | + return cPrivate->changedSettings; |
3165 | +} |
3166 | + |
3167 | +static unsigned int |
3168 | +ccsContextGetScreenNumDefault (CCSContext *context) |
3169 | +{ |
3170 | + CONTEXT_PRIV (context); |
3171 | + |
3172 | + return cPrivate->screenNum; |
3173 | +} |
3174 | + |
3175 | +static Bool |
3176 | +ccsContextAddChangedSettingDefault (CCSContext *context, CCSSetting *setting) |
3177 | +{ |
3178 | + CONTEXT_PRIV (context); |
3179 | + |
3180 | + cPrivate->changedSettings = ccsSettingListAppend (cPrivate->changedSettings, setting); |
3181 | + |
3182 | + return TRUE; |
3183 | +} |
3184 | + |
3185 | +static Bool |
3186 | +ccsContextClearChangedSettingsDefault (CCSContext *context) |
3187 | +{ |
3188 | + CONTEXT_PRIV (context); |
3189 | + |
3190 | + cPrivate->changedSettings = ccsSettingListFree (cPrivate->changedSettings, FALSE); |
3191 | + |
3192 | + return TRUE; |
3193 | +} |
3194 | + |
3195 | +static CCSSettingList |
3196 | +ccsContextStealChangedSettingsDefault (CCSContext *context) |
3197 | +{ |
3198 | + CONTEXT_PRIV (context); |
3199 | + |
3200 | + CCSSettingList l = cPrivate->changedSettings; |
3201 | + |
3202 | + cPrivate->changedSettings = NULL; |
3203 | + return l; |
3204 | +} |
3205 | + |
3206 | +CCSPluginList |
3207 | +ccsContextGetPlugins (CCSContext *context) |
3208 | +{ |
3209 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetPlugins) (context); |
3210 | +} |
3211 | + |
3212 | +CCSPluginCategory * |
3213 | +ccsContextGetCategories (CCSContext *context) |
3214 | +{ |
3215 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetCategories) (context); |
3216 | +} |
3217 | + |
3218 | +CCSSettingList |
3219 | +ccsContextGetChangedSettings (CCSContext *context) |
3220 | +{ |
3221 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetChangedSettings) (context); |
3222 | +} |
3223 | + |
3224 | +unsigned int |
3225 | +ccsContextGetScreenNum (CCSContext *context) |
3226 | +{ |
3227 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetScreenNum) (context); |
3228 | +} |
3229 | + |
3230 | +Bool |
3231 | +ccsContextAddChangedSetting (CCSContext *context, CCSSetting *setting) |
3232 | +{ |
3233 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextAddChangedSetting) (context, setting); |
3234 | +} |
3235 | + |
3236 | +Bool |
3237 | +ccsContextClearChangedSettings (CCSContext *context) |
3238 | +{ |
3239 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextClearChangedSettings) (context); |
3240 | +} |
3241 | + |
3242 | +CCSSettingList |
3243 | +ccsContextStealChangedSettings (CCSContext *context) |
3244 | +{ |
3245 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextStealChangedSettings) (context); |
3246 | +} |
3247 | + |
3248 | +void * |
3249 | +ccsContextGetPrivatePtr (CCSContext *context) |
3250 | +{ |
3251 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetPrivatePtr) (context); |
3252 | +} |
3253 | + |
3254 | +void |
3255 | +ccsContextSetPrivatePtr (CCSContext *context, void *ptr) |
3256 | +{ |
3257 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextSetPrivatePtr) (context, ptr); |
3258 | +} |
3259 | + |
3260 | +void * |
3261 | +ccsContextGetPluginsBindable (CCSContext *context) |
3262 | +{ |
3263 | + return (void *) ccsContextGetPlugins (context); |
3264 | +} |
3265 | + |
3266 | +void * |
3267 | +ccsContextStealChangedSettingsBindable (CCSContext *context) |
3268 | +{ |
3269 | + return (void *) ccsContextStealChangedSettings (context); |
3270 | +} |
3271 | + |
3272 | +void * |
3273 | +ccsContextGetChangedSettingsBindable (CCSContext *context) |
3274 | +{ |
3275 | + return (void *) ccsContextGetChangedSettings (context); |
3276 | +} |
3277 | + |
3278 | + |
3279 | static void |
3280 | ccsSetActivePluginList (CCSContext * context, CCSStringList list) |
3281 | { |
3282 | CCSPluginList l; |
3283 | CCSPlugin *plugin; |
3284 | |
3285 | - for (l = context->plugins; l; l = l->next) |
3286 | + CONTEXT_PRIV (context); |
3287 | + |
3288 | + for (l = cPrivate->plugins; l; l = l->next) |
3289 | { |
3290 | PLUGIN_PRIV (l->data); |
3291 | pPrivate->active = FALSE; |
3292 | @@ -160,10 +515,10 @@ |
3293 | } |
3294 | |
3295 | CCSContext * |
3296 | -ccsContextNew (unsigned int screenNum) |
3297 | +ccsContextNew (unsigned int screenNum, const CCSInterfaceTable *iface) |
3298 | { |
3299 | CCSPlugin *p; |
3300 | - CCSContext *context = ccsEmptyContextNew (screenNum); |
3301 | + CCSContext *context = ccsEmptyContextNew (screenNum, iface); |
3302 | if (!context) |
3303 | return NULL; |
3304 | |
3305 | @@ -197,15 +552,17 @@ |
3306 | } |
3307 | |
3308 | CCSPlugin * |
3309 | -ccsFindPlugin (CCSContext * context, const char *name) |
3310 | +ccsFindPluginDefault (CCSContext * context, const char *name) |
3311 | { |
3312 | if (!name) |
3313 | name = ""; |
3314 | |
3315 | - CCSPluginList l = context->plugins; |
3316 | + CONTEXT_PRIV (context); |
3317 | + |
3318 | + CCSPluginList l = cPrivate->plugins; |
3319 | while (l) |
3320 | { |
3321 | - if (!strcmp (l->data->name, name)) |
3322 | + if (!strcmp (ccsPluginGetName (l->data), name)) |
3323 | return l->data; |
3324 | |
3325 | l = l->next; |
3326 | @@ -214,8 +571,14 @@ |
3327 | return NULL; |
3328 | } |
3329 | |
3330 | +CCSPlugin * |
3331 | +ccsFindPlugin (CCSContext *context, const char *name) |
3332 | +{ |
3333 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextFindPlugin) (context, name); |
3334 | +} |
3335 | + |
3336 | CCSSetting * |
3337 | -ccsFindSetting (CCSPlugin * plugin, const char *name) |
3338 | +ccsFindSettingDefault (CCSPlugin * plugin, const char *name) |
3339 | { |
3340 | if (!plugin) |
3341 | return NULL; |
3342 | @@ -232,7 +595,7 @@ |
3343 | |
3344 | while (l) |
3345 | { |
3346 | - if (!strcmp (l->data->name, name)) |
3347 | + if (!strcmp (ccsSettingGetName (l->data), name)) |
3348 | return l->data; |
3349 | |
3350 | l = l->next; |
3351 | @@ -241,8 +604,17 @@ |
3352 | return NULL; |
3353 | } |
3354 | |
3355 | +CCSSetting * |
3356 | +ccsFindSetting (CCSPlugin *plugin, const char *name) |
3357 | +{ |
3358 | + if (!plugin) |
3359 | + return NULL; |
3360 | + |
3361 | + return (*(GET_INTERFACE (CCSPluginInterface, plugin))->pluginFindSetting) (plugin, name); |
3362 | +} |
3363 | + |
3364 | Bool |
3365 | -ccsPluginIsActive (CCSContext * context, char *name) |
3366 | +ccsPluginIsActiveDefault (CCSContext * context, char *name) |
3367 | { |
3368 | CCSPlugin *plugin; |
3369 | |
3370 | @@ -255,6 +627,12 @@ |
3371 | return pPrivate->active; |
3372 | } |
3373 | |
3374 | +Bool |
3375 | +ccsPluginIsActive (CCSContext *context, char *name) |
3376 | +{ |
3377 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextPluginIsActive) (context, name); |
3378 | +} |
3379 | + |
3380 | |
3381 | static void |
3382 | subGroupAdd (CCSSetting * setting, CCSGroup * group) |
3383 | @@ -264,7 +642,7 @@ |
3384 | |
3385 | while (l) |
3386 | { |
3387 | - if (!strcmp (l->data->name, setting->subGroup)) |
3388 | + if (!strcmp (l->data->name, ccsSettingGetSubGroup (setting))) |
3389 | { |
3390 | l->data->settings = ccsSettingListAppend (l->data->settings, |
3391 | setting); |
3392 | @@ -279,7 +657,7 @@ |
3393 | if (subGroup) |
3394 | { |
3395 | group->subGroups = ccsSubGroupListAppend (group->subGroups, subGroup); |
3396 | - subGroup->name = strdup (setting->subGroup); |
3397 | + subGroup->name = strdup (ccsSettingGetSubGroup (setting)); |
3398 | subGroup->settings = ccsSettingListAppend (subGroup->settings, setting); |
3399 | } |
3400 | } |
3401 | @@ -292,7 +670,7 @@ |
3402 | |
3403 | while (l) |
3404 | { |
3405 | - if (!strcmp (l->data->name, setting->group)) |
3406 | + if (!strcmp (l->data->name, ccsSettingGetGroup (setting))) |
3407 | { |
3408 | subGroupAdd (setting, l->data); |
3409 | return; |
3410 | @@ -306,7 +684,7 @@ |
3411 | { |
3412 | group->refCount = 1; |
3413 | p->groups = ccsGroupListAppend (p->groups, group); |
3414 | - group->name = strdup (setting->group); |
3415 | + group->name = strdup (ccsSettingGetGroup (setting)); |
3416 | subGroupAdd (setting, group); |
3417 | } |
3418 | } |
3419 | @@ -337,14 +715,12 @@ |
3420 | if (cPrivate->configWatchId) |
3421 | ccsRemoveFileWatch (cPrivate->configWatchId); |
3422 | |
3423 | - if (c->changedSettings) |
3424 | - ccsSettingListFree (c->changedSettings, FALSE); |
3425 | - |
3426 | - if (c->ccsPrivate) |
3427 | - free (c->ccsPrivate); |
3428 | - |
3429 | - ccsPluginListFree (c->plugins, TRUE); |
3430 | - |
3431 | + if (cPrivate->changedSettings) |
3432 | + cPrivate->changedSettings = ccsSettingListFree (cPrivate->changedSettings, FALSE); |
3433 | + |
3434 | + ccsPluginListFree (cPrivate->plugins, TRUE); |
3435 | + |
3436 | + ccsObjectFinalize (c); |
3437 | free (c); |
3438 | } |
3439 | |
3440 | @@ -354,22 +730,22 @@ |
3441 | if (!p) |
3442 | return; |
3443 | |
3444 | - free (p->name); |
3445 | - free (p->shortDesc); |
3446 | - free (p->longDesc); |
3447 | - free (p->hints); |
3448 | - free (p->category); |
3449 | - |
3450 | - ccsStringListFree (p->loadAfter, TRUE); |
3451 | - ccsStringListFree (p->loadBefore, TRUE); |
3452 | - ccsStringListFree (p->requiresPlugin, TRUE); |
3453 | - ccsStringListFree (p->conflictPlugin, TRUE); |
3454 | - ccsStringListFree (p->conflictFeature, TRUE); |
3455 | - ccsStringListFree (p->providesFeature, TRUE); |
3456 | - ccsStringListFree (p->requiresFeature, TRUE); |
3457 | - |
3458 | PLUGIN_PRIV (p); |
3459 | |
3460 | + free (pPrivate->name); |
3461 | + free (pPrivate->shortDesc); |
3462 | + free (pPrivate->longDesc); |
3463 | + free (pPrivate->hints); |
3464 | + free (pPrivate->category); |
3465 | + |
3466 | + ccsStringListFree (pPrivate->loadAfter, TRUE); |
3467 | + ccsStringListFree (pPrivate->loadBefore, TRUE); |
3468 | + ccsStringListFree (pPrivate->requiresPlugin, TRUE); |
3469 | + ccsStringListFree (pPrivate->conflictPlugin, TRUE); |
3470 | + ccsStringListFree (pPrivate->conflictFeature, TRUE); |
3471 | + ccsStringListFree (pPrivate->providesFeature, TRUE); |
3472 | + ccsStringListFree (pPrivate->requiresFeature, TRUE); |
3473 | + |
3474 | ccsSettingListFree (pPrivate->settings, TRUE); |
3475 | ccsGroupListFree (pPrivate->groups, TRUE); |
3476 | ccsStrExtensionListFree (pPrivate->stringExtensions, TRUE); |
3477 | @@ -385,7 +761,7 @@ |
3478 | free (pPrivate->pbFilePath); |
3479 | #endif |
3480 | |
3481 | - free (pPrivate); |
3482 | + ccsObjectFinalize (p); |
3483 | free (p); |
3484 | } |
3485 | |
3486 | @@ -395,38 +771,42 @@ |
3487 | if (!s) |
3488 | return; |
3489 | |
3490 | - free (s->name); |
3491 | - free (s->shortDesc); |
3492 | - free (s->longDesc); |
3493 | - free (s->group); |
3494 | - free (s->subGroup); |
3495 | - free (s->hints); |
3496 | - |
3497 | - switch (s->type) |
3498 | + SETTING_PRIV (s); |
3499 | + |
3500 | + free (sPrivate->name); |
3501 | + free (sPrivate->shortDesc); |
3502 | + free (sPrivate->longDesc); |
3503 | + free (sPrivate->group); |
3504 | + free (sPrivate->subGroup); |
3505 | + free (sPrivate->hints); |
3506 | + |
3507 | + switch (sPrivate->type) |
3508 | { |
3509 | case TypeInt: |
3510 | - ccsIntDescListFree (s->info.forInt.desc, TRUE); |
3511 | + ccsIntDescListFree (sPrivate->info.forInt.desc, TRUE); |
3512 | break; |
3513 | case TypeString: |
3514 | - ccsStrRestrictionListFree (s->info.forString.restriction, TRUE); |
3515 | + ccsStrRestrictionListFree (sPrivate->info.forString.restriction, TRUE); |
3516 | break; |
3517 | case TypeList: |
3518 | - if (s->info.forList.listType == TypeInt) |
3519 | - ccsIntDescListFree (s->info.forList.listInfo-> |
3520 | + if (sPrivate->info.forList.listType == TypeInt) |
3521 | + ccsIntDescListFree (sPrivate->info.forList.listInfo-> |
3522 | forInt.desc, TRUE); |
3523 | - free (s->info.forList.listInfo); |
3524 | - //ccsSettingValueListFree (s->value->value.asList, TRUE); |
3525 | + free (sPrivate->info.forList.listInfo); |
3526 | + //ccsSettingValueListFree (sPrivate->value->value.asList, TRUE); |
3527 | break; |
3528 | default: |
3529 | break; |
3530 | } |
3531 | |
3532 | - if (&s->defaultValue != s->value) |
3533 | + if (&sPrivate->defaultValue != sPrivate->value) |
3534 | { |
3535 | - ccsFreeSettingValue (s->value); |
3536 | + ccsFreeSettingValue (sPrivate->value); |
3537 | } |
3538 | |
3539 | - ccsFreeSettingValue (&s->defaultValue); |
3540 | + ccsFreeSettingValue (&sPrivate->defaultValue); |
3541 | + |
3542 | + ccsObjectFinalize (s); |
3543 | free (s); |
3544 | } |
3545 | |
3546 | @@ -461,10 +841,10 @@ |
3547 | if (!v->parent) |
3548 | return; |
3549 | |
3550 | - CCSSettingType type = v->parent->type; |
3551 | + CCSSettingType type = ccsSettingGetType (v->parent); |
3552 | |
3553 | if (v->isListChild) |
3554 | - type = v->parent->info.forList.listType; |
3555 | + type = ccsSettingGetInfo (v->parent)->forList.listType; |
3556 | |
3557 | switch (type) |
3558 | { |
3559 | @@ -482,7 +862,7 @@ |
3560 | break; |
3561 | } |
3562 | |
3563 | - if (v != &v->parent->defaultValue) |
3564 | + if (v != ccsSettingGetDefaultValue (v->parent)) |
3565 | free (v); |
3566 | } |
3567 | |
3568 | @@ -580,8 +960,7 @@ |
3569 | ccsFree##type (d); \ |
3570 | } \ |
3571 | |
3572 | -CCSREF (Plugin, CCSPlugin) |
3573 | -CCSREF (Setting, CCSSetting) |
3574 | + |
3575 | CCSREF (String, CCSString) |
3576 | CCSREF (Group, CCSGroup) |
3577 | CCSREF (SubGroup, CCSSubGroup) |
3578 | @@ -592,6 +971,20 @@ |
3579 | CCSREF (StrRestriction, CCSStrRestriction) |
3580 | CCSREF (StrExtension, CCSStrExtension) |
3581 | |
3582 | +#define CCSREF_OBJ(type,dtype) \ |
3583 | + void ccs##type##Ref (dtype *d) \ |
3584 | + { \ |
3585 | + ccsObjectRef (d); \ |
3586 | + } \ |
3587 | + \ |
3588 | + void ccs##type##Unref (dtype *d) \ |
3589 | + { \ |
3590 | + ccsObjectUnref (d, ccsFree##type); \ |
3591 | + } \ |
3592 | + |
3593 | +CCSREF_OBJ (Plugin, CCSPlugin) |
3594 | +CCSREF_OBJ (Setting, CCSSetting) |
3595 | + |
3596 | static void * |
3597 | openBackend (char *backend) |
3598 | { |
3599 | @@ -646,7 +1039,7 @@ |
3600 | } |
3601 | |
3602 | Bool |
3603 | -ccsSetBackend (CCSContext * context, char *name) |
3604 | +ccsSetBackendDefault (CCSContext * context, char *name) |
3605 | { |
3606 | Bool fallbackMode = FALSE; |
3607 | CONTEXT_PRIV (context); |
3608 | @@ -711,6 +1104,11 @@ |
3609 | return TRUE; |
3610 | } |
3611 | |
3612 | +Bool |
3613 | +ccsSetBackend (CCSContext *context, char *name) |
3614 | +{ |
3615 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextSetBackend) (context, name); |
3616 | +} |
3617 | |
3618 | static Bool |
3619 | ccsCompareLists (CCSSettingValueList l1, CCSSettingValueList l2, |
3620 | @@ -869,10 +1267,10 @@ |
3621 | copyValue (CCSSettingValue * from, CCSSettingValue * to) |
3622 | { |
3623 | memcpy (to, from, sizeof (CCSSettingValue)); |
3624 | - CCSSettingType type = from->parent->type; |
3625 | + CCSSettingType type = ccsSettingGetType (from->parent); |
3626 | |
3627 | if (from->isListChild) |
3628 | - type = from->parent->info.forList.listType; |
3629 | + type = ccsSettingGetInfo (from->parent)->forList.listType; |
3630 | |
3631 | switch (type) |
3632 | { |
3633 | @@ -903,43 +1301,54 @@ |
3634 | } |
3635 | } |
3636 | |
3637 | +/* TODO: CCSSetting is not meant to be copyable ... remove */ |
3638 | static void |
3639 | copySetting (CCSSetting *from, CCSSetting *to) |
3640 | -{ |
3641 | +{ |
3642 | memcpy (to, from, sizeof (CCSSetting)); |
3643 | |
3644 | - if (from->name) |
3645 | - to->name = strdup (from->name); |
3646 | - if (from->shortDesc) |
3647 | - to->shortDesc = strdup (from->shortDesc); |
3648 | - if (from->longDesc) |
3649 | - to->longDesc = strdup (from->longDesc); |
3650 | - if (from->group) |
3651 | - to->group = strdup (from->group); |
3652 | - if (from->subGroup) |
3653 | - to->subGroup = strdup (from->subGroup); |
3654 | - if (from->hints) |
3655 | - to->hints = strdup (from->hints); |
3656 | - if (from->value) |
3657 | + ccsObjectInit (from, &ccsDefaultObjectAllocator); |
3658 | + |
3659 | + /* Allocate a new private ptr for the new setting */ |
3660 | + CCSSettingPrivate *ccsPrivate = calloc (1, sizeof (CCSSettingPrivate)); |
3661 | + |
3662 | + ccsObjectSetPrivate (to, (CCSPrivate *) ccsPrivate); |
3663 | + |
3664 | + CCSSettingPrivate *fromPrivate = (CCSSettingPrivate *) ccsObjectGetPrivate (from); |
3665 | + CCSSettingPrivate *toPrivate = (CCSSettingPrivate *) ccsObjectGetPrivate (to); |
3666 | + |
3667 | + if (fromPrivate->name) |
3668 | + toPrivate->name = strdup (fromPrivate->name); |
3669 | + if (fromPrivate->shortDesc) |
3670 | + toPrivate->shortDesc = strdup (fromPrivate->shortDesc); |
3671 | + if (fromPrivate->longDesc) |
3672 | + toPrivate->longDesc = strdup (fromPrivate->longDesc); |
3673 | + if (fromPrivate->group) |
3674 | + toPrivate->group = strdup (fromPrivate->group); |
3675 | + if (fromPrivate->subGroup) |
3676 | + toPrivate->subGroup = strdup (fromPrivate->subGroup); |
3677 | + if (fromPrivate->hints) |
3678 | + toPrivate->hints = strdup (fromPrivate->hints); |
3679 | + if (fromPrivate->value) |
3680 | { |
3681 | - to->value = malloc (sizeof (CCSSettingValue)); |
3682 | + toPrivate->value = malloc (sizeof (CCSSettingValue)); |
3683 | |
3684 | - if (!from->value) |
3685 | + if (!fromPrivate->value) |
3686 | return; |
3687 | |
3688 | - copyValue (from->value, to->value); |
3689 | + copyValue (fromPrivate->value, toPrivate->value); |
3690 | |
3691 | - to->value->refCount = 1; |
3692 | - to->value->parent = to; |
3693 | + toPrivate->value->refCount = 1; |
3694 | + toPrivate->value->parent = to; |
3695 | } |
3696 | |
3697 | - copyValue (&from->defaultValue, &to->defaultValue); |
3698 | - copyInfo (&from->info, &to->info, from->type); |
3699 | + copyValue (&fromPrivate->defaultValue, &toPrivate->defaultValue); |
3700 | + copyInfo (&fromPrivate->info, &toPrivate->info, fromPrivate->type); |
3701 | |
3702 | - to->defaultValue.parent = to; |
3703 | - to->privatePtr = NULL; |
3704 | + toPrivate->defaultValue.parent = to; |
3705 | + toPrivate->privatePtr = NULL; |
3706 | |
3707 | - to->refCount = 1; |
3708 | + (to)->object.refcnt = 1; |
3709 | } |
3710 | |
3711 | static void |
3712 | @@ -947,39 +1356,41 @@ |
3713 | { |
3714 | CCSSettingValue *value; |
3715 | |
3716 | - if (setting->value != &setting->defaultValue) |
3717 | - ccsFreeSettingValue (setting->value); |
3718 | + SETTING_PRIV (setting); |
3719 | + |
3720 | + if (sPrivate->value != &sPrivate->defaultValue) |
3721 | + ccsFreeSettingValue (sPrivate->value); |
3722 | |
3723 | value = calloc (1, sizeof (CCSSettingValue)); |
3724 | if (!value) |
3725 | { |
3726 | - setting->value = &setting->defaultValue; |
3727 | - setting->isDefault = TRUE; |
3728 | + sPrivate->value = &sPrivate->defaultValue; |
3729 | + sPrivate->isDefault = TRUE; |
3730 | return; |
3731 | } |
3732 | |
3733 | value->refCount = 1; |
3734 | |
3735 | - copyValue (&setting->defaultValue, value); |
3736 | - setting->value = value; |
3737 | - setting->isDefault = FALSE; |
3738 | + copyValue (&sPrivate->defaultValue, value); |
3739 | + sPrivate->value = value; |
3740 | + sPrivate->isDefault = FALSE; |
3741 | } |
3742 | |
3743 | void |
3744 | -ccsResetToDefault (CCSSetting * setting, Bool processChanged) |
3745 | +ccsSettingResetToDefaultDefault (CCSSetting * setting, Bool processChanged) |
3746 | { |
3747 | - if (setting->value != &setting->defaultValue) |
3748 | + SETTING_PRIV (setting) |
3749 | + |
3750 | + if (sPrivate->value != &sPrivate->defaultValue) |
3751 | { |
3752 | - ccsFreeSettingValue (setting->value); |
3753 | + ccsFreeSettingValue (sPrivate->value); |
3754 | |
3755 | if (processChanged) |
3756 | - setting->parent->context->changedSettings = |
3757 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
3758 | - setting); |
3759 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
3760 | } |
3761 | |
3762 | - setting->value = &setting->defaultValue; |
3763 | - setting->isDefault = TRUE; |
3764 | + sPrivate->value = &sPrivate->defaultValue; |
3765 | + sPrivate->isDefault = TRUE; |
3766 | } |
3767 | |
3768 | Bool |
3769 | @@ -987,16 +1398,16 @@ |
3770 | { |
3771 | CCSSettingType type; |
3772 | |
3773 | - if (rhs->parent->type != lhs->parent->type) |
3774 | + if (ccsSettingGetType (rhs->parent) != ccsSettingGetType (lhs->parent)) |
3775 | { |
3776 | D (D_FULL, "[WARNING] Attempted to check equality between mismatched types!\n"); |
3777 | return FALSE; |
3778 | } |
3779 | |
3780 | if (rhs->isListChild) |
3781 | - type = rhs->parent->info.forList.listType; |
3782 | + type = ccsSettingGetInfo (rhs->parent)->forList.listType; |
3783 | else |
3784 | - type = rhs->parent->type; |
3785 | + type = ccsSettingGetType (rhs->parent); |
3786 | |
3787 | switch (type) |
3788 | { |
3789 | @@ -1026,62 +1437,67 @@ |
3790 | case TypeList: |
3791 | { |
3792 | return ccsCompareLists (lhs->value.asList, rhs->value.asList, |
3793 | - lhs->parent->info.forList); |
3794 | + ccsSettingGetInfo (lhs->parent)->forList); |
3795 | |
3796 | } |
3797 | default: |
3798 | break; |
3799 | } |
3800 | |
3801 | - D (D_FULL, "[WARNING] Failed to process type %i\n", lhs->parent->type); |
3802 | + D (D_FULL, "[WARNING] Failed to process type %i\n", ccsSettingGetType (lhs->parent)); |
3803 | return FALSE; |
3804 | } |
3805 | |
3806 | +/* FIXME: That's a lot of code for the sake of type switching ... |
3807 | + * maybe we need to switch to C++ here and use templates ... */ |
3808 | + |
3809 | Bool |
3810 | -ccsSetInt (CCSSetting * setting, int data, Bool processChanged) |
3811 | +ccsSettingSetIntDefault (CCSSetting * setting, int data, Bool processChanged) |
3812 | { |
3813 | - if (setting->type != TypeInt) |
3814 | + SETTING_PRIV (setting) |
3815 | + |
3816 | + if (sPrivate->type != TypeInt) |
3817 | return FALSE; |
3818 | |
3819 | - if (setting->isDefault && (setting->defaultValue.value.asInt == data)) |
3820 | + if (sPrivate->isDefault && (sPrivate->defaultValue.value.asInt == data)) |
3821 | return TRUE; |
3822 | |
3823 | - if (!setting->isDefault && (setting->defaultValue.value.asInt == data)) |
3824 | + if (!sPrivate->isDefault && (sPrivate->defaultValue.value.asInt == data)) |
3825 | { |
3826 | ccsResetToDefault (setting, processChanged); |
3827 | return TRUE; |
3828 | } |
3829 | |
3830 | - if (setting->value->value.asInt == data) |
3831 | + if (sPrivate->value->value.asInt == data) |
3832 | return TRUE; |
3833 | |
3834 | - if ((data < setting->info.forInt.min) || |
3835 | - (data > setting->info.forInt.max)) |
3836 | + if ((data < sPrivate->info.forInt.min) || |
3837 | + (data > sPrivate->info.forInt.max)) |
3838 | return FALSE; |
3839 | |
3840 | - if (setting->isDefault) |
3841 | + if (sPrivate->isDefault) |
3842 | copyFromDefault (setting); |
3843 | |
3844 | - setting->value->value.asInt = data; |
3845 | + sPrivate->value->value.asInt = data; |
3846 | |
3847 | if (processChanged) |
3848 | - setting->parent->context->changedSettings = |
3849 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
3850 | - setting); |
3851 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
3852 | |
3853 | return TRUE; |
3854 | } |
3855 | |
3856 | Bool |
3857 | -ccsSetFloat (CCSSetting * setting, float data, Bool processChanged) |
3858 | +ccsSettingSetFloatDefault (CCSSetting * setting, float data, Bool processChanged) |
3859 | { |
3860 | - if (setting->type != TypeFloat) |
3861 | + SETTING_PRIV (setting); |
3862 | + |
3863 | + if (sPrivate->type != TypeFloat) |
3864 | return FALSE; |
3865 | |
3866 | - if (setting->isDefault && (setting->defaultValue.value.asFloat == data)) |
3867 | + if (sPrivate->isDefault && (sPrivate->defaultValue.value.asFloat == data)) |
3868 | return TRUE; |
3869 | |
3870 | - if (!setting->isDefault && (setting->defaultValue.value.asFloat == data)) |
3871 | + if (!sPrivate->isDefault && (sPrivate->defaultValue.value.asFloat == data)) |
3872 | { |
3873 | ccsResetToDefault (setting, processChanged); |
3874 | return TRUE; |
3875 | @@ -1089,308 +1505,306 @@ |
3876 | |
3877 | /* allow the values to differ a tiny bit because of |
3878 | possible rounding / precision issues */ |
3879 | - if (fabs (setting->value->value.asFloat - data) < 1e-5) |
3880 | + if (fabs (sPrivate->value->value.asFloat - data) < 1e-5) |
3881 | return TRUE; |
3882 | |
3883 | - if ((data < setting->info.forFloat.min) || |
3884 | - (data > setting->info.forFloat.max)) |
3885 | + if ((data < sPrivate->info.forFloat.min) || |
3886 | + (data > sPrivate->info.forFloat.max)) |
3887 | return FALSE; |
3888 | |
3889 | - if (setting->isDefault) |
3890 | + if (sPrivate->isDefault) |
3891 | copyFromDefault (setting); |
3892 | |
3893 | - setting->value->value.asFloat = data; |
3894 | + sPrivate->value->value.asFloat = data; |
3895 | |
3896 | if (processChanged) |
3897 | - setting->parent->context->changedSettings = |
3898 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
3899 | - setting); |
3900 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
3901 | |
3902 | return TRUE; |
3903 | } |
3904 | |
3905 | Bool |
3906 | -ccsSetBool (CCSSetting * setting, Bool data, Bool processChanged) |
3907 | +ccsSettingSetBoolDefault (CCSSetting * setting, Bool data, Bool processChanged) |
3908 | { |
3909 | - if (setting->type != TypeBool) |
3910 | + SETTING_PRIV (setting) |
3911 | + |
3912 | + if (sPrivate->type != TypeBool) |
3913 | return FALSE; |
3914 | |
3915 | - if (setting->isDefault |
3916 | - && ((setting->defaultValue.value.asBool && data) |
3917 | - || (!setting->defaultValue.value.asBool && !data))) |
3918 | + if (sPrivate->isDefault |
3919 | + && ((sPrivate->defaultValue.value.asBool && data) |
3920 | + || (!sPrivate->defaultValue.value.asBool && !data))) |
3921 | return TRUE; |
3922 | |
3923 | - if (!setting->isDefault |
3924 | - && ((setting->defaultValue.value.asBool && data) |
3925 | - || (!setting->defaultValue.value.asBool && !data))) |
3926 | + if (!sPrivate->isDefault |
3927 | + && ((sPrivate->defaultValue.value.asBool && data) |
3928 | + || (!sPrivate->defaultValue.value.asBool && !data))) |
3929 | { |
3930 | ccsResetToDefault (setting, processChanged); |
3931 | return TRUE; |
3932 | } |
3933 | |
3934 | - if ((setting->value->value.asBool && data) |
3935 | - || (!setting->value->value.asBool && !data)) |
3936 | + if ((sPrivate->value->value.asBool && data) |
3937 | + || (!sPrivate->value->value.asBool && !data)) |
3938 | return TRUE; |
3939 | |
3940 | - if (setting->isDefault) |
3941 | + if (sPrivate->isDefault) |
3942 | copyFromDefault (setting); |
3943 | |
3944 | - setting->value->value.asBool = data; |
3945 | + sPrivate->value->value.asBool = data; |
3946 | |
3947 | if (processChanged) |
3948 | - setting->parent->context->changedSettings = |
3949 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
3950 | - setting); |
3951 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
3952 | |
3953 | return TRUE; |
3954 | } |
3955 | |
3956 | Bool |
3957 | -ccsSetString (CCSSetting * setting, const char *data, Bool processChanged) |
3958 | +ccsSettingSetStringDefault (CCSSetting * setting, const char *data, Bool processChanged) |
3959 | { |
3960 | - if (setting->type != TypeString) |
3961 | + SETTING_PRIV (setting); |
3962 | + |
3963 | + if (sPrivate->type != TypeString) |
3964 | return FALSE; |
3965 | |
3966 | if (!data) |
3967 | return FALSE; |
3968 | |
3969 | - Bool isDefault = strcmp (setting->defaultValue.value.asString, data) == 0; |
3970 | + Bool isDefault = strcmp (sPrivate->defaultValue.value.asString, data) == 0; |
3971 | |
3972 | - if (setting->isDefault && isDefault) |
3973 | + if (sPrivate->isDefault && isDefault) |
3974 | return TRUE; |
3975 | |
3976 | - if (!setting->isDefault && isDefault) |
3977 | + if (!sPrivate->isDefault && isDefault) |
3978 | { |
3979 | ccsResetToDefault (setting, processChanged); |
3980 | return TRUE; |
3981 | } |
3982 | |
3983 | - if (!strcmp (setting->value->value.asString, data)) |
3984 | + if (!strcmp (sPrivate->value->value.asString, data)) |
3985 | return TRUE; |
3986 | |
3987 | - if (setting->isDefault) |
3988 | + if (sPrivate->isDefault) |
3989 | copyFromDefault (setting); |
3990 | |
3991 | - free (setting->value->value.asString); |
3992 | + free (sPrivate->value->value.asString); |
3993 | |
3994 | - setting->value->value.asString = strdup (data); |
3995 | + sPrivate->value->value.asString = strdup (data); |
3996 | |
3997 | if (processChanged) |
3998 | - setting->parent->context->changedSettings = |
3999 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
4000 | - setting); |
4001 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
4002 | |
4003 | return TRUE; |
4004 | } |
4005 | |
4006 | Bool |
4007 | -ccsSetColor (CCSSetting * setting, CCSSettingColorValue data, Bool processChanged) |
4008 | +ccsSettingSetColorDefault (CCSSetting * setting, CCSSettingColorValue data, Bool processChanged) |
4009 | { |
4010 | - if (setting->type != TypeColor) |
4011 | + SETTING_PRIV (setting) |
4012 | + |
4013 | + if (sPrivate->type != TypeColor) |
4014 | return FALSE; |
4015 | |
4016 | - CCSSettingColorValue defValue = setting->defaultValue.value.asColor; |
4017 | + CCSSettingColorValue defValue = sPrivate->defaultValue.value.asColor; |
4018 | |
4019 | Bool isDefault = ccsIsEqualColor (defValue, data); |
4020 | |
4021 | - if (setting->isDefault && isDefault) |
4022 | + if (sPrivate->isDefault && isDefault) |
4023 | return TRUE; |
4024 | |
4025 | - if (!setting->isDefault && isDefault) |
4026 | + if (!sPrivate->isDefault && isDefault) |
4027 | { |
4028 | ccsResetToDefault (setting, processChanged); |
4029 | return TRUE; |
4030 | } |
4031 | |
4032 | - if (ccsIsEqualColor (setting->value->value.asColor, data)) |
4033 | + if (ccsIsEqualColor (sPrivate->value->value.asColor, data)) |
4034 | return TRUE; |
4035 | |
4036 | - if (setting->isDefault) |
4037 | + if (sPrivate->isDefault) |
4038 | copyFromDefault (setting); |
4039 | |
4040 | - setting->value->value.asColor = data; |
4041 | + sPrivate->value->value.asColor = data; |
4042 | |
4043 | if (processChanged) |
4044 | - setting->parent->context->changedSettings = |
4045 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
4046 | - setting); |
4047 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
4048 | |
4049 | return TRUE; |
4050 | } |
4051 | |
4052 | Bool |
4053 | -ccsSetMatch (CCSSetting * setting, const char *data, Bool processChanged) |
4054 | +ccsSettingSetMatchDefault (CCSSetting * setting, const char *data, Bool processChanged) |
4055 | { |
4056 | - if (setting->type != TypeMatch) |
4057 | + SETTING_PRIV (setting); |
4058 | + |
4059 | + if (sPrivate->type != TypeMatch) |
4060 | return FALSE; |
4061 | |
4062 | if (!data) |
4063 | return FALSE; |
4064 | |
4065 | - Bool isDefault = strcmp (setting->defaultValue.value.asMatch, data) == 0; |
4066 | + Bool isDefault = strcmp (sPrivate->defaultValue.value.asMatch, data) == 0; |
4067 | |
4068 | - if (setting->isDefault && isDefault) |
4069 | + if (sPrivate->isDefault && isDefault) |
4070 | return TRUE; |
4071 | |
4072 | - if (!setting->isDefault && isDefault) |
4073 | + if (!sPrivate->isDefault && isDefault) |
4074 | { |
4075 | ccsResetToDefault (setting, processChanged); |
4076 | return TRUE; |
4077 | } |
4078 | |
4079 | - if (!strcmp (setting->value->value.asMatch, data)) |
4080 | + if (!strcmp (sPrivate->value->value.asMatch, data)) |
4081 | return TRUE; |
4082 | |
4083 | - if (setting->isDefault) |
4084 | + if (sPrivate->isDefault) |
4085 | copyFromDefault (setting); |
4086 | |
4087 | - free (setting->value->value.asMatch); |
4088 | + free (sPrivate->value->value.asMatch); |
4089 | |
4090 | - setting->value->value.asMatch = strdup (data); |
4091 | + sPrivate->value->value.asMatch = strdup (data); |
4092 | |
4093 | if (processChanged) |
4094 | - setting->parent->context->changedSettings = |
4095 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
4096 | - setting); |
4097 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
4098 | |
4099 | return TRUE; |
4100 | } |
4101 | |
4102 | Bool |
4103 | -ccsSetKey (CCSSetting * setting, CCSSettingKeyValue data, Bool processChanged) |
4104 | +ccsSettingSetKeyDefault (CCSSetting * setting, CCSSettingKeyValue data, Bool processChanged) |
4105 | { |
4106 | - if (setting->type != TypeKey) |
4107 | + SETTING_PRIV (setting); |
4108 | + |
4109 | + if (sPrivate->type != TypeKey) |
4110 | return FALSE; |
4111 | |
4112 | - CCSSettingKeyValue defValue = setting->defaultValue.value.asKey; |
4113 | + CCSSettingKeyValue defValue = sPrivate->defaultValue.value.asKey; |
4114 | |
4115 | Bool isDefault = ccsIsEqualKey (data, defValue); |
4116 | |
4117 | - if (setting->isDefault && isDefault) |
4118 | + if (sPrivate->isDefault && isDefault) |
4119 | return TRUE; |
4120 | |
4121 | - if (!setting->isDefault && isDefault) |
4122 | + if (!sPrivate->isDefault && isDefault) |
4123 | { |
4124 | ccsResetToDefault (setting, processChanged); |
4125 | return TRUE; |
4126 | } |
4127 | |
4128 | - if (ccsIsEqualKey (setting->value->value.asKey, data)) |
4129 | + if (ccsIsEqualKey (sPrivate->value->value.asKey, data)) |
4130 | return TRUE; |
4131 | |
4132 | - if (setting->isDefault) |
4133 | + if (sPrivate->isDefault) |
4134 | copyFromDefault (setting); |
4135 | |
4136 | - setting->value->value.asKey.keysym = data.keysym; |
4137 | - setting->value->value.asKey.keyModMask = data.keyModMask; |
4138 | + sPrivate->value->value.asKey.keysym = data.keysym; |
4139 | + sPrivate->value->value.asKey.keyModMask = data.keyModMask; |
4140 | |
4141 | if (processChanged) |
4142 | - setting->parent->context->changedSettings = |
4143 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
4144 | - setting); |
4145 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
4146 | |
4147 | return TRUE; |
4148 | } |
4149 | |
4150 | Bool |
4151 | -ccsSetButton (CCSSetting * setting, CCSSettingButtonValue data, Bool processChanged) |
4152 | +ccsSettingSetButtonDefault (CCSSetting * setting, CCSSettingButtonValue data, Bool processChanged) |
4153 | { |
4154 | - if (setting->type != TypeButton) |
4155 | + SETTING_PRIV (setting); |
4156 | + |
4157 | + if (sPrivate->type != TypeButton) |
4158 | return FALSE; |
4159 | |
4160 | - CCSSettingButtonValue defValue = setting->defaultValue.value.asButton; |
4161 | + CCSSettingButtonValue defValue = sPrivate->defaultValue.value.asButton; |
4162 | |
4163 | Bool isDefault = ccsIsEqualButton (data, defValue); |
4164 | |
4165 | - if (setting->isDefault && isDefault) |
4166 | - return TRUE; |
4167 | - |
4168 | - if (!setting->isDefault && isDefault) |
4169 | - { |
4170 | - ccsResetToDefault (setting, processChanged); |
4171 | - return TRUE; |
4172 | - } |
4173 | - |
4174 | - if (ccsIsEqualButton (setting->value->value.asButton, data)) |
4175 | - return TRUE; |
4176 | - |
4177 | - if (setting->isDefault) |
4178 | - copyFromDefault (setting); |
4179 | - |
4180 | - setting->value->value.asButton.button = data.button; |
4181 | - setting->value->value.asButton.buttonModMask = data.buttonModMask; |
4182 | - setting->value->value.asButton.edgeMask = data.edgeMask; |
4183 | - |
4184 | - if (processChanged) |
4185 | - setting->parent->context->changedSettings = |
4186 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
4187 | - setting); |
4188 | - |
4189 | - return TRUE; |
4190 | -} |
4191 | - |
4192 | -Bool |
4193 | -ccsSetEdge (CCSSetting * setting, unsigned int data, Bool processChanged) |
4194 | -{ |
4195 | - if (setting->type != TypeEdge) |
4196 | - return FALSE; |
4197 | - |
4198 | - Bool isDefault = (data == setting->defaultValue.value.asEdge); |
4199 | - |
4200 | - if (setting->isDefault && isDefault) |
4201 | - return TRUE; |
4202 | - |
4203 | - if (!setting->isDefault && isDefault) |
4204 | - { |
4205 | - ccsResetToDefault (setting, processChanged); |
4206 | - return TRUE; |
4207 | - } |
4208 | - |
4209 | - if (setting->value->value.asEdge == data) |
4210 | - return TRUE; |
4211 | - |
4212 | - if (setting->isDefault) |
4213 | - copyFromDefault (setting); |
4214 | - |
4215 | - setting->value->value.asEdge = data; |
4216 | - |
4217 | - if (processChanged) |
4218 | - setting->parent->context->changedSettings = |
4219 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
4220 | - setting); |
4221 | - |
4222 | - return TRUE; |
4223 | -} |
4224 | - |
4225 | -Bool |
4226 | -ccsSetBell (CCSSetting * setting, Bool data, Bool processChanged) |
4227 | -{ |
4228 | - if (setting->type != TypeBell) |
4229 | - return FALSE; |
4230 | - |
4231 | - Bool isDefault = (data == setting->defaultValue.value.asBool); |
4232 | - |
4233 | - if (setting->isDefault && isDefault) |
4234 | - return TRUE; |
4235 | - |
4236 | - if (!setting->isDefault && isDefault) |
4237 | - { |
4238 | - ccsResetToDefault (setting, processChanged); |
4239 | - return TRUE; |
4240 | - } |
4241 | - |
4242 | - if (setting->value->value.asBell == data) |
4243 | - return TRUE; |
4244 | - |
4245 | - if (setting->isDefault) |
4246 | - copyFromDefault (setting); |
4247 | - |
4248 | - setting->value->value.asBell = data; |
4249 | - |
4250 | - if (processChanged) |
4251 | - setting->parent->context->changedSettings = |
4252 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
4253 | - setting); |
4254 | + if (sPrivate->isDefault && isDefault) |
4255 | + return TRUE; |
4256 | + |
4257 | + if (!sPrivate->isDefault && isDefault) |
4258 | + { |
4259 | + ccsResetToDefault (setting, processChanged); |
4260 | + return TRUE; |
4261 | + } |
4262 | + |
4263 | + if (ccsIsEqualButton (sPrivate->value->value.asButton, data)) |
4264 | + return TRUE; |
4265 | + |
4266 | + if (sPrivate->isDefault) |
4267 | + copyFromDefault (setting); |
4268 | + |
4269 | + sPrivate->value->value.asButton.button = data.button; |
4270 | + sPrivate->value->value.asButton.buttonModMask = data.buttonModMask; |
4271 | + sPrivate->value->value.asButton.edgeMask = data.edgeMask; |
4272 | + |
4273 | + if (processChanged) |
4274 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
4275 | + |
4276 | + return TRUE; |
4277 | +} |
4278 | + |
4279 | +Bool |
4280 | +ccsSettingSetEdgeDefault (CCSSetting * setting, unsigned int data, Bool processChanged) |
4281 | +{ |
4282 | + SETTING_PRIV (setting) |
4283 | + |
4284 | + if (sPrivate->type != TypeEdge) |
4285 | + return FALSE; |
4286 | + |
4287 | + Bool isDefault = (data == sPrivate->defaultValue.value.asEdge); |
4288 | + |
4289 | + if (sPrivate->isDefault && isDefault) |
4290 | + return TRUE; |
4291 | + |
4292 | + if (!sPrivate->isDefault && isDefault) |
4293 | + { |
4294 | + ccsResetToDefault (setting, processChanged); |
4295 | + return TRUE; |
4296 | + } |
4297 | + |
4298 | + if (sPrivate->value->value.asEdge == data) |
4299 | + return TRUE; |
4300 | + |
4301 | + if (sPrivate->isDefault) |
4302 | + copyFromDefault (setting); |
4303 | + |
4304 | + sPrivate->value->value.asEdge = data; |
4305 | + |
4306 | + if (processChanged) |
4307 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
4308 | + |
4309 | + return TRUE; |
4310 | +} |
4311 | + |
4312 | +Bool |
4313 | +ccsSettingSetBellDefault (CCSSetting * setting, Bool data, Bool processChanged) |
4314 | +{ |
4315 | + SETTING_PRIV (setting); |
4316 | + |
4317 | + if (sPrivate->type != TypeBell) |
4318 | + return FALSE; |
4319 | + |
4320 | + Bool isDefault = (data == sPrivate->defaultValue.value.asBool); |
4321 | + |
4322 | + if (sPrivate->isDefault && isDefault) |
4323 | + return TRUE; |
4324 | + |
4325 | + if (!sPrivate->isDefault && isDefault) |
4326 | + { |
4327 | + ccsResetToDefault (setting, processChanged); |
4328 | + return TRUE; |
4329 | + } |
4330 | + |
4331 | + if (sPrivate->value->value.asBell == data) |
4332 | + return TRUE; |
4333 | + |
4334 | + if (sPrivate->isDefault) |
4335 | + copyFromDefault (setting); |
4336 | + |
4337 | + sPrivate->value->value.asBell = data; |
4338 | + |
4339 | + if (processChanged) |
4340 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
4341 | |
4342 | return TRUE; |
4343 | } |
4344 | @@ -1400,6 +1814,8 @@ |
4345 | { |
4346 | CCSSettingValueList l2 = NULL; |
4347 | |
4348 | + SETTING_PRIV (setting) |
4349 | + |
4350 | while (l1) |
4351 | { |
4352 | CCSSettingValue *value = calloc (1, sizeof (CCSSettingValue)); |
4353 | @@ -1410,7 +1826,7 @@ |
4354 | value->parent = setting; |
4355 | value->isListChild = TRUE; |
4356 | |
4357 | - switch (setting->info.forList.listType) |
4358 | + switch (sPrivate->info.forList.listType) |
4359 | { |
4360 | case TypeInt: |
4361 | value->value.asInt = l1->data->value.asInt; |
4362 | @@ -1460,13 +1876,15 @@ |
4363 | } |
4364 | |
4365 | Bool |
4366 | -ccsSetList (CCSSetting * setting, CCSSettingValueList data, Bool processChanged) |
4367 | +ccsSettingSetListDefault (CCSSetting * setting, CCSSettingValueList data, Bool processChanged) |
4368 | { |
4369 | - if (setting->type != TypeList) |
4370 | + SETTING_PRIV (setting) |
4371 | + |
4372 | + if (sPrivate->type != TypeList) |
4373 | return FALSE; |
4374 | |
4375 | - Bool isDefault = ccsCompareLists (setting->defaultValue.value.asList, data, |
4376 | - setting->info.forList); |
4377 | + Bool isDefault = ccsCompareLists (sPrivate->defaultValue.value.asList, data, |
4378 | + sPrivate->info.forList); |
4379 | |
4380 | /* Don't need to worry about default values |
4381 | * when processChanged is off since use of that |
4382 | @@ -1474,53 +1892,53 @@ |
4383 | * temporary storage */ |
4384 | if (!processChanged) |
4385 | { |
4386 | - if (setting->isDefault && isDefault) |
4387 | + if (sPrivate->isDefault && isDefault) |
4388 | { |
4389 | return TRUE; |
4390 | } |
4391 | |
4392 | - if (!setting->isDefault && isDefault) |
4393 | + if (!sPrivate->isDefault && isDefault) |
4394 | { |
4395 | ccsResetToDefault (setting, processChanged); |
4396 | return TRUE; |
4397 | } |
4398 | } |
4399 | |
4400 | - if (ccsCompareLists (setting->value->value.asList, data, |
4401 | - setting->info.forList)) |
4402 | + if (ccsCompareLists (sPrivate->value->value.asList, data, |
4403 | + sPrivate->info.forList)) |
4404 | { |
4405 | return TRUE; |
4406 | } |
4407 | |
4408 | - if (setting->isDefault) |
4409 | + if (sPrivate->isDefault) |
4410 | copyFromDefault (setting); |
4411 | |
4412 | - ccsSettingValueListFree (setting->value->value.asList, TRUE); |
4413 | - |
4414 | - setting->value->value.asList = ccsCopyList (data, setting); |
4415 | - |
4416 | - if ((strcmp (setting->name, "active_plugins") == 0) && |
4417 | - (strcmp (setting->parent->name, "core") == 0) && processChanged) |
4418 | + ccsSettingValueListFree (sPrivate->value->value.asList, TRUE); |
4419 | + |
4420 | + sPrivate->value->value.asList = ccsCopyList (data, setting); |
4421 | + |
4422 | + if ((strcmp (sPrivate->name, "active_plugins") == 0) && |
4423 | + (strcmp (ccsPluginGetName (sPrivate->parent), "core") == 0) && processChanged) |
4424 | { |
4425 | CCSStringList list; |
4426 | |
4427 | - list = ccsGetStringListFromValueList (setting->value->value.asList); |
4428 | - ccsSetActivePluginList (setting->parent->context, list); |
4429 | + list = ccsGetStringListFromValueList (sPrivate->value->value.asList); |
4430 | + ccsSetActivePluginList (ccsPluginGetContext (sPrivate->parent), list); |
4431 | ccsStringListFree (list, TRUE); |
4432 | } |
4433 | |
4434 | if (processChanged) |
4435 | - setting->parent->context->changedSettings = |
4436 | - ccsSettingListAppend (setting->parent->context->changedSettings, |
4437 | - setting); |
4438 | + ccsContextAddChangedSetting (ccsPluginGetContext (sPrivate->parent), setting); |
4439 | |
4440 | return TRUE; |
4441 | } |
4442 | |
4443 | Bool |
4444 | -ccsSetValue (CCSSetting * setting, CCSSettingValue * data, Bool processChanged) |
4445 | +ccsSettingSetValueDefault (CCSSetting * setting, CCSSettingValue * data, Bool processChanged) |
4446 | { |
4447 | - switch (setting->type) |
4448 | + SETTING_PRIV (setting); |
4449 | + |
4450 | + switch (sPrivate->type) |
4451 | { |
4452 | case TypeInt: |
4453 | return ccsSetInt (setting, data->value.asInt, processChanged); |
4454 | @@ -1562,113 +1980,300 @@ |
4455 | } |
4456 | |
4457 | Bool |
4458 | -ccsGetInt (CCSSetting * setting, int *data) |
4459 | -{ |
4460 | - if (setting->type != TypeInt) |
4461 | - return FALSE; |
4462 | - |
4463 | - *data = setting->value->value.asInt; |
4464 | - return TRUE; |
4465 | -} |
4466 | - |
4467 | -Bool |
4468 | -ccsGetFloat (CCSSetting * setting, float *data) |
4469 | -{ |
4470 | - if (setting->type != TypeFloat) |
4471 | - return FALSE; |
4472 | - |
4473 | - *data = setting->value->value.asFloat; |
4474 | - return TRUE; |
4475 | -} |
4476 | - |
4477 | -Bool |
4478 | -ccsGetBool (CCSSetting * setting, Bool * data) |
4479 | -{ |
4480 | - if (setting->type != TypeBool) |
4481 | - return FALSE; |
4482 | - |
4483 | - *data = setting->value->value.asBool; |
4484 | - return TRUE; |
4485 | -} |
4486 | - |
4487 | -Bool |
4488 | -ccsGetString (CCSSetting * setting, char **data) |
4489 | -{ |
4490 | - if (setting->type != TypeString) |
4491 | - return FALSE; |
4492 | - |
4493 | - *data = setting->value->value.asString; |
4494 | - return TRUE; |
4495 | -} |
4496 | - |
4497 | -Bool |
4498 | -ccsGetColor (CCSSetting * setting, CCSSettingColorValue * data) |
4499 | -{ |
4500 | - if (setting->type != TypeColor) |
4501 | +ccsSettingGetIntDefault (CCSSetting * setting, int *data) |
4502 | +{ |
4503 | + SETTING_PRIV (setting); |
4504 | + |
4505 | + if (sPrivate->type != TypeInt) |
4506 | + return FALSE; |
4507 | + |
4508 | + *data = sPrivate->value->value.asInt; |
4509 | + return TRUE; |
4510 | +} |
4511 | + |
4512 | +Bool |
4513 | +ccsSettingGetFloatDefault (CCSSetting * setting, float *data) |
4514 | +{ |
4515 | + SETTING_PRIV (setting) |
4516 | + |
4517 | + if (sPrivate->type != TypeFloat) |
4518 | + return FALSE; |
4519 | + |
4520 | + *data = sPrivate->value->value.asFloat; |
4521 | + return TRUE; |
4522 | +} |
4523 | + |
4524 | +Bool |
4525 | +ccsSettingGetBoolDefault (CCSSetting * setting, Bool * data) |
4526 | +{ |
4527 | + SETTING_PRIV (setting) |
4528 | + |
4529 | + if (sPrivate->type != TypeBool) |
4530 | + return FALSE; |
4531 | + |
4532 | + *data = sPrivate->value->value.asBool; |
4533 | + return TRUE; |
4534 | +} |
4535 | + |
4536 | +Bool |
4537 | +ccsSettingGetStringDefault (CCSSetting * setting, char **data) |
4538 | +{ |
4539 | + SETTING_PRIV (setting) |
4540 | + |
4541 | + if (sPrivate->type != TypeString) |
4542 | + return FALSE; |
4543 | + |
4544 | + *data = sPrivate->value->value.asString; |
4545 | + return TRUE; |
4546 | +} |
4547 | + |
4548 | +Bool |
4549 | +ccsSettingGetColorDefault (CCSSetting * setting, CCSSettingColorValue * data) |
4550 | +{ |
4551 | + SETTING_PRIV (setting) |
4552 | + |
4553 | + if (sPrivate->type != TypeColor) |
4554 | return TRUE; |
4555 | |
4556 | - *data = setting->value->value.asColor; |
4557 | - return TRUE; |
4558 | -} |
4559 | - |
4560 | -Bool |
4561 | -ccsGetMatch (CCSSetting * setting, char **data) |
4562 | -{ |
4563 | - if (setting->type != TypeMatch) |
4564 | - return FALSE; |
4565 | - |
4566 | - *data = setting->value->value.asMatch; |
4567 | - return TRUE; |
4568 | -} |
4569 | - |
4570 | -Bool |
4571 | -ccsGetKey (CCSSetting * setting, CCSSettingKeyValue * data) |
4572 | -{ |
4573 | - if (setting->type != TypeKey) |
4574 | - return FALSE; |
4575 | - |
4576 | - *data = setting->value->value.asKey; |
4577 | - return TRUE; |
4578 | -} |
4579 | - |
4580 | -Bool |
4581 | -ccsGetButton (CCSSetting * setting, CCSSettingButtonValue * data) |
4582 | -{ |
4583 | - if (setting->type != TypeButton) |
4584 | - return FALSE; |
4585 | - |
4586 | - *data = setting->value->value.asButton; |
4587 | - return TRUE; |
4588 | -} |
4589 | - |
4590 | -Bool |
4591 | -ccsGetEdge (CCSSetting * setting, unsigned int * data) |
4592 | -{ |
4593 | - if (setting->type != TypeEdge) |
4594 | - return FALSE; |
4595 | - |
4596 | - *data = setting->value->value.asEdge; |
4597 | - return TRUE; |
4598 | -} |
4599 | - |
4600 | -Bool |
4601 | -ccsGetBell (CCSSetting * setting, Bool * data) |
4602 | -{ |
4603 | - if (setting->type != TypeBell) |
4604 | - return FALSE; |
4605 | - |
4606 | - *data = setting->value->value.asBell; |
4607 | - return TRUE; |
4608 | -} |
4609 | - |
4610 | -Bool |
4611 | -ccsGetList (CCSSetting * setting, CCSSettingValueList * data) |
4612 | -{ |
4613 | - if (setting->type != TypeList) |
4614 | - return FALSE; |
4615 | - |
4616 | - *data = setting->value->value.asList; |
4617 | - return TRUE; |
4618 | + *data = sPrivate->value->value.asColor; |
4619 | + return TRUE; |
4620 | +} |
4621 | + |
4622 | +Bool |
4623 | +ccsSettingGetMatchDefault (CCSSetting * setting, char **data) |
4624 | +{ |
4625 | + SETTING_PRIV (setting) |
4626 | + |
4627 | + if (sPrivate->type != TypeMatch) |
4628 | + return FALSE; |
4629 | + |
4630 | + *data = sPrivate->value->value.asMatch; |
4631 | + return TRUE; |
4632 | +} |
4633 | + |
4634 | +Bool |
4635 | +ccsSettingGetKeyDefault (CCSSetting * setting, CCSSettingKeyValue * data) |
4636 | +{ |
4637 | + SETTING_PRIV (setting) |
4638 | + |
4639 | + if (sPrivate->type != TypeKey) |
4640 | + return FALSE; |
4641 | + |
4642 | + *data = sPrivate->value->value.asKey; |
4643 | + return TRUE; |
4644 | +} |
4645 | + |
4646 | +Bool |
4647 | +ccsSettingGetButtonDefault (CCSSetting * setting, CCSSettingButtonValue * data) |
4648 | +{ |
4649 | + SETTING_PRIV (setting) |
4650 | + |
4651 | + if (sPrivate->type != TypeButton) |
4652 | + return FALSE; |
4653 | + |
4654 | + *data = sPrivate->value->value.asButton; |
4655 | + return TRUE; |
4656 | +} |
4657 | + |
4658 | +Bool |
4659 | +ccsSettingGetEdgeDefault (CCSSetting * setting, unsigned int * data) |
4660 | +{ |
4661 | + SETTING_PRIV (setting) |
4662 | + |
4663 | + if (sPrivate->type != TypeEdge) |
4664 | + return FALSE; |
4665 | + |
4666 | + *data = sPrivate->value->value.asEdge; |
4667 | + return TRUE; |
4668 | +} |
4669 | + |
4670 | +Bool |
4671 | +ccsSettingGetBellDefault (CCSSetting * setting, Bool * data) |
4672 | +{ |
4673 | + SETTING_PRIV (setting) |
4674 | + |
4675 | + if (sPrivate->type != TypeBell) |
4676 | + return FALSE; |
4677 | + |
4678 | + *data = sPrivate->value->value.asBell; |
4679 | + return TRUE; |
4680 | +} |
4681 | + |
4682 | +Bool |
4683 | +ccsSettingGetListDefault (CCSSetting * setting, CCSSettingValueList * data) |
4684 | +{ |
4685 | + SETTING_PRIV (setting) |
4686 | + |
4687 | + if (sPrivate->type != TypeList) |
4688 | + return FALSE; |
4689 | + |
4690 | + *data = sPrivate->value->value.asList; |
4691 | + return TRUE; |
4692 | +} |
4693 | + |
4694 | +Bool ccsGetInt (CCSSetting *setting, |
4695 | + int *data) |
4696 | +{ |
4697 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetInt) (setting, data); |
4698 | +} |
4699 | + |
4700 | +Bool ccsGetFloat (CCSSetting *setting, |
4701 | + float *data) |
4702 | +{ |
4703 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetFloat) (setting, data); |
4704 | +} |
4705 | + |
4706 | +Bool ccsGetBool (CCSSetting *setting, |
4707 | + Bool *data) |
4708 | +{ |
4709 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetBool) (setting, data); |
4710 | +} |
4711 | + |
4712 | +Bool ccsGetString (CCSSetting *setting, |
4713 | + char **data) |
4714 | +{ |
4715 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetString) (setting, data); |
4716 | +} |
4717 | + |
4718 | +Bool ccsGetColor (CCSSetting *setting, |
4719 | + CCSSettingColorValue *data) |
4720 | +{ |
4721 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetColor) (setting, data); |
4722 | +} |
4723 | + |
4724 | +Bool ccsGetMatch (CCSSetting *setting, |
4725 | + char **data) |
4726 | +{ |
4727 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetMatch) (setting, data); |
4728 | +} |
4729 | + |
4730 | +Bool ccsGetKey (CCSSetting *setting, |
4731 | + CCSSettingKeyValue *data) |
4732 | +{ |
4733 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetKey) (setting, data); |
4734 | +} |
4735 | + |
4736 | +Bool ccsGetButton (CCSSetting *setting, |
4737 | + CCSSettingButtonValue *data) |
4738 | +{ |
4739 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetButton) (setting, data); |
4740 | +} |
4741 | + |
4742 | +Bool ccsGetEdge (CCSSetting *setting, |
4743 | + unsigned int *data) |
4744 | +{ |
4745 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetEdge) (setting, data); |
4746 | +} |
4747 | + |
4748 | +Bool ccsGetBell (CCSSetting *setting, |
4749 | + Bool *data) |
4750 | +{ |
4751 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetBell) (setting, data); |
4752 | +} |
4753 | + |
4754 | +Bool ccsGetList (CCSSetting *setting, |
4755 | + CCSSettingValueList *data) |
4756 | +{ |
4757 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingGetList) (setting, data); |
4758 | +} |
4759 | + |
4760 | +Bool ccsSetInt (CCSSetting *setting, |
4761 | + int data, |
4762 | + Bool processChanged) |
4763 | +{ |
4764 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetInt) (setting, data, processChanged); |
4765 | +} |
4766 | + |
4767 | +Bool ccsSetFloat (CCSSetting *setting, |
4768 | + float data, |
4769 | + Bool processChanged) |
4770 | +{ |
4771 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetFloat) (setting, data, processChanged); |
4772 | +} |
4773 | + |
4774 | +Bool ccsSetBool (CCSSetting *setting, |
4775 | + Bool data, |
4776 | + Bool processChanged) |
4777 | +{ |
4778 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetBool) (setting, data, processChanged); |
4779 | +} |
4780 | + |
4781 | +Bool ccsSetString (CCSSetting *setting, |
4782 | + const char *data, |
4783 | + Bool processChanged) |
4784 | +{ |
4785 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetString) (setting, data, processChanged); |
4786 | +} |
4787 | + |
4788 | +Bool ccsSetColor (CCSSetting *setting, |
4789 | + CCSSettingColorValue data, |
4790 | + Bool processChanged) |
4791 | +{ |
4792 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetColor) (setting, data, processChanged); |
4793 | +} |
4794 | + |
4795 | +Bool ccsSetMatch (CCSSetting *setting, |
4796 | + const char *data, |
4797 | + Bool processChanged) |
4798 | +{ |
4799 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetMatch) (setting, data, processChanged); |
4800 | +} |
4801 | + |
4802 | +Bool ccsSetKey (CCSSetting *setting, |
4803 | + CCSSettingKeyValue data, |
4804 | + Bool processChanged) |
4805 | +{ |
4806 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetKey) (setting, data, processChanged); |
4807 | +} |
4808 | + |
4809 | +Bool ccsSetButton (CCSSetting *setting, |
4810 | + CCSSettingButtonValue data, |
4811 | + Bool processChanged) |
4812 | +{ |
4813 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetButton) (setting, data, processChanged); |
4814 | +} |
4815 | + |
4816 | +Bool ccsSetEdge (CCSSetting *setting, |
4817 | + unsigned int data, |
4818 | + Bool processChanged) |
4819 | +{ |
4820 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetEdge) (setting, data, processChanged); |
4821 | +} |
4822 | + |
4823 | +Bool ccsSetBell (CCSSetting *setting, |
4824 | + Bool data, |
4825 | + Bool processChanged) |
4826 | +{ |
4827 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetBell) (setting, data, processChanged); |
4828 | +} |
4829 | + |
4830 | +Bool ccsSetList (CCSSetting *setting, |
4831 | + CCSSettingValueList data, |
4832 | + Bool processChanged) |
4833 | +{ |
4834 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetList) (setting, data, processChanged); |
4835 | +} |
4836 | + |
4837 | +Bool ccsSetValue (CCSSetting *setting, |
4838 | + CCSSettingValue *data, |
4839 | + Bool processChanged) |
4840 | +{ |
4841 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingSetValue) (setting, data, processChanged); |
4842 | +} |
4843 | + |
4844 | +void ccsResetToDefault (CCSSetting * setting, Bool processChanged) |
4845 | +{ |
4846 | + (*(GET_INTERFACE (CCSSettingInterface, setting))->settingResetToDefault) (setting, processChanged); |
4847 | +} |
4848 | + |
4849 | +Bool ccsSettingIsIntegrated (CCSSetting *setting) |
4850 | +{ |
4851 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingIsIntegrated) (setting); |
4852 | +} |
4853 | + |
4854 | +Bool ccsSettingIsReadOnly (CCSSetting *setting) |
4855 | +{ |
4856 | + return (*(GET_INTERFACE (CCSSettingInterface, setting))->settingIsReadOnly) (setting); |
4857 | } |
4858 | |
4859 | void |
4860 | @@ -1693,15 +2298,17 @@ |
4861 | } |
4862 | |
4863 | CCSPluginList |
4864 | -ccsGetActivePluginList (CCSContext * context) |
4865 | +ccsGetActivePluginListDefault (CCSContext * context) |
4866 | { |
4867 | + CONTEXT_PRIV (context); |
4868 | + |
4869 | CCSPluginList rv = NULL; |
4870 | - CCSPluginList l = context->plugins; |
4871 | + CCSPluginList l = cPrivate->plugins; |
4872 | |
4873 | while (l) |
4874 | { |
4875 | PLUGIN_PRIV (l->data); |
4876 | - if (pPrivate->active && strcmp (l->data->name, "ccp")) |
4877 | + if (pPrivate->active && strcmp (ccsPluginGetName (l->data), "ccp")) |
4878 | { |
4879 | rv = ccsPluginListAppend (rv, l->data); |
4880 | } |
4881 | @@ -1712,6 +2319,12 @@ |
4882 | return rv; |
4883 | } |
4884 | |
4885 | +CCSPluginList |
4886 | +ccsGetActivePluginList (CCSContext *context) |
4887 | +{ |
4888 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetActivePluginList) (context); |
4889 | +} |
4890 | + |
4891 | static CCSPlugin * |
4892 | findPluginInList (CCSPluginList list, char *name) |
4893 | { |
4894 | @@ -1720,7 +2333,7 @@ |
4895 | |
4896 | while (list) |
4897 | { |
4898 | - if (!strcmp (list->data->name, name)) |
4899 | + if (!strcmp (ccsPluginGetName (list->data), name)) |
4900 | return list->data; |
4901 | |
4902 | list = list->next; |
4903 | @@ -1736,7 +2349,7 @@ |
4904 | } PluginSortHelper; |
4905 | |
4906 | CCSStringList |
4907 | -ccsGetSortedPluginStringList (CCSContext * context) |
4908 | +ccsGetSortedPluginStringListDefault (CCSContext * context) |
4909 | { |
4910 | CCSPluginList ap = ccsGetActivePluginList (context); |
4911 | CCSPluginList list; |
4912 | @@ -1777,7 +2390,7 @@ |
4913 | |
4914 | for (i = 0; i < len; i++) |
4915 | { |
4916 | - CCSStringList l = plugins[i].plugin->loadAfter; |
4917 | + CCSStringList l = ccsPluginGetLoadAfter (plugins[i].plugin); |
4918 | while (l) |
4919 | { |
4920 | p = findPluginInList (ap, ((CCSString *)l->data)->value); |
4921 | @@ -1788,13 +2401,13 @@ |
4922 | l = l->next; |
4923 | } |
4924 | |
4925 | - l = plugins[i].plugin->requiresPlugin; |
4926 | + l = ccsPluginGetRequiresPlugins (plugins[i].plugin); |
4927 | while (l) |
4928 | { |
4929 | Bool found = FALSE; |
4930 | p = findPluginInList (ap, ((CCSString *)l->data)->value); |
4931 | |
4932 | - CCSStringList l2 = plugins[i].plugin->loadBefore; |
4933 | + CCSStringList l2 = ccsPluginGetLoadBefore (plugins[i].plugin); |
4934 | while (l2) |
4935 | { |
4936 | if (strcmp (((CCSString *)l2->data)->value, |
4937 | @@ -1809,7 +2422,7 @@ |
4938 | l = l->next; |
4939 | } |
4940 | |
4941 | - l = plugins[i].plugin->loadBefore; |
4942 | + l = ccsPluginGetLoadBefore (plugins[i].plugin); |
4943 | while (l) |
4944 | { |
4945 | p = findPluginInList (ap, ((CCSString *)l->data)->value); |
4946 | @@ -1852,7 +2465,7 @@ |
4947 | |
4948 | /* This is a special case to ensure that bench is the last plugin */ |
4949 | if (len - removed > 1 && |
4950 | - strcmp (plugins[i].plugin->name, "bench") == 0) |
4951 | + strcmp (ccsPluginGetName (plugins[i].plugin), "bench") == 0) |
4952 | continue; |
4953 | |
4954 | found = TRUE; |
4955 | @@ -1866,7 +2479,7 @@ |
4956 | |
4957 | strPluginName = calloc (1, sizeof (CCSString)); |
4958 | |
4959 | - strPluginName->value = strdup (p->name); |
4960 | + strPluginName->value = strdup (ccsPluginGetName (p)); |
4961 | strPluginName->refCount = 1; |
4962 | |
4963 | rv = ccsStringListAppend (rv, strPluginName); |
4964 | @@ -1896,8 +2509,14 @@ |
4965 | return rv; |
4966 | } |
4967 | |
4968 | +CCSStringList |
4969 | +ccsGetSortedPluginStringList (CCSContext *context) |
4970 | +{ |
4971 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetSortedPluginStringList) (context); |
4972 | +} |
4973 | + |
4974 | char * |
4975 | -ccsGetBackend (CCSContext * context) |
4976 | +ccsGetBackendDefault (CCSContext * context) |
4977 | { |
4978 | if (!context) |
4979 | return NULL; |
4980 | @@ -1910,8 +2529,14 @@ |
4981 | return cPrivate->backend->vTable->name; |
4982 | } |
4983 | |
4984 | +char * |
4985 | +ccsGetBackend (CCSContext *context) |
4986 | +{ |
4987 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetBackend) (context); |
4988 | +} |
4989 | + |
4990 | Bool |
4991 | -ccsGetIntegrationEnabled (CCSContext * context) |
4992 | +ccsGetIntegrationEnabledDefault (CCSContext * context) |
4993 | { |
4994 | if (!context) |
4995 | return FALSE; |
4996 | @@ -1921,8 +2546,17 @@ |
4997 | return cPrivate->deIntegration; |
4998 | } |
4999 | |
5000 | +Bool |
Changed status to Needs review. Since Sam asked me to review it now.