diff options
author | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2004-01-11 18:26:02 +0000 |
---|---|---|
committer | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2004-01-11 18:26:02 +0000 |
commit | bbe7f194ee035c6cafdc5102092b7b422541aeab (patch) | |
tree | ae4d2f2e9b87822d41960e72b58d8c7de974d565 /widget.c | |
parent | e2854bdb20aa686e18df912e133b790ae39ad44d (diff) | |
download | lcd4linux-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
Diffstat (limited to 'widget.c')
-rw-r--r-- | widget.c | 49 |
1 files changed, 45 insertions, 4 deletions
@@ -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; } |