static Bool ccsGNOMEIntegrationBackendReadISAndSetSettingForType (CCSIntegratedSetting *integratedSetting, CCSSetting *setting, CCSSettingValue **v, CCSSettingType sourceType, CCSSettingType destinationType) { *v = ccsIntegratedSettingReadValue (integratedSetting, sourceType); if (*v != NULL && (*v)->value.asString) { /* Conversion to key type option necessary */ if (destinationType == TypeKey) { CCSSettingKeyValue key; memset (&key, 0, sizeof (CCSSettingKeyValue)); if (ccsStringToKeyBinding ((*v)->value.asString, &key)) { /* Since we effectively change the type of the value here * we need to free the old string value */ free ((*v)->value.asString); ccsSetKey (setting, key, TRUE); return TRUE; } else { /* We were not successful at converting strings to keybindings * but we must free the string value anyways as we present * this value to ccsSettingValueFreeWithType as a TypeKey * intentionally made empty */ free ((*v)->value.asString); return FALSE; } } return TRUE; } return FALSE; }
static void KdeKeyToCCS (CCSSetting *setting, int num) { CCSSettingKeyValue keySet; keySet.keysym = 0; keySet.keyModMask = 0; QStringList keyData = cFiles->shortcuts-> group (specialOptions[num].groupName). readEntry (specialOptions[num].kdeName, QStringList()); if (keyData.size () != 3) return; int key = QKeySequence(keyData[0].split (' ')[0])[0]; int kdeKeymod = 0; if (key & Qt::ShiftModifier) kdeKeymod |= ShiftMask; if (key & Qt::ControlModifier) kdeKeymod |= ControlMask; if (key & Qt::AltModifier) kdeKeymod |= CompAltMask; if (key & Qt::MetaModifier) kdeKeymod |= CompSuperMask; keySet.keysym = XStringToKeysym(KShortcut (key & 0x1FFFFFF).toString () .toAscii ().constData ()); keySet.keyModMask = kdeKeymod; ccsSetKey (setting, keySet); }
static void readSetting (CCSBackend *backend, CCSContext *context, CCSSetting *setting) { Bool status = FALSE; char *keyName; IniPrivData *data; data = (IniPrivData *) ccsObjectGetPrivate (backend); if (!data) return; if (asprintf (&keyName, "s%d_%s", ccsContextGetScreenNum (context), ccsSettingGetName (setting)) == -1) return; switch (ccsSettingGetType (setting)) { case TypeString: { char *value; if (ccsIniGetString (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &value)) { ccsSetString (setting, value, TRUE); free (value); status = TRUE; } } break; case TypeMatch: { char *value; if (ccsIniGetString (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &value)) { ccsSetMatch (setting, value, TRUE); free (value); status = TRUE; } } break; case TypeInt: { int value; if (ccsIniGetInt (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &value)) { ccsSetInt (setting, value, TRUE); status = TRUE; } } break; case TypeBool: { Bool value; if (ccsIniGetBool (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &value)) { ccsSetBool (setting, (value != 0), TRUE); status = TRUE; } } break; case TypeFloat: { float value; if (ccsIniGetFloat (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &value)) { ccsSetFloat (setting, value, TRUE); status = TRUE; } } break; case TypeColor: { CCSSettingColorValue color; if (ccsIniGetColor (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &color)) { ccsSetColor (setting, color, TRUE); status = TRUE; } } break; case TypeKey: { CCSSettingKeyValue key; if (ccsIniGetKey (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &key)) { ccsSetKey (setting, key, TRUE); status = TRUE; } } break; case TypeButton: { CCSSettingButtonValue button; if (ccsIniGetButton (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &button)) { ccsSetButton (setting, button, TRUE); status = TRUE; } } break; case TypeEdge: { unsigned int edges; if (ccsIniGetEdge (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &edges)) { ccsSetEdge (setting, edges, TRUE); status = TRUE; } } break; case TypeBell: { Bool bell; if (ccsIniGetBell (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &bell)) { ccsSetBell (setting, bell, TRUE); status = TRUE; } } break; case TypeList: { CCSSettingValueList value; if (ccsIniGetList (data->iniFile, ccsPluginGetName (ccsSettingGetParent (setting)), keyName, &value, setting)) { ccsSetList (setting, value, TRUE); ccsSettingValueListFree (value, TRUE); status = TRUE; } } break; default: break; } if (!status) { /* reset setting to default if it could not be read */ ccsResetToDefault (setting, TRUE); } if (keyName) free (keyName); }
static void readSetting (CCSContext *context, CCSSetting *setting) { Bool status = FALSE; char *keyName; IniPrivData *data; data = findPrivFromContext (context); if (!data) return; if (setting->isScreen) asprintf (&keyName, "s%d_%s", setting->screenNum, setting->name); else asprintf (&keyName, "as_%s", setting->name); switch (setting->type) { case TypeString: { char *value; if (ccsIniGetString (data->iniFile, setting->parent->name, keyName, &value)) { ccsSetString (setting, value); free (value); status = TRUE; } } break; case TypeMatch: { char *value; if (ccsIniGetString (data->iniFile, setting->parent->name, keyName, &value)) { ccsSetMatch (setting, value); free (value); status = TRUE; } } break; case TypeInt: { int value; if (ccsIniGetInt (data->iniFile, setting->parent->name, keyName, &value)) { ccsSetInt (setting, value); status = TRUE; } } break; case TypeBool: { Bool value; if (ccsIniGetBool (data->iniFile, setting->parent->name, keyName, &value)) { ccsSetBool (setting, (value != 0)); status = TRUE; } } break; case TypeFloat: { float value; if (ccsIniGetFloat (data->iniFile, setting->parent->name, keyName, &value)) { ccsSetFloat (setting, value); status = TRUE; } } break; case TypeColor: { CCSSettingColorValue color; if (ccsIniGetColor (data->iniFile, setting->parent->name, keyName, &color)) { ccsSetColor (setting, color); status = TRUE; } } break; case TypeKey: { CCSSettingKeyValue key; if (ccsIniGetKey (data->iniFile, setting->parent->name, keyName, &key)) { ccsSetKey (setting, key); status = TRUE; } } break; case TypeButton: { CCSSettingButtonValue button; if (ccsIniGetButton (data->iniFile, setting->parent->name, keyName, &button)) { ccsSetButton (setting, button); status = TRUE; } } break; case TypeEdge: { unsigned int edges; if (ccsIniGetEdge (data->iniFile, setting->parent->name, keyName, &edges)) { ccsSetEdge (setting, edges); status = TRUE; } } break; case TypeBell: { Bool bell; if (ccsIniGetBell (data->iniFile, setting->parent->name, keyName, &bell)) { ccsSetBell (setting, bell); status = TRUE; } } break; case TypeList: { CCSSettingValueList value; if (ccsIniGetList (data->iniFile, setting->parent->name, keyName, &value, setting)) { ccsSetList (setting, value); ccsSettingValueListFree (value, TRUE); status = TRUE; } } break; default: break; } if (!status) { /* reset setting to default if it could not be read */ ccsResetToDefault (setting); } if (keyName) free (keyName); }
static void readIntegratedOption (CCSSetting *setting, KConfigGroup *mcg) { int option = 0; KConfigGroup g; for (unsigned int i = 0; i < N_SOPTIONS; i++) { if (setting->name == specialOptions[i].settingName && QString (setting->parent->name) == specialOptions[i].pluginName) { option = i; break; } } switch (specialOptions[option].type) { case OptionInt: KdeIntToCCS (setting, option); break; case OptionBool: KdeBoolToCCS (setting, option); break; case OptionKey: KdeKeyToCCS (setting, option); break; case OptionSpecial: if (specialOptions[option].settingName == "command11") { ccsSetString (setting, "xkill"); } else if (specialOptions[option].settingName == "unmaximize_window_key" || specialOptions[option].settingName == "maximize_window_key" || specialOptions[option].settingName == "maximize_window_horizontally_key" || specialOptions[option].settingName == "maximize_window_vertically_key") { CCSSettingKeyValue keyVal; if (!ccsGetKey (setting, &keyVal) ) break; keyVal.keysym = 0; keyVal.keyModMask = 0; ccsSetKey (setting, keyVal); } else if (specialOptions[option].settingName == "click_to_focus") { Bool val = (cFiles->kwin->group ("Windows"). readEntry ("FocusPolicy") == "ClickToFocus") ? TRUE : FALSE; ccsSetBool (setting, val); } else if (specialOptions[option].settingName == "mode" && specialOptions[option].pluginName == "resize") { QString mode = cFiles->kwin->group ("Windows"). readEntry ("ResizeMode"); int imode = -1; int result = 0; if (mcg->hasKey (specialOptions[option].settingName + " (Integrated)")) imode = mcg->readEntry (specialOptions[option].settingName + " (Integrated)", int (0)); if (mode == "Opaque") { result = 0; if (imode == 3) result = 3; } else if (mode == "Transparent") { result = 1; if (imode == 2) result = 2; } ccsSetInt (setting, result); } else if (specialOptions[option].settingName == "snap_type") { static int intList[2] = {0, 1}; CCSSettingValueList list = ccsGetValueListFromIntArray (intList, 2, setting); ccsSetList (setting, list); ccsSettingValueListFree (list, TRUE); } else if (specialOptions[option].settingName == "resistance_distance" || specialOptions[option].settingName == "attraction_distance") { int val1 = cFiles->kwin->group ("Windows"). readEntry ("WindowSnapZone", int (0)); int val2 = cFiles->kwin->group ("Windows"). readEntry ("BorderSnapZone", int (0)); int result = qMax (val1, val2); if (result == 0) result = mcg->readEntry ("snap_distance (Integrated)", int (0)); if (result > 0) ccsSetInt (setting, result); } else if (specialOptions[option].settingName == "edges_categories") { int val1 = cFiles->kwin->group ("Windows"). readEntry ("WindowSnapZone", int (0)); int val2 = cFiles->kwin->group ("Windows"). readEntry ("BorderSnapZone", int (0)); int intList[2] = {0, 0}; int num = 0; if (val2 > 0) num++; if (val1 > 0) { intList[num] = 1; num++; } CCSSettingValueList list = ccsGetValueListFromIntArray (intList, num, setting); ccsSetList (setting, list); ccsSettingValueListFree (list, TRUE); } else if (specialOptions[option].settingName == "edge_flip_window" || specialOptions[option].settingName == "edgeflip_move") { int val = cFiles->kwin->group ("Windows"). readEntry ("ElectricBorders", int (0)); if (val > 0) ccsSetBool (setting, TRUE); else ccsSetBool (setting, FALSE); } else if (specialOptions[option].settingName == "edge_flip_pointer" || specialOptions[option].settingName == "edgeflip_pointer") { int val = cFiles->kwin->group ("Windows"). readEntry ("ElectricBorders", int (0)); if (val > 1) ccsSetBool (setting, TRUE); else ccsSetBool (setting, FALSE); } else if (specialOptions[option].settingName == "mode" && specialOptions[option].pluginName == "place") { QString mode = cFiles->kwin->group ("Windows"). readEntry ("Placement"); int result = 0; if (mode == "Smart") result = 2; else if (mode == "Maximizing") result = 3; else if (mode == "Cascade") result = 0; else if (mode == "Random") result = 4; else if (mode == "Centered") result = 1; ccsSetInt (setting, result); } break; default: break; } }