diff --git a/data/keyboards/geometry/compact.xml b/data/keyboards/geometry/compact.xml
index 606a4e72..a468adde 100644
--- a/data/keyboards/geometry/compact.xml
+++ b/data/keyboards/geometry/compact.xml
@@ -3,240 +3,246 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/eek/eek-section.c b/eek/eek-section.c
index be208407..91b490a7 100644
--- a/eek/eek-section.c
+++ b/eek/eek-section.c
@@ -152,22 +152,24 @@ on_cancelled (EekKey *key,
static EekKey *
eek_section_real_create_key (EekSection *self,
guint keycode,
- gint column,
- gint row)
+ gint column_index,
+ gint row_index)
{
EekKey *key;
- gint num_columns, num_rows;
- EekOrientation orientation;
+ gint num_rows;
+ EekRow *row;
num_rows = eek_section_get_n_rows (self);
- g_return_val_if_fail (0 <= row && row < num_rows, NULL);
- eek_section_get_row (self, row, &num_columns, &orientation);
- g_return_val_if_fail (column < num_columns, NULL);
+ g_return_val_if_fail (0 <= row_index && row_index < num_rows, NULL);
+
+ row = g_slist_nth_data (self->priv->rows, row_index);
+ if (row->num_columns < column_index + 1)
+ row->num_columns = column_index + 1;
key = g_object_new (EEK_TYPE_KEY,
"keycode", keycode,
- "column", column,
- "row", row,
+ "column", column_index,
+ "row", row_index,
NULL);
g_return_val_if_fail (key, NULL);
diff --git a/eek/eek-xml-layout.c b/eek/eek-xml-layout.c
index 2887f7eb..d8c1706e 100644
--- a/eek/eek-xml-layout.c
+++ b/eek/eek-xml-layout.c
@@ -240,6 +240,7 @@ struct _GeometryParseData {
EekSection *section;
EekKey *key;
gint num_columns;
+ gint num_rows;
EekOrientation orientation;
gdouble corner_radius;
GSList *points;
@@ -287,8 +288,8 @@ static const gchar *geometry_valid_path_list[] = {
"outline/geometry",
"bounds/section/geometry",
"row/section/geometry",
- "key/section/geometry",
- "bounds/key/section/geometry",
+ "key/row/section/geometry",
+ "bounds/key/row/section/geometry",
"point/outline/geometry",
};
@@ -384,27 +385,21 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
}
if (g_strcmp0 (element_name, "row") == 0) {
- attribute = get_attribute (attribute_names, attribute_values,
- "columns");
- if (attribute == NULL) {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "no \"columns\" attribute for \"row\"");
- return;
- }
- data->num_columns = strtol (attribute, NULL, 10);
-
attribute = get_attribute (attribute_names, attribute_values,
"orientation");
if (attribute != NULL)
data->orientation = strtol (attribute, NULL, 10);
+
+ eek_section_add_row (data->section,
+ data->num_columns,
+ data->orientation);
+
+ data->num_rows++;
goto out;
}
if (g_strcmp0 (element_name, "key") == 0) {
guint keycode;
- gint column, row;
attribute = get_attribute (attribute_names, attribute_values,
"keycode");
@@ -417,29 +412,10 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
}
keycode = strtoul (attribute, NULL, 10);
- attribute = get_attribute (attribute_names, attribute_values,
- "column");
- if (attribute == NULL) {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "no \"column\" attribute for \"key\"");
- return;
- }
- column = strtol (attribute, NULL, 10);
-
- attribute = get_attribute (attribute_names, attribute_values,
- "row");
- if (attribute == NULL) {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "no \"row\" attribute for \"row\"");
- return;
- }
- row = strtol (attribute, NULL, 10);
-
- data->key = eek_section_create_key (data->section, keycode, column, row);
+ data->key = eek_section_create_key (data->section,
+ keycode,
+ data->num_columns,
+ data->num_rows - 1);
attribute = get_attribute (attribute_names, attribute_values,
"name");
@@ -458,6 +434,9 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
g_hash_table_insert (data->key_oref_hash,
data->key,
g_strdup (attribute));
+
+ data->num_columns++;
+
goto out;
}
@@ -533,6 +512,7 @@ geometry_end_element_callback (GMarkupParseContext *pcontext,
if (g_strcmp0 (element_name, "section") == 0) {
data->section = NULL;
+ data->num_rows = 0;
return;
}
@@ -541,6 +521,12 @@ geometry_end_element_callback (GMarkupParseContext *pcontext,
return;
}
+ if (g_strcmp0 (element_name, "row") == 0) {
+ data->num_columns = 0;
+ data->orientation = EEK_ORIENTATION_HORIZONTAL;
+ return;
+ }
+
if (g_strcmp0 (element_name, "outline") == 0) {
EekOutline *outline = g_slice_new (EekOutline);
@@ -566,15 +552,6 @@ geometry_end_element_callback (GMarkupParseContext *pcontext,
g_free (data->oref);
return;
}
-
- if (g_strcmp0 (element_name, "row") == 0) {
- eek_section_add_row (data->section,
- data->num_columns,
- data->orientation);
- data->num_columns = 0;
- data->orientation = EEK_ORIENTATION_HORIZONTAL;
- return;
- }
}
static const GMarkupParser geometry_parser = {