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 (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 *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; }