aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widget_gpo.c48
-rw-r--r--widget_gpo.h11
2 files changed, 26 insertions, 33 deletions
diff --git a/widget_gpo.c b/widget_gpo.c
index 08e15f6..74b8f61 100644
--- a/widget_gpo.c
+++ b/widget_gpo.c
@@ -4,7 +4,7 @@
* GPO widget handling
*
* Copyright (C) 2005 Michael Reinelt <reinelt@eunet.at>
- * Copyright (C) 2005 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ * Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@
#include "debug.h"
#include "cfg.h"
-#include "evaluator.h"
+#include "property.h"
#include "timer.h"
#include "widget.h"
#include "widget_gpo.h"
@@ -54,24 +54,23 @@ void widget_gpo_update(void *Self)
{
WIDGET *W = (WIDGET *) Self;
WIDGET_GPO *GPO = W->data;
- RESULT result = { 0, 0, 0, NULL };
- int val;
+ /* evaluate properties */
+ property_eval(&GPO->expression);
+ property_eval(&GPO->update);
- /* evaluate expression */
- val = 0;
- if (GPO->tree != NULL) {
- Eval(GPO->tree, &result);
- val = R2N(&result);
- DelResult(&result);
- }
GPO->num = W->row;
- GPO->val = val;
+ GPO->val = P2N(&GPO->expression);
/* finally, draw it! */
if (W->class->draw)
W->class->draw(W);
+ /* add a new one-shot timer */
+ if (P2N(&GPO->update) > 0) {
+ timer_add(widget_gpo_update, Self, P2N(&GPO->update), 1);
+ }
+
}
@@ -89,25 +88,15 @@ int widget_gpo_init(WIDGET * Self)
GPO = malloc(sizeof(WIDGET_GPO));
memset(GPO, 0, sizeof(WIDGET_GPO));
- /* get raw expression (we evaluate them ourselves) */
- GPO->expression = cfg_get_raw(section, "expression", NULL);
-
- /* sanity check */
- if (GPO->expression == NULL || *GPO->expression == '\0') {
- error("widget %s has no expression, using '0.0'", Self->name);
- GPO->expression = "0";
- }
-
- /* compile expression */
- Compile(GPO->expression, &GPO->tree);
-
- /* update interval (msec), default 1 sec */
- cfg_number(section, "update", 1000, 10, -1, &(GPO->update));
+ /* load properties */
+ property_load(section, "expression", "0", &GPO->expression);
+ property_load(section, "update", "1000", &GPO->update);
free(section);
Self->data = GPO;
- timer_add(widget_gpo_update, Self, GPO->update, 0);
+ /* fire it the first time */
+ widget_gpo_update(Self);
return 0;
}
@@ -118,10 +107,11 @@ int widget_gpo_quit(WIDGET * Self)
if (Self) {
if (Self->data) {
WIDGET_GPO *GPO = Self->data;
- DelTree(GPO->tree);
+ property_free(&GPO->expression);
+ property_free(&GPO->update);
free(Self->data);
+ Self->data = NULL;
}
- Self->data = NULL;
}
return 0;
}
diff --git a/widget_gpo.h b/widget_gpo.h
index 4e4b128..d263c47 100644
--- a/widget_gpo.h
+++ b/widget_gpo.h
@@ -4,7 +4,7 @@
* GPO widget handling
*
* Copyright (C) 2005 Michael Reinelt <reinelt@eunet.at>
- * Copyright (C) 2005 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ * Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* This file is part of LCD4Linux.
*
@@ -28,10 +28,13 @@
#ifndef _WIDGET_GPO_H_
#define _WIDGET_GPO_H_
+
+#include "property.h"
+
+
typedef struct WIDGET_GPO {
- char *expression; /* expression that delivers the value */
- void *tree; /* pre-compiled expression that delivers the value */
- int update; /* update interval (msec) */
+ PROPERTY expression; /* main GPO expression */
+ PROPERTY update; /* update interval (msec) */
int num; /* GPO number */
int val; /* GPO value */
} WIDGET_GPO;
1-12-03 19:31:21 -0600'>2011-12-03updated readmeKevin Lange1-3/+3 2011-12-03Restore updated VT220 paletteKevin Lange1-4/+4 2011-12-03Get rid of all of that nasty pythonKevin Lange9-1769/+1147 2011-12-03Perhaps better characters for a VT220Kevin Lange1-4/+4 2011-12-03Fix string literal warningKevin Lange1-1/+1 2011-12-03Make the eyes uniformKevin Lange1-24/+24 2011-12-03Use the flat mouthKevin Lange1-24/+24 2011-12-02Added include for signal.hMyles Borins1-0/+1 2011-12-02Added SIGINT_handler to re-initialize cursor for reset on non-sane terminal ↵Myles Borins1-1/+6 emulators 2011-12-01Fixed some issues with animation.Aaron Peschel1-33/+33 Conflicts: src/nyancat.c 2011-12-01nyancat.c: Fix up sprinkles.Corbin Simpson1-24/+24 In the top left and top right, a pair of sprinkles were occasionally missing; they are now always present. In the bottom left, a corner of the poptart was occasionally frosted instead of cookie; it is now always cookie to match the other corners. In the bottom left, a sprinkle was occilating between two locations; it was moved to the more correct location on the right. 2011-12-01Update READMEKevin Lange1-2/+2 2011-12-01People won't have that, let's not scare them with an error messageKevin Lange1-1/+1 2011-12-01make that executableKevin Lange1-0/+0 2011-12-01Update everythingKevin Lange7-9/+105 2011-12-01Fixed fallback support to use bright foregrounds. Looks a lot betterKevin Lange1-16/+19 2011-12-01Add license header to c sourceKevin Lange1-1/+28 2011-12-01Fix MakefileKevin Lange1-1/+1 2011-11-30Made project more in line with Autotools standard.Aaron Peschel5-2/+50 2011-11-30Make some changes to the server to make it easier to closeKevin Lange1-2/+11 2011-11-30More readme updatesKevin Lange1-0/+6 2011-11-30Update readmeKevin Lange1-0/+16 2011-11-30That's a layover from the ToaruOS version of this...Kevin Lange1-1/+0 2011-11-30rxvt should emulate linuxKevin Lange1-1/+3 2011-11-30Buffer 1024 characters on each readKevin Lange1-1/+1 2011-11-30Hide the cursorKevin Lange1-1/+1 2011-11-30Telnet serverKevin Lange4-0/+808 2011-11-30Change description text for the modes. Standard color XTerm looks good, ↵Kevin Lange1-3/+3 linux+blink is actually the same, and standard ANSI is ugly as hell. 2011-11-30Will this work?Kevin Lange1-0/+2