From d0c7529cb9833ede3595051df5599a11fe03be48 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 5 Apr 2007 15:25:19 +0200 Subject: import new upstream --- widget_timer.c | 78 ++++++++++++++++------------------------------------------ 1 file changed, 21 insertions(+), 57 deletions(-) (limited to 'widget_timer.c') diff --git a/widget_timer.c b/widget_timer.c index 4c6b055..688e7da 100644 --- a/widget_timer.c +++ b/widget_timer.c @@ -1,4 +1,5 @@ -/* $Id: widget_timer.c,v 1.3 2006/07/31 03:48:09 reinelt Exp $ +/* $Id: widget_timer.c 749 2007-01-20 06:37:35Z michael $ + * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/widget_timer.c $ * * timer widget handling * @@ -19,17 +20,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * - * $Log: widget_timer.c,v $ - * Revision 1.3 2006/07/31 03:48:09 reinelt - * preparations for scrolling - * - * Revision 1.2 2006/02/25 13:36:33 geronet - * updated indent.sh, applied coding style - * - * Revision 1.1 2006/01/23 06:17:18 reinelt - * timer widget added - * */ /* @@ -51,7 +41,7 @@ #include "debug.h" #include "cfg.h" #include "qprintf.h" -#include "evaluator.h" +#include "property.h" #include "timer.h" #include "widget.h" #include "widget_timer.h" @@ -64,35 +54,25 @@ void widget_timer_update(void *Self) { WIDGET *W = (WIDGET *) Self; WIDGET_TIMER *Timer = W->data; - RESULT result = { 0, 0, 0, NULL }; + int update, active; /* evaluate expressions */ - Timer->update = 10; - if (Timer->update_tree != NULL) { - Eval(Timer->update_tree, &result); - Timer->update = R2N(&result); - if (Timer->update < 10) - Timer->update = 10; - DelResult(&result); - } + property_eval(&Timer->update); + property_eval(&Timer->active); - Timer->active = 1; - if (Timer->active_tree != NULL) { - Eval(Timer->active_tree, &result); - Timer->active = R2N(&result); - if (Timer->active < 0) - Timer->active = 0; - DelResult(&result); - } + /* get new update interval */ + update = P2N(&Timer->update); + if (update < 10) + update = 10; /* finally, fire it! */ - if (Timer->active) { - Eval(Timer->expr_tree, &result); - DelResult(&result); + active = P2N(&Timer->active); + if (active > 0) { + property_eval(&Timer->expression); } /* add a new one-shot timer */ - timer_add(widget_timer_update, Self, Timer->update, 1); + timer_add(widget_timer_update, Self, update, 1); } @@ -111,26 +91,10 @@ int widget_timer_init(WIDGET * Self) Timer = malloc(sizeof(WIDGET_TIMER)); memset(Timer, 0, sizeof(WIDGET_TIMER)); - /* get raw expressions (we evaluate them ourselves) */ - Timer->expression = cfg_get_raw(section, "expression", NULL); - Timer->update_expr = cfg_get_raw(section, "update", "100"); - Timer->active_expr = cfg_get_raw(section, "active", "1"); - - /* sanity checks */ - if (Timer->expression == NULL || *Timer->expression == '\0') { - error("Timer '%s' has no expression, using '1'", Self->name); - Timer->expression = "1"; - } - if (Timer->update_expr == NULL || *Timer->update_expr == '\0') { - error("Timer '%s' has no update, using '100'", Self->name); - Timer->update_expr = "100"; - } - - /* compile'em */ - Compile(Timer->expression, &Timer->expr_tree); - Compile(Timer->update_expr, &Timer->update_tree); - Compile(Timer->active_expr, &Timer->active_tree); - + /* load properties */ + property_load(section, "expression", NULL, &Timer->expression); + property_load(section, "update", "100", &Timer->update); + property_load(section, "active", "1", &Timer->active); free(section); Self->data = Timer; @@ -149,9 +113,9 @@ int widget_timer_quit(WIDGET * Self) if (Self->parent == NULL) { if (Self->data) { WIDGET_TIMER *Timer = Self->data; - DelTree(Timer->expr_tree); - DelTree(Timer->update_tree); - DelTree(Timer->active_tree); + property_free(&Timer->expression); + property_free(&Timer->update); + property_free(&Timer->active); free(Self->data); Self->data = NULL; } -- cgit v1.2.3