[caribou] Add label to all keys



commit a86790af79e0f4ab0a76ef2feb5f21377b8e22e2
Author: Raphael Freudiger <freudrap students zhaw ch>
Date:   Thu Nov 6 14:58:17 2014 +0100

    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

 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;
                 }
             }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]