key: Share state between multiple keys
This commit is contained in:
@ -1,36 +1,7 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<geometry version="0.90">
|
<geometry version="0.90">
|
||||||
<bounds x="10" y="10" width="410.0000" height="229"/>
|
<bounds x="10" y="10" width="410.0000" height="229"/>
|
||||||
<view>
|
|
||||||
<section angle="0">AD01 AD02 AD03 AD04 AD05 AD06 AD07 AD08 AD09 AD10</section>
|
|
||||||
<section angle="0">AC01 AC02 AC03 AC04 AC05 AC06 AC07 AC08 AC09 AC10</section>
|
|
||||||
<section angle="0"> LFSH AB01 AB02 AB03 AB04 AB05 AB06 AB07 BKSP </section>
|
|
||||||
<section angle="0"> ABC123 I149 SPCE AB08 RTRN </section>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<section angle="0">AD01 AD02 AD03 AD04 AD05 AD06 AD07 AD08 AD09 AD10</section>
|
|
||||||
<section angle="0">AC01 AC02 AC03 AC04 AC05 AC06 AC07 AC08 AC09 AC10</section>
|
|
||||||
<section angle="0"> LFSH AB01 AB02 AB03 AB04 AB05 AB06 AB07 BKSP </section>
|
|
||||||
<section angle="0"> ABC123 I149 SPCE AB08 RTRN </section>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<section angle="0">AD01 AD02 AD03 AD04 AD05 AD06 AD07 AD08 AD09 AD10</section>
|
|
||||||
<section angle="0">AC01 AC02 AC03 AC04 AC05 AC06 AC07 AC08 AC09 AC10</section>
|
|
||||||
<section angle="0"> LFSH AB01 AB02 AB03 AB04 AB05 AB06 AB07 BKSP </section>
|
|
||||||
<section angle="0"> ABC123 I149 SPCE AB08 RTRN </section>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<section angle="0">AD01 AD02 AD03 AD04 AD05 AD06 AD07 AD08 AD09 AD10</section>
|
|
||||||
<section angle="0">AC01 AC02 AC03 AC04 AC05 AC06 AC07 AC08 AC09 AC10</section>
|
|
||||||
<section angle="0"> LFSH AB01 AB02 AB03 AB04 AB05 AB06 AB07 BKSP </section>
|
|
||||||
<section angle="0"> ABC123 I149 SPCE AB08 RTRN </section>
|
|
||||||
</view>
|
|
||||||
<button name="LFSH" oref="altline" />
|
|
||||||
<button name="BKSP" oref="altline" />
|
|
||||||
<button name="I149" oref="altline" />
|
|
||||||
<button name="ABC123" oref="altline" keycode="0" />
|
|
||||||
<button name="SPCE" oref="spaceline" />
|
|
||||||
<button name="RTRN" oref="outline7" />
|
|
||||||
<outline id="default" corner-radius="1.000000">
|
<outline id="default" corner-radius="1.000000">
|
||||||
<point x="0.000000" y="0.000000"/>
|
<point x="0.000000" y="0.000000"/>
|
||||||
<point x="37.46341" y="0.000000"/>
|
<point x="37.46341" y="0.000000"/>
|
||||||
@ -97,4 +68,37 @@
|
|||||||
<point x="150.5853" y="52"/>
|
<point x="150.5853" y="52"/>
|
||||||
<point x="0.000000" y="52"/>
|
<point x="0.000000" y="52"/>
|
||||||
</outline>
|
</outline>
|
||||||
|
|
||||||
|
<button name="Shift_L" oref="altline" />
|
||||||
|
<button name="BackSpace" oref="altline" />
|
||||||
|
<button name="preferences" oref="altline" />
|
||||||
|
<button name="show_numbers" oref="altline" keycode="0" />
|
||||||
|
<button name="show_letters" oref="altline" keycode="0" />
|
||||||
|
<button name="space" oref="spaceline" />
|
||||||
|
<button name="return" oref="outline7" />
|
||||||
|
|
||||||
|
<view>
|
||||||
|
<section angle="0">q w e r t y u i o p</section>
|
||||||
|
<section angle="0">a s d f g h j k l</section>
|
||||||
|
<section angle="0"> Shift_L z x c v b n m BackSpace </section>
|
||||||
|
<section angle="0"> show_numbers preferences space period Return </section>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<section angle="0">Q W E R T Y U I O P</section>
|
||||||
|
<section angle="0">A S D F G H J K L</section>
|
||||||
|
<section angle="0"> Shift_L Z X C V B N M BackSpace </section>
|
||||||
|
<section angle="0"> show_numbers preferences space period Return </section>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<section angle="0">1 2 3 4 5 5 6 7 8 9 0</section>
|
||||||
|
<section angle="0">at numbersign dollar percent ampersand minus underscore plus parenleft parenright</section>
|
||||||
|
<section angle="0"> Shift_L comma quotedbl quoteright colon semicolon exclam question BackSpace </section>
|
||||||
|
<section angle="0"> show_letters preferences space period Return </section>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<section angle="0">asciitilde quoteleft bar U00B7 squareroot Greek_pi Greek_tau division multiply paragraph</section>
|
||||||
|
<section angle="0">copyright U00AE U00A3 EuroSign U00A5 asciicircum degree asterisk braceleft braceright</section>
|
||||||
|
<section angle="0"> Shift_L backslash slash less greater equal bracketleft bracketright BackSpace </section>
|
||||||
|
<section angle="0"> show_letters preferences space period Return </section>
|
||||||
|
</view>
|
||||||
</geometry>
|
</geometry>
|
||||||
|
|||||||
@ -1,34 +1,6 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<geometry version="0.90">
|
<geometry version="0.90">
|
||||||
<bounds x="0" y="10.000000" width="426.0000" height="296.5853"/>
|
<bounds x="0" y="10.000000" width="426.0000" height="296.5853"/>
|
||||||
<view>
|
|
||||||
<section angle="0">AD01 AD02 AD03 AD04 AD05</section>
|
|
||||||
<section angle="0">AC01 AC02 AC03 AC04 AC05</section>
|
|
||||||
<section angle="0">AB01 AB02 AB03 AB04 AB05</section>
|
|
||||||
<section angle="0">BKSP AB06 SPCE RTRN</section>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<section angle="0">AD01 AD02 AD03 AD04 AD05</section>
|
|
||||||
<section angle="0">AC01 AC02 AC03 AC04 AC05</section>
|
|
||||||
<section angle="0">AB01 AB02 AB03 AB04 AB05</section>
|
|
||||||
<section angle="0">BKSP AB06 SPCE RTRN</section>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<section angle="0">AD01 AD02 AD03 AD04 AD05</section>
|
|
||||||
<section angle="0">AC01 AC02 AC03 AC04 AC05</section>
|
|
||||||
<section angle="0">AB01 AB02 AB03 AB04 AB05</section>
|
|
||||||
<section angle="0">BKSP AB06 SPCE RTRN</section>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<section angle="0">AD01 AD02 AD03 AD04 AD05</section>
|
|
||||||
<section angle="0">AC01 AC02 AC03 AC04 AC05</section>
|
|
||||||
<section angle="0">AB01 AB02 AB03 AB04 AB05</section>
|
|
||||||
<section angle="0">BKSP AB06 SPCE RTRN</section>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<button name="BKSP" oref="altline" />
|
|
||||||
<button name="SPCE" oref="spaceline" />
|
|
||||||
<button name="RTRN" oref="outline7" />
|
|
||||||
|
|
||||||
<outline id="default" corner-radius="1.000000">
|
<outline id="default" corner-radius="1.000000">
|
||||||
<point x="0.000000" y="0.000000"/>
|
<point x="0.000000" y="0.000000"/>
|
||||||
@ -42,58 +14,27 @@
|
|||||||
<point x="48.39024" y="52.44877"/>
|
<point x="48.39024" y="52.44877"/>
|
||||||
<point x="0.000000" y="52.44877"/>
|
<point x="0.000000" y="52.44877"/>
|
||||||
</outline>
|
</outline>
|
||||||
<outline id="outline4" corner-radius="1.000000">
|
|
||||||
<point x="0.000000" y="0.000000"/>
|
|
||||||
<point x="59.31707" y="0.000000"/>
|
|
||||||
<point x="59.31707" y="52.44877"/>
|
|
||||||
<point x="0.000000" y="52.44877"/>
|
|
||||||
</outline>
|
|
||||||
<outline id="outline5" corner-radius="1.000000">
|
|
||||||
<point x="0.000000" y="0.000000"/>
|
|
||||||
<point x="59.31707" y="0.000000"/>
|
|
||||||
<point x="59.31707" y="52.44877"/>
|
|
||||||
<point x="0.000000" y="52.44877"/>
|
|
||||||
</outline>
|
|
||||||
<outline id="outline6" corner-radius="1.000000">
|
|
||||||
<point x="0.000000" y="0.000000"/>
|
|
||||||
<point x="68.68292" y="0.000000"/>
|
|
||||||
<point x="68.68292" y="52.44877"/>
|
|
||||||
<point x="0.000000" y="52.44877"/>
|
|
||||||
</outline>
|
|
||||||
<outline id="outline7" corner-radius="1.000000">
|
<outline id="outline7" corner-radius="1.000000">
|
||||||
<point x="0.000000" y="0.000000"/>
|
<point x="0.000000" y="0.000000"/>
|
||||||
<point x="88.97561" y="0.000000"/>
|
<point x="88.97561" y="0.000000"/>
|
||||||
<point x="88.97561" y="52.44877"/>
|
<point x="88.97561" y="52.44877"/>
|
||||||
<point x="0.000000" y="52.44877"/>
|
<point x="0.000000" y="52.44877"/>
|
||||||
</outline>
|
</outline>
|
||||||
<outline id="outline8" corner-radius="1.000000">
|
|
||||||
<point x="0.000000" y="0.000000"/>
|
|
||||||
<point x="88.97561" y="0.000000"/>
|
|
||||||
<point x="88.97561" y="52.44877"/>
|
|
||||||
<point x="0.000000" y="52.44877"/>
|
|
||||||
</outline>
|
|
||||||
<outline id="outline9" corner-radius="1.000000">
|
|
||||||
<point x="0.000000" y="0.000000"/>
|
|
||||||
<point x="109.2682" y="0.000000"/>
|
|
||||||
<point x="109.2682" y="52.44877"/>
|
|
||||||
<point x="0.000000" y="52.44877"/>
|
|
||||||
</outline>
|
|
||||||
<outline id="outline10" corner-radius="1.000000">
|
|
||||||
<point x="0.000000" y="0.000000"/>
|
|
||||||
<point x="37.46341" y="0.000000"/>
|
|
||||||
<point x="37.46341" y="52.44877"/>
|
|
||||||
<point x="0.000000" y="52.44877"/>
|
|
||||||
</outline>
|
|
||||||
<outline id="outline13" corner-radius="1.000000">
|
|
||||||
<point x="0.000000" y="0.000000"/>
|
|
||||||
<point x="79.60975" y="0.000000"/>
|
|
||||||
<point x="79.60975" y="52.44877"/>
|
|
||||||
<point x="0.000000" y="52.44877"/>
|
|
||||||
</outline>
|
|
||||||
<outline id="spaceline" corner-radius="1.000000">
|
<outline id="spaceline" corner-radius="1.000000">
|
||||||
<point x="0.000000" y="0.000000"/>
|
<point x="0.000000" y="0.000000"/>
|
||||||
<point x="120.5853" y="0.000000"/>
|
<point x="120.5853" y="0.000000"/>
|
||||||
<point x="120.5853" y="52.44877"/>
|
<point x="120.5853" y="52.44877"/>
|
||||||
<point x="0.000000" y="52.44877"/>
|
<point x="0.000000" y="52.44877"/>
|
||||||
</outline>
|
</outline>
|
||||||
|
|
||||||
|
<button name="BackSpace" oref="altline" />
|
||||||
|
<button name="space" oref="spaceline" />
|
||||||
|
<button name="Return" oref="outline7" />
|
||||||
|
|
||||||
|
<view>
|
||||||
|
<section angle="0">1 2 3 parenleft parenright</section>
|
||||||
|
<section angle="0">4 5 6 numbersign asterisk</section>
|
||||||
|
<section angle="0">7 8 9 plus minus</section>
|
||||||
|
<section angle="0">BackSpace 0 space Return</section>
|
||||||
|
</view>
|
||||||
</geometry>
|
</geometry>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?xml version='1.0' encoding='ASCII' standalone='yes'?>
|
<?xml version='1.0' encoding='ASCII' standalone='yes'?>
|
||||||
<symbols version="0.90">
|
<symbols version="0.90">
|
||||||
|
<symbol label="*">asterisk</symbol>
|
||||||
<key name="AD01">
|
<key name="AD01">
|
||||||
<symbol label="q">q</symbol>
|
<symbol label="q">q</symbol>
|
||||||
<symbol label="Q">Q</symbol>
|
<symbol label="Q">Q</symbol>
|
||||||
@ -58,7 +59,7 @@
|
|||||||
<symbol label="p">p</symbol>
|
<symbol label="p">p</symbol>
|
||||||
<symbol label="P">P</symbol>
|
<symbol label="P">P</symbol>
|
||||||
<symbol label="0">0</symbol>
|
<symbol label="0">0</symbol>
|
||||||
<symbol label="△">U25B3</symbol>
|
<symbol label="ρ">Greek_tau</symbol>
|
||||||
</key>
|
</key>
|
||||||
<key name="AC01">
|
<key name="AC01">
|
||||||
<symbol label="a">a</symbol>
|
<symbol label="a">a</symbol>
|
||||||
@ -183,10 +184,8 @@
|
|||||||
<symbol label=".">period</symbol>
|
<symbol label=".">period</symbol>
|
||||||
</key>
|
</key>
|
||||||
<key name="ABC123">
|
<key name="ABC123">
|
||||||
<symbol label="123">show-numbers</symbol>
|
<symbol label="123">show_numbers</symbol>
|
||||||
<symbol label="123">show-numbers</symbol>
|
<symbol label="ABC">show_letters</symbol>
|
||||||
<symbol label="ABC">show-letters</symbol>
|
|
||||||
<symbol label="ABC">show-letters</symbol>
|
|
||||||
</key>
|
</key>
|
||||||
<key name="I149">
|
<key name="I149">
|
||||||
<symbol label="☺" icon="keyboard-mode-symbolic" tooltip="Setup">preferences</symbol>
|
<symbol label="☺" icon="keyboard-mode-symbolic" tooltip="Setup">preferences</symbol>
|
||||||
|
|||||||
@ -194,6 +194,10 @@ eek_key_init (EekKey *self)
|
|||||||
priv->state = squeek_key_new (0);
|
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:
|
* eek_key_set_keycode:
|
||||||
* @key: an #EekKey
|
* @key: an #EekKey
|
||||||
|
|||||||
@ -71,6 +71,6 @@ gboolean eek_key_is_pressed (EekKey *key);
|
|||||||
gboolean eek_key_is_locked (EekKey *key);
|
gboolean eek_key_is_locked (EekKey *key);
|
||||||
void eek_key_set_pressed (EekKey *key,
|
void eek_key_set_pressed (EekKey *key,
|
||||||
gboolean value);
|
gboolean value);
|
||||||
|
void eek_key_share_state(EekKey *self, struct squeek_key *state);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* EEK_KEY_H */
|
#endif /* EEK_KEY_H */
|
||||||
|
|||||||
@ -144,15 +144,18 @@ eek_keyboard_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the state of locked keys based on the key that was activated
|
/// 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,
|
set_key_states (LevelKeyboard *keyboard,
|
||||||
EekKey *key)
|
EekKey *key,
|
||||||
|
guint new_level)
|
||||||
{
|
{
|
||||||
// Keys locking rules hardcoded for the time being...
|
// Keys locking rules hardcoded for the time being...
|
||||||
const gchar *name = eek_element_get_name(EEK_ELEMENT(key));
|
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
|
// 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);
|
EekModifierKey *modifier_key = g_slice_new (EekModifierKey);
|
||||||
modifier_key->modifiers = 0;
|
modifier_key->modifiers = 0;
|
||||||
modifier_key->key = g_object_ref (key);
|
modifier_key->key = g_object_ref (key);
|
||||||
@ -172,10 +175,12 @@ set_key_states (LevelKeyboard *keyboard,
|
|||||||
g_list_free1 (head);
|
g_list_free1 (head);
|
||||||
head = next;
|
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
|
static void
|
||||||
set_level_from_press (LevelKeyboard *keyboard, EekKey *key)
|
set_level_from_press (LevelKeyboard *keyboard, EekKey *key)
|
||||||
{
|
{
|
||||||
@ -184,31 +189,21 @@ set_level_from_press (LevelKeyboard *keyboard, EekKey *key)
|
|||||||
/* Handle non-emitting keys */
|
/* Handle non-emitting keys */
|
||||||
if (key) {
|
if (key) {
|
||||||
const gchar *name = eek_element_get_name(EEK_ELEMENT(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;
|
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;
|
level = 0;
|
||||||
} else if (g_strcmp0(name, "LFSH-0") == 0) {
|
} else if (g_strcmp0(name, "Shift_L") == 0) {
|
||||||
level = 1;
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_key_states(keyboard, key);
|
keyboard->level = set_key_states(keyboard, key, level);
|
||||||
|
|
||||||
keyboard->level = level;
|
|
||||||
|
|
||||||
eek_layout_update_layout(keyboard);
|
eek_layout_update_layout(keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void eek_keyboard_press_key(LevelKeyboard *keyboard, EekKey *key, guint32 timestamp) {
|
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);
|
eek_key_set_pressed(key, TRUE);
|
||||||
keyboard->pressed_keys = g_list_prepend (keyboard->pressed_keys, key);
|
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)
|
if (!symbol)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
set_key_states (keyboard, key);
|
// Only take action about setting level *after* the key has taken effect, i.e. on release
|
||||||
set_level_from_press (keyboard, key);
|
//set_level_from_press (keyboard, key);
|
||||||
|
|
||||||
// "Borrowed" from eek-context-service; doesn't influence the state but forwards the event
|
// "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,
|
void eek_keyboard_release_key(LevelKeyboard *keyboard,
|
||||||
EekKey *key,
|
EekKey *key,
|
||||||
guint32 timestamp) {
|
guint32 timestamp) {
|
||||||
EekKeyboardPrivate *priv = EEK_KEYBOARD_GET_PRIVATE(level_keyboard_current(keyboard));
|
|
||||||
|
|
||||||
for (GList *head = keyboard->pressed_keys; head; head = g_list_next (head)) {
|
for (GList *head = keyboard->pressed_keys; head; head = g_list_next (head)) {
|
||||||
if (head->data == key) {
|
if (head->data == key) {
|
||||||
keyboard->pressed_keys = g_list_remove_link (keyboard->pressed_keys, head);
|
keyboard->pressed_keys = g_list_remove_link (keyboard->pressed_keys, head);
|
||||||
@ -246,7 +239,6 @@ void eek_keyboard_release_key(LevelKeyboard *keyboard,
|
|||||||
if (!symbol)
|
if (!symbol)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
set_key_states (keyboard, key);
|
|
||||||
set_level_from_press (keyboard, key);
|
set_level_from_press (keyboard, key);
|
||||||
|
|
||||||
// "Borrowed" from eek-context-service; doesn't influence the state but forwards the event
|
// "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);
|
EekContainerClass *container_class = EEK_CONTAINER_CLASS (klass);
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
GParamSpec *pspec;
|
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
container_class->child_added = eek_keyboard_real_child_added;
|
container_class->child_added = eek_keyboard_real_child_added;
|
||||||
|
|||||||
@ -121,7 +121,8 @@ on_unlocked (EekKey *key,
|
|||||||
static EekKey *
|
static EekKey *
|
||||||
eek_section_real_create_key (EekSection *self,
|
eek_section_real_create_key (EekSection *self,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gint keycode)
|
gint keycode,
|
||||||
|
guint oref)
|
||||||
{
|
{
|
||||||
EekSectionPrivate *priv = (EekSectionPrivate*)eek_section_get_instance_private (self);
|
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,
|
EekKey *key = (EekKey*)g_object_new (EEK_TYPE_KEY,
|
||||||
"name", name,
|
"name", name,
|
||||||
NULL);
|
NULL);
|
||||||
eek_key_set_keycode(key, keycode);
|
|
||||||
g_return_val_if_fail (key, NULL);
|
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_CONTAINER_GET_CLASS(self)->add_child (EEK_CONTAINER(self),
|
||||||
EEK_ELEMENT(key));
|
EEK_ELEMENT(key));
|
||||||
@ -140,6 +142,25 @@ eek_section_real_create_key (EekSection *self,
|
|||||||
return key;
|
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
|
static void
|
||||||
eek_section_finalize (GObject *object)
|
eek_section_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
@ -383,12 +404,13 @@ eek_section_get_row (EekSection *section,
|
|||||||
EekKey *
|
EekKey *
|
||||||
eek_section_create_key (EekSection *section,
|
eek_section_create_key (EekSection *section,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
guint keycode)
|
guint keycode,
|
||||||
|
guint oref)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (EEK_IS_SECTION(section), NULL);
|
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,
|
name,
|
||||||
keycode);
|
keycode, oref);
|
||||||
}
|
}
|
||||||
|
|
||||||
const double keyspacing = 4.0;
|
const double keyspacing = 4.0;
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
#include "eek-container.h"
|
#include "eek-container.h"
|
||||||
#include "eek-types.h"
|
#include "eek-types.h"
|
||||||
#include "eek-keyboard.h"
|
#include "eek-keyboard.h"
|
||||||
|
#include "src/keyboard.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -96,8 +97,10 @@ void eek_section_get_row (EekSection *section,
|
|||||||
|
|
||||||
EekKey *eek_section_create_key (EekSection *section,
|
EekKey *eek_section_create_key (EekSection *section,
|
||||||
const gchar *name,
|
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);
|
void eek_section_place_keys (EekSection *section, LevelKeyboard *keyboard);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
@ -237,40 +237,42 @@ struct _GeometryParseData {
|
|||||||
guint view_idx;
|
guint view_idx;
|
||||||
EekSection *section;
|
EekSection *section;
|
||||||
EekKey *key;
|
EekKey *key;
|
||||||
gint num_columns;
|
|
||||||
gint num_rows;
|
gint num_rows;
|
||||||
EekOrientation orientation;
|
EekOrientation orientation;
|
||||||
gdouble corner_radius;
|
gdouble corner_radius;
|
||||||
GSList *points;
|
GSList *points;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
EekOutline outline;
|
EekOutline outline;
|
||||||
gchar *oref;
|
gchar *outline_id;
|
||||||
guint keycode;
|
guint keycode;
|
||||||
|
|
||||||
GString *text;
|
GString *text;
|
||||||
|
|
||||||
|
GArray *outline_array;
|
||||||
|
|
||||||
GHashTable *name_key_hash; // char* -> EekKey*
|
GHashTable *name_key_hash; // char* -> EekKey*
|
||||||
GHashTable *key_oref_hash;
|
GHashTable *keyname_oref_hash; // char* -> guint
|
||||||
GHashTable *oref_outline_hash;
|
GHashTable *outlineid_oref_hash; // char* -> guint
|
||||||
};
|
};
|
||||||
typedef struct _GeometryParseData GeometryParseData;
|
typedef struct _GeometryParseData GeometryParseData;
|
||||||
|
|
||||||
static 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);
|
GeometryParseData *data = g_slice_new0 (GeometryParseData);
|
||||||
|
|
||||||
data->views = views;
|
data->views = views;
|
||||||
data->key_oref_hash =
|
data->outline_array = outline_array;
|
||||||
g_hash_table_new_full (g_direct_hash,
|
data->keyname_oref_hash =
|
||||||
g_direct_equal,
|
|
||||||
NULL,
|
|
||||||
g_free);
|
|
||||||
data->oref_outline_hash =
|
|
||||||
g_hash_table_new_full (g_str_hash,
|
g_hash_table_new_full (g_str_hash,
|
||||||
g_str_equal,
|
g_str_equal,
|
||||||
g_free,
|
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->name_key_hash = name_key_hash;
|
||||||
data->text = g_string_sized_new (BUFSIZE);
|
data->text = g_string_sized_new (BUFSIZE);
|
||||||
@ -281,8 +283,8 @@ geometry_parse_data_new (EekKeyboard **views, GHashTable *name_key_hash)
|
|||||||
static void
|
static void
|
||||||
geometry_parse_data_free (GeometryParseData *data)
|
geometry_parse_data_free (GeometryParseData *data)
|
||||||
{
|
{
|
||||||
g_hash_table_destroy (data->key_oref_hash);
|
g_hash_table_destroy (data->keyname_oref_hash);
|
||||||
g_hash_table_destroy (data->oref_outline_hash);
|
g_hash_table_destroy (data->outlineid_oref_hash);
|
||||||
g_string_free (data->text, TRUE);
|
g_string_free (data->text, TRUE);
|
||||||
g_slice_free (GeometryParseData, data);
|
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,
|
const gchar *keycode_name = get_attribute (attribute_names, attribute_values,
|
||||||
"keycode");
|
"keycode");
|
||||||
|
|
||||||
for (uint i = 0; i < 4; i++) {
|
guint oref = GPOINTER_TO_UINT(g_hash_table_lookup(data->outlineid_oref_hash,
|
||||||
gchar *name = g_strdup_printf("%s-%d", base_name, i);
|
oref_name));
|
||||||
EekKey *key = g_hash_table_lookup(data->name_key_hash, name);
|
const gchar *name = base_name;
|
||||||
if (!key) {
|
g_hash_table_insert (data->keyname_oref_hash,
|
||||||
continue; // not all keys have to be defined in every view
|
g_strdup(name),
|
||||||
}
|
GUINT_TO_POINTER(oref));
|
||||||
g_hash_table_insert (data->key_oref_hash,
|
|
||||||
key,
|
|
||||||
g_strdup (oref_name));
|
|
||||||
|
|
||||||
|
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) {
|
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));
|
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\"");
|
"no \"id\" attribute for \"outline\"");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data->oref = g_strdup (attribute);
|
data->outline_id = g_strdup (attribute);
|
||||||
|
|
||||||
attribute = get_attribute (attribute_names, attribute_values,
|
attribute = get_attribute (attribute_names, attribute_values,
|
||||||
"corner-radius");
|
"corner-radius");
|
||||||
@ -484,6 +490,29 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
|
|||||||
data->text->len = 0;
|
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
|
static void
|
||||||
geometry_end_element_callback (GMarkupParseContext *pcontext,
|
geometry_end_element_callback (GMarkupParseContext *pcontext,
|
||||||
const gchar *element_name,
|
const gchar *element_name,
|
||||||
@ -529,24 +558,33 @@ geometry_end_element_callback (GMarkupParseContext *pcontext,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save button name together with its level,
|
gchar *name = g_strndup (&text[start], end - start);
|
||||||
// to account for buttons with the same name in multiple levels
|
EekKey *key = g_hash_table_lookup(data->name_key_hash, name);
|
||||||
gchar *base_name = g_strndup (&text[start], end - start);
|
if (!key) {
|
||||||
gchar *name = g_strdup_printf("%s-%d", base_name, data->view_idx);
|
// Save button name together with its level,
|
||||||
g_free(base_name);
|
// to account for buttons with the same name in multiple levels
|
||||||
guint keycode = data->keycode++;
|
guint keycode = data->keycode++;
|
||||||
|
|
||||||
data->key = eek_section_create_key (data->section,
|
guint oref = GPOINTER_TO_UINT(g_hash_table_lookup(data->keyname_oref_hash, name));
|
||||||
name,
|
// default value gives idx 0, which is guaranteed to be occupied
|
||||||
keycode);
|
key = eek_section_create_key (data->section,
|
||||||
g_hash_table_insert (data->name_key_hash,
|
name,
|
||||||
g_strdup(name),
|
keycode,
|
||||||
data->key);
|
oref);
|
||||||
data->num_columns++;
|
g_hash_table_insert (data->name_key_hash,
|
||||||
|
g_strdup(name),
|
||||||
g_hash_table_insert (data->key_oref_hash,
|
key);
|
||||||
data->key,
|
} else {
|
||||||
g_strdup ("default"));
|
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;
|
data->section = NULL;
|
||||||
@ -573,11 +611,11 @@ geometry_end_element_callback (GMarkupParseContext *pcontext,
|
|||||||
g_slist_free (data->points);
|
g_slist_free (data->points);
|
||||||
data->points = NULL;
|
data->points = NULL;
|
||||||
|
|
||||||
g_hash_table_insert (data->oref_outline_hash,
|
guint oref = add_outline (data->outline_array, outline);
|
||||||
g_strdup (data->oref),
|
|
||||||
outline);
|
|
||||||
|
|
||||||
g_free (data->oref);
|
g_hash_table_insert (data->outlineid_oref_hash,
|
||||||
|
data->outline_id,
|
||||||
|
GUINT_TO_POINTER(oref));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -607,8 +645,6 @@ struct _SymbolsParseData {
|
|||||||
|
|
||||||
LevelKeyboard *keyboard;
|
LevelKeyboard *keyboard;
|
||||||
EekKeyboard *view;
|
EekKeyboard *view;
|
||||||
guint key_level;
|
|
||||||
const gchar *key_name;
|
|
||||||
|
|
||||||
gchar *label;
|
gchar *label;
|
||||||
gchar *icon;
|
gchar *icon;
|
||||||
@ -636,6 +672,7 @@ symbols_parse_data_free (SymbolsParseData *data)
|
|||||||
|
|
||||||
static const gchar *symbols_valid_path_list[] = {
|
static const gchar *symbols_valid_path_list[] = {
|
||||||
"symbols",
|
"symbols",
|
||||||
|
"symbol/symbols",
|
||||||
"include/symbols",
|
"include/symbols",
|
||||||
"key/symbols",
|
"key/symbols",
|
||||||
"text/key/symbols",
|
"text/key/symbols",
|
||||||
@ -662,22 +699,6 @@ symbols_start_element_callback (GMarkupParseContext *pcontext,
|
|||||||
error))
|
error))
|
||||||
return;
|
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) {
|
if (g_strcmp0 (element_name, "keysym") == 0) {
|
||||||
attribute = get_attribute (attribute_names, attribute_values,
|
attribute = get_attribute (attribute_names, attribute_values,
|
||||||
"keyval");
|
"keyval");
|
||||||
@ -710,7 +731,6 @@ symbols_start_element_callback (GMarkupParseContext *pcontext,
|
|||||||
data->tooltip = g_strdup (attribute);
|
data->tooltip = g_strdup (attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
data->element_stack = g_slist_prepend (data->element_stack,
|
data->element_stack = g_slist_prepend (data->element_stack,
|
||||||
g_strdup (element_name));
|
g_strdup (element_name));
|
||||||
data->text->len = 0;
|
data->text->len = 0;
|
||||||
@ -730,33 +750,28 @@ symbols_end_element_callback (GMarkupParseContext *pcontext,
|
|||||||
data->element_stack = g_slist_next (data->element_stack);
|
data->element_stack = g_slist_next (data->element_stack);
|
||||||
g_slist_free1 (head);
|
g_slist_free1 (head);
|
||||||
|
|
||||||
|
// TODO: this could all be moved to text handler
|
||||||
text = g_strndup (data->text->str, data->text->len);
|
text = g_strndup (data->text->str, data->text->len);
|
||||||
|
|
||||||
if (g_strcmp0 (element_name, "symbol") == 0 ||
|
if (g_strcmp0 (element_name, "symbol") == 0 ||
|
||||||
g_strcmp0 (element_name, "keysym") == 0 ||
|
g_strcmp0 (element_name, "keysym") == 0 ||
|
||||||
g_strcmp0 (element_name, "text") == 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,
|
EekKey *key = eek_keyboard_find_key_by_name (data->keyboard,
|
||||||
name);
|
name);
|
||||||
if (key == NULL) {
|
if (key) {
|
||||||
g_set_error (error,
|
squeek_key_add_symbol(
|
||||||
G_MARKUP_ERROR,
|
eek_key_get_state(key),
|
||||||
G_MARKUP_ERROR_INVALID_CONTENT,
|
element_name,
|
||||||
"no such key %s", name);
|
text,
|
||||||
return;
|
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;
|
data->keyval = 0;
|
||||||
g_free(data->label);
|
g_free(data->label);
|
||||||
data->label = NULL;
|
data->label = NULL;
|
||||||
@ -764,8 +779,6 @@ symbols_end_element_callback (GMarkupParseContext *pcontext,
|
|||||||
data->icon = NULL;
|
data->icon = NULL;
|
||||||
g_free(data->tooltip);
|
g_free(data->tooltip);
|
||||||
data->tooltip = NULL;
|
data->tooltip = NULL;
|
||||||
|
|
||||||
data->key_level++;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1135,36 +1148,11 @@ eek_xml_keyboard_desc_free (EekXmlKeyboardDesc *desc)
|
|||||||
g_slice_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
|
static gboolean
|
||||||
parse_geometry (const gchar *path, EekKeyboard **views, GArray *outline_array, GHashTable *name_key_hash, GError **error)
|
parse_geometry (const gchar *path, EekKeyboard **views, GArray *outline_array, GHashTable *name_key_hash, GError **error)
|
||||||
{
|
{
|
||||||
GeometryParseData *data;
|
GeometryParseData *data;
|
||||||
GMarkupParseContext *pcontext;
|
GMarkupParseContext *pcontext;
|
||||||
GHashTable *oref_hash;
|
|
||||||
GHashTableIter iter;
|
|
||||||
gpointer k, v;
|
|
||||||
GFile *file;
|
GFile *file;
|
||||||
GFileInputStream *input;
|
GFileInputStream *input;
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
@ -1178,7 +1166,7 @@ parse_geometry (const gchar *path, EekKeyboard **views, GArray *outline_array, G
|
|||||||
if (input == NULL)
|
if (input == NULL)
|
||||||
return FALSE;
|
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,
|
pcontext = g_markup_parse_context_new (&geometry_parser,
|
||||||
0,
|
0,
|
||||||
data,
|
data,
|
||||||
@ -1193,6 +1181,11 @@ parse_geometry (const gchar *path, EekKeyboard **views, GArray *outline_array, G
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Resolve outline references. */
|
/* Resolve outline references. */
|
||||||
|
/*
|
||||||
|
* GHashTable *oref_hash;
|
||||||
|
GHashTableIter iter;
|
||||||
|
gpointer k, v;
|
||||||
|
|
||||||
oref_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
oref_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
g_hash_table_iter_init (&iter, data->oref_outline_hash);
|
g_hash_table_iter_init (&iter, data->oref_outline_hash);
|
||||||
while (g_hash_table_iter_next (&iter, &k, &v)) {
|
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);
|
oref = add_outline (outline_array, outline);
|
||||||
g_hash_table_insert (oref_hash, k, GUINT_TO_POINTER(oref));
|
g_hash_table_insert (oref_hash, k, GUINT_TO_POINTER(oref));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
/*
|
||||||
g_hash_table_iter_init (&iter, data->key_oref_hash);
|
g_hash_table_iter_init (&iter, data->key_oref_hash);
|
||||||
while (g_hash_table_iter_next (&iter, &k, &v)) {
|
while (g_hash_table_iter_next (&iter, &k, &v)) {
|
||||||
gpointer oref;
|
gpointer oref;
|
||||||
if (g_hash_table_lookup_extended (oref_hash, v, NULL, &oref))
|
if (g_hash_table_lookup_extended (oref_hash, v, NULL, &oref))
|
||||||
eek_key_set_oref (EEK_KEY(k), GPOINTER_TO_UINT(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);
|
geometry_parse_data_free (data);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
@ -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)
|
let icon = into_cstring(icon)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
eprintln!("Icon name unreadable: {}", e);
|
eprintln!("Icon name unreadable: {}", e);
|
||||||
@ -155,7 +163,6 @@ pub mod c {
|
|||||||
_ => panic!("unsupported element type {:?}", element),
|
_ => panic!("unsupported element type {:?}", element),
|
||||||
};
|
};
|
||||||
|
|
||||||
let key = unsafe { &mut *key };
|
|
||||||
key.symbols.push(symbol);
|
key.symbols.push(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +220,7 @@ pub mod c {
|
|||||||
};
|
};
|
||||||
format!("[ {} ], [ {} ]", first, second)
|
format!("[ {} ], [ {} ]", first, second)
|
||||||
},
|
},
|
||||||
_ => panic!("Unsupported number of symbols"),
|
_ => panic!("Unsupported number of symbols: {}", symbol_names.len()),
|
||||||
};
|
};
|
||||||
|
|
||||||
CString::new(format!(" key <{}> {{ {} }};\n", key_name, inner))
|
CString::new(format!(" key <{}> {{ {} }};\n", key_name, inner))
|
||||||
|
|||||||
@ -32,9 +32,9 @@ test_create (void)
|
|||||||
section = eek_keyboard_real_create_section (keyboard);
|
section = eek_keyboard_real_create_section (keyboard);
|
||||||
g_assert (EEK_IS_SECTION(section));
|
g_assert (EEK_IS_SECTION(section));
|
||||||
eek_section_add_row (section, 2, EEK_ORIENTATION_HORIZONTAL);
|
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));
|
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));
|
g_assert (EEK_IS_KEY(key1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user