CCSSettingValueList readListValue (GVariant *gsettingsValue, CCSSetting *setting, CCSObjectAllocationInterface *ai) { CCSSettingType listType = ccsSettingGetInfo (setting)->forList.listType; gboolean hasVariantType; unsigned int nItems; CCSSettingValueList list = NULL; GVariantIter iter; hasVariantType = compizconfigTypeHasVariantType (listType); if (!hasVariantType) return NULL; g_variant_iter_init (&iter, gsettingsValue); nItems = g_variant_iter_n_children (&iter); switch (listType) { case TypeBool: list = readBoolListValue (&iter, nItems, setting, ai); break; case TypeInt: list = readIntListValue (&iter, nItems, setting, ai); break; case TypeFloat: list = readFloatListValue (&iter, nItems, setting, ai); break; case TypeString: case TypeMatch: list = readStringListValue (&iter, nItems, setting, ai); break; case TypeColor: list = readColorListValue (&iter, nItems, setting, ai); break; default: break; } return list; }
static void writeSetting (CCSBackend *backend, CCSContext *context, CCSSetting *setting) { char *keyName; IniPrivData *data; data = (IniPrivData *) ccsObjectGetPrivate (backend); if (!data) return; if (asprintf (&keyName, "s%d_%s", ccsContextGetScreenNum (context), ccsSettingGetName (setting)) == -1) return; if (ccsSettingGetIsDefault (setting)) { ccsIniRemoveEntry (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName); free (keyName); return; } switch (ccsSettingGetType (setting)) { case TypeString: { char *value; if (ccsGetString (setting, (const char **) &value)) ccsIniSetString (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeMatch: { char *value; if (ccsGetMatch (setting, (const char **) &value)) ccsIniSetString (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeInt: { int value; if (ccsGetInt (setting, &value)) ccsIniSetInt (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeFloat: { float value; if (ccsGetFloat (setting, &value)) ccsIniSetFloat (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeBool: { Bool value; if (ccsGetBool (setting, &value)) ccsIniSetBool (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeColor: { CCSSettingColorValue value; if (ccsGetColor (setting, &value)) ccsIniSetColor (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeKey: { CCSSettingKeyValue value; if (ccsGetKey (setting, &value)) ccsIniSetKey (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeButton: { CCSSettingButtonValue value; if (ccsGetButton (setting, &value)) ccsIniSetButton (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeEdge: { unsigned int value; if (ccsGetEdge (setting, &value)) ccsIniSetEdge (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeBell: { Bool value; if (ccsGetBell (setting, &value)) ccsIniSetBell (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value); } break; case TypeList: { CCSSettingValueList value; if (ccsGetList (setting, &value)) ccsIniSetList (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, value, ccsSettingGetInfo (setting)->forList.listType); } break; default: break; } if (keyName) free (keyName); }
static void ccsGNOMEIntegrationBackendWriteOptionFromSetting (CCSIntegration *integration, CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *integratedSetting) { GError *err = NULL; CCSSettingType type = TypeNum; CCGNOMEIntegrationBackendPrivate *priv = (CCGNOMEIntegrationBackendPrivate *) ccsObjectGetPrivate (integration); if (ccsIntegratedSettingsStorageEmpty (priv->storage)) registerAllIntegratedOptions (integration); if (priv->noWrites) return; /* Do not allow recursing back into writeIntegratedSetting */ ccsIntegrationDisallowIntegratedWrites (integration); CCSSettingType sType = ccsSettingGetType (setting); CCSSettingInfo *sInfo = ccsSettingGetInfo (setting); CCSSettingValue *vSetting = ccsSettingGetValue (setting); CCSSettingValue *v = ccsCopyValue (vSetting, sType, sInfo); if (!v) return; switch (ccsGNOMEIntegratedSettingInfoGetSpecialOptionType ((CCSGNOMEIntegratedSettingInfo *) integratedSetting)) { case OptionInt: ccsIntegratedSettingWriteValue (integratedSetting, v, TypeInt); break; case OptionBool: ccsIntegratedSettingWriteValue (integratedSetting, v, TypeBool); break; case OptionString: ccsIntegratedSettingWriteValue (integratedSetting, v, TypeString); break; case OptionKey: { CCSSettingValue *newValue = calloc (1, sizeof (CCSSettingValue)); newValue->isListChild = FALSE; newValue->parent = NULL; newValue->refCount = 1; if (ccsGNOMEIntegrationBackendKeyValueToStringValue (v, newValue)) { /* Really this is a lie - the writer expects a string * but it needs to know if its a key or a string */ type = TypeKey; ccsIntegratedSettingWriteValue (integratedSetting, newValue, type); } if (newValue) ccsFreeSettingValueWithType (newValue, TypeString); } break; case OptionSpecial: { const char *settingName = ccsSettingGetName (setting); const char *pluginName = ccsPluginGetName (ccsSettingGetParent (setting)); CCSSettingValue *newValue = calloc (1, sizeof (CCSSettingValue)); newValue->isListChild = FALSE; newValue->parent = NULL; newValue->refCount = 1; if (strcmp (settingName, "current_viewport") == 0) { newValue->value.asBool = !v->value.asBool; type = TypeBool; ccsIntegratedSettingWriteValue (integratedSetting, newValue, type); } else if (strcmp (settingName, "fullscreen_visual_bell") == 0) { const char *newValueString = v->value.asBool ? "fullscreen" : "frame_flash"; newValue->value.asString = strdup (newValueString); type = TypeString; ccsIntegratedSettingWriteValue (integratedSetting, newValue, type); } else if (strcmp (settingName, "click_to_focus") == 0) { const char *newValueString = v->value.asBool ? "click" : "sloppy"; newValue->value.asString = strdup (newValueString); type = TypeString; ccsIntegratedSettingWriteValue (integratedSetting, newValue, type); } else if ((strcmp (settingName, "run_command_screenshot_key") == 0 || strcmp (settingName, "run_command_window_screenshot_key") == 0 || strcmp (settingName, "run_command_terminal_key") == 0)) { if (ccsGNOMEIntegrationBackendKeyValueToStringValue (v, newValue)) { /* These are actually stored as strings in the schemas */ type = TypeString; ccsIntegratedSettingWriteValue (integratedSetting, newValue, type); } } else if (((strcmp (settingName, "initiate_button") == 0) && ((strcmp (pluginName, "move") == 0) || (strcmp (pluginName, "resize") == 0))) || ((strcmp (settingName, "window_menu_button") == 0) && (strcmp (pluginName, "core") == 0))) { unsigned int modMask; Bool resizeWithRightButton = FALSE; if ((getButtonBindingForSetting (priv->context, "resize", "initiate_button") == 3) || (getButtonBindingForSetting (priv->context, "core", "window_menu_button") == 2)) { resizeWithRightButton = TRUE; } CCSIntegratedSettingList resizeButtonSetting = ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName (priv->storage, ccsGNOMEIntegratedPluginNames.SPECIAL, ccsGNOMEIntegratedSettingNames.NULL_RESIZE_WITH_RIGHT_BUTTON.compizName); newValue->value.asBool = resizeWithRightButton; type = TypeBool; ccsIntegratedSettingWriteValue (resizeButtonSetting->data, newValue, type); CCSIntegratedSettingList mouseModifierSetting = ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName (priv->storage, ccsGNOMEIntegratedPluginNames.SPECIAL, ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName); modMask = v->value.asButton.buttonModMask; if (setGnomeMouseButtonModifier (mouseModifierSetting->data, modMask)) { setButtonBindingForSetting (priv->context, "move", "initiate_button", 1, modMask); setButtonBindingForSetting (priv->context, "resize", "initiate_button", resizeWithRightButton ? 3 : 2, modMask); setButtonBindingForSetting (priv->context, "core", "window_menu_button", resizeWithRightButton ? 2 : 3, modMask); } /* We own the returned lists, so free them */ ccsIntegratedSettingListFree (resizeButtonSetting, FALSE); ccsIntegratedSettingListFree (mouseModifierSetting, FALSE); } if (newValue) ccsFreeSettingValueWithType (newValue, type); } break; } if (err) { ccsError ("%s", err->message); g_error_free (err); } if (v) ccsFreeSettingValueWithType (v, sType); /* we should immediately write changed settings */ ccsWriteChangedSettings (priv->context); ccsIntegrationAllowIntegratedWrites (integration); }