revision 1144:00dd49743974
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 1144:00dd49743974 |
parent | 1143:8ec0f1f990aa |
child | 1145:45674791c6ad |
author | nkeynes |
date | Mon Nov 08 14:12:10 2010 +1000 (13 years ago) |
Add boolean config type
src/config.c | view | annotate | diff | log | ||
src/config.h | view | annotate | diff | log |
1.1 --- a/src/config.c Fri Oct 29 07:52:45 2010 +10001.2 +++ b/src/config.c Mon Nov 08 14:12:10 2010 +10001.3 @@ -154,6 +154,21 @@1.4 return group->params[key].value;1.5 }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.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 +10002.2 +++ b/src/config.h Mon Nov 08 14:12:10 2010 +10002.3 @@ -36,6 +36,7 @@2.4 #define CONFIG_TYPE_KEY 32.5 #define CONFIG_TYPE_FILELIST 42.6 #define CONFIG_TYPE_INTEGER 52.7 +#define CONFIG_TYPE_BOOLEAN 62.9 #define DEFAULT_CONFIG_FILENAME "lxdreamrc"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.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 substitutions2.20 * for ~ and simple shell variables ($VAR and ${VAR})
.