diff --git a/data/keyboards/geometry/compact.xml b/data/keyboards/geometry/compact.xml
index 522521d2..b0942e2b 100644
--- a/data/keyboards/geometry/compact.xml
+++ b/data/keyboards/geometry/compact.xml
@@ -1,36 +1,7 @@
-
- AD01 AD02 AD03 AD04 AD05 AD06 AD07 AD08 AD09 AD10
- AC01 AC02 AC03 AC04 AC05 AC06 AC07 AC08 AC09 AC10
- LFSH AB01 AB02 AB03 AB04 AB05 AB06 AB07 BKSP
- ABC123 I149 SPCE AB08 RTRN
-
-
- AD01 AD02 AD03 AD04 AD05 AD06 AD07 AD08 AD09 AD10
- AC01 AC02 AC03 AC04 AC05 AC06 AC07 AC08 AC09 AC10
- LFSH AB01 AB02 AB03 AB04 AB05 AB06 AB07 BKSP
- ABC123 I149 SPCE AB08 RTRN
-
-
- AD01 AD02 AD03 AD04 AD05 AD06 AD07 AD08 AD09 AD10
- AC01 AC02 AC03 AC04 AC05 AC06 AC07 AC08 AC09 AC10
- LFSH AB01 AB02 AB03 AB04 AB05 AB06 AB07 BKSP
- ABC123 I149 SPCE AB08 RTRN
-
-
- AD01 AD02 AD03 AD04 AD05 AD06 AD07 AD08 AD09 AD10
- AC01 AC02 AC03 AC04 AC05 AC06 AC07 AC08 AC09 AC10
- LFSH AB01 AB02 AB03 AB04 AB05 AB06 AB07 BKSP
- ABC123 I149 SPCE AB08 RTRN
-
-
-
-
-
-
-
+
@@ -97,4 +68,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Shift_L z x c v b n m BackSpace
+ show_numbers preferences space period Return
+
+
+
+
+ Shift_L Z X C V B N M BackSpace
+ show_numbers preferences space period Return
+
+
+
+ at numbersign dollar percent ampersand minus underscore plus parenleft parenright
+ Shift_L comma quotedbl quoteright colon semicolon exclam question BackSpace
+ show_letters preferences space period Return
+
+
+ asciitilde quoteleft bar U00B7 squareroot Greek_pi Greek_tau division multiply paragraph
+ copyright U00AE U00A3 EuroSign U00A5 asciicircum degree asterisk braceleft braceright
+ Shift_L backslash slash less greater equal bracketleft bracketright BackSpace
+ show_letters preferences space period Return
+
diff --git a/data/keyboards/geometry/number-keypad.xml b/data/keyboards/geometry/number-keypad.xml
index 1894658d..59e7678e 100644
--- a/data/keyboards/geometry/number-keypad.xml
+++ b/data/keyboards/geometry/number-keypad.xml
@@ -1,34 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -42,58 +14,27 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ 1 2 3 parenleft parenright
+ 4 5 6 numbersign asterisk
+
+
+
diff --git a/data/keyboards/symbols/us.xml b/data/keyboards/symbols/us.xml
index c130029c..d058b4ae 100644
--- a/data/keyboards/symbols/us.xml
+++ b/data/keyboards/symbols/us.xml
@@ -1,5 +1,6 @@
+ asterisk
q
Q
@@ -58,7 +59,7 @@
p
P
0
- U25B3
+ Greek_tau
a
@@ -183,10 +184,8 @@
period
- show-numbers
- show-numbers
- show-letters
- show-letters
+ show_numbers
+ show_letters
preferences
diff --git a/eek/eek-key.c b/eek/eek-key.c
index 9bc19b92..0b4b6e3c 100644
--- a/eek/eek-key.c
+++ b/eek/eek-key.c
@@ -194,6 +194,10 @@ eek_key_init (EekKey *self)
priv->state = squeek_key_new (0);
}
+void eek_key_share_state(EekKey *self, struct squeek_key *state) {
+ EekKeyPrivate *priv = eek_key_get_instance_private (self);
+ priv->state = state;
+}
/**
* eek_key_set_keycode:
* @key: an #EekKey
diff --git a/eek/eek-key.h b/eek/eek-key.h
index 1213548e..a6699333 100644
--- a/eek/eek-key.h
+++ b/eek/eek-key.h
@@ -71,6 +71,6 @@ gboolean eek_key_is_pressed (EekKey *key);
gboolean eek_key_is_locked (EekKey *key);
void eek_key_set_pressed (EekKey *key,
gboolean value);
-
+void eek_key_share_state(EekKey *self, struct squeek_key *state);
G_END_DECLS
#endif /* EEK_KEY_H */
diff --git a/eek/eek-keyboard.c b/eek/eek-keyboard.c
index a5986be3..fe149e9f 100644
--- a/eek/eek-keyboard.c
+++ b/eek/eek-keyboard.c
@@ -144,15 +144,18 @@ eek_keyboard_get_property (GObject *object,
}
/// Updates the state of locked keys based on the key that was activated
-static void
+/// FIXME: make independent of what the key are named,
+/// and instead refer to the contained symbols
+static guint
set_key_states (LevelKeyboard *keyboard,
- EekKey *key)
+ EekKey *key,
+ guint new_level)
{
// Keys locking rules hardcoded for the time being...
const gchar *name = eek_element_get_name(EEK_ELEMENT(key));
- // Lock the shift whenever it's pressed
+ // Lock the shift whenever it's pressed on the baselevel
// TODO: need to lock shift on the destination level
- if (g_strcmp0(name, "LFSH-0") == 0) {
+ if (g_strcmp0(name, "Shift_L") == 0 && keyboard->level == 0) {
EekModifierKey *modifier_key = g_slice_new (EekModifierKey);
modifier_key->modifiers = 0;
modifier_key->key = g_object_ref (key);
@@ -172,10 +175,12 @@ set_key_states (LevelKeyboard *keyboard,
g_list_free1 (head);
head = next;
}
- keyboard->level = 0;
+ return 0;
}
+ return new_level;
}
+// FIXME: unhardcode, parse some user information as to which key triggers which view (level)
static void
set_level_from_press (LevelKeyboard *keyboard, EekKey *key)
{
@@ -184,31 +189,21 @@ set_level_from_press (LevelKeyboard *keyboard, EekKey *key)
/* Handle non-emitting keys */
if (key) {
const gchar *name = eek_element_get_name(EEK_ELEMENT(key));
- if (g_strcmp0(name, "ABC123-0") == 0 || g_strcmp0(name, "ABC123-1") == 0) {
+ if (g_strcmp0(name, "show_numbers") == 0) {
level = 2;
- } else if (g_strcmp0(name, "ABC123-2") == 0 || g_strcmp0(name, "ABC123-3") == 0) {
+ } else if (g_strcmp0(name, "show_letters") == 0) {
level = 0;
- } else if (g_strcmp0(name, "LFSH-0") == 0) {
- level = 1;
- } else if (g_strcmp0(name, "LFSH-1") == 0) {
- level = 0;
- } else if (g_strcmp0(name, "LFSH-2") == 0) {
- level = 3;
- } else if (g_strcmp0(name, "LFSH-3") == 0) {
- level = 2;
+ } else if (g_strcmp0(name, "Shift_L") == 0) {
+ level ^= 1;
}
}
- set_key_states(keyboard, key);
-
- keyboard->level = level;
+ keyboard->level = set_key_states(keyboard, key, level);
eek_layout_update_layout(keyboard);
}
void eek_keyboard_press_key(LevelKeyboard *keyboard, EekKey *key, guint32 timestamp) {
- EekKeyboardPrivate *priv = EEK_KEYBOARD_GET_PRIVATE(level_keyboard_current(keyboard));
-
eek_key_set_pressed(key, TRUE);
keyboard->pressed_keys = g_list_prepend (keyboard->pressed_keys, key);
@@ -218,8 +213,8 @@ void eek_keyboard_press_key(LevelKeyboard *keyboard, EekKey *key, guint32 timest
if (!symbol)
return;
- set_key_states (keyboard, key);
- set_level_from_press (keyboard, key);
+ // Only take action about setting level *after* the key has taken effect, i.e. on release
+ //set_level_from_press (keyboard, key);
// "Borrowed" from eek-context-service; doesn't influence the state but forwards the event
@@ -231,8 +226,6 @@ void eek_keyboard_press_key(LevelKeyboard *keyboard, EekKey *key, guint32 timest
void eek_keyboard_release_key(LevelKeyboard *keyboard,
EekKey *key,
guint32 timestamp) {
- EekKeyboardPrivate *priv = EEK_KEYBOARD_GET_PRIVATE(level_keyboard_current(keyboard));
-
for (GList *head = keyboard->pressed_keys; head; head = g_list_next (head)) {
if (head->data == key) {
keyboard->pressed_keys = g_list_remove_link (keyboard->pressed_keys, head);
@@ -246,7 +239,6 @@ void eek_keyboard_release_key(LevelKeyboard *keyboard,
if (!symbol)
return;
- set_key_states (keyboard, key);
set_level_from_press (keyboard, key);
// "Borrowed" from eek-context-service; doesn't influence the state but forwards the event
@@ -311,7 +303,6 @@ eek_keyboard_class_init (EekKeyboardClass *klass)
{
EekContainerClass *container_class = EEK_CONTAINER_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GParamSpec *pspec;
/* signals */
container_class->child_added = eek_keyboard_real_child_added;
diff --git a/eek/eek-section.c b/eek/eek-section.c
index 843d4fd7..88508625 100644
--- a/eek/eek-section.c
+++ b/eek/eek-section.c
@@ -121,7 +121,8 @@ on_unlocked (EekKey *key,
static EekKey *
eek_section_real_create_key (EekSection *self,
const gchar *name,
- gint keycode)
+ gint keycode,
+ guint oref)
{
EekSectionPrivate *priv = (EekSectionPrivate*)eek_section_get_instance_private (self);
@@ -131,8 +132,9 @@ eek_section_real_create_key (EekSection *self,
EekKey *key = (EekKey*)g_object_new (EEK_TYPE_KEY,
"name", name,
NULL);
- eek_key_set_keycode(key, keycode);
g_return_val_if_fail (key, NULL);
+ eek_key_set_keycode(key, keycode);
+ eek_key_set_oref(key, oref);
EEK_CONTAINER_GET_CLASS(self)->add_child (EEK_CONTAINER(self),
EEK_ELEMENT(key));
@@ -140,6 +142,25 @@ eek_section_real_create_key (EekSection *self,
return key;
}
+EekKey *eek_section_create_button(EekSection *self,
+ const gchar *name,
+ struct squeek_key *state) {
+ EekSectionPrivate *priv = (EekSectionPrivate*)eek_section_get_instance_private (self);
+
+ EekRow *row = &priv->row;
+ row->num_columns++;
+
+ EekKey *key = (EekKey*)g_object_new (EEK_TYPE_KEY,
+ "name", name,
+ NULL);
+ g_return_val_if_fail (key, NULL);
+ eek_key_share_state(key, state);
+
+ EEK_CONTAINER_GET_CLASS(self)->add_child (EEK_CONTAINER(self),
+ EEK_ELEMENT(key));
+ return key;
+}
+
static void
eek_section_finalize (GObject *object)
{
@@ -383,12 +404,13 @@ eek_section_get_row (EekSection *section,
EekKey *
eek_section_create_key (EekSection *section,
const gchar *name,
- guint keycode)
+ guint keycode,
+ guint oref)
{
g_return_val_if_fail (EEK_IS_SECTION(section), NULL);
- return EEK_SECTION_GET_CLASS(section)->create_key (section,
+ return eek_section_real_create_key (section,
name,
- keycode);
+ keycode, oref);
}
const double keyspacing = 4.0;
diff --git a/eek/eek-section.h b/eek/eek-section.h
index e0ac424b..808d0ff4 100644
--- a/eek/eek-section.h
+++ b/eek/eek-section.h
@@ -29,6 +29,7 @@
#include "eek-container.h"
#include "eek-types.h"
#include "eek-keyboard.h"
+#include "src/keyboard.h"
G_BEGIN_DECLS
@@ -96,8 +97,10 @@ void eek_section_get_row (EekSection *section,
EekKey *eek_section_create_key (EekSection *section,
const gchar *name,
- guint keycode);
-
+ guint keycode, guint oref);
+EekKey *eek_section_create_button(EekSection *self,
+ const gchar *name,
+ struct squeek_key *state);
void eek_section_place_keys (EekSection *section, LevelKeyboard *keyboard);
G_END_DECLS
diff --git a/eek/eek-xml-layout.c b/eek/eek-xml-layout.c
index 3331112b..06771df4 100644
--- a/eek/eek-xml-layout.c
+++ b/eek/eek-xml-layout.c
@@ -237,40 +237,42 @@ struct _GeometryParseData {
guint view_idx;
EekSection *section;
EekKey *key;
- gint num_columns;
gint num_rows;
EekOrientation orientation;
gdouble corner_radius;
GSList *points;
gchar *name;
EekOutline outline;
- gchar *oref;
+ gchar *outline_id;
guint keycode;
GString *text;
+ GArray *outline_array;
+
GHashTable *name_key_hash; // char* -> EekKey*
- GHashTable *key_oref_hash;
- GHashTable *oref_outline_hash;
+ GHashTable *keyname_oref_hash; // char* -> guint
+ GHashTable *outlineid_oref_hash; // char* -> guint
};
typedef struct _GeometryParseData GeometryParseData;
static GeometryParseData *
-geometry_parse_data_new (EekKeyboard **views, GHashTable *name_key_hash)
+geometry_parse_data_new (EekKeyboard **views, GHashTable *name_key_hash, GArray *outline_array)
{
GeometryParseData *data = g_slice_new0 (GeometryParseData);
data->views = views;
- data->key_oref_hash =
- g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- NULL,
- g_free);
- data->oref_outline_hash =
+ data->outline_array = outline_array;
+ data->keyname_oref_hash =
g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
- (GDestroyNotify)eek_outline_free);
+ NULL);
+ data->outlineid_oref_hash =
+ g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ NULL);
data->name_key_hash = name_key_hash;
data->text = g_string_sized_new (BUFSIZE);
@@ -281,8 +283,8 @@ geometry_parse_data_new (EekKeyboard **views, GHashTable *name_key_hash)
static void
geometry_parse_data_free (GeometryParseData *data)
{
- g_hash_table_destroy (data->key_oref_hash);
- g_hash_table_destroy (data->oref_outline_hash);
+ g_hash_table_destroy (data->keyname_oref_hash);
+ g_hash_table_destroy (data->outlineid_oref_hash);
g_string_free (data->text, TRUE);
g_slice_free (GeometryParseData, data);
}
@@ -409,17 +411,21 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
const gchar *keycode_name = get_attribute (attribute_names, attribute_values,
"keycode");
- for (uint i = 0; i < 4; i++) {
- gchar *name = g_strdup_printf("%s-%d", base_name, i);
- EekKey *key = g_hash_table_lookup(data->name_key_hash, name);
- if (!key) {
- continue; // not all keys have to be defined in every view
- }
- g_hash_table_insert (data->key_oref_hash,
- key,
- g_strdup (oref_name));
+ guint oref = GPOINTER_TO_UINT(g_hash_table_lookup(data->outlineid_oref_hash,
+ oref_name));
+ const gchar *name = base_name;
+ g_hash_table_insert (data->keyname_oref_hash,
+ g_strdup(name),
+ GUINT_TO_POINTER(oref));
+ EekKey *key = g_hash_table_lookup(data->name_key_hash, name);
+ // never gets used! this section gets executed before any buttons get defined
+ if (key) {
if (keycode_name != NULL) {
+ // This sets the keycode for all buttons,
+ // since they share state
+ // TODO: get rid of this in the parser;
+ // this belongs after keymap is defined
eek_key_set_keycode(key, strtol (keycode_name, NULL, 10));
}
}
@@ -436,7 +442,7 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
"no \"id\" attribute for \"outline\"");
return;
}
- data->oref = g_strdup (attribute);
+ data->outline_id = g_strdup (attribute);
attribute = get_attribute (attribute_names, attribute_values,
"corner-radius");
@@ -484,6 +490,29 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
data->text->len = 0;
}
+
+/**
+ * eek_keyboard_add_outline:
+ * @keyboard: an #EekKeyboard
+ * @outline: an #EekOutline
+ *
+ * Register an outline of @keyboard.
+ * Returns: an unsigned integer ID of the registered outline, for
+ * later reference
+ */
+static guint
+add_outline (GArray *outline_array,
+ EekOutline *outline)
+{
+ EekOutline *_outline;
+
+ _outline = eek_outline_copy (outline);
+ g_array_append_val (outline_array, *_outline);
+ /* don't use eek_outline_free here, so as to keep _outline->points */
+ g_slice_free (EekOutline, _outline);
+ return outline_array->len - 1;
+}
+
static void
geometry_end_element_callback (GMarkupParseContext *pcontext,
const gchar *element_name,
@@ -529,24 +558,33 @@ geometry_end_element_callback (GMarkupParseContext *pcontext,
break;
}
- // Save button name together with its level,
- // to account for buttons with the same name in multiple levels
- gchar *base_name = g_strndup (&text[start], end - start);
- gchar *name = g_strdup_printf("%s-%d", base_name, data->view_idx);
- g_free(base_name);
- guint keycode = data->keycode++;
+ gchar *name = g_strndup (&text[start], end - start);
+ EekKey *key = g_hash_table_lookup(data->name_key_hash, name);
+ if (!key) {
+ // Save button name together with its level,
+ // to account for buttons with the same name in multiple levels
+ guint keycode = data->keycode++;
- data->key = eek_section_create_key (data->section,
- name,
- keycode);
- g_hash_table_insert (data->name_key_hash,
- g_strdup(name),
- data->key);
- data->num_columns++;
-
- g_hash_table_insert (data->key_oref_hash,
- data->key,
- g_strdup ("default"));
+ guint oref = GPOINTER_TO_UINT(g_hash_table_lookup(data->keyname_oref_hash, name));
+ // default value gives idx 0, which is guaranteed to be occupied
+ key = eek_section_create_key (data->section,
+ name,
+ keycode,
+ oref);
+ g_hash_table_insert (data->name_key_hash,
+ g_strdup(name),
+ key);
+ } else {
+ EekKey *new_key = eek_section_create_button(data->section, name, eek_key_get_state(key));
+ if (!new_key) {
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_MISSING_ATTRIBUTE,
+ "Couldn't create a shared button");
+ return;
+ }
+ eek_key_set_oref(new_key, eek_key_get_oref(key));
+ }
}
data->section = NULL;
@@ -573,11 +611,11 @@ geometry_end_element_callback (GMarkupParseContext *pcontext,
g_slist_free (data->points);
data->points = NULL;
- g_hash_table_insert (data->oref_outline_hash,
- g_strdup (data->oref),
- outline);
+ guint oref = add_outline (data->outline_array, outline);
- g_free (data->oref);
+ g_hash_table_insert (data->outlineid_oref_hash,
+ data->outline_id,
+ GUINT_TO_POINTER(oref));
return;
}
}
@@ -607,8 +645,6 @@ struct _SymbolsParseData {
LevelKeyboard *keyboard;
EekKeyboard *view;
- guint key_level;
- const gchar *key_name;
gchar *label;
gchar *icon;
@@ -636,6 +672,7 @@ symbols_parse_data_free (SymbolsParseData *data)
static const gchar *symbols_valid_path_list[] = {
"symbols",
+ "symbol/symbols",
"include/symbols",
"key/symbols",
"text/key/symbols",
@@ -662,22 +699,6 @@ symbols_start_element_callback (GMarkupParseContext *pcontext,
error))
return;
- if (g_strcmp0 (element_name, "key") == 0) {
- data->key_level = 0;
- attribute = get_attribute (attribute_names, attribute_values,
- "name");
-
- if (attribute == NULL) {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_MISSING_ATTRIBUTE,
- "no \"name\" attribute for \"key\"");
- return;
- }
- data->key_name = strdup(attribute);
- goto out;
- }
-
if (g_strcmp0 (element_name, "keysym") == 0) {
attribute = get_attribute (attribute_names, attribute_values,
"keyval");
@@ -710,7 +731,6 @@ symbols_start_element_callback (GMarkupParseContext *pcontext,
data->tooltip = g_strdup (attribute);
}
- out:
data->element_stack = g_slist_prepend (data->element_stack,
g_strdup (element_name));
data->text->len = 0;
@@ -730,33 +750,28 @@ symbols_end_element_callback (GMarkupParseContext *pcontext,
data->element_stack = g_slist_next (data->element_stack);
g_slist_free1 (head);
+ // TODO: this could all be moved to text handler
text = g_strndup (data->text->str, data->text->len);
if (g_strcmp0 (element_name, "symbol") == 0 ||
g_strcmp0 (element_name, "keysym") == 0 ||
g_strcmp0 (element_name, "text") == 0) {
- gchar *name = g_strdup_printf("%s-%d", data->key_name, data->key_level);
+ gchar *name = text;
EekKey *key = eek_keyboard_find_key_by_name (data->keyboard,
name);
- if (key == NULL) {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_INVALID_CONTENT,
- "no such key %s", name);
- return;
+ if (key) {
+ squeek_key_add_symbol(
+ eek_key_get_state(key),
+ element_name,
+ text,
+ data->keyval,
+ data->label,
+ data->icon,
+ data->tooltip
+ );
}
- squeek_key_add_symbol(
- eek_key_get_state(key),
- element_name,
- text,
- data->keyval,
- data->label,
- data->icon,
- data->tooltip
- );
-
data->keyval = 0;
g_free(data->label);
data->label = NULL;
@@ -764,8 +779,6 @@ symbols_end_element_callback (GMarkupParseContext *pcontext,
data->icon = NULL;
g_free(data->tooltip);
data->tooltip = NULL;
-
- data->key_level++;
goto out;
}
@@ -1135,36 +1148,11 @@ eek_xml_keyboard_desc_free (EekXmlKeyboardDesc *desc)
g_slice_free (EekXmlKeyboardDesc, desc);
}
-/**
- * eek_keyboard_add_outline:
- * @keyboard: an #EekKeyboard
- * @outline: an #EekOutline
- *
- * Register an outline of @keyboard.
- * Returns: an unsigned integer ID of the registered outline, for
- * later reference
- */
-static guint
-add_outline (GArray *outline_array,
- EekOutline *outline)
-{
- EekOutline *_outline;
-
- _outline = eek_outline_copy (outline);
- g_array_append_val (outline_array, *_outline);
- /* don't use eek_outline_free here, so as to keep _outline->points */
- g_slice_free (EekOutline, _outline);
- return outline_array->len - 1;
-}
-
static gboolean
parse_geometry (const gchar *path, EekKeyboard **views, GArray *outline_array, GHashTable *name_key_hash, GError **error)
{
GeometryParseData *data;
GMarkupParseContext *pcontext;
- GHashTable *oref_hash;
- GHashTableIter iter;
- gpointer k, v;
GFile *file;
GFileInputStream *input;
gboolean retval;
@@ -1178,7 +1166,7 @@ parse_geometry (const gchar *path, EekKeyboard **views, GArray *outline_array, G
if (input == NULL)
return FALSE;
- data = geometry_parse_data_new (views, name_key_hash);
+ data = geometry_parse_data_new (views, name_key_hash, outline_array);
pcontext = g_markup_parse_context_new (&geometry_parser,
0,
data,
@@ -1193,6 +1181,11 @@ parse_geometry (const gchar *path, EekKeyboard **views, GArray *outline_array, G
}
/* Resolve outline references. */
+ /*
+ * GHashTable *oref_hash;
+ GHashTableIter iter;
+ gpointer k, v;
+
oref_hash = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_iter_init (&iter, data->oref_outline_hash);
while (g_hash_table_iter_next (&iter, &k, &v)) {
@@ -1201,15 +1194,16 @@ parse_geometry (const gchar *path, EekKeyboard **views, GArray *outline_array, G
oref = add_outline (outline_array, outline);
g_hash_table_insert (oref_hash, k, GUINT_TO_POINTER(oref));
- }
+ }*/
+ /*
g_hash_table_iter_init (&iter, data->key_oref_hash);
while (g_hash_table_iter_next (&iter, &k, &v)) {
gpointer oref;
if (g_hash_table_lookup_extended (oref_hash, v, NULL, &oref))
eek_key_set_oref (EEK_KEY(k), GPOINTER_TO_UINT(oref));
- }
- g_hash_table_destroy (oref_hash);
+ }*/
+// g_hash_table_destroy (oref_hash);
geometry_parse_data_free (data);
return TRUE;
diff --git a/src/keyboard.rs b/src/keyboard.rs
index 6be9cdb1..a7be346e 100644
--- a/src/keyboard.rs
+++ b/src/keyboard.rs
@@ -94,6 +94,14 @@ pub mod c {
}
});
+ let key = unsafe { &mut *key };
+
+ if key.symbols.len() > 0 {
+ eprintln!("Key {:?} already has a symbol defined", text);
+ return;
+ }
+
+
let icon = into_cstring(icon)
.unwrap_or_else(|e| {
eprintln!("Icon name unreadable: {}", e);
@@ -155,7 +163,6 @@ pub mod c {
_ => panic!("unsupported element type {:?}", element),
};
- let key = unsafe { &mut *key };
key.symbols.push(symbol);
}
@@ -213,7 +220,7 @@ pub mod c {
};
format!("[ {} ], [ {} ]", first, second)
},
- _ => panic!("Unsupported number of symbols"),
+ _ => panic!("Unsupported number of symbols: {}", symbol_names.len()),
};
CString::new(format!(" key <{}> {{ {} }};\n", key_name, inner))
diff --git a/tests/eek-simple-test.c b/tests/eek-simple-test.c
index 0e300645..3fa4ff32 100644
--- a/tests/eek-simple-test.c
+++ b/tests/eek-simple-test.c
@@ -32,9 +32,9 @@ test_create (void)
section = eek_keyboard_real_create_section (keyboard);
g_assert (EEK_IS_SECTION(section));
eek_section_add_row (section, 2, EEK_ORIENTATION_HORIZONTAL);
- key0 = eek_section_create_key (section, "key0", 1);
+ key0 = eek_section_create_key (section, "key0", 1, 0);
g_assert (EEK_IS_KEY(key0));
- key1 = eek_section_create_key (section, "key1", 2);
+ key1 = eek_section_create_key (section, "key1", 2, 0);
g_assert (EEK_IS_KEY(key1));
}