geometry: Move customizations to the button table
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
<key name="AC10" />
|
||||
</section>
|
||||
<section angle="0">
|
||||
<key name="LFSH" oref="altline" />
|
||||
<key name="LFSH" />
|
||||
<key name="AB01" />
|
||||
<key name="AB02" />
|
||||
<key name="AB03" />
|
||||
@ -34,15 +34,21 @@
|
||||
<key name="AB05" />
|
||||
<key name="AB06" />
|
||||
<key name="AB07" />
|
||||
<key name="BKSP" oref="altline" />
|
||||
<key name="BKSP" />
|
||||
</section>
|
||||
<section angle="0">
|
||||
<key keycode="0" name="ABC123" oref="altline" />
|
||||
<key name="I149" oref="altline" />
|
||||
<key name="SPCE" oref="spaceline" />
|
||||
<key keycode="0" name="ABC123" />
|
||||
<key name="I149" />
|
||||
<key name="SPCE" />
|
||||
<key name="AB08" />
|
||||
<key name="RTRN" oref="outline7" />
|
||||
<key name="RTRN" />
|
||||
</section>
|
||||
<button name="LFSH" oref="altline" />
|
||||
<button name="BKSP" oref="altline" />
|
||||
<button name="I149" oref="altline" />
|
||||
<button name="ABC123" oref="altline" />
|
||||
<button name="SPCE" oref="spaceline" />
|
||||
<button name="RTRN" oref="outline7" />
|
||||
<outline id="default" corner-radius="1.000000">
|
||||
<point x="0.000000" y="0.000000"/>
|
||||
<point x="37.46341" y="0.000000"/>
|
||||
|
||||
@ -454,7 +454,7 @@ eek_section_get_row (EekSection *section,
|
||||
EekKey *
|
||||
eek_section_create_key (EekSection *section,
|
||||
const gchar *name,
|
||||
gint keycode)
|
||||
guint keycode)
|
||||
{
|
||||
g_return_val_if_fail (EEK_IS_SECTION(section), NULL);
|
||||
return EEK_SECTION_GET_CLASS(section)->create_key (section,
|
||||
|
||||
@ -99,10 +99,7 @@ void eek_section_get_row (EekSection *section,
|
||||
|
||||
EekKey *eek_section_create_key (EekSection *section,
|
||||
const gchar *name,
|
||||
gint keycode);
|
||||
|
||||
EekKey *eek_section_find_key_by_keycode (EekSection *section,
|
||||
guint keycode);
|
||||
guint keycode);
|
||||
|
||||
void eek_section_place_keys (EekSection *section, EekKeyboard *keyboard);
|
||||
|
||||
|
||||
@ -244,8 +244,9 @@ struct _GeometryParseData {
|
||||
gchar *name;
|
||||
EekOutline outline;
|
||||
gchar *oref;
|
||||
gint keycode;
|
||||
guint keycode;
|
||||
|
||||
GHashTable *name_key_hash; // char* -> EekKey*
|
||||
GHashTable *key_oref_hash;
|
||||
GHashTable *oref_outline_hash;
|
||||
};
|
||||
@ -267,6 +268,12 @@ geometry_parse_data_new (EekKeyboard *keyboard)
|
||||
g_str_equal,
|
||||
g_free,
|
||||
(GDestroyNotify)eek_outline_free);
|
||||
|
||||
data->name_key_hash =
|
||||
g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
g_free,
|
||||
NULL);
|
||||
data->keycode = 8;
|
||||
return data;
|
||||
}
|
||||
@ -282,6 +289,7 @@ geometry_parse_data_free (GeometryParseData *data)
|
||||
|
||||
static const gchar *geometry_valid_path_list[] = {
|
||||
"geometry",
|
||||
"button/geometry",
|
||||
"bounds/geometry",
|
||||
"section/geometry",
|
||||
"outline/geometry",
|
||||
@ -375,20 +383,6 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (element_name, "row") == 0) {
|
||||
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;
|
||||
|
||||
@ -413,18 +407,40 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
|
||||
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"));
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (element_name, "button") == 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 \"button\"");
|
||||
return;
|
||||
}
|
||||
gchar *name = g_strdup (attribute);
|
||||
|
||||
EekKey *key = g_hash_table_lookup(data->name_key_hash, name);
|
||||
attribute = get_attribute (attribute_names, attribute_values,
|
||||
"oref");
|
||||
if (attribute == NULL) {
|
||||
attribute = g_strdup("default");
|
||||
}
|
||||
g_hash_table_insert (data->key_oref_hash,
|
||||
data->key,
|
||||
key,
|
||||
g_strdup (attribute));
|
||||
|
||||
data->num_columns++;
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user