diff options
author | Raphael Freudiger <freudrap@students.zhaw.ch> | 2014-11-06 14:58:17 +0100 |
---|---|---|
committer | Daiki Ueno <dueno@src.gnome.org> | 2014-11-09 14:17:19 +0900 |
commit | a86790af79e0f4ab0a76ef2feb5f21377b8e22e2 (patch) | |
tree | 37ab58ce84ddf68c6c14051e2e5a3feb7ed50909 /libcaribou | |
parent | 43beb5d130a5c38e3650206aa343296fed12c400 (diff) | |
download | caribou-a86790af79e0f4ab0a76ef2feb5f21377b8e22e2.tar.gz |
Add label to all keys
Some keys do not have a label, so one has to guess what it does.
Do the following for keys we do not have a label yet.
First, try to find a label for dead keys by looking for the label
of the non-dead key.
Second, if no label is found use the key name as a label.
https://bugzilla.gnome.org/show_bug.cgi?id=739526
Diffstat (limited to 'libcaribou')
-rw-r--r-- | libcaribou/key-model.vala | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/libcaribou/key-model.vala b/libcaribou/key-model.vala index f4b54dd..0005ba7 100644 --- a/libcaribou/key-model.vala +++ b/libcaribou/key-model.vala @@ -118,15 +118,34 @@ namespace Caribou { break; } } + if (i == label_map.length) { if (text != null) label = text; else if (name.has_prefix ("Caribou_")) label = name["Caribou_".length:name.length]; - else if (_keyvals.length > 0) { - unichar uc = Gdk.keyval_to_unicode (_keyvals[0]); - if (!uc.isspace () && uc != 0) - label = uc.to_string (); + else { + // Try to use Unicode symbol as label. + if (_keyvals.length > 0) { + unichar uc = Gdk.keyval_to_unicode (_keyvals[0]); + if (!uc.isspace () && uc != 0) + label = uc.to_string (); + } + // If no usable Unicode symbol is assigned to the + // key, guess the best possible label. + // + // First, it is known that dead keys are not + // assigned Unicode symbols. Use the ones + // assigned to non-dead keys instead. + if (label == "" && name.has_prefix ("dead_")) { + uint keyval = Gdk.keyval_from_name (name["dead_".length:name.length]); + unichar uc = Gdk.keyval_to_unicode (keyval); + if (!uc.isspace () && uc != 0) + label = uc.to_string (); + } + // Second, use the key name as label. + if (label == "" && _keyvals.length > 0) + label = name; } } |