diff options
Diffstat (limited to '')
-rw-r--r-- | property.c | 40 |
1 files changed, 24 insertions, 16 deletions
@@ -1,4 +1,5 @@ -/* $Id: property.c,v 1.3 2006/08/13 18:14:03 harbaum Exp $ +/* $Id: property.c 749 2007-01-20 06:37:35Z michael $ + * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/property.c $ * * dynamic properties * @@ -21,17 +22,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * - * $Log: property.c,v $ - * Revision 1.3 2006/08/13 18:14:03 harbaum - * Added KVV plugin - * - * Revision 1.2 2006/08/13 11:38:20 reinelt - * text widget uses dynamic properties - * - * Revision 1.1 2006/08/13 09:53:10 reinelt - * dynamic properties added (used by 'style' of text widget) - * */ @@ -74,7 +64,10 @@ void property_load(const char *section, const char *name, const char *defval, PROPERTY * prop) { + char *expression; + /* initialize structure */ + prop->valid = 0; prop->name = NULL; prop->expression = NULL; prop->compiled = NULL; @@ -84,7 +77,16 @@ void property_load(const char *section, const char *name, const char *defval, PR prop->name = strdup(name); /* load expression from config, but do not evaluate it */ - prop->expression = cfg_get_raw(section, name, defval); + expression = cfg_get_raw(section, name, NULL); + + if (expression == NULL) { + if (defval != NULL && *defval != '\0') + debug("Notice: using default value <%s> for property '%s.%s'", defval, section, name); + prop->expression = (char *) defval; + } else { + prop->valid = 1; + prop->expression = expression; + } /* pre-compile the expression */ Compile(prop->expression, &prop->compiled); @@ -92,13 +94,18 @@ void property_load(const char *section, const char *name, const char *defval, PR } +int property_valid(PROPERTY * prop) +{ + return prop->valid; +} + + int property_eval(PROPERTY * prop) { RESULT old; - int update = 1; + int update; /* this is a bit ugly: we need to remember the old value */ - old.type = prop->result.type; old.size = prop->result.size; old.number = prop->result.number; @@ -107,10 +114,11 @@ int property_eval(PROPERTY * prop) DelResult(&prop->result); Eval(prop->compiled, &prop->result); + /* check if property value has changed */ + update = 1; if (prop->result.type & R_NUMBER && old.type & R_NUMBER && prop->result.number == old.number) { update = 0; } - if (prop->result.type & R_STRING && old.type & R_STRING && prop->result.size == old.size) { if (prop->result.string == NULL && old.string == NULL) { update = 0; |