Search
lxdream.org :: lxdream :: r1144:00dd49743974
lxdream 0.9.1
released Jun 29
Download Now
changeset1144:00dd49743974
parent1143:8ec0f1f990aa
child1145:45674791c6ad
authornkeynes
dateMon Nov 08 14:12:10 2010 +1000 (9 years ago)
Add boolean config type
src/config.c
src/config.h
1.1 --- a/src/config.c Fri Oct 29 07:52:45 2010 +1000
1.2 +++ b/src/config.c Mon Nov 08 14:12:10 2010 +1000
1.3 @@ -154,6 +154,21 @@
1.4 return group->params[key].value;
1.5 }
1.6
1.7 +gboolean lxdream_get_config_boolean_value( lxdream_config_group_t group, int key )
1.8 +{
1.9 + const gchar *value = lxdream_get_config_value(group, key);
1.10 + if( strcasecmp(value, "on") == 0 || strcasecmp(value, "true") == 0 ||
1.11 + strcasecmp(value, "yes") == 0 || strcasecmp(value, "1") == 0 ) {
1.12 + return TRUE;
1.13 + } else {
1.14 + return FALSE;
1.15 + }
1.16 +}
1.17 +
1.18 +gboolean lxdream_set_config_boolean_value( lxdream_config_group_t group, int key, gboolean value )
1.19 +{
1.20 + return lxdream_set_config_value(group, key, value ? "on" : "off");
1.21 +}
1.22
1.23 gboolean lxdream_set_config_value( lxdream_config_group_t group, int key, const gchar *value )
1.24 {
2.1 --- a/src/config.h Fri Oct 29 07:52:45 2010 +1000
2.2 +++ b/src/config.h Mon Nov 08 14:12:10 2010 +1000
2.3 @@ -36,6 +36,7 @@
2.4 #define CONFIG_TYPE_KEY 3
2.5 #define CONFIG_TYPE_FILELIST 4
2.6 #define CONFIG_TYPE_INTEGER 5
2.7 +#define CONFIG_TYPE_BOOLEAN 6
2.8
2.9 #define DEFAULT_CONFIG_FILENAME "lxdreamrc"
2.10
2.11 @@ -97,6 +98,9 @@
2.12 void lxdream_copy_config_group( lxdream_config_group_t dest, lxdream_config_group_t src );
2.13 void lxdream_clone_config_group( lxdream_config_group_t dest, lxdream_config_group_t src );
2.14
2.15 +gboolean lxdream_get_config_boolean_value( lxdream_config_group_t group, int key );
2.16 +gboolean lxdream_set_config_boolean_value( lxdream_config_group_t group, int key, gboolean value );
2.17 +
2.18 /**
2.19 * Return a fully expanded path value for a key - this performs substitutions
2.20 * for ~ and simple shell variables ($VAR and ${VAR})
.