Beispiel #1
0
void subsurface_set_conf(char *name, pref_type_t type, const void *value)
{
    switch (type) {
    case PREF_BOOL:
        CFPreferencesSetAppValue(CFSTR_VAR(name),
                                 value == NULL ? kCFBooleanFalse : kCFBooleanTrue, SUBSURFACE_PREFERENCES);
        break;
    case PREF_STRING:
        CFPreferencesSetAppValue(CFSTR_VAR(name), CFSTR_VAR(value), SUBSURFACE_PREFERENCES);
    }
}
Beispiel #2
0
void subsurface_set_conf(char *name, pref_type_t type, const void *value)
{
	if (!dict)
		dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
						&kCFTypeDictionaryKeyCallBacks,
						&kCFTypeDictionaryValueCallBacks);
	switch (type) {
	case PREF_BOOL:
		CFDictionarySetValue(dict, CFSTR_VAR(name), value == NULL ? CFSTR("0") : CFSTR("1"));
		break;
	case PREF_STRING:
		CFDictionarySetValue(dict, CFSTR_VAR(name), CFSTR_VAR(value));
	}
}
Beispiel #3
0
int subsurface_get_conf_bool(char *name)
{
	Boolean boolpref, exists;

	boolpref = CFPreferencesGetAppBooleanValue(CFSTR_VAR(name), SUBSURFACE_PREFERENCES, &exists);
	if (!exists)
		return -1;
	return boolpref;
}
Beispiel #4
0
const void *subsurface_get_conf(char *name)
{
	CFPropertyListRef strpref;

	strpref = CFPreferencesCopyAppValue(CFSTR_VAR(name), SUBSURFACE_PREFERENCES);
	if (!strpref)
		return NULL;
	return strdup(CFStringGetCStringPtr(strpref, kCFStringEncodingMacRoman));
}
Beispiel #5
0
const void *subsurface_get_conf(char *name, pref_type_t type)
{
    Boolean boolpref;
    CFPropertyListRef strpref;

    switch (type) {
    case PREF_BOOL:
        boolpref = CFPreferencesGetAppBooleanValue(CFSTR_VAR(name), SUBSURFACE_PREFERENCES, FALSE);
        if (boolpref)
            return (void *) 1;
        else
            return NULL;
    case PREF_STRING:
        strpref = CFPreferencesCopyAppValue(CFSTR_VAR(name), SUBSURFACE_PREFERENCES);
        if (!strpref)
            return NULL;
        return strdup(CFStringGetCStringPtr(strpref, kCFStringEncodingMacRoman));
    }
    /* we shouldn't get here, but having this line makes the compiler happy */
    return NULL;
}
Beispiel #6
0
const void *subsurface_get_conf(char *name, pref_type_t type)
{
	CFStringRef dict_entry;

	/* if no settings exist, we return the value for FALSE */
	if (!propertyList)
		return NULL;

	switch (type) {
	case PREF_BOOL:
		dict_entry = CFDictionaryGetValue(propertyList, CFSTR_VAR(name));
		if (dict_entry && ! CFStringCompare(CFSTR("1"), dict_entry, 0))
			return (void *) 1;
		else
			return NULL;
	case PREF_STRING:
		return CFStringGetCStringPtr(CFDictionaryGetValue(propertyList,
						CFSTR_VAR(name)), kCFStringEncodingMacRoman);
	}
	/* we shouldn't get here, but having this line makes the compiler happy */
	return NULL;
}
Beispiel #7
0
void subsurface_set_conf_bool(char *name, int value)
{
	CFPreferencesSetAppValue(CFSTR_VAR(name),
		value ? kCFBooleanTrue : kCFBooleanFalse, SUBSURFACE_PREFERENCES);
}
Beispiel #8
0
void subsurface_set_conf(char *name, const char *value)
{
	CFPreferencesSetAppValue(CFSTR_VAR(name), CFSTR_VAR(value), SUBSURFACE_PREFERENCES);
}
Beispiel #9
0
void subsurface_unset_conf(char *name)
{
	CFPreferencesSetAppValue(CFSTR_VAR(name), NULL, SUBSURFACE_PREFERENCES);
}