Merge lp:~compiz-team/compiz/compiz.fix_1050796 into lp:compiz/0.9.8

Proposed by Sam Spilsbury
Status: Merged
Approved by: Daniel van Vugt
Approved revision: 3391
Merged at revision: 3393
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1050796
Merge into: lp:compiz/0.9.8
Prerequisite: lp:~compiz-team/compiz/compiz.fix_1042041
Diff against target: 991 lines (+463/-160)
12 files modified
compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting.h (+11/-0)
compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h (+11/-0)
compizconfig/integration/gnome/gsettings/org.compiz.integrated.gschema.xml (+0/-21)
compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c (+26/-2)
compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c (+37/-1)
compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h (+2/-0)
compizconfig/integration/gnome/src/ccs_gnome_integration.c (+97/-30)
compizconfig/integration/gnome/src/ccs_gnome_integration_constants.c (+13/-9)
compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c (+0/-2)
compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp (+194/-48)
compizconfig/libcompizconfig/include/ccs.h (+6/-0)
compizconfig/libcompizconfig/src/main.c (+66/-47)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1050796
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
jenkins (community) continuous-integration Needs Fixing
Review via email: mp+126270@code.launchpad.net

This proposal supersedes a proposal from 2012-09-25.

Commit message

