Merge lp:~compiz-team/compiz/compiz.fix_1064791 into lp:compiz/0.9.9

Proposed by Sam Spilsbury
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
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.

Commit message

Don't write plugins-with-set-keys every single time we read a schema, if
the value is already in plugins-with-set-keys. Added tests to demonstrate
behaviour.
(LP: #1064791)

vanvugt says: This also seems to fix LP: #1044662, somehow.

Description of the change

Don't write plugins-with-set-keys every single time we read a schema, if the value is already in plugins-with-set-keys. Added tests to demonstrate behaviour.

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

As above.

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I am concerned about very long identifiers...
  typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate;
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-with-set-keys" suggests a very simple problem that should have a very simple solution. So why "1663 lines (+1030/-243) 21 files modified" ?

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

> I am concerned about very long identifiers...
> typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate
> CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate;
> 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 GNOMEGSettingsWrapperFactoryPrivate or just WrapperFactoryPrivate since its exclusive to this file.

>
> 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-with-set-keys" suggests a
> 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

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
Daniel van Vugt (vanvugt) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'compizconfig/gsettings/CMakeLists.txt'
--- compizconfig/gsettings/CMakeLists.txt 2012-09-27 09:28:59 +0000
+++ compizconfig/gsettings/CMakeLists.txt 2012-10-12 01:30:30 +0000
@@ -21,9 +21,19 @@
21add_subdirectory (gsettings_backend_shared)21add_subdirectory (gsettings_backend_shared)
2222
23include_directories (${CMAKE_CURRENT_SOURCE_DIR}/gsettings_backend_shared23include_directories (${CMAKE_CURRENT_SOURCE_DIR}/gsettings_backend_shared
24 ${CMAKE_SOURCE_DIR}/compizconfig/integration/gnome/gsettings/include)24 ${CMAKE_SOURCE_DIR}/compizconfig/integration/gnome/gsettings/include
2525 ${CMAKE_SOURCE_DIR}/compizconfig/integration/gnome/include)
26compizconfig_backend (gsettings PKGDEPS ${_deps} LIBRARIES compizconfig_gsettings_backend)26
27set (COMPIZCONFIG_GSETTINGS_BACKEND_LIBRARIES
28 compizconfig_gsettings_wrapper
29 compizconfig_gnome_integration
30 compizconfig_gnome_integration_gsettings_setting_factory
31 compizconfig_gnome_integration_gsettings_wrapper_factory
32 compizconfig_gsettings_wrapper_factory_interface
33 compizconfig_gsettings_wrapper_factory
34 compizconfig_gsettings_backend)
35
36compizconfig_backend (gsettings PKGDEPS ${_deps} LIBRARIES ${COMPIZCONFIG_GSETTINGS_BACKEND_LIBRARIES})
2737
28find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas)38find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas)
2939
3040
=== modified file 'compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt'
--- compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-10-06 16:11:05 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/CMakeLists.txt 2012-10-12 01:30:30 +0000
@@ -24,6 +24,12 @@
24 add_library (compizconfig_gsettings_backend_interface STATIC24 add_library (compizconfig_gsettings_backend_interface STATIC
25 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_interface.c)25 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_interface.c)
2626
27 add_library (compizconfig_gsettings_wrapper_factory_interface STATIC
28 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_factory_interface.c)
29
30 add_library (compizconfig_gsettings_wrapper_factory STATIC
31 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_factory.c)
32
27 add_library (compizconfig_gsettings_wrapper_interface STATIC33 add_library (compizconfig_gsettings_wrapper_interface STATIC
28 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_interface.c)34 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_interface.c)
2935
@@ -53,6 +59,8 @@
53 compizconfig_gsettings_wrapper59 compizconfig_gsettings_wrapper
54 compizconfig_gnome_integration60 compizconfig_gnome_integration
55 compizconfig_gnome_integration_gsettings_setting_factory61 compizconfig_gnome_integration_gsettings_setting_factory
62 compizconfig_gsettings_wrapper_factory_interface
63 compizconfig_gsettings_wrapper_factory
56 compizconfig)64 compizconfig)
5765
58 if (USE_GCONF)66 if (USE_GCONF)
5967
=== modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c'
--- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-09-23 04:35:00 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.c 2012-10-12 01:30:30 +0000
@@ -8,22 +8,24 @@
8#include "ccs_gsettings_backend_interface.h"8#include "ccs_gsettings_backend_interface.h"
9#include "ccs_gsettings_interface.h"9#include "ccs_gsettings_interface.h"
10#include "ccs_gsettings_interface_wrapper.h"10#include "ccs_gsettings_interface_wrapper.h"
11#include "ccs_gsettings_wrapper_factory_interface.h"
11#include "ccs_gnome_integration.h"12#include "ccs_gnome_integration.h"
12#include "ccs_gnome_integration_gsettings_integrated_setting_factory.h"13#include "ccs_gnome_integration_gsettings_integrated_setting_factory.h"
13#include "gsettings_shared.h"14#include "gsettings_shared.h"
1415
15struct _CCSGSettingsBackendPrivate16struct _CCSGSettingsBackendPrivate
16{17{
17 GList *settingsList;18 GList *settingsList;
18 CCSGSettingsWrapper *compizconfigSettings;19 CCSGSettingsWrapper *compizconfigSettings;
19 CCSGSettingsWrapper *currentProfileSettings;20 CCSGSettingsWrapper *currentProfileSettings;
21 CCSGSettingsWrapperFactory *wrapperFactory;
2022
21 char *currentProfile;23 char *currentProfile;
22 CCSContext *context;24 CCSContext *context;
2325
24 CCSIntegration *integration;26 CCSIntegration *integration;
2527
26 CCSGNOMEValueChangeData valueChangeData;28 CCSGNOMEValueChangeData *valueChangeData;
27};29};
2830
29void31void
@@ -112,7 +114,7 @@
112114
113 /* No existing settings object found for this schema, create one */115 /* No existing settings object found for this schema, create one */
114 116
115 settingsObj = ccsGSettingsWrapperNewForSchemaWithPath (schemaName, path, &ccsDefaultObjectAllocator);117 settingsObj = ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (priv->wrapperFactory, schemaName, path, &ccsDefaultObjectAllocator);
116 ccsGSettingsBackendConnectToChangedSignal (backend, settingsObj);118 ccsGSettingsBackendConnectToChangedSignal (backend, settingsObj);
117 priv->settingsList = g_list_append (priv->settingsList, (void *) settingsObj);119 priv->settingsList = g_list_append (priv->settingsList, (void *) settingsObj);
118120
@@ -124,11 +126,12 @@
124126
125 writtenPlugins = ccsGSettingsWrapperGetValue (priv->currentProfileSettings, "plugins-with-set-keys");127 writtenPlugins = ccsGSettingsWrapperGetValue (priv->currentProfileSettings, "plugins-with-set-keys");
126128
127 appendToPluginsWithSetKeysList (plugin, writtenPlugins, &newWrittenPlugins, &newWrittenPluginsSize);129 if (appendToPluginsWithSetKeysList (plugin, writtenPlugins, &newWrittenPlugins, &newWrittenPluginsSize))
128130 {
129 GVariant *newWrittenPluginsVariant = g_variant_new_strv ((const gchar * const *) newWrittenPlugins, newWrittenPluginsSize);131 GVariant *newWrittenPluginsVariant = g_variant_new_strv ((const gchar * const *) newWrittenPlugins, newWrittenPluginsSize);
130132
131 ccsGSettingsWrapperSetValue (priv->currentProfileSettings, "plugins-with-set-keys", newWrittenPluginsVariant);133 ccsGSettingsWrapperSetValue (priv->currentProfileSettings, "plugins-with-set-keys", newWrittenPluginsVariant);
134 }
132135
133 g_variant_unref (writtenPlugins);136 g_variant_unref (writtenPlugins);
134 g_free (schemaName);137 g_free (schemaName);
@@ -367,26 +370,6 @@
367 return priv;370 return priv;
368}371}
369372
370static char*
371getCurrentProfileName (CCSBackend *backend)
372{
373 GVariant *value;
374 char *ret = NULL;
375
376 CCSGSettingsBackendPrivate *priv = (CCSGSettingsBackendPrivate *) ccsObjectGetPrivate (backend);
377
378 value = ccsGSettingsWrapperGetValue (priv->compizconfigSettings, "current-profile");
379
380 if (value)
381 ret = strdup (g_variant_get_string (value, NULL));
382 else
383 ret = strdup (DEFAULTPROF);
384
385 g_variant_unref (value);
386
387 return ret;
388}
389
390static void373static void
391ccsGSettingsWrapperDestroyNotify (gpointer o)374ccsGSettingsWrapperDestroyNotify (gpointer o)
392{375{
@@ -418,6 +401,9 @@
418 priv->compizconfigSettings = NULL;401 priv->compizconfigSettings = NULL;
419402
420 ccsIntegrationUnref (priv->integration);403 ccsIntegrationUnref (priv->integration);
404 ccsGSettingsWrapperFactoryUnref (priv->wrapperFactory);
405
406 free (priv->valueChangeData);
421407
422 free (priv);408 free (priv);
423 ccsObjectSetPrivate (backend, NULL);409 ccsObjectSetPrivate (backend, NULL);
@@ -425,41 +411,26 @@
425}411}
426412
427Bool413Bool
428ccsGSettingsBackendAttachNewToBackend (CCSBackend *backend, CCSContext *context)414ccsGSettingsBackendAttachNewToBackend (CCSBackend *backend,
415 CCSContext *context,
416 CCSGSettingsWrapper *compizconfigSettings,
417 CCSGSettingsWrapper *currentProfileSettings,
418 CCSGSettingsWrapperFactory *wrapperFactory,
419 CCSIntegration *integration,
420 CCSGNOMEValueChangeData *valueChangeData,
421 char *currentProfile)
429{422{
430 char *currentProfilePath;
431
432 ccsObjectAddInterface (backend, (CCSInterface *) &gsettingsAdditionalDefaultInterface, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface));423 ccsObjectAddInterface (backend, (CCSInterface *) &gsettingsAdditionalDefaultInterface, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface));
433424
434 CCSGSettingsBackendPrivate *priv = addPrivateToBackend (backend, backend->object.object_allocation);425 CCSGSettingsBackendPrivate *priv = addPrivateToBackend (backend, backend->object.object_allocation);
435426
436 priv->compizconfigSettings = ccsGSettingsWrapperNewForSchema (COMPIZCONFIG_SCHEMA_ID,427 priv->compizconfigSettings = compizconfigSettings;
437 backend->object.object_allocation);428 priv->currentProfile = currentProfile;
438 priv->currentProfile = getCurrentProfileName (backend);429 priv->currentProfileSettings = currentProfileSettings;
439 currentProfilePath = makeCompizProfilePath (priv->currentProfile);
440 priv->currentProfileSettings = ccsGSettingsWrapperNewForSchemaWithPath (PROFILE_SCHEMA_ID,
441 currentProfilePath,
442 backend->object.object_allocation);
443 priv->context = context;430 priv->context = context;
444431 priv->valueChangeData = valueChangeData;
445 CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory = ccsGNOMEIntegrationGSettingsWrapperDefaultImplNew (&ccsDefaultObjectAllocator);432 priv->integration = integration;
446 CCSIntegratedSettingsStorage *storage = ccsIntegratedSettingsStorageDefaultImplNew (&ccsDefaultObjectAllocator);433 priv->wrapperFactory = wrapperFactory;
447434
448 priv->valueChangeData.storage = storage;
449 priv->valueChangeData.context = priv->context;
450
451 CCSIntegratedSettingFactory *factory = ccsGSettingsIntegratedSettingFactoryNew (wrapperFactory,
452 &priv->valueChangeData,
453 &ccsDefaultObjectAllocator);
454
455 priv->valueChangeData.factory = factory;
456
457 priv->integration = ccsGNOMEIntegrationBackendNew (backend, context, factory, storage, backend->object.object_allocation);
458
459
460
461 priv->valueChangeData.integration = priv->integration;
462
463 g_free (currentProfilePath);
464 return TRUE;435 return TRUE;
465}436}
466437
=== modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.h'
--- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.h 2012-10-06 16:11:05 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend.h 2012-10-12 01:30:30 +0000
@@ -4,12 +4,20 @@
4#include <ccs-defs.h>4#include <ccs-defs.h>
5#include <ccs-backend.h>5#include <ccs-backend.h>
6#include <ccs_gsettings_backend_fwd.h>6#include <ccs_gsettings_backend_fwd.h>
7#include <ccs_gnome_fwd.h>
7#include <glib.h>8#include <glib.h>
89
9COMPIZCONFIG_BEGIN_DECLS10COMPIZCONFIG_BEGIN_DECLS
1011
11Bool12Bool
12ccsGSettingsBackendAttachNewToBackend (CCSBackend *backend, CCSContext *context);13ccsGSettingsBackendAttachNewToBackend (CCSBackend *backend,
14 CCSContext *context,
15 CCSGSettingsWrapper *compizconfigSettings,
16 CCSGSettingsWrapper *currentProfileSettings,
17 CCSGSettingsWrapperFactory *wrapperFactory,
18 CCSIntegration *integration,
19 CCSGNOMEValueChangeData *valueChangeData,
20 char *currentProfile);
1321
14void22void
15ccsGSettingsBackendDetachFromBackend (CCSBackend *backend);23ccsGSettingsBackendDetachFromBackend (CCSBackend *backend);
1624
=== modified file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_fwd.h'
--- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_fwd.h 2012-10-06 16:11:05 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_backend_fwd.h 2012-10-12 01:30:30 +0000
@@ -7,6 +7,7 @@
77
8typedef struct _CCSGSettingsWrapper CCSGSettingsWrapper;8typedef struct _CCSGSettingsWrapper CCSGSettingsWrapper;
9typedef struct _CCSGSettingsBackend CCSGSettingsBackend;9typedef struct _CCSGSettingsBackend CCSGSettingsBackend;
10typedef struct _CCSGSettingsWrapperFactory CCSGSettingsWrapperFactory;
1011
11COMPIZCONFIG_END_DECLS12COMPIZCONFIG_END_DECLS
1213
1314
=== added file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.c'
--- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.c 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.c 2012-10-12 01:30:30 +0000
@@ -0,0 +1,96 @@
1/**
2 *
3 * GSettings libcompizconfig backend
4 *
5 * ccs_gsettings_wrapper_factory.c
6 *
7 * Copyright (c) 2012 Canonical Ltd
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * Authored By:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 *
22 **/
23#include <ccs-object.h>
24#include "ccs_gsettings_wrapper_factory.h"
25#include "ccs_gsettings_wrapper_factory_interface.h"
26#include "ccs_gsettings_interface.h"
27#include "ccs_gsettings_interface_wrapper.h"
28
29/* CCSGSettingsWrapperFactory implementation */
30typedef struct _CCSGSettingsWrapperFactoryPrivate CCSGSettingsWrapperFactoryPrivate;
31struct _CCSGSettingsWrapperFactoryPrivate
32{
33};
34
35static void
36ccsGSettingsWrapperDefaultImplFree (CCSGSettingsWrapperFactory *wrapperFactory)
37{
38 ccsObjectFinalize (wrapperFactory);
39 (*wrapperFactory->object.object_allocation->free_) (wrapperFactory->object.object_allocation->allocator,
40 wrapperFactory);
41}
42
43static CCSGSettingsWrapper *
44ccsGSettingsWrapperFactoryNewGSettingsWrapperDefault (CCSGSettingsWrapperFactory *factory,
45 const gchar *schemaName,
46 CCSObjectAllocationInterface *ai)
47{
48 CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperNewForSchema (schemaName, ai);
49
50 return wrapper;
51}
52
53CCSGSettingsWrapper *
54ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPathDefault (CCSGSettingsWrapperFactory *wrapperFactory,
55 const gchar *schemaName,
56 const gchar *path,
57 CCSObjectAllocationInterface *ai)
58{
59 CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperNewForSchemaWithPath (schemaName,
60 path,
61 ai);
62
63 return wrapper;
64}
65
66const CCSGSettingsWrapperFactoryInterface ccsGSettingsWrapperFactoryInterface =
67{
68 ccsGSettingsWrapperFactoryNewGSettingsWrapperDefault,
69 ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPathDefault,
70 ccsGSettingsWrapperDefaultImplFree
71};
72
73CCSGSettingsWrapperFactory *
74ccsGSettingsWrapperFactoryDefaultImplNew (CCSObjectAllocationInterface *ai)
75{
76 CCSGSettingsWrapperFactory *wrapperFactory = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGSettingsWrapperFactory));
77
78 if (!wrapperFactory)
79 return NULL;
80
81 CCSGSettingsWrapperFactoryPrivate *priv = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGSettingsWrapperFactoryPrivate));
82
83 if (!priv)
84 {
85 (*ai->free_) (ai->allocator, wrapperFactory);
86 return NULL;
87 }
88
89 ccsObjectInit (wrapperFactory, ai);
90 ccsObjectAddInterface (wrapperFactory, (const CCSInterface *) &ccsGSettingsWrapperFactoryInterface, GET_INTERFACE_TYPE (CCSGSettingsWrapperFactoryInterface));
91 ccsObjectSetPrivate (wrapperFactory, (CCSPrivate *) priv);
92
93 ccsGSettingsWrapperFactoryRef (wrapperFactory);
94
95 return wrapperFactory;
96}
097
=== added file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.h'
--- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.h 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory.h 2012-10-12 01:30:30 +0000
@@ -0,0 +1,38 @@
1/**
2 *
3 * GSettings libcompizconfig backend
4 *
5 * ccs_gsettings_wrapper_factory.h
6 *
7 * Copyright (c) 2012 Canonical Ltd
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * Authored By:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 *
22 **/
23#ifndef _CCS_GSETTINGS_WRAPPER_FACTORY_H
24#define _CCS_GSETTINGS_WRAPPER_FACTORY_H
25
26#include <ccs-defs.h>
27
28COMPIZCONFIG_BEGIN_DECLS
29
30#include <ccs-fwd.h>
31#include <ccs_gsettings_backend_fwd.h>
32
33CCSGSettingsWrapperFactory *
34ccsGSettingsWrapperFactoryDefaultImplNew (CCSObjectAllocationInterface *ai);
35
36COMPIZCONFIG_END_DECLS
37
38#endif
039
=== added file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.c'
--- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.c 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.c 2012-10-12 01:30:30 +0000
@@ -0,0 +1,51 @@
1/**
2 *
3 * GSettings libcompizconfig backend
4 *
5 * ccs_gsettings_wrapper_factory_interface.c
6 *
7 * Copyright (c) 2012 Canonical Ltd
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * Authored By:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 *
22 **/
23#include <ccs-object.h>
24#include "ccs_gsettings_wrapper_factory_interface.h"
25
26INTERFACE_TYPE (CCSGSettingsWrapperFactoryInterface);
27
28CCSGSettingsWrapper *
29ccsGSettingsWrapperFactoryNewGSettingsWrapper (CCSGSettingsWrapperFactory *factory,
30 const gchar *schemaName,
31 CCSObjectAllocationInterface *ai)
32{
33 return (*(GET_INTERFACE (CCSGSettingsWrapperFactoryInterface, factory))->newGSettingsWrapper) (factory, schemaName, ai);
34}
35
36CCSGSettingsWrapper *
37ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (CCSGSettingsWrapperFactory *factory,
38 const gchar *schemaName,
39 const gchar *path,
40 CCSObjectAllocationInterface *ai)
41{
42 return (*(GET_INTERFACE (CCSGSettingsWrapperFactoryInterface, factory))->newGSettingsWrapperWithPath) (factory, schemaName, path, ai);
43}
44
45void
46ccsFreeGSettingsWrapperFactory (CCSGSettingsWrapperFactory *factory)
47{
48 return (*(GET_INTERFACE (CCSGSettingsWrapperFactoryInterface, factory))->free) (factory);
49}
50
51CCSREF_OBJ (GSettingsWrapperFactory, CCSGSettingsWrapperFactory)
052
=== added file 'compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.h'
--- compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.h 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/ccs_gsettings_wrapper_factory_interface.h 2012-10-12 01:30:30 +0000
@@ -0,0 +1,82 @@
1/**
2 *
3 * GSettings libcompizconfig backend
4 *
5 * ccs_gsettings_wrapper_factory_interface.h
6 *
7 * Copyright (c) 2012 Canonical Ltd
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * Authored By:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 *
22 **/
23
24#ifndef _CCS_GSETTINGS_WRAPPER_FACTORY_INTERFACE_H
25#define _CCS_GSETTINGS_WRAPPER_FACTORY_INTERFACE_H
26
27#include <ccs-defs.h>
28
29COMPIZCONFIG_BEGIN_DECLS
30
31#include <gio/gio.h>
32#include <ccs-fwd.h>
33#include <ccs-object.h>
34#include <ccs_gsettings_backend_fwd.h>
35
36typedef struct _CCSGSettingsWrapperFactoryInterface CCSGSettingsWrapperFactoryInterface;
37
38typedef CCSGSettingsWrapper * (*CCSGSettingsWrapperFactoryNewGSettingsWrapper) (CCSGSettingsWrapperFactory *wrapperFactory,
39 const gchar *schema,
40 CCSObjectAllocationInterface *ai);
41typedef CCSGSettingsWrapper * (*CCSGSettingsWrapperFactoryNewGSettingsWrapperWithPath) (CCSGSettingsWrapperFactory *wrapperFactory,
42 const gchar *schema,
43 const gchar *path,
44 CCSObjectAllocationInterface *ai);
45
46typedef void (*CCSGSettingsWrapperFactoryFree) (CCSGSettingsWrapperFactory *wrapperFactory);
47
48struct _CCSGSettingsWrapperFactoryInterface
49{
50 CCSGSettingsWrapperFactoryNewGSettingsWrapper newGSettingsWrapper;
51 CCSGSettingsWrapperFactoryNewGSettingsWrapperWithPath newGSettingsWrapperWithPath;
52 CCSGSettingsWrapperFactoryFree free;
53};
54
55/**
56 * @brief The _CCSGSettingsWrapperFactory struct
57 *
58 * Will create new CCSGSettingsIntegratedSetting objects on demand
59 */
60struct _CCSGSettingsWrapperFactory
61{
62 CCSObject object;
63};
64
65unsigned int ccsCCSGSettingsWrapperFactoryInterfaceGetType ();
66
67CCSREF_HDR (GSettingsWrapperFactory, CCSGSettingsWrapperFactory);
68
69CCSGSettingsWrapper *
70ccsGSettingsWrapperFactoryNewGSettingsWrapper (CCSGSettingsWrapperFactory *wrapperFactory,
71 const gchar *schema,
72 CCSObjectAllocationInterface *ai);
73
74CCSGSettingsWrapper *
75ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (CCSGSettingsWrapperFactory *factory,
76 const gchar *schemaName,
77 const gchar *path,
78 CCSObjectAllocationInterface *ai);
79
80COMPIZCONFIG_END_DECLS
81
82#endif
083
=== modified file 'compizconfig/gsettings/mocks/CMakeLists.txt'
--- compizconfig/gsettings/mocks/CMakeLists.txt 2012-09-11 17:37:45 +0000
+++ compizconfig/gsettings/mocks/CMakeLists.txt 2012-10-12 01:30:30 +0000
@@ -8,12 +8,16 @@
8 ${CMAKE_CURRENT_SOURCE_DIR}/../gsettings_backend_shared8 ${CMAKE_CURRENT_SOURCE_DIR}/../gsettings_backend_shared
9 ${GLIB_INCLUDE_DIRS})9 ${GLIB_INCLUDE_DIRS})
1010
11set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")11 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
1212
13 add_library (compizconfig_ccs_gsettings_wrapper_mock STATIC13 add_library (compizconfig_ccs_gsettings_wrapper_mock STATIC
14 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.cpp14 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.cpp
15 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.h)15 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_mock.h)
1616
17 add_library (compizconfig_ccs_gsettings_wrapper_factory_mock STATIC
18 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_factory_mock.cpp
19 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_wrapper_factory_mock.h)
20
17 add_library (compizconfig_ccs_gsettings_backend_mock STATIC21 add_library (compizconfig_ccs_gsettings_backend_mock STATIC
18 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.cpp22 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.cpp
19 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.h)23 ${CMAKE_CURRENT_SOURCE_DIR}/ccs_gsettings_backend_mock.h)
2024
=== added file 'compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.cpp'
--- compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.cpp 2012-10-12 01:30:30 +0000
@@ -0,0 +1,47 @@
1#include <ccs_gsettings_wrapper_factory_mock.h>
2#include <ccs-object.h>
3
4const CCSGSettingsWrapperFactoryInterface mockInterface =
5{
6 CCSGSettingsWrapperFactoryGMock::ccsGSettingsWrapperFactoryNewGSettingsWrapper,
7 CCSGSettingsWrapperFactoryGMock::ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath,
8 CCSGSettingsWrapperFactoryGMock::ccsFreeGSettingsWrapperFactory
9};
10
11CCSGSettingsWrapperFactory *
12ccsMockGSettingsWrapperFactoryNew ()
13{
14 CCSGSettingsWrapperFactory *wrapper = (CCSGSettingsWrapperFactory *) calloc (1, sizeof (CCSGSettingsWrapperFactory));
15
16 if (!wrapper)
17 return NULL;
18
19 CCSGSettingsWrapperFactoryGMock *gmockWrapper = new CCSGSettingsWrapperFactoryGMock (wrapper);
20
21 if (!gmockWrapper)
22 {
23 free (wrapper);
24 return NULL;
25 }
26
27 ccsObjectInit (wrapper, &ccsDefaultObjectAllocator);
28 ccsObjectAddInterface (wrapper, (const CCSInterface *) &mockInterface, GET_INTERFACE_TYPE (CCSGSettingsWrapperFactoryInterface));
29 ccsObjectSetPrivate (wrapper, (CCSPrivate *) gmockWrapper);
30
31 ccsGSettingsWrapperFactoryRef (wrapper);
32
33 return wrapper;
34}
35
36void
37ccsMockGSettingsWrapperFactoryFree (CCSGSettingsWrapperFactory *wrapper)
38{
39 CCSGSettingsWrapperFactoryGMock *gmockWrapper = reinterpret_cast <CCSGSettingsWrapperFactoryGMock *> (ccsObjectGetPrivate (wrapper));
40
41 delete gmockWrapper;
42
43 ccsObjectSetPrivate (wrapper, NULL);
44 ccsObjectFinalize (wrapper);
45 free (wrapper);
46}
47
048
=== added file 'compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.h'
--- compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.h 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/mocks/ccs_gsettings_wrapper_factory_mock.h 2012-10-12 01:30:30 +0000
@@ -0,0 +1,92 @@
1/**
2 *
3 * GSettings libcompizconfig backend
4 *
5 * ccs_gsettings_wrapper_factory_mock.h
6 *
7 * Copyright (c) 2012 Canonical Ltd
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * Authored By:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 *
22 **/
23#ifndef _COMPIZCONFIG_CCS_GSETTINGS_WRAPPER_FACTORY_MOCK
24#define _COMPIZCONFIG_CCS_GSETTINGS_WRAPPER_FACTORY_MOCK
25
26#include <gtest/gtest.h>
27#include <gmock/gmock.h>
28
29#include <ccs_gsettings_wrapper_factory_interface.h>
30
31CCSGSettingsWrapperFactory * ccsMockGSettingsWrapperFactoryNew ();
32void ccsMockGSettingsWrapperFactoryFree (CCSGSettingsWrapperFactory *);
33
34class CCSGSettingsWrapperFactoryMockInterface
35{
36 public:
37
38 virtual ~CCSGSettingsWrapperFactoryMockInterface () {}
39 virtual CCSGSettingsWrapper * newGSettingsWrapper (const gchar *schema,
40 CCSObjectAllocationInterface *ai) = 0;
41 virtual CCSGSettingsWrapper * newGSettingsWrapperWithPath (const gchar *schema,
42 const gchar *path,
43 CCSObjectAllocationInterface *ai) = 0;
44};
45
46class CCSGSettingsWrapperFactoryGMock :
47 public CCSGSettingsWrapperFactoryMockInterface
48{
49 public:
50
51 CCSGSettingsWrapperFactoryGMock (CCSGSettingsWrapperFactory *wrapper) :
52 mWrapper (wrapper)
53 {
54 }
55
56 MOCK_METHOD2 (newGSettingsWrapper, CCSGSettingsWrapper * (const gchar *schema,
57 CCSObjectAllocationInterface *ai));
58 MOCK_METHOD3 (newGSettingsWrapperWithPath, CCSGSettingsWrapper * (const gchar *schema,
59 const gchar *path,
60 CCSObjectAllocationInterface *ai));
61
62 private:
63
64 CCSGSettingsWrapperFactory *mWrapper;
65
66 public:
67
68 static CCSGSettingsWrapper *
69 ccsGSettingsWrapperFactoryNewGSettingsWrapper (CCSGSettingsWrapperFactory *wrapperFactory,
70 const gchar *schema,
71 CCSObjectAllocationInterface *ai)
72 {
73 return reinterpret_cast <CCSGSettingsWrapperFactoryMockInterface *> (ccsObjectGetPrivate (wrapperFactory))->newGSettingsWrapper (schema, ai);
74 }
75
76 static CCSGSettingsWrapper *
77 ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (CCSGSettingsWrapperFactory *wrapperFactory,
78 const gchar *schema,
79 const gchar *path,
80 CCSObjectAllocationInterface *ai)
81 {
82 return reinterpret_cast <CCSGSettingsWrapperFactoryMockInterface *> (ccsObjectGetPrivate (wrapperFactory))->newGSettingsWrapperWithPath (schema, path, ai);
83 }
84
85 static void
86 ccsFreeGSettingsWrapperFactory (CCSGSettingsWrapperFactory *wrapperFactory)
87 {
88 ccsMockGSettingsWrapperFactoryFree (wrapperFactory);
89 }
90};
91
92#endif
093
=== modified file 'compizconfig/gsettings/src/gsettings.c'
--- compizconfig/gsettings/src/gsettings.c 2012-09-25 06:12:24 +0000
+++ compizconfig/gsettings/src/gsettings.c 2012-10-12 01:30:30 +0000
@@ -39,6 +39,11 @@
39#include "ccs_gsettings_backend.h"39#include "ccs_gsettings_backend.h"
40#include "ccs_gsettings_interface.h"40#include "ccs_gsettings_interface.h"
41#include "ccs_gsettings_interface_wrapper.h"41#include "ccs_gsettings_interface_wrapper.h"
42#include "ccs_gsettings_wrapper_factory_interface.h"
43#include "ccs_gsettings_wrapper_factory.h"
44#include "ccs_gnome_integration_gsettings_wrapper_factory.h"
45#include "ccs_gnome_integration_gsettings_integrated_setting_factory.h"
46#include "ccs_gnome_integration.h"
4247
43GVariant *48GVariant *
44getVariantForCCSSetting (CCSBackend *backend, CCSSetting *setting)49getVariantForCCSSetting (CCSBackend *backend, CCSSetting *setting)
@@ -437,12 +442,72 @@
437 }442 }
438}443}
439444
445static char *
446getCurrentProfileName (CCSGSettingsWrapper *compizconfigSettings)
447{
448 GVariant *value;
449 char *ret = NULL;
450
451 value = ccsGSettingsWrapperGetValue (compizconfigSettings, "current-profile");
452
453 if (value)
454 ret = strdup (g_variant_get_string (value, NULL));
455 else
456 ret = strdup (DEFAULTPROF);
457
458 g_variant_unref (value);
459
460 return ret;
461}
462
440static Bool463static Bool
441initBackend (CCSBackend *backend, CCSContext * context)464initBackend (CCSBackend *backend, CCSContext * context)
442{465{
443 g_type_init ();466 g_type_init ();
444467
445 return ccsGSettingsBackendAttachNewToBackend (backend, context);468 CCSGSettingsWrapper *compizconfigSettings = ccsGSettingsWrapperNewForSchema (COMPIZCONFIG_SCHEMA_ID,
469 backend->object.object_allocation);
470 char *currentProfile = getCurrentProfileName (compizconfigSettings);
471 char *currentProfilePath = currentProfilePath = makeCompizProfilePath (currentProfile);
472 CCSGSettingsWrapper *currentProfileSettings = ccsGSettingsWrapperNewForSchemaWithPath (PROFILE_SCHEMA_ID,
473 currentProfilePath,
474 backend->object.object_allocation);
475 CCSGNOMEValueChangeData *valueChangeData = calloc (1, sizeof (CCSGNOMEValueChangeData));
476 CCSGSettingsWrapperFactory *wrapperFactory = ccsGSettingsWrapperFactoryDefaultImplNew (backend->object.object_allocation);
477 CCSGSettingsWrapperFactory *gnomeWrapperFactory = ccsGNOMEIntegrationGSettingsWrapperFactoryDefaultImplNew (backend->object.object_allocation,
478 wrapperFactory,
479 ccsGSettingsIntegratedSettingsChangeCallback (),
480 valueChangeData);
481 CCSIntegratedSettingsStorage *storage = ccsIntegratedSettingsStorageDefaultImplNew (backend->object.object_allocation);
482
483 valueChangeData->storage = storage;
484 valueChangeData->context = context;
485
486 CCSIntegratedSettingFactory *factory = ccsGSettingsIntegratedSettingFactoryNew (gnomeWrapperFactory,
487 valueChangeData,
488 backend->object.object_allocation);
489
490 valueChangeData->factory = factory;
491
492 CCSIntegration *integration = ccsGNOMEIntegrationBackendNew (backend, context, factory, storage, backend->object.object_allocation);
493
494
495
496 valueChangeData->integration = integration;
497
498 g_free (currentProfilePath);
499
500 /* Drop our reference to the wrapper factory */
501 ccsGSettingsWrapperFactoryUnref (gnomeWrapperFactory);
502
503 return ccsGSettingsBackendAttachNewToBackend (backend,
504 context,
505 compizconfigSettings,
506 currentProfileSettings,
507 wrapperFactory,
508 integration,
509 valueChangeData,
510 currentProfile);
446}511}
447512
448static Bool513static Bool
449514
=== modified file 'compizconfig/gsettings/tests/CMakeLists.txt'
--- compizconfig/gsettings/tests/CMakeLists.txt 2012-10-04 06:14:43 +0000
+++ compizconfig/gsettings/tests/CMakeLists.txt 2012-10-12 01:30:30 +0000
@@ -39,8 +39,10 @@
39 compizconfig_ccs_setting_mock39 compizconfig_ccs_setting_mock
40 compizconfig_ccs_plugin_mock40 compizconfig_ccs_plugin_mock
41 compizconfig_ccs_context_mock41 compizconfig_ccs_context_mock
42 compizconfig_ccs_integration_mock
42 compizconfig_ccs_gsettings_backend_mock43 compizconfig_ccs_gsettings_backend_mock
43 compizconfig_ccs_gsettings_wrapper_mock44 compizconfig_ccs_gsettings_wrapper_mock
45 compizconfig_ccs_gsettings_wrapper_factory_mock
44 compizconfig_ccs_test_value_combinations46 compizconfig_ccs_test_value_combinations
45 ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES}47 ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES}
46 ${GTEST_BOTH_LIBRARIES}48 ${GTEST_BOTH_LIBRARIES}
4749
=== modified file 'compizconfig/gsettings/tests/test_gsettings_tests.cpp'
--- compizconfig/gsettings/tests/test_gsettings_tests.cpp 2012-10-04 09:19:38 +0000
+++ compizconfig/gsettings/tests/test_gsettings_tests.cpp 2012-10-12 01:30:30 +0000
@@ -7,13 +7,21 @@
7#include <boost/shared_ptr.hpp>7#include <boost/shared_ptr.hpp>
8#include <boost/scoped_array.hpp>8#include <boost/scoped_array.hpp>
99
10#include "gtest_shared_autodestroy.h"
11
10#include "test_gsettings_tests.h"12#include "test_gsettings_tests.h"
11#include "gsettings.h"13#include "gsettings.h"
12#include "ccs_gsettings_backend.h"14#include "ccs_gsettings_backend.h"
15#include "ccs_gsettings_backend_interface.h"
13#include "ccs_gsettings_backend_mock.h"16#include "ccs_gsettings_backend_mock.h"
14#include "compizconfig_ccs_context_mock.h"17#include "compizconfig_ccs_context_mock.h"
15#include "compizconfig_ccs_plugin_mock.h"18#include "compizconfig_ccs_plugin_mock.h"
16#include "compizconfig_ccs_setting_mock.h"19#include "compizconfig_ccs_setting_mock.h"
20#include "compizconfig_ccs_integration_mock.h"
21#include "ccs_gsettings_wrapper_mock.h"
22#include "ccs_gsettings_wrapper_factory_mock.h"
23#include "ccs_gsettings_wrapper_factory_interface.h"
24#include "ccs_gnome_integration.h"
17#include "gtest_shared_characterwrapper.h"25#include "gtest_shared_characterwrapper.h"
18#include "compizconfig_test_value_combiners.h"26#include "compizconfig_test_value_combiners.h"
19#include "compizconfig_ccs_mocked_allocator.h"27#include "compizconfig_ccs_mocked_allocator.h"
@@ -1959,8 +1967,6 @@
1959 boost::shared_ptr <CCSContext> context (ccsMockContextNew (),1967 boost::shared_ptr <CCSContext> context (ccsMockContextNew (),
1960 boost::bind (ccsFreeMockContext, _1));1968 boost::bind (ccsFreeMockContext, _1));
19611969
1962 GVariantBuilder pluginsWithChangedKeysBuilder;
1963
1964 const unsigned short NUM_KEYS = 3;1970 const unsigned short NUM_KEYS = 3;
19651971
1966 gchar ** fooKeys = (gchar **) calloc (1, sizeof (char *) * (NUM_KEYS + 1));1972 gchar ** fooKeys = (gchar **) calloc (1, sizeof (char *) * (NUM_KEYS + 1));
@@ -1975,6 +1981,8 @@
1975 barKeys[2] = g_strdup (KEY_EXAMPLE_THREE.c_str ());1981 barKeys[2] = g_strdup (KEY_EXAMPLE_THREE.c_str ());
1976 barKeys[3] = NULL;1982 barKeys[3] = NULL;
19771983
1984 GVariantBuilder pluginsWithChangedKeysBuilder;
1985
1978 g_variant_builder_init (&pluginsWithChangedKeysBuilder, G_VARIANT_TYPE ("as"));1986 g_variant_builder_init (&pluginsWithChangedKeysBuilder, G_VARIANT_TYPE ("as"));
1979 g_variant_builder_add (&pluginsWithChangedKeysBuilder, "s", PLUGIN_FOO.c_str ());1987 g_variant_builder_add (&pluginsWithChangedKeysBuilder, "s", PLUGIN_FOO.c_str ());
1980 g_variant_builder_add (&pluginsWithChangedKeysBuilder, "s", PLUGIN_BAR.c_str ());1988 g_variant_builder_add (&pluginsWithChangedKeysBuilder, "s", PLUGIN_BAR.c_str ());
@@ -2017,3 +2025,235 @@
2017 pluginsWithChangedKeys.get (),2025 pluginsWithChangedKeys.get (),
2018 "mock");2026 "mock");
2019}2027}
2028
2029namespace
2030{
2031 const CCSBackendInfo stubBackendInfo =
2032 {
2033 "stub",
2034 "stub",
2035 "stub",
2036 FALSE,
2037 FALSE
2038 };
2039
2040 const CCSBackendInfo *
2041 stubBackendGetInfo (CCSBackend *backend)
2042 {
2043 return &stubBackendInfo;
2044 }
2045
2046 Bool
2047 stubBackendInit (CCSBackend *backend, CCSContext *context)
2048 {
2049 return TRUE;
2050 }
2051
2052 Bool
2053 stubBackendFini (CCSBackend *backend)
2054 {
2055 return TRUE;
2056 }
2057
2058 CCSBackendInterface stubBackendInterface =
2059 {
2060 stubBackendGetInfo,
2061 NULL,
2062 stubBackendInit,
2063 stubBackendFini,
2064 NULL,
2065 NULL,
2066 NULL,
2067 NULL,
2068 NULL,
2069 NULL,
2070 NULL,
2071 NULL,
2072 NULL,
2073 NULL,
2074 NULL,
2075 NULL
2076 };
2077}
2078
2079namespace
2080{
2081 const std::string MOCK_PLUGIN_NAME ("mock");
2082 const std::string MOCK_SCHEMA_NAME ("org.compiz.mock");
2083 const std::string MOCK_PROFILE_NAME ("mock");
2084 const std::string MOCK_GSCHEMA_PATH ("/org/compiz/profiles/mock/plugins/mock");
2085 const std::string PLUGINS_WITH_SET_KEYS ("plugins-with-set-keys");
2086
2087 boost::shared_ptr <GVariant>
2088 GetEmptyPluginsWithSetKeys ()
2089 {
2090 GVariantBuilder pluginsWithChangedKeysBuilder;
2091
2092 g_variant_builder_init (&pluginsWithChangedKeysBuilder, G_VARIANT_TYPE ("as"));
2093 return AutoDestroy (g_variant_ref_sink (g_variant_builder_end (&pluginsWithChangedKeysBuilder)),
2094 g_variant_unref);
2095 }
2096}
2097
2098class CCSGSettingsTestCCSGSettingsBackend :
2099 public CCSGSettingsTestIndependent
2100{
2101 public:
2102
2103 CCSGSettingsTestCCSGSettingsBackend () :
2104 mockContext (AutoDestroy (ccsMockContextNew (), ccsFreeMockContext)),
2105 stubBackend (AutoDestroy (ccsBackendNewWithDynamicInterface (mockContext.get (), &stubBackendInterface),
2106 ccsBackendUnref)),
2107 mockCompizconfigSettings (ccsMockGSettingsWrapperNew ()),
2108 mockCurrentProfileSettings (ccsMockGSettingsWrapperNew ()),
2109 mockWrapperFactory (ccsMockGSettingsWrapperFactoryNew ()),
2110 mockIntegration (ccsMockIntegrationBackendNew (&ccsDefaultObjectAllocator)),
2111 valueChangeData (reinterpret_cast <CCSGNOMEValueChangeData *> (calloc (1, sizeof (CCSGNOMEValueChangeData)))),
2112 currentProfile (strdup (MOCK_PROFILE_NAME.c_str ())),
2113 mockMockPluginWrapper (ccsMockGSettingsWrapperNew ()),
2114 gmockWrapperFactory (reinterpret_cast <CCSGSettingsWrapperFactoryGMock *> (ccsObjectGetPrivate (mockWrapperFactory))),
2115 gmockWrapper (reinterpret_cast <CCSGSettingsWrapperGMock *> (ccsObjectGetPrivate (mockMockPluginWrapper))),
2116 gmockCurrentProfileSettings (reinterpret_cast <CCSGSettingsWrapperGMock *> (ccsObjectGetPrivate (mockCurrentProfileSettings)))
2117
2118 {
2119 valueChangeData->integration = mockIntegration;
2120 valueChangeData->factory = NULL;
2121 valueChangeData->storage = NULL;
2122 valueChangeData->context = mockContext.get ();
2123
2124 if (!ccsGSettingsBackendAttachNewToBackend (stubBackend.get (),
2125 mockContext.get (),
2126 mockCompizconfigSettings,
2127 mockCurrentProfileSettings,
2128 mockWrapperFactory,
2129 mockIntegration,
2130 valueChangeData,
2131 currentProfile))
2132 throw std::runtime_error ("Failed to attach GSettings backend");
2133 }
2134
2135 virtual void TearDown ()
2136 {
2137 ccsGSettingsBackendDetachFromBackend (stubBackend.get ());
2138
2139 CCSGSettingsTestIndependent::TearDown ();
2140 }
2141
2142 boost::shared_ptr <CCSContext> mockContext;
2143 boost::shared_ptr <CCSBackend> stubBackend;
2144 CCSGSettingsWrapper *mockCompizconfigSettings;
2145 CCSGSettingsWrapper *mockCurrentProfileSettings;
2146 CCSGSettingsWrapperFactory *mockWrapperFactory;
2147 CCSIntegration *mockIntegration;
2148 CCSGNOMEValueChangeData *valueChangeData;
2149 char *currentProfile;
2150 CCSGSettingsWrapper *mockMockPluginWrapper;
2151
2152 CCSGSettingsWrapperFactoryGMock *gmockWrapperFactory;
2153 CCSGSettingsWrapperGMock *gmockWrapper;
2154 CCSGSettingsWrapperGMock *gmockCurrentProfileSettings;
2155
2156};
2157
2158TEST_F (CCSGSettingsTestCCSGSettingsBackend, TestWriteOutSetKeysOnGetSettingsObject)
2159{
2160 /* Should create a new wrapper for this "plugin" */
2161 EXPECT_CALL (*gmockWrapperFactory, newGSettingsWrapperWithPath (Eq (MOCK_SCHEMA_NAME),
2162 Eq (MOCK_GSCHEMA_PATH),
2163 _)).WillOnce (Return (mockMockPluginWrapper));
2164 EXPECT_CALL (*gmockWrapper, connectToChangedSignal (_, stubBackend.get ()));
2165
2166
2167 boost::shared_ptr <GVariant> pluginsWithSetKeysVariantEmpty (GetEmptyPluginsWithSetKeys ());
2168
2169 /* Should now get the value of plugins-with-set-keys from
2170 * mockCurrentProfileSettings */
2171 EXPECT_CALL (*gmockCurrentProfileSettings, getValue (Eq (PLUGINS_WITH_SET_KEYS)))
2172 .WillOnce (Return (g_variant_ref (pluginsWithSetKeysVariantEmpty.get ())));
2173
2174 /* Should acknowledge that we wrote to this schema */
2175 EXPECT_CALL (*gmockCurrentProfileSettings, setValue (Eq (PLUGINS_WITH_SET_KEYS),
2176 GVariantHasValueInArray <const gchar *> ("s",
2177 MOCK_PLUGIN_NAME.c_str (),
2178 boost::bind (streq, _1, _2))))
2179 .WillOnce (WithArgs <1> (Invoke (g_variant_unref)));;
2180
2181 CCSGSettingsWrapper *wrapper = ccsGSettingsGetSettingsObjectForPluginWithPath (stubBackend.get (),
2182 MOCK_PLUGIN_NAME.c_str (),
2183 MOCK_GSCHEMA_PATH.c_str (),
2184 mockContext.get ());
2185
2186 EXPECT_EQ (wrapper, mockMockPluginWrapper);
2187}
2188
2189TEST_F (CCSGSettingsTestCCSGSettingsBackend, TestNoWriteOutSetKeysOnGetSettingsObjectIfAlreadyWritten)
2190{
2191 /* Should create a new wrapper for this "plugin" */
2192 EXPECT_CALL (*gmockWrapperFactory, newGSettingsWrapperWithPath (Eq (MOCK_SCHEMA_NAME),
2193 Eq (MOCK_GSCHEMA_PATH),
2194 _)).WillOnce (Return (mockMockPluginWrapper));
2195 EXPECT_CALL (*gmockWrapper, connectToChangedSignal (_, stubBackend.get ()));
2196
2197
2198 GVariantBuilder pluginsWithChangedKeysBuilder;
2199
2200 g_variant_builder_init (&pluginsWithChangedKeysBuilder, G_VARIANT_TYPE ("as"));
2201 g_variant_builder_add (&pluginsWithChangedKeysBuilder, "s", MOCK_PLUGIN_NAME.c_str ());
2202 boost::shared_ptr <GVariant> pluginsWithSetKeysVariantNonEmpty (AutoDestroy (g_variant_ref_sink (g_variant_builder_end (&pluginsWithChangedKeysBuilder)),
2203 g_variant_unref));
2204
2205 /* Should now get the value of plugins-with-set-keys from
2206 * mockCurrentProfileSettings */
2207 EXPECT_CALL (*gmockCurrentProfileSettings, getValue (Eq (PLUGINS_WITH_SET_KEYS)))
2208 .WillOnce (Return (g_variant_ref (pluginsWithSetKeysVariantNonEmpty.get ())));
2209
2210 /* No acknowledgement */
2211 EXPECT_CALL (*gmockCurrentProfileSettings, setValue (_, _)).Times (0);
2212
2213 CCSGSettingsWrapper *wrapper = ccsGSettingsGetSettingsObjectForPluginWithPath (stubBackend.get (),
2214 MOCK_PLUGIN_NAME.c_str (),
2215 MOCK_GSCHEMA_PATH.c_str (),
2216 mockContext.get ());
2217
2218 EXPECT_EQ (wrapper, mockMockPluginWrapper);
2219}
2220
2221TEST_F (CCSGSettingsTestCCSGSettingsBackend, TestReturnExistingWrapper)
2222{
2223 /* Should create a new wrapper for this "plugin" */
2224 EXPECT_CALL (*gmockWrapperFactory, newGSettingsWrapperWithPath (Eq (MOCK_SCHEMA_NAME),
2225 Eq (MOCK_GSCHEMA_PATH),
2226 _)).WillOnce (Return (mockMockPluginWrapper));
2227 EXPECT_CALL (*gmockWrapper, connectToChangedSignal (_, stubBackend.get ()));
2228
2229
2230 boost::shared_ptr <GVariant> pluginsWithSetKeysVariantEmpty (GetEmptyPluginsWithSetKeys ());
2231
2232 /* Should now get the value of plugins-with-set-keys from
2233 * mockCurrentProfileSettings */
2234 EXPECT_CALL (*gmockCurrentProfileSettings, getValue (Eq (PLUGINS_WITH_SET_KEYS)))
2235 .WillOnce (Return (g_variant_ref (pluginsWithSetKeysVariantEmpty.get ())));
2236
2237 /* Should acknowledge that we wrote to this schema */
2238 EXPECT_CALL (*gmockCurrentProfileSettings, setValue (Eq (PLUGINS_WITH_SET_KEYS),
2239 _))
2240 .WillOnce (WithArgs <1> (Invoke (g_variant_unref)));
2241
2242 CCSGSettingsWrapper *wrapper = ccsGSettingsGetSettingsObjectForPluginWithPath (stubBackend.get (),
2243 MOCK_PLUGIN_NAME.c_str (),
2244 MOCK_GSCHEMA_PATH.c_str (),
2245 mockContext.get ());
2246
2247 EXPECT_CALL (*gmockWrapper, getSchemaName ()).WillOnce (Return (MOCK_SCHEMA_NAME.c_str ()));
2248
2249 /* Shouldn't be called again */
2250 EXPECT_CALL (*gmockWrapperFactory, newGSettingsWrapperWithPath (_, _, _)).Times (0);
2251
2252 wrapper = ccsGSettingsGetSettingsObjectForPluginWithPath (stubBackend.get (),
2253 MOCK_PLUGIN_NAME.c_str (),
2254 MOCK_GSCHEMA_PATH.c_str (),
2255 mockContext.get ());
2256
2257 /* It should return the cached one */
2258 EXPECT_EQ (mockMockPluginWrapper, wrapper);
2259}
20202260
=== modified file 'compizconfig/integration/gnome/gsettings/CMakeLists.txt'
--- compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-09-25 08:17:14 +0000
+++ compizconfig/integration/gnome/gsettings/CMakeLists.txt 2012-10-12 01:30:30 +0000
@@ -37,12 +37,21 @@
37 ${CMAKE_CURRENT_SOURCE_DIR}/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c)37 ${CMAKE_CURRENT_SOURCE_DIR}/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c)
3838
39 target_link_libraries (compizconfig_gnome_integration_gsettings_setting_factory39 target_link_libraries (compizconfig_gnome_integration_gsettings_setting_factory
40 compizconfig_gsettings_wrapper_factory_interface
40 compizconfig_gnome_integration_constants41 compizconfig_gnome_integration_constants
41 compizconfig_gnome_integrated_setting42 compizconfig_gnome_integrated_setting
42 compizconfig_gnome_integration_gsettings_integrated_setting43 compizconfig_gnome_integration_gsettings_integrated_setting
43 compizconfig44 compizconfig
44 compizconfig_gsettings_util45 compizconfig_gsettings_util
45 ${COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATIONLIBRARIES})46 ${COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_LIBRARIES})
47
48 add_library (compizconfig_gnome_integration_gsettings_wrapper_factory STATIC
49 ${CMAKE_CURRENT_SOURCE_DIR}/src/ccs_gnome_integration_gsettings_wrapper_factory.c)
50
51 target_link_libraries (compizconfig_gnome_integration_gsettings_setting_factory
52 compizconfig_gsettings_wrapper_factory_interface
53 compizconfig
54 ${COMPIZCONFIG_GNOME_GSETTINGS_INTEGRATION_LIBRARIES})
4655
47 find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas)56 find_program (GLIB_COMPILE_SCHEMAS glib-compile-schemas)
4857
4958
=== removed file 'compizconfig/integration/gnome/gsettings/include/ccs_gnome_gsettings_fwd.h'
--- compizconfig/integration/gnome/gsettings/include/ccs_gnome_gsettings_fwd.h 2012-10-06 16:11:05 +0000
+++ compizconfig/integration/gnome/gsettings/include/ccs_gnome_gsettings_fwd.h 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
1#ifndef _CCS_GNOME_INTEGRATION_GSETTINGS_FWD_H
2#define _CCS_GNOME_INTEGRATION_GSETTINGS_FWD_H
3
4#include <ccs-defs.h>
5
6COMPIZCONFIG_BEGIN_DECLS
7
8typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactory CCSGNOMEIntegrationGSettingsWrapperFactory;
9
10COMPIZCONFIG_END_DECLS
11
12#endif
130
=== modified file 'compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h'
--- compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h 2012-10-06 16:11:05 +0000
+++ compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h 2012-10-12 01:30:30 +0000
@@ -1,41 +1,14 @@
1#ifndef _CCS_GNOME_GCONF_INTEGRATED_SETTING_FACTORY_H1#ifndef _CCS_GNOME_GSETTINGS_INTEGRATED_SETTING_FACTORY_H
2#define _CCS_GNOME_GCONF_INTEGRATED_SETTING_FACTORY_H2#define _CCS_GNOME_GSETTINGS_INTEGRATED_SETTING_FACTORY_H
33
4#include <ccs-defs.h>4#include <ccs-defs.h>
5#include <ccs-fwd.h>5#include <ccs-fwd.h>
6#include <ccs_gnome_fwd.h>6#include <ccs_gnome_fwd.h>
7#include <ccs_gnome_gsettings_fwd.h>7#include <ccs_gsettings_backend_fwd.h>
8#include <gio/gio.h>8#include <gio/gio.h>
99
10COMPIZCONFIG_BEGIN_DECLS10COMPIZCONFIG_BEGIN_DECLS
1111
12typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactoryInterface CCSGNOMEIntegrationGSettingsWrapperFactoryInterface;
13
14typedef void (*CCSGNOMEIntegrationGSettingsChangedCallback) (GSettings *, gchar *, gpointer);
15
16typedef CCSGSettingsWrapper * (*CCSGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper) (CCSGNOMEIntegrationGSettingsWrapperFactory *,
17 const gchar *schema,
18 CCSGNOMEIntegrationGSettingsChangedCallback callback,
19 CCSGNOMEValueChangeData *data,
20 CCSObjectAllocationInterface *ai);
21
22struct _CCSGNOMEIntegrationGSettingsWrapperFactoryInterface
23{
24 CCSGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper newGSettingsWrapper;
25};
26
27/**
28 * @brief The _CCSGNOMEIntegrationGSettingsWrapperFactory struct
29 *
30 * Will create new CCSGSettingsIntegratedSetting objects on demand
31 */
32struct _CCSGNOMEIntegrationGSettingsWrapperFactory
33{
34 CCSObject object;
35};
36
37unsigned int ccsCCSGNOMEIntegrationGSettingsWrapperFactoryInterfaceGetType ();
38
39/**12/**
40 * @brief ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS13 * @brief ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS
41 * @param key the old style gnome key to translate14 * @param key the old style gnome key to translate
@@ -47,22 +20,25 @@
47char *20char *
48ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key);21ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key);
4922
50CCSGSettingsWrapper *23/**
51ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory,24 * @brief ccsGSettingsIntegratedSettingsChangeCallback
52 const gchar *schemaName,25 * @return callback for settings change data
53 CCSGNOMEIntegrationGSettingsChangedCallback callback,26 *
54 CCSGNOMEValueChangeData *data,27 * This returns the default callback used for settings changes
55 CCSObjectAllocationInterface *ai);28 *
5629 * TODO: This API doesn't make a whole lot of sense, but we need
57CCSGNOMEIntegrationGSettingsWrapperFactory *30 * it if we want to inject CCSGSettingsWrapperFactory into
58ccsGNOMEIntegrationGSettingsWrapperDefaultImplNew (CCSObjectAllocationInterface *ai);31 * ccsGSettingsIntegratedSettingFactoryNew.
5932 *
60void33 * The return type is GCallback to hide the details of this function
61ccsGNOMEIntegrationGSettingsWrapperDefaultImplFree (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory);34 * from callers
35 */
36GCallback
37ccsGSettingsIntegratedSettingsChangeCallback ();
6238
63CCSIntegratedSettingFactory *39CCSIntegratedSettingFactory *
64ccsGSettingsIntegratedSettingFactoryNew (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory,40ccsGSettingsIntegratedSettingFactoryNew (CCSGSettingsWrapperFactory *wrapperFactory,
65 CCSGNOMEValueChangeData *data,41 CCSGNOMEValueChangeData *data,
66 CCSObjectAllocationInterface *ai);42 CCSObjectAllocationInterface *ai);
6743
68COMPIZCONFIG_END_DECLS44COMPIZCONFIG_END_DECLS
6945
=== added file 'compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_wrapper_factory.h'
--- compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_wrapper_factory.h 1970-01-01 00:00:00 +0000
+++ compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_wrapper_factory.h 2012-10-12 01:30:30 +0000
@@ -0,0 +1,44 @@
1/**
2 *
3 * GSettings libcompizconfig backend
4 *
5 * ccs_gsettings_wrapper_factory.h
6 *
7 * Copyright (c) 2012 Canonical Ltd
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * Authored By:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 *
22 **/
23#ifndef _CCS_GNOME_INTEGRATION_GSETTINGS_WRAPPER_FACTORY_H
24#define _CCS_GNOME_INTEGRATION_GSETTINGS_WRAPPER_FACTORY_H
25
26#include <ccs-defs.h>
27
28COMPIZCONFIG_BEGIN_DECLS
29
30#include <gio/gio.h>
31
32#include <ccs-fwd.h>
33#include <ccs_gsettings_backend_fwd.h>
34#include <ccs_gnome_fwd.h>
35
36CCSGSettingsWrapperFactory *
37ccsGNOMEIntegrationGSettingsWrapperFactoryDefaultImplNew (CCSObjectAllocationInterface *ai,
38 CCSGSettingsWrapperFactory *factory,
39 GCallback callback,
40 CCSGNOMEValueChangeData *data);
41
42COMPIZCONFIG_END_DECLS
43
44#endif
045
=== modified file 'compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c'
--- compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c 2012-09-25 06:12:24 +0000
+++ compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c 2012-10-12 01:30:30 +0000
@@ -11,6 +11,7 @@
11#include <ccs_gsettings_interface_wrapper.h>11#include <ccs_gsettings_interface_wrapper.h>
1212
13#include <gsettings_util.h>13#include <gsettings_util.h>
14#include <ccs_gsettings_wrapper_factory_interface.h>
1415
15#include "ccs_gnome_integration.h"16#include "ccs_gnome_integration.h"
16#include "ccs_gnome_integrated_setting.h"17#include "ccs_gnome_integrated_setting.h"
@@ -19,8 +20,6 @@
19#include "ccs_gnome_integration_gsettings_integrated_setting.h"20#include "ccs_gnome_integration_gsettings_integrated_setting.h"
20#include "ccs_gnome_integration_gsettings_integrated_setting_factory.h"21#include "ccs_gnome_integration_gsettings_integrated_setting_factory.h"
2122
22INTERFACE_TYPE (CCSGNOMEIntegrationGSettingsWrapperFactoryInterface);
23
24char *23char *
25ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key)24ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key)
26{25{
@@ -45,83 +44,11 @@
45 return newKey;44 return newKey;
46}45}
4746
48CCSGSettingsWrapper *
49ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory,
50 const gchar *schemaName,
51 CCSGNOMEIntegrationGSettingsChangedCallback callback,
52 CCSGNOMEValueChangeData *data,
53 CCSObjectAllocationInterface *ai)
54{
55 return (*(GET_INTERFACE (CCSGNOMEIntegrationGSettingsWrapperFactoryInterface, factory))->newGSettingsWrapper) (factory, schemaName, callback, data, ai);
56}
57
58/* CCSGNOMEIntegrationGSettingsWrapperFactory implementation */
59typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate;
60struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate
61{
62};
63
64CCSGSettingsWrapper *
65ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapperDefault (CCSGNOMEIntegrationGSettingsWrapperFactory *factory,
66 const gchar *schemaName,
67 CCSGNOMEIntegrationGSettingsChangedCallback callback,
68 CCSGNOMEValueChangeData *data,
69 CCSObjectAllocationInterface *ai)
70{
71 CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperNewForSchema (schemaName, ai);
72 ccsGSettingsWrapperConnectToChangedSignal (wrapper, (GCallback) callback, data);
73
74 return wrapper;
75}
76
77const CCSGNOMEIntegrationGSettingsWrapperFactoryInterface ccsGNOMEIntegrationGSettingsWrapperFactoryInterface =
78{
79 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapperDefault
80};
81
82void
83ccsGNOMEIntegrationGSettingsWrapperDefaultImplFree (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory)
84{
85 ccsObjectFinalize (wrapperFactory);
86 (*wrapperFactory->object.object_allocation->free_) (wrapperFactory->object.object_allocation->allocator,
87 wrapperFactory);
88}
89
90CCSGNOMEIntegrationGSettingsWrapperFactory *
91ccsGNOMEIntegrationGSettingsWrapperDefaultImplNew (CCSObjectAllocationInterface *ai)
92{
93 CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGNOMEIntegrationGSettingsWrapperFactory));
94
95 if (!wrapperFactory)
96 return NULL;
97
98 CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate));
99
100 if (!priv)
101 {
102 (*ai->free_) (ai->allocator, wrapperFactory);
103 return NULL;
104 }
105
106 ccsObjectInit (wrapperFactory, ai);
107 ccsObjectAddInterface (wrapperFactory, (const CCSInterface *) &ccsGNOMEIntegrationGSettingsWrapperFactoryInterface, GET_INTERFACE_TYPE (CCSGNOMEIntegrationGSettingsWrapperFactoryInterface));
108 ccsObjectSetPrivate (wrapperFactory, (CCSPrivate *) priv);
109
110 return wrapperFactory;
111}
112
113void
114ccsGNOMEIntegrationGSettingsWrapperDefaultImpl (CCSGNOMEIntegrationGSettingsWrapperFactory *factory)
115{
116 ccsObjectFinalize (factory);
117 (*factory->object.object_allocation->free_) (factory->object.object_allocation->allocator, factory);
118}
119
120typedef struct _CCSGSettingsIntegratedSettingFactoryPrivate CCSGSettingsIntegratedSettingFactoryPrivate;47typedef struct _CCSGSettingsIntegratedSettingFactoryPrivate CCSGSettingsIntegratedSettingFactoryPrivate;
12148
122struct _CCSGSettingsIntegratedSettingFactoryPrivate49struct _CCSGSettingsIntegratedSettingFactoryPrivate
123{50{
124 CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory;51 CCSGSettingsWrapperFactory *wrapperFactory;
125 GHashTable *pluginsToSettingsGSettingsWrapperQuarksHashTable;52 GHashTable *pluginsToSettingsGSettingsWrapperQuarksHashTable;
126 GHashTable *quarksToGSettingsWrappersHashTable;53 GHashTable *quarksToGSettingsWrappersHashTable;
127 GHashTable *pluginsToSettingsSpecialTypesHashTable;54 GHashTable *pluginsToSettingsSpecialTypesHashTable;
@@ -153,6 +80,12 @@
15380
154}81}
15582
83GCallback
84ccsGSettingsIntegratedSettingsChangeCallback ()
85{
86 return (GCallback) gnomeGSettingsValueChanged;
87}
88
156static CCSIntegratedSetting *89static CCSIntegratedSetting *
157createNewGSettingsIntegratedSetting (CCSGSettingsWrapper *wrapper,90createNewGSettingsIntegratedSetting (CCSGSettingsWrapper *wrapper,
158 const char *gnomeName,91 const char *gnomeName,
@@ -193,52 +126,41 @@
193}126}
194127
195static GHashTable *128static GHashTable *
196initializeGSettingsWrappers (CCSGNOMEIntegrationGSettingsWrapperFactory *factory,129initializeGSettingsWrappers (CCSGSettingsWrapperFactory *factory)
197 CCSGNOMEValueChangeData *data)
198{130{
199 const CCSGSettingsWrapperIntegratedSchemasQuarks *quarks = ccsGNOMEGSettingsWrapperQuarks ();131 const CCSGSettingsWrapperIntegratedSchemasQuarks *quarks = ccsGNOMEGSettingsWrapperQuarks ();
200 GHashTable *quarksToGSettingsWrappers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, ccsGSettingsWrapperUnrefWrapper);132 GHashTable *quarksToGSettingsWrappers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, ccsGSettingsWrapperUnrefWrapper);
201133
202 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED),134 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED),
203 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory,135 ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory,
204 g_quark_to_string (quarks->ORG_COMPIZ_INTEGRATED),136 g_quark_to_string (quarks->ORG_COMPIZ_INTEGRATED),
205 gnomeGSettingsValueChanged,137 factory->object.object_allocation));
206 data,
207 factory->object.object_allocation));
208 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS),138 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS),
209 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory,139 ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory,
210 g_quark_to_string (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS),140 g_quark_to_string (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS),
211 gnomeGSettingsValueChanged,141 factory->object.object_allocation));
212 data,
213 factory->object.object_allocation));
214 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES),142 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES),
215 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory,143 ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory,
216 g_quark_to_string (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES),144 g_quark_to_string (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES),
217 gnomeGSettingsValueChanged,145 factory->object.object_allocation));
218 data,
219 factory->object.object_allocation));
220 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL),146 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL),
221 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory,147 ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory,
222 g_quark_to_string (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL),148 g_quark_to_string (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL),
223 gnomeGSettingsValueChanged,149 factory->object.object_allocation));
224 data,
225 factory->object.object_allocation));
226 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS),150 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS),
227 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory,151 ccsGSettingsWrapperFactoryNewGSettingsWrapper (factory,
228 g_quark_to_string (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS),152 g_quark_to_string (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS),
229 gnomeGSettingsValueChanged,153 factory->object.object_allocation));
230 data,
231 factory->object.object_allocation));
232154
233 return quarksToGSettingsWrappers;155 return quarksToGSettingsWrappers;
234}156}
235157
236CCSIntegratedSetting *158CCSIntegratedSetting *
237ccsGSettingsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType (CCSIntegratedSettingFactory *factory,159ccsGSettingsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType (CCSIntegratedSettingFactory *factory,
238 CCSIntegration *integration,160 CCSIntegration *integration,
239 const char *pluginName,161 const char *pluginName,
240 const char *settingName,162 const char *settingName,
241 CCSSettingType type)163 CCSSettingType type)
242{164{
243 CCSGSettingsIntegratedSettingFactoryPrivate *priv = (CCSGSettingsIntegratedSettingFactoryPrivate *) ccsObjectGetPrivate (factory);165 CCSGSettingsIntegratedSettingFactoryPrivate *priv = (CCSGSettingsIntegratedSettingFactoryPrivate *) ccsObjectGetPrivate (factory);
244 GHashTable *settingsGSettingsWrapperQuarksHashTable = g_hash_table_lookup (priv->pluginsToSettingsGSettingsWrapperQuarksHashTable, pluginName);166 GHashTable *settingsGSettingsWrapperQuarksHashTable = g_hash_table_lookup (priv->pluginsToSettingsGSettingsWrapperQuarksHashTable, pluginName);
@@ -246,7 +168,7 @@
246 GHashTable *settingsSettingNameGNOMENameHashTable = g_hash_table_lookup (priv->pluginsToSettingNameGNOMENameHashTable, pluginName);168 GHashTable *settingsSettingNameGNOMENameHashTable = g_hash_table_lookup (priv->pluginsToSettingNameGNOMENameHashTable, pluginName);
247169
248 if (!priv->quarksToGSettingsWrappersHashTable)170 if (!priv->quarksToGSettingsWrappersHashTable)
249 priv->quarksToGSettingsWrappersHashTable = initializeGSettingsWrappers (priv->wrapperFactory, priv->valueChangeData);171 priv->quarksToGSettingsWrappersHashTable = initializeGSettingsWrappers (priv->wrapperFactory);
250172
251 if (settingsGSettingsWrapperQuarksHashTable &&173 if (settingsGSettingsWrapperQuarksHashTable &&
252 settingsSpecialTypesHashTable &&174 settingsSpecialTypesHashTable &&
@@ -258,12 +180,12 @@
258 const gchar *integratedName = g_hash_table_lookup (settingsSettingNameGNOMENameHashTable, settingName);180 const gchar *integratedName = g_hash_table_lookup (settingsSettingNameGNOMENameHashTable, settingName);
259181
260 return createNewGSettingsIntegratedSetting (wrapper,182 return createNewGSettingsIntegratedSetting (wrapper,
261 integratedName,183 integratedName,
262 pluginName,184 pluginName,
263 settingName,185 settingName,
264 type,186 type,
265 specialType,187 specialType,
266 factory->object.object_allocation);188 factory->object.object_allocation);
267 }189 }
268190
269191
@@ -287,13 +209,12 @@
287 if (priv->pluginsToSettingNameGNOMENameHashTable)209 if (priv->pluginsToSettingNameGNOMENameHashTable)
288 g_hash_table_unref (priv->pluginsToSettingNameGNOMENameHashTable);210 g_hash_table_unref (priv->pluginsToSettingNameGNOMENameHashTable);
289211
290 ccsGNOMEIntegrationGSettingsWrapperDefaultImplFree (priv->wrapperFactory);212 ccsGSettingsWrapperFactoryUnref (priv->wrapperFactory);
291213
292 ccsObjectFinalize (factory);214 ccsObjectFinalize (factory);
293 (*factory->object.object_allocation->free_) (factory->object.object_allocation->allocator, factory);215 (*factory->object.object_allocation->free_) (factory->object.object_allocation->allocator, factory);
294}216}
295217
296
297const CCSIntegratedSettingFactoryInterface ccsGSettingsIntegratedSettingFactoryInterface =218const CCSIntegratedSettingFactoryInterface ccsGSettingsIntegratedSettingFactoryInterface =
298{219{
299 ccsGSettingsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType,220 ccsGSettingsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType,
@@ -301,9 +222,9 @@
301};222};
302223
303CCSIntegratedSettingFactory *224CCSIntegratedSettingFactory *
304ccsGSettingsIntegratedSettingFactoryNew (CCSGNOMEIntegrationGSettingsWrapperFactory *wrapperFactory,225ccsGSettingsIntegratedSettingFactoryNew (CCSGSettingsWrapperFactory *wrapperFactory,
305 CCSGNOMEValueChangeData *valueChangeData,226 CCSGNOMEValueChangeData *valueChangeData,
306 CCSObjectAllocationInterface *ai)227 CCSObjectAllocationInterface *ai)
307{228{
308 CCSIntegratedSettingFactory *factory = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSettingFactory));229 CCSIntegratedSettingFactory *factory = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSIntegratedSettingFactory));
309230
@@ -318,6 +239,8 @@
318 return NULL;239 return NULL;
319 }240 }
320241
242 ccsGSettingsWrapperFactoryRef (wrapperFactory);
243
321 priv->wrapperFactory = wrapperFactory;244 priv->wrapperFactory = wrapperFactory;
322 priv->pluginsToSettingsGSettingsWrapperQuarksHashTable = ccsGNOMEGSettingsIntegrationPopulateSettingNameToIntegratedSchemasQuarksHashTable ();245 priv->pluginsToSettingsGSettingsWrapperQuarksHashTable = ccsGNOMEGSettingsIntegrationPopulateSettingNameToIntegratedSchemasQuarksHashTable ();
323 priv->pluginsToSettingsSpecialTypesHashTable = ccsGNOMEIntegrationPopulateSpecialTypesHashTables ();246 priv->pluginsToSettingsSpecialTypesHashTable = ccsGNOMEIntegrationPopulateSpecialTypesHashTables ();
324247
=== added file 'compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_wrapper_factory.c'
--- compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_wrapper_factory.c 1970-01-01 00:00:00 +0000
+++ compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_wrapper_factory.c 2012-10-12 01:30:30 +0000
@@ -0,0 +1,135 @@
1/**
2 *
3 * GSettings libcompizconfig backend
4 *
5 * ccs_gnome_integration_gsettings_wrapper_factory.c
6 *
7 * Copyright (c) 2012 Canonical Ltd
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * Authored By:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 *
22 **/
23#include <ccs-object.h>
24#include "ccs_gsettings_wrapper_factory.h"
25#include "ccs_gsettings_wrapper_factory_interface.h"
26#include "ccs_gsettings_interface.h"
27#include "ccs_gsettings_interface_wrapper.h"
28#include "ccs_gnome_integration_gsettings_wrapper_factory.h"
29
30/* CCSGSettingsWrapperFactory implementation */
31typedef struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate;
32struct _CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate
33{
34 CCSGSettingsWrapperFactory *wrapperFactory;
35 GCallback callback;
36
37 /* This is expected to stay alive during the
38 * lifetime of this object */
39 CCSGNOMEValueChangeData *data;
40};
41
42static void
43ccsGNOMEIntegrationGSettingsWrapperFree (CCSGSettingsWrapperFactory *wrapperFactory)
44{
45 CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv =
46 GET_PRIVATE (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate, wrapperFactory);
47
48 ccsGSettingsWrapperFactoryUnref (priv->wrapperFactory);
49
50 ccsObjectFinalize (wrapperFactory);
51 (*wrapperFactory->object.object_allocation->free_) (wrapperFactory->object.object_allocation->allocator,
52 wrapperFactory);
53}
54
55static void
56connectWrapperToChangedSignal (CCSGSettingsWrapper *wrapper,
57 CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv)
58{
59 ccsGSettingsWrapperConnectToChangedSignal (wrapper, priv->callback, priv->data);
60}
61
62static CCSGSettingsWrapper *
63ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGSettingsWrapperFactory *factory,
64 const gchar *schemaName,
65 CCSObjectAllocationInterface *ai)
66{
67 CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv =
68 GET_PRIVATE (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate, factory);
69 CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperFactoryNewGSettingsWrapper (priv->wrapperFactory,
70 schemaName,
71 factory->object.object_allocation);
72
73 connectWrapperToChangedSignal (wrapper, priv);
74
75 return wrapper;
76}
77
78static CCSGSettingsWrapper *
79ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapperWithPath (CCSGSettingsWrapperFactory *factory,
80 const gchar *schemaName,
81 const gchar *path,
82 CCSObjectAllocationInterface *ai)
83{
84 CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv =
85 GET_PRIVATE (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate, factory);
86 CCSGSettingsWrapper *wrapper = ccsGSettingsWrapperFactoryNewGSettingsWrapperWithPath (priv->wrapperFactory,
87 schemaName,
88 path,
89 factory->object.object_allocation);
90
91 connectWrapperToChangedSignal (wrapper, priv);
92
93 return wrapper;
94}
95
96const CCSGSettingsWrapperFactoryInterface ccsGNOMEIntegrationGSettingsWrapperFactoryInterface =
97{
98 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper,
99 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapperWithPath,
100 ccsGNOMEIntegrationGSettingsWrapperFree
101};
102
103CCSGSettingsWrapperFactory *
104ccsGNOMEIntegrationGSettingsWrapperFactoryDefaultImplNew (CCSObjectAllocationInterface *ai,
105 CCSGSettingsWrapperFactory *factory,
106 GCallback callback,
107 CCSGNOMEValueChangeData *data)
108{
109 CCSGSettingsWrapperFactory *wrapperFactory = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGSettingsWrapperFactory));
110
111 if (!wrapperFactory)
112 return NULL;
113
114 CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate *priv = (*ai->calloc_) (ai->allocator, 1, sizeof (CCSGNOMEIntegrationGSettingsWrapperFactoryPrivate));
115
116 if (!priv)
117 {
118 (*ai->free_) (ai->allocator, wrapperFactory);
119 return NULL;
120 }
121
122 ccsGSettingsWrapperFactoryRef (factory);
123
124 priv->wrapperFactory = factory;
125 priv->callback = callback;
126 priv->data = data;
127
128 ccsObjectInit (wrapperFactory, ai);
129 ccsObjectAddInterface (wrapperFactory, (const CCSInterface *) &ccsGNOMEIntegrationGSettingsWrapperFactoryInterface, GET_INTERFACE_TYPE (CCSGSettingsWrapperFactoryInterface));
130 ccsObjectSetPrivate (wrapperFactory, (CCSPrivate *) priv);
131
132 ccsGSettingsWrapperFactoryRef (wrapperFactory);
133
134 return wrapperFactory;
135}

Subscribers

People subscribed via source and target branches