static void KdeBoolToCCS (CCSSetting *setting, int num) { Bool val = (cFiles->kwin->group (specialOptions[num].groupName). readEntry (specialOptions[num].kdeName, (setting->defaultValue.value.asBool)? true: false))? TRUE : FALSE; ccsSetBool (setting, val); }
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 Bool ccsGNOMEIntegrationBackendReadOptionIntoSetting (CCSIntegration *integration, CCSContext *context, CCSSetting *setting, CCSIntegratedSetting *integratedSetting) { Bool ret = FALSE; CCSSettingValue *v = NULL; CCSSettingType type = TypeNum; CCGNOMEIntegrationBackendPrivate *priv = (CCGNOMEIntegrationBackendPrivate *) ccsObjectGetPrivate (integration); if (ccsIntegratedSettingsStorageEmpty (priv->storage)) registerAllIntegratedOptions (integration); if (!ccsSettingIsReadableByBackend (setting)) return FALSE; switch (ccsGNOMEIntegratedSettingInfoGetSpecialOptionType ((CCSGNOMEIntegratedSettingInfo *) integratedSetting)) { case OptionInt: { type = TypeInt; v = ccsIntegratedSettingReadValue (integratedSetting, type); if (!v) break; ccsSetInt (setting, v->value.asInt, TRUE); ret = TRUE; } break; case OptionBool: { type = TypeBool; v = ccsIntegratedSettingReadValue (integratedSetting, type); if (!v) break; ccsSetBool (setting, v->value.asBool, TRUE); ret = TRUE; } break; case OptionString: { type = TypeString; v = ccsIntegratedSettingReadValue (integratedSetting, type); if (!v) break; char *str = v->value.asString; ccsSetString (setting, str, TRUE); ret = TRUE; } break; case OptionKey: { /* Some backends store keys differently so we need to let the backend know * that we really intend to read a key and let it handle the conversion */ type = TypeKey; if (ccsGNOMEIntegrationBackendReadISAndSetSettingForType (integratedSetting, setting, &v, TypeKey, type)) ret = TRUE; } break; case OptionSpecial: { const char *settingName = ccsSettingGetName (setting); const char *pluginName = ccsPluginGetName (ccsSettingGetParent (setting)); if (strcmp (settingName, "current_viewport") == 0) { type = TypeBool; v = ccsIntegratedSettingReadValue (integratedSetting, type); if (!v) break; Bool showAll = v->value.asBool; ccsSetBool (setting, !showAll, TRUE); ret = TRUE; } else if (strcmp (settingName, "fullscreen_visual_bell") == 0) { type = TypeString; v = ccsIntegratedSettingReadValue (integratedSetting, type); if (!v) break; const char *value = v->value.asString; if (value) { Bool fullscreen; fullscreen = strcmp (value, "fullscreen") == 0; ccsSetBool (setting, fullscreen, TRUE); ret = TRUE; } } else if (strcmp (settingName, "click_to_focus") == 0) { type = TypeString; v = ccsIntegratedSettingReadValue (integratedSetting, type); if (!v) break; const char *focusMode = v->value.asString; if (focusMode) { Bool clickToFocus = (strcmp (focusMode, "click") == 0); ccsSetBool (setting, clickToFocus, TRUE); ret = TRUE; } } else if ((strcmp (settingName, "run_command_screenshot_key") == 0 || strcmp (settingName, "run_command_window_screenshot_key") == 0 || strcmp (settingName, "run_command_terminal_key") == 0)) { /* These are always stored as strings, no matter what the backend is * so the source type should be string */ type = TypeKey; if (ccsGNOMEIntegrationBackendReadISAndSetSettingForType (integratedSetting, setting, &v, TypeString, type)) ret = TRUE; } 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))) { gboolean resizeWithRightButton; CCSSettingButtonValue button; memset (&button, 0, sizeof (CCSSettingButtonValue)); ccsGetButton (setting, &button); CCSIntegratedSettingList mouseModifierSetting = ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName (priv->storage, ccsGNOMEIntegratedPluginNames.SPECIAL, ccsGNOMEIntegratedSettingNames.NULL_MOUSE_BUTTON_MODIFIER.compizName); button.buttonModMask = getGnomeMouseButtonModifier (mouseModifierSetting->data); CCSIntegratedSettingList resizeButtonSetting = ccsIntegratedSettingsStorageFindMatchingSettingsByPluginAndSettingName (priv->storage, ccsGNOMEIntegratedPluginNames.SPECIAL, ccsGNOMEIntegratedSettingNames.NULL_RESIZE_WITH_RIGHT_BUTTON.compizName); type = TypeBool; v = ccsIntegratedSettingReadValue (resizeButtonSetting->data, type); resizeWithRightButton = v->value.asBool; if (strcmp (settingName, "window_menu_button") == 0) button.button = resizeWithRightButton ? 2 : 3; else if (strcmp (pluginName, "resize") == 0) button.button = resizeWithRightButton ? 3 : 2; else button.button = 1; ccsSetButton (setting, button, TRUE); ret = TRUE; /* Free the returned lists */ ccsIntegratedSettingListFree (mouseModifierSetting, FALSE); ccsIntegratedSettingListFree (resizeButtonSetting, FALSE); } } break; default: break; } if (v) ccsFreeSettingValueWithType (v, type); return ret; }
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 readSetting (CCSContext *c, CCSSetting *setting) { QString key (setting->name); QString group (setting->parent->name); group += "_display"; KConfigGroup cfg = cFiles->main->group (group); if (ccsGetIntegrationEnabled (c) && isIntegratedOption (setting) ) { readIntegratedOption (setting, &cfg); return; } if (!cfg.hasKey (key) ) { ccsResetToDefault (setting); return; } switch (setting->type) { case TypeString: ccsSetString (setting, cfg.readEntry (key, "").toAscii ().constData ()); break; case TypeMatch: ccsSetMatch (setting, cfg.readEntry (key, "").toAscii ().constData ()); break; case TypeFloat: ccsSetFloat (setting, cfg.readEntry (key, double(0.0))); break; case TypeInt: ccsSetInt (setting, cfg.readEntry (key, int(0))); break; case TypeBool: { Bool val = (cfg.readEntry (key, false)) ? TRUE : FALSE; ccsSetBool (setting, val); } break; case TypeColor: { CCSSettingColorValue color; QString value = cfg.readEntry (key, ""); if (ccsStringToColor (value.toAscii ().constData (), &color)) ccsSetColor (setting, color); } break; case TypeList: { switch (setting->info.forList.listType) { case TypeBool: { QList<bool> list = cfg.readEntry (key, QList<bool> ()); Bool *array = new Bool[list.count ()]; int i = 0; foreach (Bool val, list) { array[i] = (val) ? TRUE : FALSE; i++; } CCSSettingValueList l = ccsGetValueListFromBoolArray (array, i, setting); ccsSetList (setting, l); ccsSettingValueListFree (l, TRUE); delete array; } break; case TypeInt: { QList<int> list = cfg.readEntry (key, QList<int> ()); int *array = new int[list.count ()]; int i = 0; foreach (int val, list) { array[i] = val; i++; } CCSSettingValueList l = ccsGetValueListFromIntArray (array, i, setting); ccsSetList (setting, l); ccsSettingValueListFree (l, TRUE); delete array; } break; case TypeString: { QStringList list = cfg.readEntry (key, QStringList ()); if (!list.count ()) break; char **array = new char *[list.count ()]; int i = 0; foreach (QString val, list) { array[i] = strdup (val.toAscii ().constData ()); i++; } CCSSettingValueList l = ccsGetValueListFromStringArray (array, i, setting); ccsSetList (setting, l); ccsSettingValueListFree (l, TRUE); for (int j = 0; j < i; j++) free (array[j]); delete [] array; } break; case TypeMatch: { QStringList list = cfg.readEntry (key, QStringList ()); if (!list.count ()) break; char **array = new char *[list.count ()]; int i = 0; foreach (QString val, list) { array[i] = strdup (val.toAscii ().constData ()); i++; } CCSSettingValueList l = ccsGetValueListFromStringArray (array, i, setting); ccsSetList (setting, l); ccsSettingValueListFree (l, TRUE); for (int j = 0; j < i; j++) free (array[j]); delete [] array; }
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; } }