Remove some options from org.compiz.integrated and integrate them properly - adding special cases for options where upstream gnome forgot to change the key type.
(LP: #1050796)

Description of the change

Remove some options from org.compiz.integrated and integrate them properly - adding special cases for options where upstream gnome forgot to change the key type.

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
jenkins (martin-mrazik+qa) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Looks and works fine to me.

A couple of potential issues in ccsCopyValue:
  1. This is not C: 872 + if (!value)
  2. Unreachable code: 918 + return NULL;

But when and if those become a problem, the compiler will tell you.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

The prerequisite lp:~compiz-team/compiz/compiz.fix_1042041 has not yet been merged into lp:compiz.

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
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Still approved as per previous comments.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting.h'
--- compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting.h 2012-08-17 07:33:02 +0000
+++ compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting.h 2012-09-25 15:17:24 +0000
@@ -26,6 +26,17 @@
26 CCSGSettingsWrapper *wrapper,26 CCSGSettingsWrapper *wrapper,
27 CCSObjectAllocationInterface *ai);27 CCSObjectAllocationInterface *ai);
2828
29/**
30 * @brief ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings
31 * @param key the old style gnome key to translate
32 * @return new-style key. Caller should free
33 *
34 * This translates old style keys (eg foo_bar) to new style keys
35 * foo-bar and special cases a few keys
36 */
37char *
38ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings (const char *key);
39
29COMPIZCONFIG_END_DECLS40COMPIZCONFIG_END_DECLS
3041
31#endif42#endif
3243
=== 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-08-17 02:20:20 +0000
+++ compizconfig/integration/gnome/gsettings/include/ccs_gnome_integration_gsettings_integrated_setting_factory.h 2012-09-25 15:17:24 +0000
@@ -39,6 +39,17 @@
3939
40unsigned int ccsCCSGNOMEIntegrationGSettingsWrapperFactoryInterfaceGetType ();40unsigned int ccsCCSGNOMEIntegrationGSettingsWrapperFactoryInterfaceGetType ();
4141
42/**
43 * @brief ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS
44 * @param key the old style gnome key to translate
45 * @return new-style key. Caller should free
46 *
47 * This translates new style keys (eg foo-bar) to old style keys
48 * foo_bar and special cases a few keys
49 */
50char *
51ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key);
52
42CCSGSettingsWrapper *53CCSGSettingsWrapper *
43ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory,54ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory,
44 const gchar *schemaName,55 const gchar *schemaName,
4556
=== modified file 'compizconfig/integration/gnome/gsettings/org.compiz.integrated.gschema.xml'
--- compizconfig/integration/gnome/gsettings/org.compiz.integrated.gschema.xml 2012-09-05 23:26:55 +0000
+++ compizconfig/integration/gnome/gsettings/org.compiz.integrated.gschema.xml 2012-09-25 15:17:24 +0000
@@ -4,18 +4,12 @@
4 <key type="b" name="display-all-workspaces">4 <key type="b" name="display-all-workspaces">
5 <default>true</default>5 <default>true</default>
6 </key>6 </key>
7 <key type="s" name="exec">
8 <default>"gnome-terminal"</default>
9 </key>
10 <key type="s" name="command-window-screenshot">7 <key type="s" name="command-window-screenshot">
11 <default>"gnome-screenshot -w"</default>8 <default>"gnome-screenshot -w"</default>
12 </key>9 </key>
13 <key type="s" name="command-screenshot">10 <key type="s" name="command-screenshot">
14 <default>"gnome-screenshot"</default>11 <default>"gnome-screenshot"</default>
15 </key>12 </key>
16 <key type="s" name="command-terminal">
17 <default>"gnome-terminal"</default>
18 </key>
19 <key type="as" name="run-command-12">13 <key type="as" name="run-command-12">
20 <default>["Disabled"]</default>14 <default>["Disabled"]</default>
21 </key>15 </key>
@@ -88,21 +82,6 @@
88 <key type="s" name="command-1">82 <key type="s" name="command-1">
89 <default>""</default>83 <default>""</default>
90 </key>84 </key>
91 <key type="as" name="run-command-terminal">
92 <default>["&lt;Control&gt;&lt;Alt&gt;t"]</default>
93 </key>
94 <key type="as" name="run-command-window-screenshot">
95 <default>["&lt;Alt&gt;Print"]</default>
96 </key>
97 <key type="as" name="run-command-screenshot">
98 <default>["Print"]</default>
99 </key>
100 <key type="as" name="panel-main-menu">
101 <default>["&lt;Alt&gt;F1"]</default>
102 </key>
103 <key type="as" name="panel-run-dialog">
104 <default>["&lt;Alt&gt;F2"]</default>
105 </key>
106 <key type="as" name="show-hud">85 <key type="as" name="show-hud">
107 <default>["&lt;Alt&gt;"]</default>86 <default>["&lt;Alt&gt;"]</default>
108 </key>87 </key>
10988
=== modified file 'compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c'
--- compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c 2012-09-24 10:44:29 +0000
+++ compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting.c 2012-09-25 15:17:24 +0000
@@ -24,6 +24,30 @@
24 CCSGSettingsWrapper *wrapper;24 CCSGSettingsWrapper *wrapper;
25};25};
2626
27char *
28ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings (const char *key)
29{
30 char *newKey = translateKeyForGSettings (key);
31
32 if (g_strcmp0 (newKey, "run-command-screenshot") == 0)
33 {
34 free (newKey);
35 newKey = strdup ("screenshot");
36 }
37 else if (g_strcmp0 (newKey, "run-command-window-screenshot") == 0)
38 {
39 free (newKey);
40 newKey = strdup ("window-screenshot");
41 }
42 else if (g_strcmp0 (newKey, "run-command-terminal") == 0)
43 {
44 free (newKey);
45 newKey = strdup ("terminal");
46 }
47
48 return newKey;
49}
50
27SpecialOptionType51SpecialOptionType
28ccsGSettingsIntegratedSettingGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *setting)52ccsGSettingsIntegratedSettingGetSpecialOptionType (CCSGNOMEIntegratedSettingInfo *setting)
29{53{
@@ -46,7 +70,7 @@
46 CCSGSettingsIntegratedSettingPrivate *priv = (CCSGSettingsIntegratedSettingPrivate *) ccsObjectGetPrivate (setting);70 CCSGSettingsIntegratedSettingPrivate *priv = (CCSGSettingsIntegratedSettingPrivate *) ccsObjectGetPrivate (setting);
47 CCSSettingValue *v = calloc (1, sizeof (CCSSettingValue));71 CCSSettingValue *v = calloc (1, sizeof (CCSSettingValue));
48 const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting);72 const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting);
49 char *gsettingsTranslatedName = translateKeyForGSettings (gnomeKeyName);73 char *gsettingsTranslatedName = ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings (gnomeKeyName);
5074
51 v->isListChild = FALSE;75 v->isListChild = FALSE;
52 v->parent = NULL;76 v->parent = NULL;
@@ -137,7 +161,7 @@
137{161{
138 CCSGSettingsIntegratedSettingPrivate *priv = (CCSGSettingsIntegratedSettingPrivate *) ccsObjectGetPrivate (setting);162 CCSGSettingsIntegratedSettingPrivate *priv = (CCSGSettingsIntegratedSettingPrivate *) ccsObjectGetPrivate (setting);
139 const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting);163 const char *gnomeKeyName = ccsGNOMEIntegratedSettingInfoGetGNOMEName ((CCSGNOMEIntegratedSettingInfo *) setting);
140 char *gsettingsTranslatedName = translateKeyForGSettings (gnomeKeyName);164 char *gsettingsTranslatedName = ccsGSettingsIntegratedSettingsTranslateOldGNOMEKeyForGSettings (gnomeKeyName);
141165
142 GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName);166 GVariant *variant = ccsGSettingsWrapperGetValue (priv->wrapper, gsettingsTranslatedName);
143 const GVariantType *variantType = g_variant_get_type (variant);167 const GVariantType *variantType = g_variant_get_type (variant);
144168
=== 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-08-17 07:33:02 +0000
+++ compizconfig/integration/gnome/gsettings/src/ccs_gnome_integration_gsettings_integrated_setting_factory.c 2012-09-25 15:17:24 +0000
@@ -21,6 +21,30 @@
2121
22INTERFACE_TYPE (CCSGNOMEIntegrationGSettingsWrapperFactoryInterface);22INTERFACE_TYPE (CCSGNOMEIntegrationGSettingsWrapperFactoryInterface);
2323
24char *
25ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (const char *key)
26{
27 char *newKey = translateKeyForCCS (key);
28
29 if (g_strcmp0 (newKey, "screenshot") == 0)
30 {
31 free (newKey);
32 newKey = strdup ("run_command_screenshot");
33 }
34 else if (g_strcmp0 (newKey, "window_screenshot") == 0)
35 {
36 free (newKey);
37 newKey = strdup ("run_command_window_screenshot");
38 }
39 else if (g_strcmp0 (newKey, "terminal") == 0)
40 {
41 free (newKey);
42 newKey = strdup ("run_command_terminal");
43 }
44
45 return newKey;
46}
47
24CCSGSettingsWrapper *48CCSGSettingsWrapper *
25ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory,49ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (CCSGNOMEIntegrationGSettingsWrapperFactory *factory,
26 const gchar *schemaName,50 const gchar *schemaName,
@@ -103,7 +127,7 @@
103 gpointer user_data)127 gpointer user_data)
104{128{
105 CCSGNOMEValueChangeData *data = (CCSGNOMEValueChangeData *) user_data;129 CCSGNOMEValueChangeData *data = (CCSGNOMEValueChangeData *) user_data;
106 char *baseName = translateKeyForCCS (key);130 char *baseName = ccsGSettingsIntegratedSettingsTranslateNewGNOMEKeyForCCS (key);
107131
108 /* We don't care if integration is not enabled */132 /* We don't care if integration is not enabled */
109 if (!ccsGetIntegrationEnabled (data->context))133 if (!ccsGetIntegrationEnabled (data->context))
@@ -185,6 +209,18 @@
185 gnomeGSettingsValueChanged,209 gnomeGSettingsValueChanged,
186 data,210 data,
187 factory->object.object_allocation));211 factory->object.object_allocation));
212 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL),
213 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory,
214 g_quark_to_string (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL),
215 gnomeGSettingsValueChanged,
216 data,
217 factory->object.object_allocation));
218 g_hash_table_insert (quarksToGSettingsWrappers, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS),
219 ccsGNOMEIntegrationGSettingsWrapperFactoryNewGSettingsWrapper (factory,
220 g_quark_to_string (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS),
221 gnomeGSettingsValueChanged,
222 data,
223 factory->object.object_allocation));
188224
189 return quarksToGSettingsWrappers;225 return quarksToGSettingsWrappers;
190}226}
191227
=== modified file 'compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h'
--- compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h 2012-09-23 16:46:19 +0000
+++ compizconfig/integration/gnome/include/ccs_gnome_integration_constants.h 2012-09-25 15:17:24 +0000
@@ -188,6 +188,8 @@
188{188{
189 GQuark ORG_GNOME_DESKTOP_WM_PREFERENCES;189 GQuark ORG_GNOME_DESKTOP_WM_PREFERENCES;
190 GQuark ORG_GNOME_DESKTOP_WM_KEYBINDINGS;190 GQuark ORG_GNOME_DESKTOP_WM_KEYBINDINGS;
191 GQuark ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS;
192 GQuark ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL;
191 GQuark ORG_COMPIZ_INTEGRATED;193 GQuark ORG_COMPIZ_INTEGRATED;
192} CCSGSettingsWrapperIntegratedSchemasQuarks;194} CCSGSettingsWrapperIntegratedSchemasQuarks;
193195
194196
=== modified file 'compizconfig/integration/gnome/src/ccs_gnome_integration.c'
--- compizconfig/integration/gnome/src/ccs_gnome_integration.c 2012-09-24 03:55:38 +0000
+++ compizconfig/integration/gnome/src/ccs_gnome_integration.c 2012-09-25 15:17:24 +0000
@@ -160,6 +160,29 @@
160}160}
161161
162static Bool162static Bool
163ccsGNOMEIntegrationBackendReadISAndSetSettingForType (CCSIntegratedSetting *integratedSetting,
164 CCSSetting *setting,
165 CCSSettingValue **v,
166 CCSSettingType type)
167{
168 *v = ccsIntegratedSettingReadValue (integratedSetting, type);
169
170 if ((*v)->value.asString)
171 {
172 CCSSettingKeyValue key;
173
174 memset (&key, 0, sizeof (CCSSettingKeyValue));
175 if (ccsStringToKeyBinding ((*v)->value.asString, &key))
176 {
177 ccsSetKey (setting, key, TRUE);
178 return TRUE;
179 }
180 }
181
182 return FALSE;
183}
184
185static Bool
163ccsGNOMEIntegrationBackendReadOptionIntoSetting (CCSIntegration *integration,186ccsGNOMEIntegrationBackendReadOptionIntoSetting (CCSIntegration *integration,
164 CCSContext *context,187 CCSContext *context,
165 CCSSetting *setting,188 CCSSetting *setting,
@@ -209,20 +232,11 @@
209 case OptionKey:232 case OptionKey:
210 {233 {
211 type = TypeKey;234 type = TypeKey;
212 v = ccsIntegratedSettingReadValue (integratedSetting, type);235 if (ccsGNOMEIntegrationBackendReadISAndSetSettingForType (integratedSetting,
213236 setting,
214 if (v->value.asString)237 &v,
215 {238 type))
216 CCSSettingKeyValue key;239 ret = TRUE;
217
218 memset (&key, 0, sizeof (CCSSettingKeyValue));
219 ccsGetKey (setting, &key);
220 if (ccsStringToKeyBinding (v->value.asString, &key))
221 {
222 ccsSetKey (setting, key, TRUE);
223 ret = TRUE;
224 }
225 }
226 }240 }
227 break;241 break;
228 case OptionSpecial:242 case OptionSpecial:
@@ -268,6 +282,17 @@
268 ret = TRUE;282 ret = TRUE;
269 }283 }
270 }284 }
285 else if ((strcmp (settingName, "run_command_screenshot_key") == 0 ||
286 strcmp (settingName, "run_command_window_screenshot_key") == 0 ||
287 strcmp (settingName, "run_command_terminal_key") == 0))
288 {
289 type = TypeString;
290 if (ccsGNOMEIntegrationBackendReadISAndSetSettingForType (integratedSetting,
291 setting,
292 &v,
293 type))
294 ret = TRUE;
295 }
271 else if (((strcmp (settingName, "initiate_button") == 0) &&296 else if (((strcmp (settingName, "initiate_button") == 0) &&
272 ((strcmp (pluginName, "move") == 0) ||297 ((strcmp (pluginName, "move") == 0) ||
273 (strcmp (pluginName, "resize") == 0))) ||298 (strcmp (pluginName, "resize") == 0))) ||
@@ -373,6 +398,29 @@
373 }398 }
374}399}
375400
401static Bool
402ccsGNOMEIntegrationBackendKeyValueToStringValue (CCSSettingValue *keyValue,
403 CCSSettingValue *stringValue)
404{
405 char *newValue;
406
407 newValue = ccsKeyBindingToString (&keyValue->value.asKey);
408 if (newValue)
409 {
410 if (strcmp (newValue, "Disabled") == 0)
411 {
412 /* Metacity doesn't like "Disabled", it wants "disabled" */
413 newValue[0] = 'd';
414 }
415
416 stringValue->value.asString = newValue;
417
418 return TRUE;
419 }
420
421 return FALSE;
422}
423
376static void424static void
377ccsGNOMEIntegrationBackendWriteOptionFromSetting (CCSIntegration *integration,425ccsGNOMEIntegrationBackendWriteOptionFromSetting (CCSIntegration *integration,
378 CCSContext *context,426 CCSContext *context,
@@ -393,7 +441,14 @@
393 /* Do not allow recursing back into writeIntegratedSetting */441 /* Do not allow recursing back into writeIntegratedSetting */
394 ccsIntegrationDisallowIntegratedWrites (integration);442 ccsIntegrationDisallowIntegratedWrites (integration);
395443
396 CCSSettingValue *v = ccsSettingGetValue (setting);444 CCSSettingType sType = ccsSettingGetType (setting);
445 CCSSettingInfo *sInfo = ccsSettingGetInfo (setting);
446
447 CCSSettingValue *vSetting = ccsSettingGetValue (setting);
448 CCSSettingValue *v = ccsCopyValue (vSetting, sType, sInfo);
449
450 if (!v)
451 return;
397452
398 switch (ccsGNOMEIntegratedSettingInfoGetSpecialOptionType ((CCSGNOMEIntegratedSettingInfo *) integratedSetting))453 switch (ccsGNOMEIntegratedSettingInfoGetSpecialOptionType ((CCSGNOMEIntegratedSettingInfo *) integratedSetting))
399 {454 {
@@ -408,25 +463,22 @@
408 break;463 break;
409 case OptionKey:464 case OptionKey:
410 { 465 {
411 char *newValue;466 CCSSettingValue *newValue = calloc (1, sizeof (CCSSettingValue));
412467
413 newValue = ccsKeyBindingToString (&(ccsSettingGetValue (setting)->value.asKey));468 newValue->isListChild = FALSE;
414 if (newValue)469 newValue->parent = NULL;
415 {470 newValue->refCount = 1;
416 if (strcmp (newValue, "Disabled") == 0)471
417 {472 if (ccsGNOMEIntegrationBackendKeyValueToStringValue (v, newValue))
418 /* Metacity doesn't like "Disabled", it wants "disabled" */473 {
419 newValue[0] = 'd';
420 }
421
422 /* Really this is a lie - the writer expects a string474 /* Really this is a lie - the writer expects a string
423 * but it needs to know if its a key or a string */475 * but it needs to know if its a key or a string */
424 type = TypeKey;476 type = TypeKey;
425 v->value.asString = newValue;477 ccsIntegratedSettingWriteValue (integratedSetting, newValue, type);
426
427 ccsIntegratedSettingWriteValue (integratedSetting, v, type);
428 free (newValue);
429 }478 }
479
480 if (newValue)
481 ccsFreeSettingValueWithType (newValue, TypeString);
430 }482 }
431 break;483 break;
432 case OptionSpecial:484 case OptionSpecial:
@@ -462,6 +514,18 @@
462514
463 ccsIntegratedSettingWriteValue (integratedSetting, newValue, type);515 ccsIntegratedSettingWriteValue (integratedSetting, newValue, type);
464 }516 }
517 else if ((strcmp (settingName, "run_command_screenshot_key") == 0 ||
518 strcmp (settingName, "run_command_window_screenshot_key") == 0 ||
519 strcmp (settingName, "run_command_terminal_key") == 0))
520 {
521 if (ccsGNOMEIntegrationBackendKeyValueToStringValue (v, newValue))
522 {
523 /* These are actually stored as strings in the schemas */
524 type = TypeString;
525 ccsIntegratedSettingWriteValue (integratedSetting, newValue, type);
526 }
527
528 }
465 else if (((strcmp (settingName, "initiate_button") == 0) &&529 else if (((strcmp (settingName, "initiate_button") == 0) &&
466 ((strcmp (pluginName, "move") == 0) ||530 ((strcmp (pluginName, "move") == 0) ||
467 (strcmp (pluginName, "resize") == 0))) ||531 (strcmp (pluginName, "resize") == 0))) ||
@@ -520,6 +584,9 @@
520 g_error_free (err);584 g_error_free (err);
521 }585 }
522586
587 if (v)
588 ccsFreeSettingValueWithType (v, sType);
589
523 /* we should immediately write changed settings */590 /* we should immediately write changed settings */
524 ccsWriteChangedSettings (priv->context);591 ccsWriteChangedSettings (priv->context);
525 ccsIntegrationAllowIntegratedWrites (integration);592 ccsIntegrationAllowIntegratedWrites (integration);
526593
=== modified file 'compizconfig/integration/gnome/src/ccs_gnome_integration_constants.c'
--- compizconfig/integration/gnome/src/ccs_gnome_integration_constants.c 2012-08-22 09:15:24 +0000
+++ compizconfig/integration/gnome/src/ccs_gnome_integration_constants.c 2012-09-25 15:17:24 +0000
@@ -431,10 +431,14 @@
431 static const char *org_compiz_integrated = "org.compiz.integrated";431 static const char *org_compiz_integrated = "org.compiz.integrated";
432 static const char *org_gnome_desktop_wm_keybindings = "org.gnome.desktop.wm.keybindings";432 static const char *org_gnome_desktop_wm_keybindings = "org.gnome.desktop.wm.keybindings";
433 static const char *org_gnome_desktop_wm_preferences = "org.gnome.desktop.wm.preferences";433 static const char *org_gnome_desktop_wm_preferences = "org.gnome.desktop.wm.preferences";
434 static const char *org_gnome_settings_daemon_plugins_media_keys = "org.gnome.settings-daemon.plugins.media-keys";
435 static const char *org_gnome_desktop_default_applications_terminal = "org.gnome.desktop.default-applications.terminal";
434436
435 quarks->ORG_COMPIZ_INTEGRATED = g_quark_from_string (org_compiz_integrated);437 quarks->ORG_COMPIZ_INTEGRATED = g_quark_from_string (org_compiz_integrated);
436 quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS = g_quark_from_string (org_gnome_desktop_wm_keybindings);438 quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS = g_quark_from_string (org_gnome_desktop_wm_keybindings);
437 quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES = g_quark_from_string (org_gnome_desktop_wm_preferences);439 quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES = g_quark_from_string (org_gnome_desktop_wm_preferences);
440 quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS = g_quark_from_string (org_gnome_settings_daemon_plugins_media_keys);
441 quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL = g_quark_from_string (org_gnome_desktop_default_applications_terminal);
438442
439 return NULL;443 return NULL;
440}444}
@@ -501,7 +505,7 @@
501 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_AUTORAISE_DELAY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES));505 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_AUTORAISE_DELAY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES));
502 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_AUTORAISE.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES));506 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_AUTORAISE.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_PREFERENCES));
503 g_hash_table_insert (thumbnailHashTable, (gpointer) names->THUMBNAIL_CURRENT_VIEWPORT.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));507 g_hash_table_insert (thumbnailHashTable, (gpointer) names->THUMBNAIL_CURRENT_VIEWPORT.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));
504 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_TERMINAL.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));508 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_TERMINAL.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_DEFAULT_APPLICATIONS_TERMINAL));
505 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_WINDOW_SCREENSHOT.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));509 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_WINDOW_SCREENSHOT.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));
506 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_SCREENSHOT.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));510 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_COMMAND_SCREENSHOT.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));
507 g_hash_table_insert (rotateHashTable, (gpointer) names->ROTATE_ROTATE_RIGHT_WINDOW_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));511 g_hash_table_insert (rotateHashTable, (gpointer) names->ROTATE_ROTATE_RIGHT_WINDOW_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));
@@ -609,11 +613,11 @@
609 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MAXIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));613 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MAXIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));
610 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MINIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));614 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MINIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));
611 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_TOGGLE_WINDOW_MAXIMIZED_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));615 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_TOGGLE_WINDOW_MAXIMIZED_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));
612 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_TERMINAL_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));616 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_TERMINAL_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS));
613 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_WINDOW_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));617 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_WINDOW_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS));
614 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));618 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_SETTINGS_DAEMON_PLUGINS_MEDIA_KEYS));
615 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_MAIN_MENU_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));619 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_MAIN_MENU_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));
616 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_KEY.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));620 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_KEY.compizName, GINT_TO_POINTER (quarks->ORG_GNOME_DESKTOP_WM_KEYBINDINGS));
617 g_hash_table_insert (unityshellHashTable, (gpointer) names->UNITYSHELL_SHOW_HUD.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));621 g_hash_table_insert (unityshellHashTable, (gpointer) names->UNITYSHELL_SHOW_HUD.compizName, GINT_TO_POINTER (quarks->ORG_COMPIZ_INTEGRATED));
618622
619 return masterHashTable;623 return masterHashTable;
@@ -937,9 +941,9 @@
937 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MAXIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (OptionKey));941 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MAXIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (OptionKey));
938 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MINIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (OptionKey));942 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_MINIMIZE_WINDOW_KEY.compizName, GINT_TO_POINTER (OptionKey));
939 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_TOGGLE_WINDOW_MAXIMIZED_KEY.compizName, GINT_TO_POINTER (OptionKey));943 g_hash_table_insert (coreHashTable, (gpointer) names->CORE_TOGGLE_WINDOW_MAXIMIZED_KEY.compizName, GINT_TO_POINTER (OptionKey));
940 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_TERMINAL_KEY.compizName, GINT_TO_POINTER (OptionKey));944 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_TERMINAL_KEY.compizName, GINT_TO_POINTER (OptionSpecial));
941 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_WINDOW_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (OptionKey));945 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_WINDOW_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (OptionSpecial));
942 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (OptionKey));946 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_COMMAND_SCREENSHOT_KEY.compizName, GINT_TO_POINTER (OptionSpecial));
943 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_MAIN_MENU_KEY.compizName, GINT_TO_POINTER (OptionKey));947 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_MAIN_MENU_KEY.compizName, GINT_TO_POINTER (OptionKey));
944 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_KEY.compizName, GINT_TO_POINTER (OptionKey));948 g_hash_table_insert (gnomecompatHashTable, (gpointer) names->GNOMECOMPAT_RUN_KEY.compizName, GINT_TO_POINTER (OptionKey));
945 g_hash_table_insert (unityshellHashTable, (gpointer) names->UNITYSHELL_SHOW_HUD.compizName, GINT_TO_POINTER (OptionKey));949 g_hash_table_insert (unityshellHashTable, (gpointer) names->UNITYSHELL_SHOW_HUD.compizName, GINT_TO_POINTER (OptionKey));
946950
=== modified file 'compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c'
--- compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c 2012-09-23 16:46:19 +0000
+++ compizconfig/integration/gnome/tests/compizconfig_ccs_mock_gnome_integrated_setting_composition.c 2012-09-25 15:17:24 +0000
@@ -131,7 +131,6 @@
131131
132 ccsIntegratedSettingUnref (priv->integratedSetting);132 ccsIntegratedSettingUnref (priv->integratedSetting);
133 ccsGNOMEIntegratedSettingInfoUnref (priv->gnomeIntegratedSettingInfo);133 ccsGNOMEIntegratedSettingInfoUnref (priv->gnomeIntegratedSettingInfo);
134 ccsIntegratedSettingInfoUnref (priv->integratedSettingInfo);
135134
136 ccsObjectFinalize (integratedSetting);135 ccsObjectFinalize (integratedSetting);
137 (*integratedSetting->object.object_allocation->free_)136 (*integratedSetting->object.object_allocation->free_)
@@ -202,7 +201,6 @@
202201
203 ccsIntegratedSettingRef (priv->integratedSetting);202 ccsIntegratedSettingRef (priv->integratedSetting);
204 ccsGNOMEIntegratedSettingInfoRef (priv->gnomeIntegratedSettingInfo);203 ccsGNOMEIntegratedSettingInfoRef (priv->gnomeIntegratedSettingInfo);
205 ccsIntegratedSettingInfoRef (priv->integratedSettingInfo);
206204
207 ccsObjectSetPrivate (composition, (CCSPrivate *) (priv));205 ccsObjectSetPrivate (composition, (CCSPrivate *) (priv));
208 ccsObjectAddInterface (composition,206 ccsObjectAddInterface (composition,
209207
=== modified file 'compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp'
--- compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp 2012-09-24 03:44:08 +0000
+++ compizconfig/integration/gnome/tests/compizconfig_test_ccs_gnome_integration.cpp 2012-09-25 15:17:24 +0000
@@ -58,6 +58,8 @@
58using ::testing::ReturnNull;58using ::testing::ReturnNull;
59using ::testing::SetArgPointee;59using ::testing::SetArgPointee;
60using ::testing::DoAll;60using ::testing::DoAll;
61using ::testing::Values;
62using ::testing::WithParamInterface;
61using ::testing::_;63using ::testing::_;
6264
63namespace65namespace
@@ -80,6 +82,7 @@
80 setting.c_str (),82 setting.c_str (),
81 type,83 type,
82 allocator);84 allocator);
85 /* This takes ownership of integratedSettingInfo */
83 CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSettingInfo =86 CCSGNOMEIntegratedSettingInfo *gnomeIntegratedSettingInfo =
84 ccsGNOMEIntegratedSettingInfoNew (integratedSettingInfo,87 ccsGNOMEIntegratedSettingInfoNew (integratedSettingInfo,
85 gnomeType,88 gnomeType,
@@ -100,7 +103,6 @@
100103
101 /* We want the composition to take ownership here, so unref the104 /* We want the composition to take ownership here, so unref the
102 * original members of the composition */105 * original members of the composition */
103 ccsIntegratedSettingInfoUnref (integratedSettingInfo);
104 ccsGNOMEIntegratedSettingInfoUnref (gnomeIntegratedSettingInfo);106 ccsGNOMEIntegratedSettingInfoUnref (gnomeIntegratedSettingInfo);
105 ccsIntegratedSettingUnref (integratedSetting);107 ccsIntegratedSettingUnref (integratedSetting);
106108
@@ -119,38 +121,37 @@
119 return std::tr1::get <1> (integratedSettingWithMocks).get ();121 return std::tr1::get <1> (integratedSettingWithMocks).get ();
120 }122 }
121123
122 typedef std::tr1::tuple <CCSContextGMock &,124 typedef std::tr1::tuple <CCSContextGMock &,
123 CCSBackendGMock &,125 CCSBackendGMock &,
124 CCSIntegratedSettingsStorageGMock &,126 CCSIntegratedSettingsStorageGMock &,
125 CCSIntegratedSettingFactoryGMock &,127 CCSIntegratedSettingFactoryGMock &,
126 boost::shared_ptr <CCSContext> ,128 boost::shared_ptr <CCSContext> ,
127 boost::shared_ptr <CCSBackend> ,129 boost::shared_ptr <CCSBackend> ,
128 boost::shared_ptr <CCSIntegratedSettingsStorage> ,130 CCSIntegratedSettingsStorage *,
129 boost::shared_ptr <CCSIntegratedSettingFactory> ,131 CCSIntegratedSettingFactory *,
130 boost::shared_ptr <CCSIntegration> > CCSGNOMEIntegrationWithMocks;132 boost::shared_ptr <CCSIntegration> > CCSGNOMEIntegrationWithMocks;
131133
132 CCSGNOMEIntegrationWithMocks134 CCSGNOMEIntegrationWithMocks
133 createIntegrationWithMocks (CCSObjectAllocationInterface *ai)135 createIntegrationWithMocks (CCSObjectAllocationInterface *ai)
134 {136 {
135 boost::shared_ptr <CCSContext> context (AutoDestroy (ccsMockContextNew (),137 boost::shared_ptr <CCSContext> context (AutoDestroy (ccsMockContextNew (),
136 ccsFreeContext));138 ccsFreeContext));
137 boost::shared_ptr <CCSBackend> backend (AutoDestroy (ccsMockBackendNew (),139 boost::shared_ptr <CCSBackend> backend (AutoDestroy (ccsMockBackendNew (),
138 ccsBackendUnref));140 ccsFreeMockBackend));
139 boost::shared_ptr <CCSIntegratedSettingsStorage> storage (AutoDestroy (ccsMockIntegratedSettingsStorageNew (ai),141 /* The GNOME Integration backend takes ownership of these two */
140 ccsIntegratedSettingsStorageUnref));142 CCSIntegratedSettingsStorage *storage (ccsMockIntegratedSettingsStorageNew (ai));
141 boost::shared_ptr <CCSIntegratedSettingFactory> factory (AutoDestroy (ccsMockIntegratedSettingFactoryNew (ai),143 CCSIntegratedSettingFactory *factory (ccsMockIntegratedSettingFactoryNew (ai));
142 ccsIntegratedSettingFactoryUnref));144 boost::shared_ptr <CCSIntegration> integration (AutoDestroy (ccsGNOMEIntegrationBackendNew (backend.get (),
143 boost::shared_ptr <CCSIntegration> integration (AutoDestroy (ccsGNOMEIntegrationBackendNew (backend.get (),145 context.get (),
144 context.get (),146 factory,
145 factory.get (),147 storage,
146 storage.get (),148 ai),
147 ai),149 ccsIntegrationUnref));
148 ccsIntegrationUnref));
149150
150 CCSContextGMock &gmockContext = *(reinterpret_cast <CCSContextGMock *> (ccsObjectGetPrivate (context.get ())));151 CCSContextGMock &gmockContext = *(reinterpret_cast <CCSContextGMock *> (ccsObjectGetPrivate (context.get ())));
151 CCSBackendGMock &gmockBackend = *(reinterpret_cast <CCSBackendGMock *> (ccsObjectGetPrivate (backend.get ())));152 CCSBackendGMock &gmockBackend = *(reinterpret_cast <CCSBackendGMock *> (ccsObjectGetPrivate (backend.get ())));
152 CCSIntegratedSettingsStorageGMock &gmockStorage = *(reinterpret_cast <CCSIntegratedSettingsStorageGMock *> (ccsObjectGetPrivate (storage.get ())));153 CCSIntegratedSettingsStorageGMock &gmockStorage = *(reinterpret_cast <CCSIntegratedSettingsStorageGMock *> (ccsObjectGetPrivate (storage)));
153 CCSIntegratedSettingFactoryGMock &gmockFactory = *(reinterpret_cast <CCSIntegratedSettingFactoryGMock *> (ccsObjectGetPrivate (factory.get ())));154 CCSIntegratedSettingFactoryGMock &gmockFactory = *(reinterpret_cast <CCSIntegratedSettingFactoryGMock *> (ccsObjectGetPrivate (factory)));
154155
155 return CCSGNOMEIntegrationWithMocks (gmockContext,156 return CCSGNOMEIntegrationWithMocks (gmockContext,
156 gmockBackend,157 gmockBackend,
@@ -222,10 +223,19 @@
222 EXPECT_CALL (plugin, getName ()).WillOnce (Return (pluginName.c_str ()));223 EXPECT_CALL (plugin, getName ()).WillOnce (Return (pluginName.c_str ()));
223 }224 }
224225
226 void
227 SetTypeInfo (CCSSettingGMock &setting,
228 CCSSettingType type,
229 CCSSettingInfo *info)
230 {
231 EXPECT_CALL (setting, getType ()).WillOnce (Return (type));
232 EXPECT_CALL (setting, getInfo ()).WillOnce (Return (info));
233 }
234
225 CCSSettingValue *235 CCSSettingValue *
226 MakeSettingValue ()236 MakeSettingValue ()
227 {237 {
228 CCSSettingValue *v = new CCSSettingValue;238 CCSSettingValue *v = reinterpret_cast <CCSSettingValue *> (calloc (1, sizeof (CCSSettingValue)));
229 v->parent = NULL;239 v->parent = NULL;
230 v->isListChild = FALSE;240 v->isListChild = FALSE;
231 v->refCount = 1;241 v->refCount = 1;
@@ -236,7 +246,7 @@
236 boost::shared_ptr <CCSSettingValue>246 boost::shared_ptr <CCSSettingValue>
237 MakeAutoDestroySettingValue (CCSSettingType type)247 MakeAutoDestroySettingValue (CCSSettingType type)
238 {248 {
239 CCSSettingValue *v = new CCSSettingValue;249 CCSSettingValue *v = reinterpret_cast <CCSSettingValue *> (calloc (1, sizeof (CCSSettingValue)));
240 v->parent = NULL;250 v->parent = NULL;
241 v->isListChild = FALSE;251 v->isListChild = FALSE;
242 v->refCount = 1;252 v->refCount = 1;
@@ -387,6 +397,82 @@
387397
388namespace398namespace
389{399{
400 struct IntegratedMediaKeysParam
401 {
402 public:
403
404 IntegratedMediaKeysParam (const std::string &settingName,
405 const std::string &integratedName,
406 const std::string &keyValueString) :
407 settingName (settingName),
408 integratedName (integratedName),
409 keyValueString (keyValueString)
410 {
411 EXPECT_TRUE (ccsStringToKeyBinding (keyValueString.c_str (),
412 &keyValue));
413 }
414
415 const std::string settingName;
416 const std::string integratedName;
417 const std::string keyValueString;
418 CCSSettingKeyValue keyValue;
419 };
420}
421
422namespace
423{
424 std::string RUN_COMMAND_SCREENSHOT_KEY ("run_command_screenshot_key");
425 std::string SCREENSHOT ("screenshot");
426 std::string SCREENSHOT_BINDING ("<Alt>Print");
427 std::string RUN_COMMAND_WINDOW_SCREENSHOT_KEY ("run_command_window_screenshot_key");
428 std::string WINDOW_SCREENSHOT ("window_screenshot");
429 std::string WINDOW_SCREENSHOT_BINDING ("<Control><Alt>Print");
430 std::string RUN_COMMAND_TERMINAL_KEY ("run_command_terminal_key");
431 std::string TERMINAL ("terminal");
432 std::string TERMINAL_BINDING ("<Control><Alt>t");
433}
434
435class CCSGNOMEIntegrationTestReadIntegratedMediaKeys :
436 public CCSGNOMEIntegrationTestReadIntegrated,
437 public WithParamInterface <IntegratedMediaKeysParam>
438{
439};
440
441TEST_P (CCSGNOMEIntegrationTestReadIntegratedMediaKeys, TestReadIntegratedMediaKey)
442{
443 const std::string settingName (GetParam ().settingName);
444 CCSSettingValue *v = MakeSettingValue ();
445 v->value.asString = strdup (GetParam ().keyValueString.c_str ());
446
447 mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN,
448 settingName,
449 TypeString,
450 OptionSpecial,
451 MOCK_GNOME_NAME,
452 &ccsDefaultObjectAllocator);
453 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
454 EXPECT_CALL (Mock (*mIntegratedSetting), readValue (TypeString)).WillOnce (Return (v));
455 EXPECT_CALL (mSettingMock, setKey (Eq (GetParam ().keyValue), IsTrue ()));
456
457 EXPECT_THAT (ccsIntegrationReadOptionIntoSetting (Real (mIntegration),
458 NULL,
459 mSetting.get (),
460 Real (*mIntegratedSetting)), IsTrue ());
461}
462
463INSTANTIATE_TEST_CASE_P (CCSGNOMEMediaKeys, CCSGNOMEIntegrationTestReadIntegratedMediaKeys,
464 Values (IntegratedMediaKeysParam (RUN_COMMAND_SCREENSHOT_KEY,
465 SCREENSHOT,
466 SCREENSHOT_BINDING),
467 IntegratedMediaKeysParam (RUN_COMMAND_WINDOW_SCREENSHOT_KEY,
468 WINDOW_SCREENSHOT,
469 WINDOW_SCREENSHOT_BINDING),
470 IntegratedMediaKeysParam (RUN_COMMAND_TERMINAL_KEY,
471 TERMINAL,
472 TERMINAL_BINDING)));
473
474namespace
475{
390 const std::string DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING ("<Alt>");476 const std::string DEFAULT_MOUSE_BUTTON_MODIFIERS_STRING ("<Alt>");
391 const std::string GNOME_MOUSE_BUTTON_MODIFIERS_STRING ("<Super>");477 const std::string GNOME_MOUSE_BUTTON_MODIFIERS_STRING ("<Super>");
392 const unsigned int DEFAULT_MOUSE_BUTTON_MODIFIERS =478 const unsigned int DEFAULT_MOUSE_BUTTON_MODIFIERS =
@@ -622,7 +708,8 @@
622 newButtonValue.buttonModMask = 0;708 newButtonValue.buttonModMask = 0;
623709
624 /* Clear the old expectation */710 /* Clear the old expectation */
625 ccsIntegratedSettingReadValue (mIntegratedSettingMBM.get (), TypeString);711 ccsFreeSettingValueWithType (ccsIntegratedSettingReadValue (mIntegratedSettingMBM.get (), TypeString),
712 TypeString);
626 /* Now return null */713 /* Now return null */
627 EXPECT_CALL (mIntegratedSettingMBMMock, readValue (TypeString)).WillOnce (ReturnNull ());714 EXPECT_CALL (mIntegratedSettingMBMMock, readValue (TypeString)).WillOnce (ReturnNull ());
628715
@@ -661,6 +748,7 @@
661 MOCK_GNOME_NAME,748 MOCK_GNOME_NAME,
662 &ccsDefaultObjectAllocator);749 &ccsDefaultObjectAllocator);
663 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);750 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
751 SetTypeInfo (mSettingMock, TypeBool, &info);
664752
665 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));753 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));
666 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,754 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,
@@ -690,6 +778,7 @@
690 MOCK_GNOME_NAME,778 MOCK_GNOME_NAME,
691 &ccsDefaultObjectAllocator);779 &ccsDefaultObjectAllocator);
692 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);780 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
781 SetTypeInfo (mSettingMock, TypeBool, &info);
693782
694 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));783 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));
695 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,784 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,
@@ -719,25 +808,81 @@
719 MOCK_GNOME_NAME,808 MOCK_GNOME_NAME,
720 &ccsDefaultObjectAllocator);809 &ccsDefaultObjectAllocator);
721 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);810 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
722811 SetTypeInfo (mSettingMock, TypeBool, &info);
723 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));812
724 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,813 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));
725 TypeString,814 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,
726 &info)),815 TypeString,
727 TypeString));816 &info)),
728 ccsIntegrationWriteSettingIntoOption (Real (mIntegration),817 TypeString));
729 NULL,818 ccsIntegrationWriteSettingIntoOption (Real (mIntegration),
730 mSetting.get (),819 NULL,
731 Real (*mIntegratedSetting));820 mSetting.get (),
732}821 Real (*mIntegratedSetting));
822}
823
824class CCSGNOMEIntegrationTestWriteIntegratedMediaKeys :
825 public CCSGNOMEIntegrationTestWriteIntegrated,
826 public WithParamInterface <IntegratedMediaKeysParam>
827{
828};
829
830TEST_P (CCSGNOMEIntegrationTestWriteIntegratedMediaKeys, TestWriteIntegratedMediaKey)
831{
832 const std::string settingName (GetParam ().settingName);
833 boost::shared_ptr <CCSSettingValue> compizValue (MakeAutoDestroySettingValue (TypeKey));
834 boost::shared_ptr <CCSSettingValue> gnomeValue (MakeAutoDestroySettingValue (TypeString));
835 CCSSettingInfo info;
836
837 compizValue->value.asKey = GetParam ().keyValue;
838 gnomeValue->value.asString = strdup (GetParam ().keyValueString.c_str ());
839
840 mIntegratedSetting = createIntegratedSettingCompositionFromMock (MOCK_PLUGIN,
841 settingName,
842 TypeString,
843 OptionSpecial,
844 MOCK_GNOME_NAME,
845 &ccsDefaultObjectAllocator);
846 SetNames (mSettingMock, mPluginMock, settingName, MOCK_PLUGIN);
847 SetTypeInfo (mSettingMock, TypeKey, &info);
848
849 EXPECT_CALL (mSettingMock, getValue ()).WillOnce (Return (compizValue.get ()));
850 EXPECT_CALL (Mock (*mIntegratedSetting), writeValue (Pointee (SettingValueMatch (*gnomeValue,
851 TypeString,
852 &info)),
853 TypeString));
854 ccsIntegrationWriteSettingIntoOption (Real (mIntegration),
855 NULL,
856 mSetting.get (),
857 Real (*mIntegratedSetting));
858}
859
860INSTANTIATE_TEST_CASE_P (CCSGNOMEMediaKeys, CCSGNOMEIntegrationTestWriteIntegratedMediaKeys,
861 Values (IntegratedMediaKeysParam (RUN_COMMAND_SCREENSHOT_KEY,
862 SCREENSHOT,
863 SCREENSHOT_BINDING),
864 IntegratedMediaKeysParam (RUN_COMMAND_WINDOW_SCREENSHOT_KEY,
865 WINDOW_SCREENSHOT,
866 WINDOW_SCREENSHOT_BINDING),
867 IntegratedMediaKeysParam (RUN_COMMAND_TERMINAL_KEY,
868 TERMINAL,
869 TERMINAL_BINDING)));
733870
734/*871/*
735 * TODO: Break up the function that this test covers. Its way too complicated872 * TODO: Break up the function that this test covers. Its way too complicated
736 */873 */
737TEST_F (CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers, TestWriteMouseButtonModifier)874TEST_F (CCSGNOMEIntegrationTestWithMocksWriteIntegratedMouseButtonModifiers, TestWriteMouseButtonModifier)
738{875{
739 const std::string settingName ("initiate_button");876 const std::string moveSettingName ("initiate_button");
740 const std::string pluginName ("move");877 const std::string movePluginName ("move");
878 const std::string resizeSettingName ("initiate_button");
879 const std::string resizePluginName ("resize");
880 const std::string coreSettingName ("window_menu_button");
881 const std::string corePluginName ("core");
882
883 const std::string settingName (moveSettingName);
884 const std::string pluginName (movePluginName);
885
741 CCSSettingInfo info;886 CCSSettingInfo info;
742887
743 mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName,888 mIntegratedSetting = createIntegratedSettingCompositionFromMock (pluginName,
@@ -747,19 +892,20 @@
747 MOCK_GNOME_NAME,892 MOCK_GNOME_NAME,
748 &ccsDefaultObjectAllocator);893 &ccsDefaultObjectAllocator);
749 SetNames (mSettingMock, mPluginMock, settingName, pluginName);894 SetNames (mSettingMock, mPluginMock, settingName, pluginName);
895 SetTypeInfo (mSettingMock, TypeButton, &info);
750896
751 EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq ("move"))).WillRepeatedly (Return (movePlugin.get ()));897 EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq (movePluginName))).WillRepeatedly (Return (movePlugin.get ()));
752 EXPECT_CALL (movePluginMock, findSetting (Eq ("initiate_button"))).WillRepeatedly (Return (moveInitiateButtonSetting.get ()));898 EXPECT_CALL (movePluginMock, findSetting (Eq (moveSettingName))).WillRepeatedly (Return (moveInitiateButtonSetting.get ()));
753 EXPECT_CALL (moveInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton));899 EXPECT_CALL (moveInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton));
754 EXPECT_CALL (moveInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (moveInitiateButton.get ()));900 EXPECT_CALL (moveInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (moveInitiateButton.get ()));
755901
756 EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq ("resize"))).WillRepeatedly (Return (resizePlugin.get ()));902 EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq (resizePluginName))).WillRepeatedly (Return (resizePlugin.get ()));
757 EXPECT_CALL (resizePluginMock, findSetting (Eq ("initiate_button"))).WillRepeatedly (Return (resizeInitiateButtonSetting.get ()));903 EXPECT_CALL (resizePluginMock, findSetting (Eq (resizeSettingName))).WillRepeatedly (Return (resizeInitiateButtonSetting.get ()));
758 EXPECT_CALL (resizeInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton));904 EXPECT_CALL (resizeInitiateButtonSettingMock, getType ()).WillRepeatedly (Return (TypeButton));
759 EXPECT_CALL (resizeInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (resizeInitiateButton.get ()));905 EXPECT_CALL (resizeInitiateButtonSettingMock, getValue ()).WillRepeatedly (Return (resizeInitiateButton.get ()));
760906
761 EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq ("core"))).WillRepeatedly (Return (corePlugin.get ()));907 EXPECT_CALL (MockContext (mIntegration), findPlugin (Eq (corePluginName))).WillRepeatedly (Return (corePlugin.get ()));
762 EXPECT_CALL (corePluginMock, findSetting (Eq ("window_menu_button"))).WillRepeatedly (Return (coreWindowMenuSetting.get ()));908 EXPECT_CALL (corePluginMock, findSetting (Eq (coreSettingName))).WillRepeatedly (Return (coreWindowMenuSetting.get ()));
763 EXPECT_CALL (coreWindowMenuSettingMock, getType ()).WillRepeatedly (Return (TypeButton));909 EXPECT_CALL (coreWindowMenuSettingMock, getType ()).WillRepeatedly (Return (TypeButton));
764 EXPECT_CALL (coreWindowMenuSettingMock, getValue ()).WillRepeatedly (Return (coreWindowMenuButton.get ()));910 EXPECT_CALL (coreWindowMenuSettingMock, getValue ()).WillRepeatedly (Return (coreWindowMenuButton.get ()));
765911
766912
=== modified file 'compizconfig/libcompizconfig/include/ccs.h'
--- compizconfig/libcompizconfig/include/ccs.h 2012-09-10 01:06:55 +0000
+++ compizconfig/libcompizconfig/include/ccs.h 2012-09-25 15:17:24 +0000
@@ -772,6 +772,12 @@
772CCSSettingValueList772CCSSettingValueList
773ccsCopyList (CCSSettingValueList l1, CCSSetting * setting);773ccsCopyList (CCSSettingValueList l1, CCSSetting * setting);
774774
775/* Deep copy setting value */
776CCSSettingValue *
777ccsCopyValue (CCSSettingValue *orig,
778 CCSSettingType type,
779 CCSSettingInfo *info);
780
775/* Converts an array of data items to a setting value list. Behaves similar781/* Converts an array of data items to a setting value list. Behaves similar
776 to ccsGetListFromStringArray */782 to ccsGetListFromStringArray */
777CCSSettingValueList ccsGetValueListFromStringArray (const char **array,783CCSSettingValueList ccsGetValueListFromStringArray (const char **array,
778784
=== modified file 'compizconfig/libcompizconfig/src/main.c'
--- compizconfig/libcompizconfig/src/main.c 2012-09-25 08:39:18 +0000
+++ compizconfig/libcompizconfig/src/main.c 2012-09-25 15:17:24 +0000
@@ -2461,64 +2461,83 @@
2461 return TRUE;2461 return TRUE;
2462}2462}
24632463
2464CCSSettingValue *
2465ccsCopyValue (CCSSettingValue *orig,
2466 CCSSettingType type,
2467 CCSSettingInfo *info)
2468{
2469 CCSSettingValue *value = calloc (1, sizeof (CCSSettingValue));
2470
2471 if (!value)
2472 return NULL;
2473
2474 value->refCount = 1;
2475 value->parent = orig->parent;
2476 value->isListChild = orig->isListChild;
2477
2478 CCSSettingType vType = value->isListChild ? info->forList.listType : type;
2479
2480 switch (vType)
2481 {
2482 case TypeInt:
2483 value->value.asInt = orig->value.asInt;
2484 break;
2485 case TypeBool:
2486 value->value.asBool = orig->value.asBool;
2487 break;
2488 case TypeFloat:
2489 value->value.asFloat = orig->value.asFloat;
2490 break;
2491 case TypeString:
2492 value->value.asString = strdup (orig->value.asString);
2493 break;
2494 case TypeMatch:
2495 value->value.asMatch = strdup (orig->value.asMatch);
2496 break;
2497 case TypeKey:
2498 memcpy (&value->value.asKey, &orig->value.asKey,
2499 sizeof (CCSSettingKeyValue));
2500 break;
2501 case TypeButton:
2502 memcpy (&value->value.asButton, &orig->value.asButton,
2503 sizeof (CCSSettingButtonValue));
2504 break;
2505 case TypeEdge:
2506 value->value.asEdge = orig->value.asEdge;
2507 break;
2508 case TypeBell:
2509 value->value.asBell = orig->value.asBell;
2510 break;
2511 case TypeColor:
2512 memcpy (&value->value.asColor, &orig->value.asColor,
2513 sizeof (CCSSettingColorValue));
2514 break;
2515 default:
2516 free (value);
2517 return NULL;
2518 break;
2519 }
2520
2521 return value;
2522}
2523
2464CCSSettingValueList2524CCSSettingValueList
2465ccsCopyList (CCSSettingValueList l1, CCSSetting * setting)2525ccsCopyList (CCSSettingValueList l1, CCSSetting * setting)
2466{2526{
2467 CCSSettingInfo *info = ccsSettingGetInfo (setting);2527 CCSSettingInfo *info = ccsSettingGetInfo (setting);
2528 CCSSettingType type = ccsSettingGetType (setting);
2468 CCSSettingValueList l2 = NULL;2529 CCSSettingValueList l2 = NULL;
24692530
2470 while (l1)2531 while (l1)
2471 {2532 {
2472 CCSSettingValue *value = calloc (1, sizeof (CCSSettingValue));2533 CCSSettingValue *value = ccsCopyValue (l1->data,
2534 type,
2535 info);
2536
2537 /* FIXME If l2 != NULL, we leak l2 */
2473 if (!value)2538 if (!value)
2474 return l2;2539 return l2;
24752540
2476 value->refCount = 1;
2477 value->parent = setting;
2478 value->isListChild = TRUE;
2479
2480 switch (info->forList.listType)
2481 {
2482 case TypeInt:
2483 value->value.asInt = l1->data->value.asInt;
2484 break;
2485 case TypeBool:
2486 value->value.asBool = l1->data->value.asBool;
2487 break;
2488 case TypeFloat:
2489 value->value.asFloat = l1->data->value.asFloat;
2490 break;
2491 case TypeString:
2492 value->value.asString = strdup (l1->data->value.asString);
2493 break;
2494 case TypeMatch:
2495 value->value.asMatch = strdup (l1->data->value.asMatch);
2496 break;
2497 case TypeKey:
2498 memcpy (&value->value.asKey, &l1->data->value.asKey,
2499 sizeof (CCSSettingKeyValue));
2500 break;
2501 case TypeButton:
2502 memcpy (&value->value.asButton, &l1->data->value.asButton,
2503 sizeof (CCSSettingButtonValue));
2504 break;
2505 case TypeEdge:
2506 value->value.asEdge = l1->data->value.asEdge;
2507 break;
2508 case TypeBell:
2509 value->value.asBell = l1->data->value.asBell;
2510 break;
2511 case TypeColor:
2512 memcpy (&value->value.asColor, &l1->data->value.asColor,
2513 sizeof (CCSSettingColorValue));
2514 break;
2515 default:
2516 /* FIXME If l2 != NULL, we leak l2 */
2517 free (value);
2518 return NULL;
2519 break;
2520 }
2521
2522 l2 = ccsSettingValueListAppend (l2, value);2541 l2 = ccsSettingValueListAppend (l2, value);
2523 l1 = l1->next;2542 l1 = l1->next;
2524 }2543 }

Subscribers

People subscribed via source and target branches