Merge lp:~compiz-team/compiz/compiz.fix_1064791 into lp:compiz/0.9.9
- compiz.fix_1064791
- Merge into 0.9.9
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Daniel van Vugt | ||||
Approved revision: | 3422 | ||||
Merged at revision: | 3425 | ||||
Proposed branch: | lp:~compiz-team/compiz/compiz.fix_1064791 | ||||
Merge into: | lp:compiz/0.9.9 | ||||
Diff against target: |
1666 lines (+1033/-243) 21 files modified
compizconfig/gsettings/CMakeLists.txt (+13/-3) compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt (+8/-0) compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c (+31/-60) compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.h (+9/-1) compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_fwd.h (+1/-0) compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.c (+96/-0) compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.h (+38/-0) compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.c (+51/-0) compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.h (+82/-0) compizconfig/gsettings/mocks/CMakeLists.txt (+5/-1) compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.cpp (+47/-0) compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.h (+92/-0) compizconfig/gsettings/src/gsettings.c (+66/-1) compizconfig/gsettings/tests/CMakeLists.txt (+2/-0) compizconfig/gsettings/tests/test_gsettings_tests.cpp (+242/-2) compizconfig/integration/gnome/gsettings/CMakeLists.txt (+10/-1) compizconfig/integration/gnome/gsettings/include/ccs_gnome_gsettings_fwd.h (+0/-12) compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h (+20/-44) compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_wrapper_factory.h (+44/-0) compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c (+41/-118) compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_wrapper_factory.c (+135/-0) |
||||
To merge this branch: | bzr merge lp:~compiz-team/compiz/compiz.fix_1064791 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
jenkins (community) | continuous-integration | Needs Fixing | |
Review via email: mp+129088@code.launchpad.net |
This proposal supersedes a proposal from 2012-10-10.
Description of the change
Don't write plugins-
jenkins (martin-mrazik+qa) wrote : Posted in a previous version of this proposal | # |
Sam Spilsbury (smspillaz) wrote : | # |
As above.
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:3421
http://
Executed test runs:
FAILURE: http://
Daniel van Vugt (vanvugt) wrote : | # |
I am concerned about very long identifiers...
typedef struct _CCSGNOMEIntegr
I cannot read that. The words are too long for my feeble human brain to recognize symbolically. And I'm sure most humans would agree. It is however very important for code to be readable by human beings for the sake of maintenance.
I know there's a lot of existing code written that way already. However it was landed without review due to limited time before release. So I'd like to say: No more new code with unreadably long identifiers please.
AFAIK, C/C++ should only accept up to 32 characters. And I've never seen anything even that long before now.
Secondly, "Bug #1064791: Redundant writes to plugins-
Sam Spilsbury (smspillaz) wrote : | # |
> I am concerned about very long identifiers...
> typedef struct _CCSGNOMEIntegr
> CCSGNOMEIntegra
> I cannot read that. The words are too long for my feeble human brain to
> recognize symbolically. And I'm sure most humans would agree. It is however
> very important for code to be readable by human beings for the sake of
> maintenance.
>
> I know there's a lot of existing code written that way already. However it was
> landed without review due to limited time before release. So I'd like to say:
> No more new code with unreadably long identifiers please.
Yeah this sucks, but it does accurately describe its role. Its a libcompizconfig gnome-integration gsettings-wrapper factory private-data. That's not really something that can be shortened, and c's lack of namespaces makes it a lot harder to do so. I can perhaps drop the CCS and Integration to just have GNOMEGSettingsW
>
> AFAIK, C/C++ should only accept up to 32 characters. And I've never seen
> anything even that long before now.
That would be a god-awful old compiler that did that. Sure you're not typing this on a VT-100 ;-) ?
>
> Secondly, "Bug #1064791: Redundant writes to plugins-
> very simple problem that should have a very simple solution. So why "1663
> lines (+1030/-243) 21 files modified" ?
Tests basically, and the fun-stuff that comes with that. I need to instantiate CCSGSettingsBackend independently, and it turned out that this wasn't trivial with the current design because CCSGSettingsBackend creates a lot of objects on construction.
- 3422. By Sam Spilsbury
-
Drop reference to factory as the integrated setting factory takes one. Fixes
a memory leak
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:3422
http://
Executed test runs:
FAILURE: http://
Daniel van Vugt (vanvugt) wrote : | # |
Certainly if the type, or any identifier at all, is local to one file then you don't need to over-prefix it like a namespace. The identifier only needs to be unique within the file. Yes, "Integration" is a redundant word. And while "Wrapper", "Factory" and "Private" may be accurate you should re-evaluate if you need to have things wrapped, from factories or pimpl'd at all.
32 characters is too long already. I'm sure you can find some literature about how human beings read text. You will find that we recognise words as symbols and do not look at the individual letters. However this readability breaks down at some length (which IMHO is shorter than 32).
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3422
http://
Executed test runs:
FAILURE: http://
Sam Spilsbury (smspillaz) wrote : | # |
> Certainly if the type, or any identifier at all, is local to one file then you
> don't need to over-prefix it like a namespace. The identifier only needs to be
> unique within the file. Yes, "Integration" is a redundant word. And while
> "Wrapper", "Factory" and "Private" may be accurate you should re-evaluate if
> you need to have things wrapped, from factories or pimpl'd at all.
Wrappers - required for testing purposes
Private - that's fundamentally how libcompizconfig's object system works
Factory - need to delay instance creation until later, need to change the way instance creation works (we can't ever create a wrapper around a real GSettings object in testing)
>
> 32 characters is too long already. I'm sure you can find some literature about
> how human beings read text. You will find that we recognise words as symbols
> and do not look at the individual letters. However this readability breaks
> down at some length (which IMHO is shorter than 32).
To be fair, type names don't come up all that much - long names is more of a problem for variables than it is types, because types need to be searchable and not recognizable.
Daniel van Vugt (vanvugt) wrote : | # |
OK, I don't claim to understand it. And I still think it's not readable (although that problem mostly pre-dates this proposal).
All tests pass. Clang is happy. Valgrind is happy. I don't know of any functional problems.
In fact, this branch fixes bug 1044662 for me. Don't know why, but I have triple checked. So that's awesome.
Daniel van Vugt (vanvugt) : | # |
Preview Diff
1 | === modified file 'compizconfig/gsettings/CMakeLists.txt' |
2 | --- compizconfig/gsettings/CMakeLists.txt 2012-09-27 09:28:59 +0000 |
3 | +++ compizconfig/gsettings/CMakeLists.txt 2012-10-12 01:30:30 +0000 |
4 | @@ -21,9 +21,19 @@ |
5 | add_subdirectory (gsettings_backend_shared) |
6 | |
7 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/gsettings_backend_shared |
8 | - ${CMAKE_SOURCE_DIR}/compizconfig/integration/gnome/gsettings/include) |
9 | - |
10 | -compizconfig_backend (gsettings PKGDEPS ${_deps} LIBRARIES compizconfig_gsettings_backend) |
11 | + ${CMAKE_SOURCE_DIR}/compizconfig/integration/gnome/gsettings/include |
12 | + ${CMAKE_SOURCE_DIR}/compizconfig/integration/gnome/include) |
13 | + |
14 | +set (COMPIZCONFIG_GSETTINGS_BACKEND_LIBRARIES |
15 | + compizconfig_gsettings_wrapper |
16 | + compizconfig_gnome_integration |
17 | + compizconfig_gnome_integration_gsettings_setting_factory |
18 | + compizconfig_gnome_integration_gsettings_wrapper_factory |
19 | + compizconfig_gsettings_wrapper_factory_interface |
20 | + compizconfig_gsettings_wrapper_factory |
21 | + compizconfig_gsettings_backend) |
22 | + |
23 | +compizconfig_backend (gsettings PKGDEPS ${_deps} LIBRARIES ${COMPIZCONFIG_GSETTINGS_BACKEND_LIBRARIES}) |
24 | |
25 | find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas) |
26 | |
27 | |
28 | === modified file 'compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt' |
29 | --- compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-10-06 16:11:05 +0000 |
30 | +++ compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-10-12 01:30:30 +0000 |
31 | @@ -24,6 +24,12 @@ |
32 | add_library (compizconfig_gsettings_backend_interface STATIC |
33 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_interface.c) |
34 | |
35 | + add_library (compizconfig_gsettings_wrapper_factory_interface STATIC |
36 | + ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_factory_interface.c) |
37 | + |
38 | + add_library (compizconfig_gsettings_wrapper_factory STATIC |
39 | + ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_factory.c) |
40 | + |
41 | add_library (compizconfig_gsettings_wrapper_interface STATIC |
42 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_interface.c) |
43 | |
44 | @@ -53,6 +59,8 @@ |
45 | compizconfig_gsettings_wrapper |
46 | compizconfig_gnome_integration |
47 | compizconfig_gnome_integration_gsettings_setting_factory |
48 | + compizconfig_gsettings_wrapper_factory_interface |
49 | + compizconfig_gsettings_wrapper_factory |
50 | compizconfig) |
51 | |
52 | if (USE_GCONF) |
53 | |
54 | === modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c' |
55 | --- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-09-23 04:35:00 +0000 |
56 | +++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-10-12 01:30:30 +0000 |
57 | @@ -8,22 +8,24 @@ |
58 | #include "ccs_gsettings_backend_interface.h" |
59 | #include "ccs_gsettings_interface.h" |
60 | #include "ccs_gsettings_interface_wrapper.h" |
61 | +#include "ccs_gsettings_wrapper_factory_interface.h" |
62 | #include "ccs_gnome_integration.h" |
63 | #include "ccs_gnome_integration_gsettings_integrated_setting_factory.h" |
64 | #include "gsettings_shared.h" |
65 | |
66 | struct _CCSGSettingsBackendPrivate |
67 | { |
68 | - GList *settingsList; |
69 | - CCSGSettingsWrapper *compizconfigSettings; |
70 | - CCSGSettingsWrapper *currentProfileSettings; |
71 | + GList *settingsList; |
72 | + CCSGSettingsWrapper *compizconfigSettings; |
73 | + CCSGSettingsWrapper *currentProfileSettings; |
74 | + CCSGSettingsWrapperFactory *wrapperFactory; |
75 | |
76 | char *currentProfile; |
77 | CCSContext *context; |
78 | |
79 | CCSIntegration *integration; |
80 | |
81 | - CCSGNOMEValueChangeData valueChangeData; |
82 | + CCSGNOMEValueChangeData *valueChangeData; |
83 | }; |
84 | |
85 | void |
86 | @@ -112,7 +114,7 @@ |
87 | |
88 | /* No existing settings object found for this schema, create one */ |
89 | |
90 | - settingsObj = ccsGSettingsWrapperNewForSchemaWithPath (schemaName, path, &ccsDefaultObjectAllocator); |
91 | + settingsObj = ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (priv->wrapperFactory, schemaName, path, &ccsDefaultObjectAllocator); |
92 | ccsGSettingsBackendConnectToChangedSignal (backend, settingsObj); |
93 | priv->settingsList = g_list_append (priv->settingsList, (void *) settingsObj); |
94 | |
95 | @@ -124,11 +126,12 @@ |
96 | |
97 | writtenPlugins = ccsGSettingsWrapperGetValue (priv->currentProfileSettings, "plugins-with-set-keys"); |
98 | |
99 | - appendToPluginsWithSetKeysList (plugin, writtenPlugins, &newWrittenPlugins, &newWrittenPluginsSize); |
100 | - |
101 | - GVariant *newWrittenPluginsVariant = g_variant_new_strv ((const gchar * const *) newWrittenPlugins, newWrittenPluginsSize); |
102 | - |
103 | - ccsGSettingsWrapperSetValue (priv->currentProfileSettings, "plugins-with-set-keys", newWrittenPluginsVariant); |
104 | + if (appendToPluginsWithSetKeysList (plugin, writtenPlugins, &newWrittenPlugins, &newWrittenPluginsSize)) |
105 | + { |
106 | + GVariant *newWrittenPluginsVariant = g_variant_new_strv ((const gchar * const *) newWrittenPlugins, newWrittenPluginsSize); |
107 | + |
108 | + ccsGSettingsWrapperSetValue (priv->currentProfileSettings, "plugins-with-set-keys", newWrittenPluginsVariant); |
109 | + } |
110 | |
111 | g_variant_unref (writtenPlugins); |
112 | g_free (schemaName); |
113 | @@ -367,26 +370,6 @@ |
114 | return priv; |
115 | } |
116 | |
117 | -static char* |
118 | -getCurrentProfileName (CCSBackend *backend) |
119 | -{ |
120 | - GVariant *value; |
121 | - char *ret = NULL; |
122 | - |
123 | - CCSGSettingsBackendPrivate *priv = (CCSGSettingsBackendPrivate *) ccsObjectGetPrivate (backend); |
124 | - |
125 | - value = ccsGSettingsWrapperGetValue (priv->compizconfigSettings, "current-profile"); |
126 | - |
127 | - if (value) |
128 | - ret = strdup (g_variant_get_string (value, NULL)); |
129 | - else |
130 | - ret = strdup (DEFAULTPROF); |
131 | - |
132 | - g_variant_unref (value); |
133 | - |
134 | - return ret; |
135 | -} |
136 | - |
137 | static void |
138 | ccsGSettingsWrapperDestroyNotify (gpointer o) |
139 | { |
140 | @@ -418,6 +401,9 @@ |
141 | priv->compizconfigSettings = NULL; |
142 | |
143 | ccsIntegrationUnref (priv->integration); |
144 | + ccsGSettingsWrapperFactoryUnref (priv->wrapperFactory); |
145 | + |
146 | + free (priv->valueChangeData); |
147 | |
148 | free (priv); |
149 | ccsObjectSetPrivate (backend, NULL); |
150 | @@ -425,41 +411,26 @@ |
151 | } |
152 | |
153 | Bool |
154 | -ccsGSettingsBackendAttachNewToBackend (CCSBackend *backend, CCSContext *context) |
155 | +ccsGSettingsBackendAttachNewToBackend (CCSBackend *backend, |
156 | + CCSContext *context, |
157 | + CCSGSettingsWrapper *compizconfigSettings, |
158 | + CCSGSettingsWrapper *currentProfileSettings, |
159 | + CCSGSettingsWrapperFactory *wrapperFactory, |
160 | + CCSIntegration *integration, |
161 | + CCSGNOMEValueChangeData *valueChangeData, |
162 | + char *currentProfile) |
163 | { |
164 | - char *currentProfilePath; |
165 | - |
166 | ccsObjectAddInterface (backend, (CCSInterface *) &gsettingsAdditionalDefaultInterface, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface)); |
167 | |
168 | CCSGSettingsBackendPrivate *priv = addPrivateToBackend (backend, backend->object.object_allocation); |
169 | |
170 | - priv->compizconfigSettings = ccsGSettingsWrapperNewForSchema (COMPIZCONFIG_SCHEMA_ID, |
171 | - backend->object.object_allocation); |
172 | - priv->currentProfile = getCurrentProfileName (backend); |
173 | - currentProfilePath = makeCompizProfilePath (priv->currentProfile); |
174 | - priv->currentProfileSettings = ccsGSettingsWrapperNewForSchemaWithPath (PROFILE_SCHEMA_ID, |
175 | - currentProfilePath, |
176 | - backend->object.object_allocation); |
177 | + priv->compizconfigSettings = compizconfigSettings; |
178 | + priv->currentProfile = currentProfile; |
179 | + priv->currentProfileSettings = currentProfileSettings; |
180 | priv->context = context; |
181 | - |
182 | - CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory = ccsGNOMEIntegrationGSettingsWrapperDefaultImplNew (&ccsDefaultObjectAllocator); |
183 | - CCSIntegratedSettingsStorage *storage = ccsIntegratedSettingsStorageDefaultImplNew (&ccsDefaultObjectAllocator); |
184 | - |
185 | - priv->valueChangeData.storage = storage; |
186 | - priv->valueChangeData.context = priv->context; |
187 | - |
188 | - CCSIntegratedSettingFactory *factory = ccsGSettingsIntegratedSettingFactoryNew (wrapperFactory, |
189 | - &priv->valueChangeData, |
190 | - &ccsDefaultObjectAllocator); |
191 | - |
192 | - priv->valueChangeData.factory = factory; |
193 | - |
194 | - priv->integration = ccsGNOMEIntegrationBackendNew (backend, context, factory, storage, backend->object.object_allocation); |
195 | - |
196 | - |
197 | - |
198 | - priv->valueChangeData.integration = priv->integration; |
199 | - |
200 | - g_free (currentProfilePath); |
201 | + priv->valueChangeData = valueChangeData; |
202 | + priv->integration = integration; |
203 | + priv->wrapperFactory = wrapperFactory; |
204 | + |
205 | return TRUE; |
206 | } |
207 | |
208 | === modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.h' |
209 | --- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.h 2012-10-06 16:11:05 +0000 |
210 | +++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.h 2012-10-12 01:30:30 +0000 |
211 | @@ -4,12 +4,20 @@ |
212 | #include <ccs-defs.h> |
213 | #include <ccs-backend.h> |
214 | #include <ccs_gsettings_backend_fwd.h> |
215 | +#include <ccs_gnome_fwd.h> |
216 | #include <glib.h> |
217 | |
218 | COMPIZCONFIG_BEGIN_DECLS |
219 | |
220 | Bool |
221 | -ccsGSettingsBackendAttachNewToBackend (CCSBackend *backend, CCSContext *context); |
222 | +ccsGSettingsBackendAttachNewToBackend (CCSBackend *backend, |
223 | + CCSContext *context, |
224 | + CCSGSettingsWrapper *compizconfigSettings, |
225 | + CCSGSettingsWrapper *currentProfileSettings, |
226 | + CCSGSettingsWrapperFactory *wrapperFactory, |
227 | + CCSIntegration *integration, |
228 | + CCSGNOMEValueChangeData *valueChangeData, |
229 | + char *currentProfile); |
230 | |
231 | void |
232 | ccsGSettingsBackendDetachFromBackend (CCSBackend *backend); |
233 | |
234 | === modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_fwd.h' |
235 | --- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_fwd.h 2012-10-06 16:11:05 +0000 |
236 | +++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_fwd.h 2012-10-12 01:30:30 +0000 |
237 | @@ -7,6 +7,7 @@ |
238 | |
239 | typedef struct _CCSGSettingsWrapper CCSGSettingsWrapper; |
240 | typedef struct _CCSGSettingsBackend CCSGSettingsBackend; |
241 | +typedef struct _CCSGSettingsWrapperFactory CCSGSettingsWrapperFactory; |
242 | |
243 | COMPIZCONFIG_END_DECLS |
244 | |
245 | |
246 | === added file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.c' |
247 | --- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.c 1970-01-01 00:00:00 +0000 |
248 | +++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.c 2012-10-12 01:30:30 +0000 |
249 | @@ -0,0 +1,96 @@ |
250 | +/** |
251 | + * |
252 | + * GSettings libcompizconfig backend |
253 | + * |
254 | + * ccs_gsettings_wrapper_factory.c |
255 | + * |
256 | + * Copyright (c) 2012 Canonical Ltd |
257 | + * |
258 | + * This program is free software; you can redistribute it and/or |
259 | + * modify it under the terms of the GNU General Public License |
260 | + * as published by the Free Software Foundation; either version 2 |
261 | + * of the License, or (at your option) any later version. |
262 | + * |
263 | + * This program is distributed in the hope that it will be useful, |
264 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
265 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
266 | + * GNU General Public License for more details. |
267 | + * |
268 | + * Authored By: |
269 | + * Sam Spilsbury <sam.spilsbury@canonical.com> |
270 | + * |
271 | + **/ |
272 | +#include <ccs-object.h> |
273 | +#include "ccs_gsettings_wrapper_factory.h" |
274 | +#include "ccs_gsettings_wrapper_factory_interface.h" |
275 | +#include "ccs_gsettings_interface.h" |
276 | +#include "ccs_gsettings_interface_wrapper.h" |
277 | + |
278 | +/* CCSGSettingsWrapperFactory implementation */ |
279 | +typedef struct _CCSGSettingsWrapperFactoryPrivate CCSGSettingsWrapperFactoryPrivate; |
280 | +struct _CCSGSettingsWrapperFactoryPrivate |
281 | +{ |
282 | +}; |
283 | + |
284 | +static void |
285 | +ccsGSettingsWrapperDefaultImplFree (CCSGSettingsWrapperFactory *wrapperFactory) |
286 | +{ |
287 | + ccsObjectFinalize (wrapperFactory); |
288 | + (*wrapperFactory->object.object_allocation->free_) (wrapperFactory->object.object_allocation->allocator, |
289 | + wrapperFactory); |
290 | +} |
291 | + |
292 | +static CCSGSettingsWrapper * |
293 | +ccsGSettingsWrapperFactoryNewGSettingsWrapperDefault (CCSGSettingsWrapperFactory *factory, |
294 | + const gchar *schemaName, |
295 | + CCSObjectAllocationInterface *ai) |
296 | +{ |
297 | + CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperNewForSchema (schemaName, ai); |
298 | + |
299 | + return wrapper; |
300 | +} |
301 | + |
302 | +CCSGSettingsWrapper * |
303 | +ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPathDefault (CCSGSettingsWrapperFactory *wrapperFactory, |
304 | + const gchar *schemaName, |
305 | + const gchar *path, |
306 | + CCSObjectAllocationInterface *ai) |
307 | +{ |
308 | + CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperNewForSchemaWithPath (schemaName, |
309 | + path, |
310 | + ai); |
311 | + |
312 | + return wrapper; |
313 | +} |
314 | + |
315 | +const CCSGSettingsWrapperFactoryInterface ccsGSettingsWrapperFactoryInterface = |
316 | +{ |
317 | + ccsGSettingsWrapperFactoryNewGSettingsWrapperDefault, |
318 | + ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPathDefault, |
319 | + ccsGSettingsWrapperDefaultImplFree |
320 | +}; |
321 | + |
322 | +CCSGSettingsWrapperFactory * |
323 | +ccsGSettingsWrapperFactoryDefaultImplNew (CCSObjectAllocationInterface *ai) |
324 | +{ |
325 | + CCSGSettingsWrapperFactory *wrapperFactory = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGSettingsWrapperFactory)); |
326 | + |
327 | + if (!wrapperFactory) |
328 | + return NULL; |
329 | + |
330 | + CCSGSettingsWrapperFactoryPrivate *priv = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGSettingsWrapperFactoryPrivate)); |
331 | + |
332 | + if (!priv) |
333 | + { |
334 | + (*ai->free_) (ai->allocator, wrapperFactory); |
335 | + return NULL; |
336 | + } |
337 | + |
338 | + ccsObjectInit (wrapperFactory, ai); |
339 | + ccsObjectAddInterface (wrapperFactory, (const CCSInterface *) &ccsGSettingsWrapperFactoryInterface, GET_INTERFACE_TYPE (CCSGSettingsWrapperFactoryInterface)); |
340 | + ccsObjectSetPrivate (wrapperFactory, (CCSPrivate *) priv); |
341 | + |
342 | + ccsGSettingsWrapperFactoryRef (wrapperFactory); |
343 | + |
344 | + return wrapperFactory; |
345 | +} |
346 | |
347 | === added file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.h' |
348 | --- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.h 1970-01-01 00:00:00 +0000 |
349 | +++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.h 2012-10-12 01:30:30 +0000 |
350 | @@ -0,0 +1,38 @@ |
351 | +/** |
352 | + * |
353 | + * GSettings libcompizconfig backend |
354 | + * |
355 | + * ccs_gsettings_wrapper_factory.h |
356 | + * |
357 | + * Copyright (c) 2012 Canonical Ltd |
358 | + * |
359 | + * This program is free software; you can redistribute it and/or |
360 | + * modify it under the terms of the GNU General Public License |
361 | + * as published by the Free Software Foundation; either version 2 |
362 | + * of the License, or (at your option) any later version. |
363 | + * |
364 | + * This program is distributed in the hope that it will be useful, |
365 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
366 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
367 | + * GNU General Public License for more details. |
368 | + * |
369 | + * Authored By: |
370 | + * Sam Spilsbury <sam.spilsbury@canonical.com> |
371 | + * |
372 | + **/ |
373 | +#ifndef _CCS_GSETTINGS_WRAPPER_FACTORY_H |
374 | +#define _CCS_GSETTINGS_WRAPPER_FACTORY_H |
375 | + |
376 | +#include <ccs-defs.h> |
377 | + |
378 | +COMPIZCONFIG_BEGIN_DECLS |
379 | + |
380 | +#include <ccs-fwd.h> |
381 | +#include <ccs_gsettings_backend_fwd.h> |
382 | + |
383 | +CCSGSettingsWrapperFactory * |
384 | +ccsGSettingsWrapperFactoryDefaultImplNew (CCSObjectAllocationInterface *ai); |
385 | + |
386 | +COMPIZCONFIG_END_DECLS |
387 | + |
388 | +#endif |
389 | |
390 | === added file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.c' |
391 | --- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.c 1970-01-01 00:00:00 +0000 |
392 | +++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.c 2012-10-12 01:30:30 +0000 |
393 | @@ -0,0 +1,51 @@ |
394 | +/** |
395 | + * |
396 | + * GSettings libcompizconfig backend |
397 | + * |
398 | + * ccs_gsettings_wrapper_factory_interface.c |
399 | + * |
400 | + * Copyright (c) 2012 Canonical Ltd |
401 | + * |
402 | + * This program is free software; you can redistribute it and/or |
403 | + * modify it under the terms of the GNU General Public License |
404 | + * as published by the Free Software Foundation; either version 2 |
405 | + * of the License, or (at your option) any later version. |
406 | + * |
407 | + * This program is distributed in the hope that it will be useful, |
408 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
409 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
410 | + * GNU General Public License for more details. |
411 | + * |
412 | + * Authored By: |
413 | + * Sam Spilsbury <sam.spilsbury@canonical.com> |
414 | + * |
415 | + **/ |
416 | +#include <ccs-object.h> |
417 | +#include "ccs_gsettings_wrapper_factory_interface.h" |
418 | + |
419 | +INTERFACE_TYPE (CCSGSettingsWrapperFactoryInterface); |
420 | + |
421 | +CCSGSettingsWrapper * |
422 | +ccsGSettingsWrapperFactoryNewGSettingsWrapper (CCSGSettingsWrapperFactory *factory, |
423 | + const gchar *schemaName, |
424 | + CCSObjectAllocationInterface *ai) |
425 | +{ |
426 | + return (*(GET_INTERFACE (CCSGSettingsWrapperFactoryInterface, factory))->newGSettingsWrapper) (factory, schemaName, ai); |
427 | +} |
428 | + |
429 | +CCSGSettingsWrapper * |
430 | +ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (CCSGSettingsWrapperFactory *factory, |
431 | + const gchar *schemaName, |
432 | + const gchar *path, |
433 | + CCSObjectAllocationInterface *ai) |
434 | +{ |
435 | + return (*(GET_INTERFACE (CCSGSettingsWrapperFactoryInterface, factory))->newGSettingsWrapperWithPath) (factory, schemaName, path, ai); |
436 | +} |
437 | + |
438 | +void |
439 | +ccsFreeGSettingsWrapperFactory (CCSGSettingsWrapperFactory *factory) |
440 | +{ |
441 | + return (*(GET_INTERFACE (CCSGSettingsWrapperFactoryInterface, factory))->free) (factory); |
442 | +} |
443 | + |
444 | +CCSREF_OBJ (GSettingsWrapperFactory, CCSGSettingsWrapperFactory) |
445 | |
446 | === added file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.h' |
447 | --- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.h 1970-01-01 00:00:00 +0000 |
448 | +++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.h 2012-10-12 01:30:30 +0000 |
449 | @@ -0,0 +1,82 @@ |
450 | +/** |
451 | + * |
452 | + * GSettings libcompizconfig backend |
453 | + * |
454 | + * ccs_gsettings_wrapper_factory_interface.h |
455 | + * |
456 | + * Copyright (c) 2012 Canonical Ltd |
457 | + * |
458 | + * This program is free software; you can redistribute it and/or |
459 | + * modify it under the terms of the GNU General Public License |
460 | + * as published by the Free Software Foundation; either version 2 |
461 | + * of the License, or (at your option) any later version. |
462 | + * |
463 | + * This program is distributed in the hope that it will be useful, |
464 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
465 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
466 | + * GNU General Public License for more details. |
467 | + * |
468 | + * Authored By: |
469 | + * Sam Spilsbury <sam.spilsbury@canonical.com> |
470 | + * |
471 | + **/ |
472 | + |
473 | +#ifndef _CCS_GSETTINGS_WRAPPER_FACTORY_INTERFACE_H |
474 | +#define _CCS_GSETTINGS_WRAPPER_FACTORY_INTERFACE_H |
475 | + |
476 | +#include <ccs-defs.h> |
477 | + |
478 | +COMPIZCONFIG_BEGIN_DECLS |
479 | + |
480 | +#include <gio/gio.h> |
481 | +#include <ccs-fwd.h> |
482 | +#include <ccs-object.h> |
483 | +#include <ccs_gsettings_backend_fwd.h> |
484 | + |
485 | +typedef struct _CCSGSettingsWrapperFactoryInterface CCSGSettingsWrapperFactoryInterface; |
486 | + |
487 | +typedef CCSGSettingsWrapper * (*CCSGSettingsWrapperFactoryNewGSettingsWrapper) (CCSGSettingsWrapperFactory *wrapperFactory, |
488 | + const gchar *schema, |
489 | + CCSObjectAllocationInterface *ai); |
490 | +typedef CCSGSettingsWrapper * (*CCSGSettingsWrapperFactoryNewGSettingsWrapperWithPath) (CCSGSettingsWrapperFactory *wrapperFactory, |
491 | + const gchar *schema, |
492 | + const gchar *path, |
493 | + CCSObjectAllocationInterface *ai); |
494 | + |
495 | +typedef void (*CCSGSettingsWrapperFactoryFree) (CCSGSettingsWrapperFactory *wrapperFactory); |
496 | + |
497 | +struct _CCSGSettingsWrapperFactoryInterface |
498 | +{ |
499 | + CCSGSettingsWrapperFactoryNewGSettingsWrapper newGSettingsWrapper; |
500 | + CCSGSettingsWrapperFactoryNewGSettingsWrapperWithPath newGSettingsWrapperWithPath; |
501 | + CCSGSettingsWrapperFactoryFree free; |
502 | +}; |
503 | + |
504 | +/** |
505 | + * @brief The _CCSGSettingsWrapperFactory struct |
506 | + * |
507 | + * Will create new CCSGSettingsIntegratedSetting objects on demand |
508 | + */ |
509 | +struct _CCSGSettingsWrapperFactory |
510 | +{ |
511 | + CCSObject object; |
512 | +}; |
513 | + |
514 | +unsigned int ccsCCSGSettingsWrapperFactoryInterfaceGetType (); |
515 | + |
516 | +CCSREF_HDR (GSettingsWrapperFactory, CCSGSettingsWrapperFactory); |
517 | + |
518 | +CCSGSettingsWrapper * |
519 | +ccsGSettingsWrapperFactoryNewGSettingsWrapper (CCSGSettingsWrapperFactory *wrapperFactory, |
520 | + const gchar *schema, |
521 | + CCSObjectAllocationInterface *ai); |
522 | + |
523 | +CCSGSettingsWrapper * |
524 | +ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (CCSGSettingsWrapperFactory *factory, |
525 | + const gchar *schemaName, |
526 | + const gchar *path, |
527 | + CCSObjectAllocationInterface *ai); |
528 | + |
529 | +COMPIZCONFIG_END_DECLS |
530 | + |
531 | +#endif |
532 | |
533 | === modified file 'compizconfig/gsettings/mocks/CMakeLists.txt' |
534 | --- compizconfig/gsettings/mocks/CMakeLists.txt 2012-09-11 17:37:45 +0000 |
535 | +++ compizconfig/gsettings/mocks/CMakeLists.txt 2012-10-12 01:30:30 +0000 |
536 | @@ -8,12 +8,16 @@ |
537 | ${CMAKE_CURRENT_SOURCE_DIR}/../gsettings_backend_shared |
538 | ${GLIB_INCLUDE_DIRS}) |
539 | |
540 | -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") |
541 | + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") |
542 | |
543 | add_library (compizconfig_ccs_gsettings_wrapper_mock STATIC |
544 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.cpp |
545 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.h) |
546 | |
547 | + add_library (compizconfig_ccs_gsettings_wrapper_factory_mock STATIC |
548 | + ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_factory_mock.cpp |
549 | + ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_factory_mock.h) |
550 | + |
551 | add_library (compizconfig_ccs_gsettings_backend_mock STATIC |
552 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.cpp |
553 | ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.h) |
554 | |
555 | === added file 'compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.cpp' |
556 | --- compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.cpp 1970-01-01 00:00:00 +0000 |
557 | +++ compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.cpp 2012-10-12 01:30:30 +0000 |
558 | @@ -0,0 +1,47 @@ |
559 | +#include <ccs_gsettings_wrapper_factory_mock.h> |
560 | +#include <ccs-object.h> |
561 | + |
562 | +const CCSGSettingsWrapperFactoryInterface mockInterface = |
563 | +{ |
564 | + CCSGSettingsWrapperFactoryGMock::ccsGSettingsWrapperFactoryNewGSettingsWrapper, |
565 | + CCSGSettingsWrapperFactoryGMock::ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath, |
566 | + CCSGSettingsWrapperFactoryGMock::ccsFreeGSettingsWrapperFactory |
567 | +}; |
568 | + |
569 | +CCSGSettingsWrapperFactory * |
570 | +ccsMockGSettingsWrapperFactoryNew () |
571 | +{ |
572 | + CCSGSettingsWrapperFactory *wrapper = (CCSGSettingsWrapperFactory *) calloc (1, sizeof (CCSGSettingsWrapperFactory)); |
573 | + |
574 | + if (!wrapper) |
575 | + return NULL; |
576 | + |
577 | + CCSGSettingsWrapperFactoryGMock *gmockWrapper = new CCSGSettingsWrapperFactoryGMock (wrapper); |
578 | + |
579 | + if (!gmockWrapper) |
580 | + { |
581 | + free (wrapper); |
582 | + return NULL; |
583 | + } |
584 | + |
585 | + ccsObjectInit (wrapper, &ccsDefaultObjectAllocator); |
586 | + ccsObjectAddInterface (wrapper, (const CCSInterface *) &mockInterface, GET_INTERFACE_TYPE (CCSGSettingsWrapperFactoryInterface)); |
587 | + ccsObjectSetPrivate (wrapper, (CCSPrivate *) gmockWrapper); |
588 | + |
589 | + ccsGSettingsWrapperFactoryRef (wrapper); |
590 | + |
591 | + return wrapper; |
592 | +} |
593 | + |
594 | +void |
595 | +ccsMockGSettingsWrapperFactoryFree (CCSGSettingsWrapperFactory *wrapper) |
596 | +{ |
597 | + CCSGSettingsWrapperFactoryGMock *gmockWrapper = reinterpret_cast <CCSGSettingsWrapperFactoryGMock *> (ccsObjectGetPrivate (wrapper)); |
598 | + |
599 | + delete gmockWrapper; |
600 | + |
601 | + ccsObjectSetPrivate (wrapper, NULL); |
602 | + ccsObjectFinalize (wrapper); |
603 | + free (wrapper); |
604 | +} |
605 | + |
606 | |
607 | === added file 'compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.h' |
608 | --- compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.h 1970-01-01 00:00:00 +0000 |
609 | +++ compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.h 2012-10-12 01:30:30 +0000 |
610 | @@ -0,0 +1,92 @@ |
611 | +/** |
612 | + * |
613 | + * GSettings libcompizconfig backend |
614 | + * |
615 | + * ccs_gsettings_wrapper_factory_mock.h |
616 | + * |
617 | + * Copyright (c) 2012 Canonical Ltd |
618 | + * |
619 | + * This program is free software; you can redistribute it and/or |
620 | + * modify it under the terms of the GNU General Public License |
621 | + * as published by the Free Software Foundation; either version 2 |
622 | + * of the License, or (at your option) any later version. |
623 | + * |
624 | + * This program is distributed in the hope that it will be useful, |
625 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
626 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
627 | + * GNU General Public License for more details. |
628 | + * |
629 | + * Authored By: |
630 | + * Sam Spilsbury <sam.spilsbury@canonical.com> |
631 | + * |
632 | + **/ |
633 | +#ifndef _COMPIZCONFIG_CCS_GSETTINGS_WRAPPER_FACTORY_MOCK |
634 | +#define _COMPIZCONFIG_CCS_GSETTINGS_WRAPPER_FACTORY_MOCK |
635 | + |
636 | +#include <gtest/gtest.h> |
637 | +#include <gmock/gmock.h> |
638 | + |
639 | +#include <ccs_gsettings_wrapper_factory_interface.h> |
640 | + |
641 | +CCSGSettingsWrapperFactory * ccsMockGSettingsWrapperFactoryNew (); |
642 | +void ccsMockGSettingsWrapperFactoryFree (CCSGSettingsWrapperFactory *); |
643 | + |
644 | +class CCSGSettingsWrapperFactoryMockInterface |
645 | +{ |
646 | + public: |
647 | + |
648 | + virtual ~CCSGSettingsWrapperFactoryMockInterface () {} |
649 | + virtual CCSGSettingsWrapper * newGSettingsWrapper (const gchar *schema, |
650 | + CCSObjectAllocationInterface *ai) = 0; |
651 | + virtual CCSGSettingsWrapper * newGSettingsWrapperWithPath (const gchar *schema, |
652 | + const gchar *path, |
653 | + CCSObjectAllocationInterface *ai) = 0; |
654 | +}; |
655 | + |
656 | +class CCSGSettingsWrapperFactoryGMock : |
657 | + public CCSGSettingsWrapperFactoryMockInterface |
658 | +{ |
659 | + public: |
660 | + |
661 | + CCSGSettingsWrapperFactoryGMock (CCSGSettingsWrapperFactory *wrapper) : |
662 | + mWrapper (wrapper) |
663 | + { |
664 | + } |
665 | + |
666 | + MOCK_METHOD2 (newGSettingsWrapper, CCSGSettingsWrapper * (const gchar *schema, |
667 | + CCSObjectAllocationInterface *ai)); |
668 | + MOCK_METHOD3 (newGSettingsWrapperWithPath, CCSGSettingsWrapper * (const gchar *schema, |
669 | + const gchar *path, |
670 | + CCSObjectAllocationInterface *ai)); |
671 | + |
672 | + private: |
673 | + |
674 | + CCSGSettingsWrapperFactory *mWrapper; |
675 | + |
676 | + public: |
677 | + |
678 | + static CCSGSettingsWrapper * |
679 | + ccsGSettingsWrapperFactoryNewGSettingsWrapper (CCSGSettingsWrapperFactory *wrapperFactory, |
680 | + const gchar *schema, |
681 | + CCSObjectAllocationInterface *ai) |
682 | + { |
683 | + return reinterpret_cast <CCSGSettingsWrapperFactoryMockInterface *> (ccsObjectGetPrivate (wrapperFactory))->newGSettingsWrapper (schema, ai); |
684 | + } |
685 | + |
686 | + static CCSGSettingsWrapper * |
687 | + ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (CCSGSettingsWrapperFactory *wrapperFactory, |
688 | + const gchar *schema, |
689 | + const gchar *path, |
690 | + CCSObjectAllocationInterface *ai) |
691 | + { |
692 | + return reinterpret_cast <CCSGSettingsWrapperFactoryMockInterface *> (ccsObjectGetPrivate (wrapperFactory))->newGSettingsWrapperWithPath (schema, path, ai); |
693 | + } |
694 | + |
695 | + static void |
696 | + ccsFreeGSettingsWrapperFactory (CCSGSettingsWrapperFactory *wrapperFactory) |
697 | + { |
698 | + ccsMockGSettingsWrapperFactoryFree (wrapperFactory); |
699 | + } |
700 | +}; |
701 | + |
702 | +#endif |
703 | |
704 | === modified file 'compizconfig/gsettings/src/gsettings.c' |
705 | --- compizconfig/gsettings/src/gsettings.c 2012-09-25 06:12:24 +0000 |
706 | +++ compizconfig/gsettings/src/gsettings.c 2012-10-12 01:30:30 +0000 |
707 | @@ -39,6 +39,11 @@ |
708 | #include "ccs_gsettings_backend.h" |
709 | #include "ccs_gsettings_interface.h" |
710 | #include "ccs_gsettings_interface_wrapper.h" |
711 | +#include "ccs_gsettings_wrapper_factory_interface.h" |
712 | +#include "ccs_gsettings_wrapper_factory.h" |
713 | +#include "ccs_gnome_integration_gsettings_wrapper_factory.h" |
714 | +#include "ccs_gnome_integration_gsettings_integrated_setting_factory.h" |
715 | +#include "ccs_gnome_integration.h" |
716 | |
717 | GVariant * |
718 | getVariantForCCSSetting (CCSBackend *backend, CCSSetting *setting) |
719 | @@ -437,12 +442,72 @@ |
720 | } |
721 | } |
722 | |
723 | +static char * |
724 | +getCurrentProfileName (CCSGSettingsWrapper *compizconfigSettings) |
725 | +{ |
726 | + GVariant *value; |
727 | + char *ret = NULL; |
728 | + |
729 | + value = ccsGSettingsWrapperGetValue (compizconfigSettings, "current-profile"); |
730 | + |
731 | + if (value) |
732 | + ret = strdup (g_variant_get_string (value, NULL)); |
733 | + else |
734 | + ret = strdup (DEFAULTPROF); |
735 | + |
736 | + g_variant_unref (value); |
737 | + |
738 | + return ret; |
739 | +} |
740 | + |
741 | static Bool |
742 | initBackend (CCSBackend *backend, CCSContext * context) |
743 | { |
744 | g_type_init (); |
745 | |
746 | - return ccsGSettingsBackendAttachNewToBackend (backend, context); |
747 | + CCSGSettingsWrapper *compizconfigSettings = ccsGSettingsWrapperNewForSchema (COMPIZCONFIG_SCHEMA_ID, |
748 | + backend->object.object_allocation); |
749 | + char *currentProfile = getCurrentProfileName (compizconfigSettings); |
750 | + char *currentProfilePath = currentProfilePath = makeCompizProfilePath (currentProfile); |
751 | + CCSGSettingsWrapper *currentProfileSettings = ccsGSettingsWrapperNewForSchemaWithPath (PROFILE_SCHEMA_ID, |
752 | + currentProfilePath, |
753 | + backend->object.object_allocation); |
754 | + CCSGNOMEValueChangeData *valueChangeData = calloc (1, sizeof (CCSGNOMEValueChangeData)); |
755 | + CCSGSettingsWrapperFactory *wrapperFactory = ccsGSettingsWrapperFactoryDefaultImplNew (backend->object.object_allocation); |
756 | + CCSGSettingsWrapperFactory *gnomeWrapperFactory = ccsGNOMEIntegrationGSettingsWrapperFactoryDefaultImplNew (backend->object.object_allocation, |
757 | + wrapperFactory, |
758 | + ccsGSettingsIntegratedSettingsChangeCallback (), |
759 | + valueChangeData); |
760 | + CCSIntegratedSettingsStorage *storage = ccsIntegratedSettingsStorageDefaultImplNew (backend->object.object_allocation); |
761 | + |
762 | + valueChangeData->storage = storage; |
763 | + valueChangeData->context = context; |
764 | + |
765 | + CCSIntegratedSettingFactory *factory = ccsGSettingsIntegratedSettingFactoryNew (gnomeWrapperFactory, |
766 | + valueChangeData, |
767 | + backend->object.object_allocation); |
768 | + |
769 | + valueChangeData->factory = factory; |
770 | + |
771 | + CCSIntegration *integration = ccsGNOMEIntegrationBackendNew (backend, context, factory, storage, backend->object.object_allocation); |
772 | + |
773 | + |
774 | + |
775 | + valueChangeData->integration = integration; |
776 | + |
777 | + g_free (currentProfilePath); |
778 | + |
779 | + /* Drop our reference to the wrapper factory */ |
780 | + ccsGSettingsWrapperFactoryUnref (gnomeWrapperFactory); |
781 | + |
782 | + return ccsGSettingsBackendAttachNewToBackend (backend, |
783 | + context, |
784 | + compizconfigSettings, |
785 | + currentProfileSettings, |
786 | + wrapperFactory, |
787 | + integration, |
788 | + valueChangeData, |
789 | + currentProfile); |
790 | } |
791 | |
792 | static Bool |
793 | |
794 | === modified file 'compizconfig/gsettings/tests/CMakeLists.txt' |
795 | --- compizconfig/gsettings/tests/CMakeLists.txt 2012-10-04 06:14:43 +0000 |
796 | +++ compizconfig/gsettings/tests/CMakeLists.txt 2012-10-12 01:30:30 +0000 |
797 | @@ -39,8 +39,10 @@ |
798 | compizconfig_ccs_setting_mock |
799 | compizconfig_ccs_plugin_mock |
800 | compizconfig_ccs_context_mock |
801 | + compizconfig_ccs_integration_mock |
802 | compizconfig_ccs_gsettings_backend_mock |
803 | compizconfig_ccs_gsettings_wrapper_mock |
804 | + compizconfig_ccs_gsettings_wrapper_factory_mock |
805 | compizconfig_ccs_test_value_combinations |
806 | ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES} |
807 | ${GTEST_BOTH_LIBRARIES} |
808 | |
809 | === modified file 'compizconfig/gsettings/tests/test_gsettings_tests.cpp' |
810 | --- compizconfig/gsettings/tests/test_gsettings_tests.cpp 2012-10-04 09:19:38 +0000 |
811 | +++ compizconfig/gsettings/tests/test_gsettings_tests.cpp 2012-10-12 01:30:30 +0000 |
812 | @@ -7,13 +7,21 @@ |
813 | #include <boost/shared_ptr.hpp> |
814 | #include <boost/scoped_array.hpp> |
815 | |
816 | +#include "gtest_shared_autodestroy.h" |
817 | + |
818 | #include "test_gsettings_tests.h" |
819 | #include "gsettings.h" |
820 | #include "ccs_gsettings_backend.h" |
821 | +#include "ccs_gsettings_backend_interface.h" |
822 | #include "ccs_gsettings_backend_mock.h" |
823 | #include "compizconfig_ccs_context_mock.h" |
824 | #include "compizconfig_ccs_plugin_mock.h" |
825 | #include "compizconfig_ccs_setting_mock.h" |
826 | +#include "compizconfig_ccs_integration_mock.h" |
827 | +#include "ccs_gsettings_wrapper_mock.h" |
828 | +#include "ccs_gsettings_wrapper_factory_mock.h" |
829 | +#include "ccs_gsettings_wrapper_factory_interface.h" |
830 | +#include "ccs_gnome_integration.h" |
831 | #include "gtest_shared_characterwrapper.h" |
832 | #include "compizconfig_test_value_combiners.h" |
833 | #include "compizconfig_ccs_mocked_allocator.h" |
834 | @@ -1959,8 +1967,6 @@ |
835 | boost::shared_ptr <CCSContext> context (ccsMockContextNew (), |
836 | boost::bind (ccsFreeMockContext, _1)); |
837 | |
838 | - GVariantBuilder pluginsWithChangedKeysBuilder; |
839 | - |
840 | const unsigned short NUM_KEYS = 3; |
841 | |
842 | gchar ** fooKeys = (gchar **) calloc (1, sizeof (char *) * (NUM_KEYS + 1)); |
843 | @@ -1975,6 +1981,8 @@ |
844 | barKeys[2] = g_strdup (KEY_EXAMPLE_THREE.c_str ()); |
845 | barKeys[3] = NULL; |
846 | |
847 | + GVariantBuilder pluginsWithChangedKeysBuilder; |
848 | + |
849 | g_variant_builder_init (&pluginsWithChangedKeysBuilder, G_VARIANT_TYPE ("as")); |
850 | g_variant_builder_add (&pluginsWithChangedKeysBuilder, "s", PLUGIN_FOO.c_str ()); |
851 | g_variant_builder_add (&pluginsWithChangedKeysBuilder, "s", PLUGIN_BAR.c_str ()); |
852 | @@ -2017,3 +2025,235 @@ |
853 | pluginsWithChangedKeys.get (), |
854 | "mock"); |
855 | } |
856 | + |
857 | +namespace |
858 | +{ |
859 | + const CCSBackendInfo stubBackendInfo = |
860 | + { |
861 | + "stub", |
862 | + "stub", |
863 | + "stub", |
864 | + FALSE, |
865 | + FALSE |
866 | + }; |
867 | + |
868 | + const CCSBackendInfo * |
869 | + stubBackendGetInfo (CCSBackend *backend) |
870 | + { |
871 | + return &stubBackendInfo; |
872 | + } |
873 | + |
874 | + Bool |
875 | + stubBackendInit (CCSBackend *backend, CCSContext *context) |
876 | + { |
877 | + return TRUE; |
878 | + } |
879 | + |
880 | + Bool |
881 | + stubBackendFini (CCSBackend *backend) |
882 | + { |
883 | + return TRUE; |
884 | + } |
885 | + |
886 | + CCSBackendInterface stubBackendInterface = |
887 | + { |
888 | + stubBackendGetInfo, |
889 | + NULL, |
890 | + stubBackendInit, |
891 | + stubBackendFini, |
892 | + NULL, |
893 | + NULL, |
894 | + NULL, |
895 | + NULL, |
896 | + NULL, |
897 | + NULL, |
898 | + NULL, |
899 | + NULL, |
900 | + NULL, |
901 | + NULL, |
902 | + NULL, |
903 | + NULL |
904 | + }; |
905 | +} |
906 | + |
907 | +namespace |
908 | +{ |
909 | + const std::string MOCK_PLUGIN_NAME ("mock"); |
910 | + const std::string MOCK_SCHEMA_NAME ("org.compiz.mock"); |
911 | + const std::string MOCK_PROFILE_NAME ("mock"); |
912 | + const std::string MOCK_GSCHEMA_PATH ("/org/compiz/profiles/mock/plugins/mock"); |
913 | + const std::string PLUGINS_WITH_SET_KEYS ("plugins-with-set-keys"); |
914 | + |
915 | + boost::shared_ptr <GVariant> |
916 | + GetEmptyPluginsWithSetKeys () |
917 | + { |
918 | + GVariantBuilder pluginsWithChangedKeysBuilder; |
919 | + |
920 | + g_variant_builder_init (&pluginsWithChangedKeysBuilder, G_VARIANT_TYPE ("as")); |
921 | + return AutoDestroy (g_variant_ref_sink (g_variant_builder_end (&pluginsWithChangedKeysBuilder)), |
922 | + g_variant_unref); |
923 | + } |
924 | +} |
925 | + |
926 | +class CCSGSettingsTestCCSGSettingsBackend : |
927 | + public CCSGSettingsTestIndependent |
928 | +{ |
929 | + public: |
930 | + |
931 | + CCSGSettingsTestCCSGSettingsBackend () : |
932 | + mockContext (AutoDestroy (ccsMockContextNew (), ccsFreeMockContext)), |
933 | + stubBackend (AutoDestroy (ccsBackendNewWithDynamicInterface (mockContext.get (), &stubBackendInterface), |
934 | + ccsBackendUnref)), |
935 | + mockCompizconfigSettings (ccsMockGSettingsWrapperNew ()), |
936 | + mockCurrentProfileSettings (ccsMockGSettingsWrapperNew ()), |
937 | + mockWrapperFactory (ccsMockGSettingsWrapperFactoryNew ()), |
938 | + mockIntegration (ccsMockIntegrationBackendNew (&ccsDefaultObjectAllocator)), |
939 | + valueChangeData (reinterpret_cast <CCSGNOMEValueChangeData *> (calloc (1, sizeof (CCSGNOMEValueChangeData)))), |
940 | + currentProfile (strdup (MOCK_PROFILE_NAME.c_str ())), |
941 | + mockMockPluginWrapper (ccsMockGSettingsWrapperNew ()), |
942 | + gmockWrapperFactory (reinterpret_cast <CCSGSettingsWrapperFactoryGMock *> (ccsObjectGetPrivate (mockWrapperFactory))), |
943 | + gmockWrapper (reinterpret_cast <CCSGSettingsWrapperGMock *> (ccsObjectGetPrivate (mockMockPluginWrapper))), |
944 | + gmockCurrentProfileSettings (reinterpret_cast <CCSGSettingsWrapperGMock *> (ccsObjectGetPrivate (mockCurrentProfileSettings))) |
945 | + |
946 | + { |
947 | + valueChangeData->integration = mockIntegration; |
948 | + valueChangeData->factory = NULL; |
949 | + valueChangeData->storage = NULL; |
950 | + valueChangeData->context = mockContext.get (); |
951 | + |
952 | + if (!ccsGSettingsBackendAttachNewToBackend (stubBackend.get (), |
953 | + mockContext.get (), |
954 | + mockCompizconfigSettings, |
955 | + mockCurrentProfileSettings, |
956 | + mockWrapperFactory, |
957 | + mockIntegration, |
958 | + valueChangeData, |
959 | + currentProfile)) |
960 | + throw std::runtime_error ("Failed to attach GSettings backend"); |
961 | + } |
962 | + |
963 | + virtual void TearDown () |
964 | + { |
965 | + ccsGSettingsBackendDetachFromBackend (stubBackend.get ()); |
966 | + |
967 | + CCSGSettingsTestIndependent::TearDown (); |
968 | + } |
969 | + |
970 | + boost::shared_ptr <CCSContext> mockContext; |
971 | + boost::shared_ptr <CCSBackend> stubBackend; |
972 | + CCSGSettingsWrapper *mockCompizconfigSettings; |
973 | + CCSGSettingsWrapper *mockCurrentProfileSettings; |
974 | + CCSGSettingsWrapperFactory *mockWrapperFactory; |
975 | + CCSIntegration *mockIntegration; |
976 | + CCSGNOMEValueChangeData *valueChangeData; |
977 | + char *currentProfile; |
978 | + CCSGSettingsWrapper *mockMockPluginWrapper; |
979 | + |
980 | + CCSGSettingsWrapperFactoryGMock *gmockWrapperFactory; |
981 | + CCSGSettingsWrapperGMock *gmockWrapper; |
982 | + CCSGSettingsWrapperGMock *gmockCurrentProfileSettings; |
983 | + |
984 | +}; |
985 | + |
986 | +TEST_F (CCSGSettingsTestCCSGSettingsBackend, TestWriteOutSetKeysOnGetSettingsObject) |
987 | +{ |
988 | + /* Should create a new wrapper for this "plugin" */ |
989 | + EXPECT_CALL (*gmockWrapperFactory, newGSettingsWrapperWithPath (Eq (MOCK_SCHEMA_NAME), |
990 | + Eq (MOCK_GSCHEMA_PATH), |
991 | + _)).WillOnce (Return (mockMockPluginWrapper)); |
992 | + EXPECT_CALL (*gmockWrapper, connectToChangedSignal (_, stubBackend.get ())); |
993 | + |
994 | + |
995 | + boost::shared_ptr <GVariant> pluginsWithSetKeysVariantEmpty (GetEmptyPluginsWithSetKeys ()); |
996 | + |
997 | + /* Should now get the value of plugins-with-set-keys from |
998 | + * mockCurrentProfileSettings */ |
999 | + EXPECT_CALL (*gmockCurrentProfileSettings, getValue (Eq (PLUGINS_WITH_SET_KEYS))) |
1000 | + .WillOnce (Return (g_variant_ref (pluginsWithSetKeysVariantEmpty.get ()))); |
1001 | + |
1002 | + /* Should acknowledge that we wrote to this schema */ |
1003 | + EXPECT_CALL (*gmockCurrentProfileSettings, setValue (Eq (PLUGINS_WITH_SET_KEYS), |
1004 | + GVariantHasValueInArray <const gchar *> ("s", |
1005 | + MOCK_PLUGIN_NAME.c_str (), |
1006 | + boost::bind (streq, _1, _2)))) |
1007 | + .WillOnce (WithArgs <1> (Invoke (g_variant_unref)));; |
1008 | + |
1009 | + CCSGSettingsWrapper *wrapper = ccsGSettingsGetSettingsObjectForPluginWithPath (stubBackend.get (), |
1010 | + MOCK_PLUGIN_NAME.c_str (), |
1011 | + MOCK_GSCHEMA_PATH.c_str (), |
1012 | + mockContext.get ()); |
1013 | + |
1014 | + EXPECT_EQ (wrapper, mockMockPluginWrapper); |
1015 | +} |
1016 | + |
1017 | +TEST_F (CCSGSettingsTestCCSGSettingsBackend, TestNoWriteOutSetKeysOnGetSettingsObjectIfAlreadyWritten) |
1018 | +{ |
1019 | + /* Should create a new wrapper for this "plugin" */ |
1020 | + EXPECT_CALL (*gmockWrapperFactory, newGSettingsWrapperWithPath (Eq (MOCK_SCHEMA_NAME), |
1021 | + Eq (MOCK_GSCHEMA_PATH), |
1022 | + _)).WillOnce (Return (mockMockPluginWrapper)); |
1023 | + EXPECT_CALL (*gmockWrapper, connectToChangedSignal (_, stubBackend.get ())); |
1024 | + |
1025 | + |
1026 | + GVariantBuilder pluginsWithChangedKeysBuilder; |
1027 | + |
1028 | + g_variant_builder_init (&pluginsWithChangedKeysBuilder, G_VARIANT_TYPE ("as")); |
1029 | + g_variant_builder_add (&pluginsWithChangedKeysBuilder, "s", MOCK_PLUGIN_NAME.c_str ()); |
1030 | + boost::shared_ptr <GVariant> pluginsWithSetKeysVariantNonEmpty (AutoDestroy (g_variant_ref_sink (g_variant_builder_end (&pluginsWithChangedKeysBuilder)), |
1031 | + g_variant_unref)); |
1032 | + |
1033 | + /* Should now get the value of plugins-with-set-keys from |
1034 | + * mockCurrentProfileSettings */ |
1035 | + EXPECT_CALL (*gmockCurrentProfileSettings, getValue (Eq (PLUGINS_WITH_SET_KEYS))) |
1036 | + .WillOnce (Return (g_variant_ref (pluginsWithSetKeysVariantNonEmpty.get ()))); |
1037 | + |
1038 | + /* No acknowledgement */ |
1039 | + EXPECT_CALL (*gmockCurrentProfileSettings, setValue (_, _)).Times (0); |
1040 | + |
1041 | + CCSGSettingsWrapper *wrapper = ccsGSettingsGetSettingsObjectForPluginWithPath (stubBackend.get (), |
1042 | + MOCK_PLUGIN_NAME.c_str (), |
1043 | + MOCK_GSCHEMA_PATH.c_str (), |
1044 | + mockContext.get ()); |
1045 | + |
1046 | + EXPECT_EQ (wrapper, mockMockPluginWrapper); |
1047 | +} |
1048 | + |
1049 | +TEST_F (CCSGSettingsTestCCSGSettingsBackend, TestReturnExistingWrapper) |
1050 | +{ |
1051 | + /* Should create a new wrapper for this "plugin" */ |
1052 | + EXPECT_CALL (*gmockWrapperFactory, newGSettingsWrapperWithPath (Eq (MOCK_SCHEMA_NAME), |
1053 | + Eq (MOCK_GSCHEMA_PATH), |
1054 | + _)).WillOnce (Return (mockMockPluginWrapper)); |
1055 | + EXPECT_CALL (*gmockWrapper, connectToChangedSignal (_, stubBackend.get ())); |
1056 | + |
1057 | + |
1058 | + boost::shared_ptr <GVariant> pluginsWithSetKeysVariantEmpty (GetEmptyPluginsWithSetKeys ()); |
1059 | + |
1060 | + /* Should now get the value of plugins-with-set-keys from |
1061 | + * mockCurrentProfileSettings */ |
1062 | + EXPECT_CALL (*gmockCurrentProfileSettings, getValue (Eq (PLUGINS_WITH_SET_KEYS))) |
1063 | + .WillOnce (Return (g_variant_ref (pluginsWithSetKeysVariantEmpty.get ()))); |
1064 | + |
1065 | + /* Should acknowledge that we wrote to this schema */ |
1066 | + EXPECT_CALL (*gmockCurrentProfileSettings, setValue (Eq (PLUGINS_WITH_SET_KEYS), |
1067 | + _)) |
1068 | + .WillOnce (WithArgs <1> (Invoke (g_variant_unref))); |
1069 | + |
1070 | + CCSGSettingsWrapper *wrapper = ccsGSettingsGetSettingsObjectForPluginWithPath (stubBackend.get (), |
1071 | + MOCK_PLUGIN_NAME.c_str (), |
1072 | + MOCK_GSCHEMA_PATH.c_str (), |
1073 | + mockContext.get ()); |
1074 | + |
1075 | + EXPECT_CALL (*gmockWrapper, getSchemaName ()).WillOnce (Return (MOCK_SCHEMA_NAME.c_str ())); |
1076 | + |
1077 | + /* Shouldn't be called again */ |
1078 | + EXPECT_CALL (*gmockWrapperFactory, newGSettingsWrapperWithPath (_, _, _)).Times (0); |
1079 | + |
1080 | + wrapper = ccsGSettingsGetSettingsObjectForPluginWithPath (stubBackend.get (), |
1081 | + MOCK_PLUGIN_NAME.c_str (), |
1082 | + MOCK_GSCHEMA_PATH.c_str (), |
1083 | + mockContext.get ()); |
1084 | + |
1085 | + /* It should return the cached one */ |
1086 | + EXPECT_EQ (mockMockPluginWrapper, wrapper); |
1087 | +} |
1088 | |
1089 | === modified file 'compizconfig/integration/gnome/gsettings/CMakeLists.txt' |
1090 | --- compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-09-25 08:17:14 +0000 |
1091 | +++ compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-10-12 01:30:30 +0000 |
1092 | @@ -37,12 +37,21 @@ |
1093 | ${CMAKE_CURRENT_SOURCE_DIR}/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c) |
1094 | |
1095 | target_link_libraries (compizconfig_gnome_integration_gsettings_setting_factory |
1096 | + compizconfig_gsettings_wrapper_factory_interface |
1097 | compizconfig_gnome_integration_constants |
1098 | compizconfig_gnome_integrated_setting |
1099 | compizconfig_gnome_integration_gsettings_integrated_setting |
1100 | compizconfig |
1101 | compizconfig_gsettings_util |
1102 | - ${COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATIONLIBRARIES}) |
1103 | + ${COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_LIBRARIES}) |
1104 | + |
1105 | + add_library (compizconfig_gnome_integration_gsettings_wrapper_factory STATIC |
1106 | + ${CMAKE_CURRENT_SOURCE_DIR}/src/ccs_gnome_integration_gsettings_wrapper_factory.c) |
1107 | + |
1108 | + target_link_libraries (compizconfig_gnome_integration_gsettings_setting_factory |
1109 | + compizconfig_gsettings_wrapper_factory_interface |
1110 | + compizconfig |
1111 | + ${COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_LIBRARIES}) |
1112 | |
1113 | find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas) |
1114 | |
1115 | |
1116 | === removed file 'compizconfig/integration/gnome/gsettings/include/ccs_gnome_gsettings_fwd.h' |
1117 | --- compizconfig/integration/gnome/gsettings/include/ccs_gnome_gsettings_fwd.h 2012-10-06 16:11:05 +0000 |
1118 | +++ compizconfig/integration/gnome/gsettings/include/ccs_gnome_gsettings_fwd.h 1970-01-01 00:00:00 +0000 |
1119 | @@ -1,12 +0,0 @@ |
1120 | -#ifndef _CCS_GNOME_INTEGRATION_GSETTINGS_FWD_H |
1121 | -#define _CCS_GNOME_INTEGRATION_GSETTINGS_FWD_H |
1122 | - |
1123 | -#include <ccs-defs.h> |
1124 | - |
1125 | -COMPIZCONFIG_BEGIN_DECLS |
1126 | - |
1127 | -typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactory CCSGNOMEIntegrationGSettingsWrapperFactory; |
1128 | - |
1129 | -COMPIZCONFIG_END_DECLS |
1130 | - |
1131 | -#endif |
1132 | |
1133 | === modified file 'compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h' |
1134 | --- compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h 2012-10-06 16:11:05 +0000 |
1135 | +++ compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h 2012-10-12 01:30:30 +0000 |
1136 | @@ -1,41 +1,14 @@ |
1137 | -#ifndef _CCS_GNOME_GCONF_INTEGRATED_SETTING_FACTORY_H |
1138 | -#define _CCS_GNOME_GCONF_INTEGRATED_SETTING_FACTORY_H |
1139 | +#ifndef _CCS_GNOME_GSETTINGS_INTEGRATED_SETTING_FACTORY_H |
1140 | +#define _CCS_GNOME_GSETTINGS_INTEGRATED_SETTING_FACTORY_H |
1141 | |
1142 | #include <ccs-defs.h> |
1143 | #include <ccs-fwd.h> |
1144 | #include <ccs_gnome_fwd.h> |
1145 | -#include <ccs_gnome_gsettings_fwd.h> |
1146 | +#include <ccs_gsettings_backend_fwd.h> |
1147 | #include <gio/gio.h> |
1148 | |
1149 | COMPIZCONFIG_BEGIN_DECLS |
1150 | |
1151 | -typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactoryInterface CCSGNOMEIntegrationGSettingsWrapperFactoryInterface; |
1152 | - |
1153 | -typedef void (*CCSGNOMEIntegrationGSettingsChangedCallback) (GSettings *, gchar *, gpointer); |
1154 | - |
1155 | -typedef CCSGSettingsWrapper * (*CCSGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper) (CCSGNOMEIntegrationGSettingsWrapperFactory *, |
1156 | - const gchar *schema, |
1157 | - CCSGNOMEIntegrationGSettingsChangedCallback callback, |
1158 | - CCSGNOMEValueChangeData *data, |
1159 | - CCSObjectAllocationInterface *ai); |
1160 | - |
1161 | -struct _CCSGNOMEIntegrationGSettingsWrapperFactoryInterface |
1162 | -{ |
1163 | - CCSGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper newGSettingsWrapper; |
1164 | -}; |
1165 | - |
1166 | -/** |
1167 | - * @brief The _CCSGNOMEIntegrationGSettingsWrapperFactory struct |
1168 | - * |
1169 | - * Will create new CCSGSettingsIntegratedSetting objects on demand |
1170 | - */ |
1171 | -struct _CCSGNOMEIntegrationGSettingsWrapperFactory |
1172 | -{ |
1173 | - CCSObject object; |
1174 | -}; |
1175 | - |
1176 | -unsigned int ccsCCSGNOMEIntegrationGSettingsWrapperFactoryInterfaceGetType (); |
1177 | - |
1178 | /** |
1179 | * @brief ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS |
1180 | * @param key the old style gnome key to translate |
1181 | @@ -47,22 +20,25 @@ |
1182 | char * |
1183 | ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key); |
1184 | |
1185 | -CCSGSettingsWrapper * |
1186 | -ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory, |
1187 | - const gchar *schemaName, |
1188 | - CCSGNOMEIntegrationGSettingsChangedCallback callback, |
1189 | - CCSGNOMEValueChangeData *data, |
1190 | - CCSObjectAllocationInterface *ai); |
1191 | - |
1192 | -CCSGNOMEIntegrationGSettingsWrapperFactory * |
1193 | -ccsGNOMEIntegrationGSettingsWrapperDefaultImplNew (CCSObjectAllocationInterface *ai); |
1194 | - |
1195 | -void |
1196 | -ccsGNOMEIntegrationGSettingsWrapperDefaultImplFree (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory); |
1197 | +/** |
1198 | + * @brief ccsGSettingsIntegratedSettingsChangeCallback |
1199 | + * @return callback for settings change data |
1200 | + * |
1201 | + * This returns the default callback used for settings changes |
1202 | + * |
1203 | + * TODO: This API doesn't make a whole lot of sense, but we need |
1204 | + * it if we want to inject CCSGSettingsWrapperFactory into |
1205 | + * ccsGSettingsIntegratedSettingFactoryNew. |
1206 | + * |
1207 | + * The return type is GCallback to hide the details of this function |
1208 | + * from callers |
1209 | + */ |
1210 | +GCallback |
1211 | +ccsGSettingsIntegratedSettingsChangeCallback (); |
1212 | |
1213 | CCSIntegratedSettingFactory * |
1214 | -ccsGSettingsIntegratedSettingFactoryNew (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory, |
1215 | - CCSGNOMEValueChangeData *data, |
1216 | +ccsGSettingsIntegratedSettingFactoryNew (CCSGSettingsWrapperFactory *wrapperFactory, |
1217 | + CCSGNOMEValueChangeData *data, |
1218 | CCSObjectAllocationInterface *ai); |
1219 | |
1220 | COMPIZCONFIG_END_DECLS |
1221 | |
1222 | === added file 'compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_wrapper_factory.h' |
1223 | --- compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_wrapper_factory.h 1970-01-01 00:00:00 +0000 |
1224 | +++ compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_wrapper_factory.h 2012-10-12 01:30:30 +0000 |
1225 | @@ -0,0 +1,44 @@ |
1226 | +/** |
1227 | + * |
1228 | + * GSettings libcompizconfig backend |
1229 | + * |
1230 | + * ccs_gsettings_wrapper_factory.h |
1231 | + * |
1232 | + * Copyright (c) 2012 Canonical Ltd |
1233 | + * |
1234 | + * This program is free software; you can redistribute it and/or |
1235 | + * modify it under the terms of the GNU General Public License |
1236 | + * as published by the Free Software Foundation; either version 2 |
1237 | + * of the License, or (at your option) any later version. |
1238 | + * |
1239 | + * This program is distributed in the hope that it will be useful, |
1240 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1241 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1242 | + * GNU General Public License for more details. |
1243 | + * |
1244 | + * Authored By: |
1245 | + * Sam Spilsbury <sam.spilsbury@canonical.com> |
1246 | + * |
1247 | + **/ |
1248 | +#ifndef _CCS_GNOME_INTEGRATION_GSETTINGS_WRAPPER_FACTORY_H |
1249 | +#define _CCS_GNOME_INTEGRATION_GSETTINGS_WRAPPER_FACTORY_H |
1250 | + |
1251 | +#include <ccs-defs.h> |
1252 | + |
1253 | +COMPIZCONFIG_BEGIN_DECLS |
1254 | + |
1255 | +#include <gio/gio.h> |
1256 | + |
1257 | +#include <ccs-fwd.h> |
1258 | +#include <ccs_gsettings_backend_fwd.h> |
1259 | +#include <ccs_gnome_fwd.h> |
1260 | + |
1261 | +CCSGSettingsWrapperFactory * |
1262 | +ccsGNOMEIntegrationGSettingsWrapperFactoryDefaultImplNew (CCSObjectAllocationInterface *ai, |
1263 | + CCSGSettingsWrapperFactory *factory, |
1264 | + GCallback callback, |
1265 | + CCSGNOMEValueChangeData *data); |
1266 | + |
1267 | +COMPIZCONFIG_END_DECLS |
1268 | + |
1269 | +#endif |
1270 | |
1271 | === modified file 'compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c' |
1272 | --- compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c 2012-09-25 06:12:24 +0000 |
1273 | +++ compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c 2012-10-12 01:30:30 +0000 |
1274 | @@ -11,6 +11,7 @@ |
1275 | #include <ccs_gsettings_interface_wrapper.h> |
1276 | |
1277 | #include <gsettings_util.h> |
1278 | +#include <ccs_gsettings_wrapper_factory_interface.h> |
1279 | |
1280 | #include "ccs_gnome_integration.h" |
1281 | #include "ccs_gnome_integrated_setting.h" |
1282 | @@ -19,8 +20,6 @@ |
1283 | #include "ccs_gnome_integration_gsettings_integrated_setting.h" |
1284 | #include "ccs_gnome_integration_gsettings_integrated_setting_factory.h" |
1285 | |
1286 | -INTERFACE_TYPE (CCSGNOMEIntegrationGSettingsWrapperFactoryInterface); |
1287 | - |
1288 | char * |
1289 | ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key) |
1290 | { |
1291 | @@ -45,83 +44,11 @@ |
1292 | return newKey; |
1293 | } |
1294 | |
1295 | -CCSGSettingsWrapper * |
1296 | -ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory, |
1297 | - const gchar *schemaName, |
1298 | - CCSGNOMEIntegrationGSettingsChangedCallback callback, |
1299 | - CCSGNOMEValueChangeData *data, |
1300 | - CCSObjectAllocationInterface *ai) |
1301 | -{ |
1302 | - return (*(GET_INTERFACE (CCSGNOMEIntegrationGSettingsWrapperFactoryInterface, factory))->newGSettingsWrapper) (factory, schemaName, callback, data, ai); |
1303 | -} |
1304 | - |
1305 | -/* CCSGNOMEIntegrationGSettingsWrapperFactory implementation */ |
1306 | -typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate; |
1307 | -struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate |
1308 | -{ |
1309 | -}; |
1310 | - |
1311 | -CCSGSettingsWrapper * |
1312 | -ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapperDefault (CCSGNOMEIntegrationGSettingsWrapperFactory *factory, |
1313 | - const gchar *schemaName, |
1314 | - CCSGNOMEIntegrationGSettingsChangedCallback callback, |
1315 | - CCSGNOMEValueChangeData *data, |
1316 | - CCSObjectAllocationInterface *ai) |
1317 | -{ |
1318 | - CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperNewForSchema (schemaName, ai); |
1319 | - ccsGSettingsWrapperConnectToChangedSignal (wrapper, (GCallback) callback, data); |
1320 | - |
1321 | - return wrapper; |
1322 | -} |
1323 | - |
1324 | -const CCSGNOMEIntegrationGSettingsWrapperFactoryInterface ccsGNOMEIntegrationGSettingsWrapperFactoryInterface = |
1325 | -{ |
1326 | - ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapperDefault |
1327 | -}; |
1328 | - |
1329 | -void |
1330 | -ccsGNOMEIntegrationGSettingsWrapperDefaultImplFree (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory) |
1331 | -{ |
1332 | - ccsObjectFinalize (wrapperFactory); |
1333 | - (*wrapperFactory->object.object_allocation->free_) (wrapperFactory->object.object_allocation->allocator, |
1334 | - wrapperFactory); |
1335 | -} |
1336 | - |
1337 | -CCSGNOMEIntegrationGSettingsWrapperFactory * |
1338 | -ccsGNOMEIntegrationGSettingsWrapperDefaultImplNew (CCSObjectAllocationInterface *ai) |
1339 | -{ |
1340 | - CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGNOMEIntegrationGSettingsWrapperFactory)); |
1341 | - |
1342 | - if (!wrapperFactory) |
1343 | - return NULL; |
1344 | - |
1345 | - CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate)); |
1346 | - |
1347 | - if (!priv) |
1348 | - { |
1349 | - (*ai->free_) (ai->allocator, wrapperFactory); |
1350 | - return NULL; |
1351 | - } |
1352 | - |
1353 | - ccsObjectInit (wrapperFactory, ai); |
1354 | - ccsObjectAddInterface (wrapperFactory, (const CCSInterface *) &ccsGNOMEIntegrationGSettingsWrapperFactoryInterface, GET_INTERFACE_TYPE (CCSGNOMEIntegrationGSettingsWrapperFactoryInterface)); |
1355 | - ccsObjectSetPrivate (wrapperFactory, (CCSPrivate *) priv); |
1356 | - |
1357 | - return wrapperFactory; |
1358 | -} |
1359 | - |
1360 | -void |
1361 | -ccsGNOMEIntegrationGSettingsWrapperDefaultImpl (CCSGNOMEIntegrationGSettingsWrapperFactory *factory) |
1362 | -{ |
1363 | - ccsObjectFinalize (factory); |
1364 | - (*factory->object.object_allocation->free_) (factory->object.object_allocation->allocator, factory); |
1365 | -} |
1366 | - |
1367 | typedef struct _CCSGSettingsIntegratedSettingFactoryPrivate CCSGSettingsIntegratedSettingFactoryPrivate; |
1368 | |
1369 | struct _CCSGSettingsIntegratedSettingFactoryPrivate |
1370 | { |
1371 | - CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory; |
1372 | + CCSGSettingsWrapperFactory *wrapperFactory; |
1373 | GHashTable *pluginsToSettingsGSettingsWrapperQuarksHashTable; |
1374 | GHashTable *quarksToGSettingsWrappersHashTable; |
1375 | GHashTable *pluginsToSettingsSpecialTypesHashTable; |
1376 | @@ -153,6 +80,12 @@ |
1377 | |
1378 | } |
1379 | |
1380 | +GCallback |
1381 | +ccsGSettingsIntegratedSettingsChangeCallback () |
1382 | +{ |
1383 | + return (GCallback) gnomeGSettingsValueChanged; |
1384 | +} |
1385 | + |
1386 | static CCSIntegratedSetting * |
1387 | createNewGSettingsIntegratedSetting (CCSGSettingsWrapper *wrapper, |
1388 | const char *gnomeName, |
1389 | @@ -193,52 +126,41 @@ |
1390 | } |
1391 | |
1392 | static GHashTable * |
1393 | -initializeGSettingsWrappers (CCSGNOMEIntegrationGSettingsWrapperFactory *factory, |
1394 | - CCSGNOMEValueChangeData *data) |
1395 | +initializeGSettingsWrappers (CCSGSettingsWrapperFactory *factory) |
1396 | { |
1397 | const CCSGSettingsWrapperIntegratedSchemasQuarks *quarks = ccsGNOMEGSettingsWrapperQuarks (); |
1398 | GHashTable *quarksToGSettingsWrappers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, ccsGSettingsWrapperUnrefWrapper); |
1399 | |
1400 | g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED), |
1401 | - ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1402 | - g_quark_to_string (quarks->ORG_COMPIZ_INTEGRATED), |
1403 | - gnomeGSettingsValueChanged, |
1404 | - data, |
1405 | - factory->object.object_allocation)); |
1406 | + ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1407 | + g_quark_to_string (quarks->ORG_COMPIZ_INTEGRATED), |
1408 | + factory->object.object_allocation)); |
1409 | g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS), |
1410 | - ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1411 | - g_quark_to_string (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS), |
1412 | - gnomeGSettingsValueChanged, |
1413 | - data, |
1414 | - factory->object.object_allocation)); |
1415 | + ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1416 | + g_quark_to_string (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS), |
1417 | + factory->object.object_allocation)); |
1418 | g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES), |
1419 | - ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1420 | - g_quark_to_string (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES), |
1421 | - gnomeGSettingsValueChanged, |
1422 | - data, |
1423 | - factory->object.object_allocation)); |
1424 | + ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1425 | + g_quark_to_string (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES), |
1426 | + factory->object.object_allocation)); |
1427 | g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL), |
1428 | - ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1429 | - g_quark_to_string (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL), |
1430 | - gnomeGSettingsValueChanged, |
1431 | - data, |
1432 | - factory->object.object_allocation)); |
1433 | + ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1434 | + g_quark_to_string (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL), |
1435 | + factory->object.object_allocation)); |
1436 | g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS), |
1437 | - ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1438 | - g_quark_to_string (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS), |
1439 | - gnomeGSettingsValueChanged, |
1440 | - data, |
1441 | - factory->object.object_allocation)); |
1442 | + ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory, |
1443 | + g_quark_to_string (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS), |
1444 | + factory->object.object_allocation)); |
1445 | |
1446 | return quarksToGSettingsWrappers; |
1447 | } |
1448 | |
1449 | CCSIntegratedSetting * |
1450 | ccsGSettingsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType (CCSIntegratedSettingFactory *factory, |
1451 | - CCSIntegration *integration, |
1452 | - const char *pluginName, |
1453 | - const char *settingName, |
1454 | - CCSSettingType type) |
1455 | + CCSIntegration *integration, |
1456 | + const char *pluginName, |
1457 | + const char *settingName, |
1458 | + CCSSettingType type) |
1459 | { |
1460 | CCSGSettingsIntegratedSettingFactoryPrivate *priv = (CCSGSettingsIntegratedSettingFactoryPrivate *) ccsObjectGetPrivate (factory); |
1461 | GHashTable *settingsGSettingsWrapperQuarksHashTable = g_hash_table_lookup (priv->pluginsToSettingsGSettingsWrapperQuarksHashTable, pluginName); |
1462 | @@ -246,7 +168,7 @@ |
1463 | GHashTable *settingsSettingNameGNOMENameHashTable = g_hash_table_lookup (priv->pluginsToSettingNameGNOMENameHashTable, pluginName); |
1464 | |
1465 | if (!priv->quarksToGSettingsWrappersHashTable) |
1466 | - priv->quarksToGSettingsWrappersHashTable = initializeGSettingsWrappers (priv->wrapperFactory, priv->valueChangeData); |
1467 | + priv->quarksToGSettingsWrappersHashTable = initializeGSettingsWrappers (priv->wrapperFactory); |
1468 | |
1469 | if (settingsGSettingsWrapperQuarksHashTable && |
1470 | settingsSpecialTypesHashTable && |
1471 | @@ -258,12 +180,12 @@ |
1472 | const gchar *integratedName = g_hash_table_lookup (settingsSettingNameGNOMENameHashTable, settingName); |
1473 | |
1474 | return createNewGSettingsIntegratedSetting (wrapper, |
1475 | - integratedName, |
1476 | - pluginName, |
1477 | - settingName, |
1478 | - type, |
1479 | - specialType, |
1480 | - factory->object.object_allocation); |
1481 | + integratedName, |
1482 | + pluginName, |
1483 | + settingName, |
1484 | + type, |
1485 | + specialType, |
1486 | + factory->object.object_allocation); |
1487 | } |
1488 | |
1489 | |
1490 | @@ -287,13 +209,12 @@ |
1491 | if (priv->pluginsToSettingNameGNOMENameHashTable) |
1492 | g_hash_table_unref (priv->pluginsToSettingNameGNOMENameHashTable); |
1493 | |
1494 | - ccsGNOMEIntegrationGSettingsWrapperDefaultImplFree (priv->wrapperFactory); |
1495 | + ccsGSettingsWrapperFactoryUnref (priv->wrapperFactory); |
1496 | |
1497 | ccsObjectFinalize (factory); |
1498 | (*factory->object.object_allocation->free_) (factory->object.object_allocation->allocator, factory); |
1499 | } |
1500 | |
1501 | - |
1502 | const CCSIntegratedSettingFactoryInterface ccsGSettingsIntegratedSettingFactoryInterface = |
1503 | { |
1504 | ccsGSettingsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType, |
1505 | @@ -301,9 +222,9 @@ |
1506 | }; |
1507 | |
1508 | CCSIntegratedSettingFactory * |
1509 | -ccsGSettingsIntegratedSettingFactoryNew (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory, |
1510 | - CCSGNOMEValueChangeData *valueChangeData, |
1511 | - CCSObjectAllocationInterface *ai) |
1512 | +ccsGSettingsIntegratedSettingFactoryNew (CCSGSettingsWrapperFactory *wrapperFactory, |
1513 | + CCSGNOMEValueChangeData *valueChangeData, |
1514 | + CCSObjectAllocationInterface *ai) |
1515 | { |
1516 | CCSIntegratedSettingFactory *factory = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSettingFactory)); |
1517 | |
1518 | @@ -318,6 +239,8 @@ |
1519 | return NULL; |
1520 | } |
1521 | |
1522 | + ccsGSettingsWrapperFactoryRef (wrapperFactory); |
1523 | + |
1524 | priv->wrapperFactory = wrapperFactory; |
1525 | priv->pluginsToSettingsGSettingsWrapperQuarksHashTable = ccsGNOMEGSettingsIntegrationPopulateSettingNameToIntegratedSchemasQuarksHashTable (); |
1526 | priv->pluginsToSettingsSpecialTypesHashTable = ccsGNOMEIntegrationPopulateSpecialTypesHashTables (); |
1527 | |
1528 | === added file 'compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_wrapper_factory.c' |
1529 | --- compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_wrapper_factory.c 1970-01-01 00:00:00 +0000 |
1530 | +++ compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_wrapper_factory.c 2012-10-12 01:30:30 +0000 |
1531 | @@ -0,0 +1,135 @@ |
1532 | +/** |
1533 | + * |
1534 | + * GSettings libcompizconfig backend |
1535 | + * |
1536 | + * ccs_gnome_integration_gsettings_wrapper_factory.c |
1537 | + * |
1538 | + * Copyright (c) 2012 Canonical Ltd |
1539 | + * |
1540 | + * This program is free software; you can redistribute it and/or |
1541 | + * modify it under the terms of the GNU General Public License |
1542 | + * as published by the Free Software Foundation; either version 2 |
1543 | + * of the License, or (at your option) any later version. |
1544 | + * |
1545 | + * This program is distributed in the hope that it will be useful, |
1546 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1547 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1548 | + * GNU General Public License for more details. |
1549 | + * |
1550 | + * Authored By: |
1551 | + * Sam Spilsbury <sam.spilsbury@canonical.com> |
1552 | + * |
1553 | + **/ |
1554 | +#include <ccs-object.h> |
1555 | +#include "ccs_gsettings_wrapper_factory.h" |
1556 | +#include "ccs_gsettings_wrapper_factory_interface.h" |
1557 | +#include "ccs_gsettings_interface.h" |
1558 | +#include "ccs_gsettings_interface_wrapper.h" |
1559 | +#include "ccs_gnome_integration_gsettings_wrapper_factory.h" |
1560 | + |
1561 | +/* CCSGSettingsWrapperFactory implementation */ |
1562 | +typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate; |
1563 | +struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate |
1564 | +{ |
1565 | + CCSGSettingsWrapperFactory *wrapperFactory; |
1566 | + GCallback callback; |
1567 | + |
1568 | + /* This is expected to stay alive during the |
1569 | + * lifetime of this object */ |
1570 | + CCSGNOMEValueChangeData *data; |
1571 | +}; |
1572 | + |
1573 | +static void |
1574 | +ccsGNOMEIntegrationGSettingsWrapperFree (CCSGSettingsWrapperFactory *wrapperFactory) |
1575 | +{ |
1576 | + CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv = |
1577 | + GET_PRIVATE (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate, wrapperFactory); |
1578 | + |
1579 | + ccsGSettingsWrapperFactoryUnref (priv->wrapperFactory); |
1580 | + |
1581 | + ccsObjectFinalize (wrapperFactory); |
1582 | + (*wrapperFactory->object.object_allocation->free_) (wrapperFactory->object.object_allocation->allocator, |
1583 | + wrapperFactory); |
1584 | +} |
1585 | + |
1586 | +static void |
1587 | +connectWrapperToChangedSignal (CCSGSettingsWrapper *wrapper, |
1588 | + CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv) |
1589 | +{ |
1590 | + ccsGSettingsWrapperConnectToChangedSignal (wrapper, priv->callback, priv->data); |
1591 | +} |
1592 | + |
1593 | +static CCSGSettingsWrapper * |
1594 | +ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGSettingsWrapperFactory *factory, |
1595 | + const gchar *schemaName, |
1596 | + CCSObjectAllocationInterface *ai) |
1597 | +{ |
1598 | + CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv = |
1599 | + GET_PRIVATE (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate, factory); |
1600 | + CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperFactoryNewGSettingsWrapper (priv->wrapperFactory, |
1601 | + schemaName, |
1602 | + factory->object.object_allocation); |
1603 | + |
1604 | + connectWrapperToChangedSignal (wrapper, priv); |
1605 | + |
1606 | + return wrapper; |
1607 | +} |
1608 | + |
1609 | +static CCSGSettingsWrapper * |
1610 | +ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapperWithPath (CCSGSettingsWrapperFactory *factory, |
1611 | + const gchar *schemaName, |
1612 | + const gchar *path, |
1613 | + CCSObjectAllocationInterface *ai) |
1614 | +{ |
1615 | + CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv = |
1616 | + GET_PRIVATE (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate, factory); |
1617 | + CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (priv->wrapperFactory, |
1618 | + schemaName, |
1619 | + path, |
1620 | + factory->object.object_allocation); |
1621 | + |
1622 | + connectWrapperToChangedSignal (wrapper, priv); |
1623 | + |
1624 | + return wrapper; |
1625 | +} |
1626 | + |
1627 | +const CCSGSettingsWrapperFactoryInterface ccsGNOMEIntegrationGSettingsWrapperFactoryInterface = |
1628 | +{ |
1629 | + ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper, |
1630 | + ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapperWithPath, |
1631 | + ccsGNOMEIntegrationGSettingsWrapperFree |
1632 | +}; |
1633 | + |
1634 | +CCSGSettingsWrapperFactory * |
1635 | +ccsGNOMEIntegrationGSettingsWrapperFactoryDefaultImplNew (CCSObjectAllocationInterface *ai, |
1636 | + CCSGSettingsWrapperFactory *factory, |
1637 | + GCallback callback, |
1638 | + CCSGNOMEValueChangeData *data) |
1639 | +{ |
1640 | + CCSGSettingsWrapperFactory *wrapperFactory = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGSettingsWrapperFactory)); |
1641 | + |
1642 | + if (!wrapperFactory) |
1643 | + return NULL; |
1644 | + |
1645 | + CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate)); |
1646 | + |
1647 | + if (!priv) |
1648 | + { |
1649 | + (*ai->free_) (ai->allocator, wrapperFactory); |
1650 | + return NULL; |
1651 | + } |
1652 | + |
1653 | + ccsGSettingsWrapperFactoryRef (factory); |
1654 | + |
1655 | + priv->wrapperFactory = factory; |
1656 | + priv->callback = callback; |
1657 | + priv->data = data; |
1658 | + |
1659 | + ccsObjectInit (wrapperFactory, ai); |
1660 | + ccsObjectAddInterface (wrapperFactory, (const CCSInterface *) &ccsGNOMEIntegrationGSettingsWrapperFactoryInterface, GET_INTERFACE_TYPE (CCSGSettingsWrapperFactoryInterface)); |
1661 | + ccsObjectSetPrivate (wrapperFactory, (CCSPrivate *) priv); |
1662 | + |
1663 | + ccsGSettingsWrapperFactoryRef (wrapperFactory); |
1664 | + |
1665 | + return wrapperFactory; |
1666 | +} |
FAILED: Continuous integration, rev:3421 jenkins. qa.ubuntu. com/job/ compiz- ci/167/ jenkins. qa.ubuntu. com/job/ compiz- ci/./build= pbuilder, distribution= quantal, flavor= amd64/167/ console
http://
Executed test runs:
FAILURE: http://