aboutsummaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'layout.c')
-rw-r--r--layout.c70
1 files changed, 56 insertions, 14 deletions
diff --git a/layout.c b/layout.c
index 9c8f2c4..1d91f0b 100644
--- a/layout.c
+++ b/layout.c
@@ -1,9 +1,9 @@
-/* $Id: layout.c 728 2007-01-14 11:14:38Z michael $
- * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/layout.c $
+/* $Id: layout.c 1057 2009-11-17 01:47:43Z edman007 $
+ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/layout.c $
*
* new layouter framework
*
- * Copyright (C) 2003 Michael Reinelt <reinelt@eunet.at>
+ * Copyright (C) 2003 Michael Reinelt <michael@reinelt.co.at>
* Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* This file is part of LCD4Linux.
@@ -49,6 +49,56 @@
#endif
+/* rename old-style widgets without layer */
+static int layout_migrate(const char *section)
+{
+ char *list, *old, *new;
+ int row, col;
+
+ /* get a list of all keys in this section */
+ list = cfg_list(section);
+
+ /* map to lower char for scanf() */
+ for (old = list; *old != '\0'; old++)
+ *old = tolower(*old);
+
+ old = list;
+ while (old != NULL) {
+
+ char *p;
+ int i, n;
+
+ /* list is delimited by | */
+ while (*old == '|')
+ old++;
+ if ((p = strchr(old, '|')) != NULL)
+ *p = '\0';
+
+ /* row/col widgets w/o layer */
+ i = sscanf(old, "row%d.col%d%n", &row, &col, &n);
+ if (i == 2 && old[n] == '\0') {
+
+ /* prepare new key */
+ /* strlen("Layer:1.")=8 */
+ new = malloc(strlen(old) + 9);
+ strcpy(new, "Layer:1.");
+ strcat(new, old);
+
+ debug("%s: migrating '%s' to '%s'", section, old, new);
+ if (cfg_rename(section, old, new) < 0) {
+ error("WARNING: %s: both keys '%s' and '%s' may not exist!", section, old, new);
+ }
+ free(new);
+ }
+
+ /* next field */
+ old = p ? p + 1 : NULL;
+ }
+ free(list);
+ return 0;
+}
+
+
int layout_init(const char *layout)
{
char *section;
@@ -64,6 +114,9 @@ int layout_init(const char *layout)
strcpy(section, "Layout:");
strcat(section, layout);
+ /* mirate layout to common format */
+ layout_migrate(section);
+
/* get a list of all keys in this section */
list = cfg_list(section);
@@ -111,17 +164,6 @@ int layout_init(const char *layout)
}
}
- /* row/col widgets w/o layer */
- i = sscanf(l, "row%d.col%d%n", &row, &col, &n);
- if (i == 2 && l[n] == '\0') {
- widget = cfg_get(section, l, NULL);
- if (widget != NULL && *widget != '\0') {
- /* default is layer 1 if outside layer section */
- widget_add(widget, WIDGET_TYPE_RC, 1, row - 1, col - 1);
- }
- free(widget);
- }
-
/* GPO widgets */
i = sscanf(l, "gpo%d%n", &num, &n);
if (i == 1 && l[n] == '\0') {