コード例 #1
0
ファイル: ini.c プロジェクト: Jubei-Mitsuyoshi/aaa-compiz
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);
}
コード例 #2
0
ファイル: ini.c プロジェクト: compiz-reloaded/libcompizconfig
static void
writeSetting (CCSContext *context,
              CCSSetting *setting)
{
    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);

    if (setting->isDefault)
    {
        ccsIniRemoveEntry (data->iniFile, setting->parent->name, keyName);
        free (keyName);
        return;
    }

    switch (setting->type)
    {
    case TypeString:
    {
        char *value;
        if (ccsGetString (setting, &value))
            ccsIniSetString (data->iniFile, setting->parent->name,
                             keyName, value);
    }
    break;
    case TypeMatch:
    {
        char *value;
        if (ccsGetMatch (setting, &value))
            ccsIniSetString (data->iniFile, setting->parent->name,
                             keyName, value);
    }
    break;
    case TypeInt:
    {
        int value;
        if (ccsGetInt (setting, &value))
            ccsIniSetInt (data->iniFile, setting->parent->name,
                          keyName, value);
    }
    break;
    case TypeFloat:
    {
        float value;
        if (ccsGetFloat (setting, &value))
            ccsIniSetFloat (data->iniFile, setting->parent->name,
                            keyName, value);
    }
    break;
    case TypeBool:
    {
        Bool value;
        if (ccsGetBool (setting, &value))
            ccsIniSetBool (data->iniFile, setting->parent->name,
                           keyName, value);
    }
    break;
    case TypeColor:
    {
        CCSSettingColorValue value;
        if (ccsGetColor (setting, &value))
            ccsIniSetColor (data->iniFile, setting->parent->name,
                            keyName, value);
    }
    break;
    case TypeKey:
    {
        CCSSettingKeyValue value;
        if (ccsGetKey (setting, &value))
            ccsIniSetKey (data->iniFile, setting->parent->name,
                          keyName, value);
    }
    break;
    case TypeButton:
    {
        CCSSettingButtonValue value;
        if (ccsGetButton (setting, &value))
            ccsIniSetButton (data->iniFile, setting->parent->name,
                             keyName, value);
    }
    break;
    case TypeEdge:
    {
        unsigned int value;
        if (ccsGetEdge (setting, &value))
            ccsIniSetEdge (data->iniFile, setting->parent->name,
                           keyName, value);
    }
    break;
    case TypeBell:
    {
        Bool value;
        if (ccsGetBell (setting, &value))
            ccsIniSetBell (data->iniFile, setting->parent->name,
                           keyName, value);
    }
    break;
    case TypeList:
    {
        CCSSettingValueList value;
        if (ccsGetList (setting, &value))
            ccsIniSetList (data->iniFile, setting->parent->name,
                           keyName, value, setting->info.forList.listType);
    }
    break;
    default:
        break;
    }

    if (keyName)
        free (keyName);
}