aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-01-11 18:26:02 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-01-11 18:26:02 +0000
commitbbe7f194ee035c6cafdc5102092b7b422541aeab (patch)
treeae4d2f2e9b87822d41960e72b58d8c7de974d565
parente2854bdb20aa686e18df912e133b790ae39ad44d (diff)
downloadlcd4linux-bbe7f194ee035c6cafdc5102092b7b422541aeab.tar.gz
[lcd4linux @ 2004-01-11 18:26:02 by reinelt]
further widget and layout processing git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@306 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--Makefile.am1
-rw-r--r--Makefile.in20
-rw-r--r--cfg.c55
-rw-r--r--drv_MatrixOrbital.c7
-rw-r--r--layout.c14
-rw-r--r--plugin.c7
-rw-r--r--plugin_string.c8
-rw-r--r--widget.c49
-rw-r--r--widget.h15
-rw-r--r--widget_text.c61
10 files changed, 158 insertions, 79 deletions
diff --git a/Makefile.am b/Makefile.am
index 25f1164..d143f1c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,6 +22,7 @@ evaluator.c evaluator.h \
plugin.c plugin.h \
plugin_math.c \
plugin_string.c \
+plugin_cfg.c \
plugin_xmms.c \
plugin_i2c_sensors.c \
widget.c widget.h \
diff --git a/Makefile.in b/Makefile.in
index 77ce17d..83c17af 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -101,7 +101,7 @@ AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall
lcd4linux_LDFLAGS = $(X_LIBS)
lcd4linux_LDADD = liblcd4linux.la @DRVLIBS@
-lcd4linux_SOURCES = lcd4linux.c pid.c pid.h parser.c parser.h processor.c processor.h layout.c layout.h evaluator.c evaluator.h plugin.c plugin.h plugin_math.c plugin_string.c plugin_xmms.c plugin_i2c_sensors.c widget.c widget.h widget_text.c widget_text.h system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h
+lcd4linux_SOURCES = lcd4linux.c pid.c pid.h parser.c parser.h processor.c processor.h layout.c layout.h evaluator.c evaluator.h plugin.c plugin.h plugin_math.c plugin_string.c plugin_cfg.c plugin_xmms.c plugin_i2c_sensors.c widget.c widget.h widget_text.c widget_text.h system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h
liblcd4linux_la_DEPENDENCIES = @DRIVERS@
@@ -139,11 +139,11 @@ PROGRAMS = $(bin_PROGRAMS)
lcd4linux_OBJECTS = lcd4linux.$(OBJEXT) pid.$(OBJEXT) parser.$(OBJEXT) \
processor.$(OBJEXT) layout.$(OBJEXT) evaluator.$(OBJEXT) \
plugin.$(OBJEXT) plugin_math.$(OBJEXT) plugin_string.$(OBJEXT) \
-plugin_xmms.$(OBJEXT) plugin_i2c_sensors.$(OBJEXT) widget.$(OBJEXT) \
-widget_text.$(OBJEXT) system.$(OBJEXT) isdn.$(OBJEXT) wifi.$(OBJEXT) \
-mail.$(OBJEXT) seti.$(OBJEXT) battery.$(OBJEXT) dvb.$(OBJEXT) \
-filter.$(OBJEXT) exec.$(OBJEXT) expr.$(OBJEXT) mail2.$(OBJEXT) \
-socket.$(OBJEXT) imon.$(OBJEXT)
+plugin_cfg.$(OBJEXT) plugin_xmms.$(OBJEXT) plugin_i2c_sensors.$(OBJEXT) \
+widget.$(OBJEXT) widget_text.$(OBJEXT) system.$(OBJEXT) isdn.$(OBJEXT) \
+wifi.$(OBJEXT) mail.$(OBJEXT) seti.$(OBJEXT) battery.$(OBJEXT) \
+dvb.$(OBJEXT) filter.$(OBJEXT) exec.$(OBJEXT) expr.$(OBJEXT) \
+mail2.$(OBJEXT) socket.$(OBJEXT) imon.$(OBJEXT)
lcd4linux_DEPENDENCIES = liblcd4linux.la
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -169,10 +169,10 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/Cwlinux.P \
.deps/expr.P .deps/filter.P .deps/fontmap.P .deps/icon.P .deps/imon.P \
.deps/isdn.P .deps/layout.P .deps/lcd4linux.P .deps/lock.P .deps/mail.P \
.deps/mail2.P .deps/parport.P .deps/parser.P .deps/pid.P .deps/pixmap.P \
-.deps/plugin.P .deps/plugin_i2c_sensors.P .deps/plugin_math.P \
-.deps/plugin_string.P .deps/plugin_xmms.P .deps/processor.P \
-.deps/seti.P .deps/socket.P .deps/system.P .deps/udelay.P \
-.deps/widget.P .deps/widget_text.P .deps/wifi.P
+.deps/plugin.P .deps/plugin_cfg.P .deps/plugin_i2c_sensors.P \
+.deps/plugin_math.P .deps/plugin_string.P .deps/plugin_xmms.P \
+.deps/processor.P .deps/seti.P .deps/socket.P .deps/system.P \
+.deps/udelay.P .deps/widget.P .deps/widget_text.P .deps/wifi.P
SOURCES = $(liblcd4linux_la_SOURCES) $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
OBJECTS = $(liblcd4linux_la_OBJECTS) $(lcd4linux_OBJECTS)
diff --git a/cfg.c b/cfg.c
index c5983d4..7e0becf 100644
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.25 2004/01/11 09:26:15 reinelt Exp $^
+/* $Id: cfg.c,v 1.26 2004/01/11 18:26:02 reinelt Exp $^
*
* config file stuff
*
@@ -23,6 +23,9 @@
*
*
* $Log: cfg.c,v $
+ * Revision 1.26 2004/01/11 18:26:02 reinelt
+ * further widget and layout processing
+ *
* Revision 1.25 2004/01/11 09:26:15 reinelt
* layout starts to exist...
*
@@ -181,7 +184,6 @@
#include "debug.h"
#include "cfg.h"
-#include "plugin.h"
typedef struct {
char *key;
@@ -396,12 +398,15 @@ char *l4l_cfg_get (char *section, char *key, char *defval)
int l4l_cfg_number (char *section, char *key, int defval, int min, int max, int *value)
{
-
char *s, *e;
+ // start with default value
+ // in case of an (uncatched) error, you have the
+ // default value set, which may be handy...
+ *value=defval;
+
s=cfg_get(section, key, NULL);
if (s==NULL) {
- *value=defval;
return 0;
}
@@ -529,12 +534,6 @@ static int cfg_read (char *file)
val++;
}
- // provess 'value' in single-quotes
- else if (*val=='\'' && *end=='\'') {
- *end='\0';
- val++;
- }
-
// if key is '}', a section has been closed
if (strcmp(key, "}")==0) {
section_close=1;
@@ -613,39 +612,6 @@ static int cfg_read (char *file)
}
-static void cfg_plugin (RESULT *result, int argc, RESULT *argv[])
-{
- int i, len;
- char *value;
- char *buffer;
-
- // calculate key length
- len=0;
- for (i=0; i<argc; i++) {
- len+=strlen(R2S(argv[i]))+1;
- }
-
- // allocate key buffer
- buffer=malloc(len+1);
-
- // prepare key buffer
- *buffer='\0';
- for (i=0; i<argc; i++) {
- strcat (buffer, ".");
- strcat (buffer, R2S(argv[i]));
- }
-
- // buffer starts with '.', so cut off first char
- value=cfg_get("", buffer+1, "");
-
- // free buffer again
- free (buffer);
-
- // store result
- SetResult(&result, R_STRING, value);
-}
-
-
int l4l_cfg_init (char *file)
{
if (cfg_check_source(file) == -1) {
@@ -658,9 +624,6 @@ int l4l_cfg_init (char *file)
if (Config_File) free (Config_File);
Config_File=strdup(file);
- // register as a plugin
- AddFunction ("cfg", -1, cfg_plugin);
-
return 0;
}
diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c
index 03fc5b4..5ca694a 100644
--- a/drv_MatrixOrbital.c
+++ b/drv_MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.5 2004/01/11 09:26:15 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.6 2004/01/11 18:26:02 reinelt Exp $
*
* new style driver for Matrix Orbital serial display modules
*
@@ -23,6 +23,9 @@
*
*
* $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.6 2004/01/11 18:26:02 reinelt
+ * further widget and layout processing
+ *
* Revision 1.5 2004/01/11 09:26:15 reinelt
* layout starts to exist...
*
@@ -678,7 +681,7 @@ int drv_MO_init (char *section)
// register text widget
wc=Widget_Text;
- wc.render=NULL;
+ wc.draw=NULL; //Fixme
widget_register(&wc);
// register plugins
diff --git a/layout.c b/layout.c
index 65b0373..13d05f9 100644
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.2 2004/01/11 09:26:15 reinelt Exp $
+/* $Id: layout.c,v 1.3 2004/01/11 18:26:02 reinelt Exp $
*
* new layouter framework
*
@@ -23,6 +23,9 @@
*
*
* $Log: layout.c,v $
+ * Revision 1.3 2004/01/11 18:26:02 reinelt
+ * further widget and layout processing
+ *
* Revision 1.2 2004/01/11 09:26:15 reinelt
* layout starts to exist...
*
@@ -54,10 +57,11 @@
#include "layout.h"
-void layout_addItem (char *name, int row, int col)
+int layout_addItem (char *name, int row, int col)
{
-
- debug ("layout_addItem(%s, %d, %d)", name, row, col);
+ // allocate widget
+ widget_add (name);
+
}
@@ -69,8 +73,6 @@ int layout_init (char *layout)
char *widget;
int row, col;
- char buffer[32];
-
info ("initializing layout '%s'", layout);
// prepare config section
diff --git a/plugin.c b/plugin.c
index 405f15d..ec60dbe 100644
--- a/plugin.c
+++ b/plugin.c
@@ -1,4 +1,4 @@
-/* $Id: plugin.c,v 1.8 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: plugin.c,v 1.9 2004/01/11 18:26:02 reinelt Exp $
*
* plugin handler for the Evaluator
*
@@ -22,6 +22,9 @@
*
*
* $Log: plugin.c,v $
+ * Revision 1.9 2004/01/11 18:26:02 reinelt
+ * further widget and layout processing
+ *
* Revision 1.8 2004/01/10 20:22:33 reinelt
* added new function 'cfg_list()' (not finished yet)
* added layout.c (will replace processor.c someday)
@@ -93,6 +96,7 @@
// Prototypes
int plugin_init_math (void);
int plugin_init_string (void);
+int plugin_init_cfg (void);
int plugin_init_xmms (void);
int plugin_init_i2c_sensors (void);
@@ -101,6 +105,7 @@ int plugin_init (void)
{
plugin_init_math();
plugin_init_string();
+ plugin_init_cfg();
plugin_init_xmms();
// MR: segfaults here
// plugin_init_i2c_sensors();
diff --git a/plugin_string.c b/plugin_string.c
index 63ca3a7..1b3050a 100644
--- a/plugin_string.c
+++ b/plugin_string.c
@@ -1,8 +1,9 @@
-/* $Id: plugin_string.c,v 1.1 2003/12/19 05:50:34 reinelt Exp $
+/* $Id: plugin_string.c,v 1.2 2004/01/11 18:26:02 reinelt Exp $
*
* string plugin
*
- * Copyright 2003 Michael Reinelt <reinelt@eunet.at>
+ * Copyright 2003,2004 Michael Reinelt <reinelt@eunet.at>
+ * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* This file is part of LCD4Linux.
*
@@ -22,6 +23,9 @@
*
*
* $Log: plugin_string.c,v $
+ * Revision 1.2 2004/01/11 18:26:02 reinelt
+ * further widget and layout processing
+ *
* Revision 1.1 2003/12/19 05:50:34 reinelt
* added plugin_math.c and plugin_string.c
*
diff --git a/widget.c b/widget.c
index 301914d..60414fe 100644
--- a/widget.c
+++ b/widget.c
@@ -1,4 +1,4 @@
-/* $Id: widget.c,v 1.5 2004/01/11 09:26:15 reinelt Exp $
+/* $Id: widget.c,v 1.6 2004/01/11 18:26:02 reinelt Exp $
*
* generic widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget.c,v $
+ * Revision 1.6 2004/01/11 18:26:02 reinelt
+ * further widget and layout processing
+ *
* Revision 1.5 2004/01/11 09:26:15 reinelt
* layout starts to exist...
*
@@ -86,12 +89,50 @@ int widget_register (WIDGET_CLASS *widget)
}
-int widget_add (char *section, char *name)
+int widget_add (char *name)
{
+ int i;
+ char *section;
+ char *class;
+
+ WIDGET_CLASS *Class;
+ WIDGET *Widget;
+
+ // prepare config section
+ // strlen("Widget:")=7
+ section=malloc(strlen(name)+8);
+ strcpy(section, "Widget:");
+ strcat(section, name);
+
+ // get widget class
+ class=cfg_get(section, "class", NULL);
+ if (class==NULL || *class=='\0') {
+ error ("error: widget '%s' has no class!", name);
+ return -1;
+ }
+
+ // lookup widget class
+ for (i=0; i<nClasses; i++) {
+ if (strcasecmp(class, Classes[i].name)==0) {
+ Class=&(Classes[i]);
+ break;
+ }
+ }
+ if (i==nClasses) {
+ error ("widget '%s': class '%s' not supported");
+ return -1;
+ }
+
nWidgets++;
Widgets=realloc(Widgets, nWidgets*sizeof(WIDGET));
-
- Widgets[nWidgets-1].name = name;
+ Widget=&(Widgets[nWidgets-1]);
+
+ Widget->name = name;
+ Widget->class = Class;
+ if (Class->init!=0) {
+ Class->init(Widget);
+ }
+
return 0;
}
diff --git a/widget.h b/widget.h
index 2ff0c8d..181e20b 100644
--- a/widget.h
+++ b/widget.h
@@ -1,4 +1,4 @@
-/* $Id: widget.h,v 1.4 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: widget.h,v 1.5 2004/01/11 18:26:02 reinelt Exp $
*
* generic widget handling
*
@@ -23,6 +23,9 @@
*
*
* $Log: widget.h,v $
+ * Revision 1.5 2004/01/11 18:26:02 reinelt
+ * further widget and layout processing
+ *
* Revision 1.4 2004/01/10 20:22:33 reinelt
* added new function 'cfg_list()' (not finished yet)
* added layout.c (will replace processor.c someday)
@@ -48,20 +51,24 @@
struct WIDGET; // forward declaration
+
typedef struct WIDGET_CLASS {
char *name;
int (*init) (struct WIDGET *Self);
- int (*update) (struct WIDGET *Self);
- int (*render) (struct WIDGET *Self);
+ int (*update) (struct WIDGET *Self); // Fixme: do we really need this?
+ int (*draw) (struct WIDGET *Self);
int (*quit) (struct WIDGET *Self);
} WIDGET_CLASS;
+
typedef struct WIDGET{
- char *name;
+ char *name;
WIDGET_CLASS *class;
+ void *data;
} WIDGET;
+
int widget_register (WIDGET_CLASS *widget);
diff --git a/widget_text.c b/widget_text.c
index 59a122d..c644ce6 100644
--- a/widget_text.c
+++ b/widget_text.c
@@ -1,4 +1,4 @@
-/* $Id: widget_text.c,v 1.1 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: widget_text.c,v 1.2 2004/01/11 18:26:02 reinelt Exp $
*
* simple text widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget_text.c,v $
+ * Revision 1.2 2004/01/11 18:26:02 reinelt
+ * further widget and layout processing
+ *
* Revision 1.1 2004/01/10 20:22:33 reinelt
* added new function 'cfg_list()' (not finished yet)
* added layout.c (will replace processor.c someday)
@@ -48,12 +51,62 @@
#include "widget.h"
+typedef struct WIDGET_TEXT {
+ char *value;
+ char *align;
+ int width;
+ int update;
+} WIDGET_TEXT;
+
+
+int widget_text_init (WIDGET *Self) {
+
+ char *section;
+ WIDGET_TEXT *data;
+
+ debug ("Michi: widget_text_init(%s)", Self->name);
+
+ // prepare config section
+ // strlen("Widget:")=7
+ section=malloc(strlen(Self->name)+8);
+ strcpy(section, "Widget:");
+ strcat(section, Self->name);
+
+ data=malloc(sizeof(WIDGET_TEXT));
+
+ data->value = cfg_get (section, "value", "''");
+ data->align = cfg_get (section, "align", "L");
+
+ cfg_number (section, "width", 5, 0, 99999, &(data->width));
+ cfg_number (section, "update", -1, -1, 99999, &(data->update));
+
+ free (section);
+ Self->data=data;
+
+
+ return 0;
+}
+
+
+int widget_text_quit (WIDGET *Self) {
+
+ if (Self->data) {
+ free (Self->data);
+ Self->data=NULL;
+ }
+
+ return 0;
+
+}
+
+
+
WIDGET_CLASS Widget_Text = {
name: "text",
- init: NULL,
+ init: widget_text_init,
update: NULL,
- render: NULL,
- quit: NULL,
+ draw: NULL,
+ quit: widget_text_quit,
};