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); }