After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 739526 - Some buttons do not have a label.
Some buttons do not have a label.
Status: RESOLVED FIXED
Product: caribou
Classification: Applications
Component: default
git master
Other Linux
: Normal major
: ---
Assigned To: caribou-maint
caribou-maint
Depends on:
Blocks:
 
 
Reported: 2014-11-02 08:46 UTC by Raphael Freudiger
Modified: 2014-11-09 06:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add custom labels for keys (8.48 KB, patch)
2014-11-02 09:10 UTC, Raphael Freudiger
none Details | Review
Add label for all keys (2.21 KB, patch)
2014-11-06 07:37 UTC, Raphael Freudiger
needs-work Details | Review
Add label for all keys (4.32 KB, patch)
2014-11-06 14:06 UTC, Raphael Freudiger
none Details | Review
Add label to all keys (2.55 KB, patch)
2014-11-07 09:05 UTC, Daiki Ueno
committed Details | Review

Description Raphael Freudiger 2014-11-02 08:46:09 UTC
The default fullscale layout does have many buttons without any label. In fact the complete top row is empty. One has to guess what each of these buttons does.

I have created my own layout for the neo layout and ended up with half empty layers.

There should be a possibility to declare a custom label in the keyboard layouts, which is used for the keys.

Currently there is the possibility to set a text, which is used for the key value and the label. But this is not useful for dead keys or function keys.
Comment 1 Raphael Freudiger 2014-11-02 09:10:59 UTC
Created attachment 289824 [details] [review]
Add custom labels for keys

Some keys do not have a label, so one has to guess what it does.

This tries to find a label for dead keys by looking for the label of the non-dead key.
And it adds the posibility to force a custom label for a key in the layout:
Just add a label attribute to your key.
I.e. <key name="Esc" label="Esc" />

Added custom labels for the us-layout.
Comment 2 Daiki Ueno 2014-11-03 07:20:22 UTC
Thanks for the report and patch, but wouldn't it be a pain if all such symbols need to have a label="..." attribute?   I agree it is a good idea to use Gdk.keyval_name() as a fallback.
Comment 3 Raphael Freudiger 2014-11-03 14:18:55 UTC
Currently only a small subset of the needed labels is defined. And even the default keyboard has some missing labels. Of course it would be best to have as many labels as possible predefined. But I think it is good to have the option to set a custom label when it is needed.

Personally, I am using the neo layout (http://en.wikipedia.org/wiki/Keyboard_layout#Neo) for which I have written a custom layout for caribou. But It contains many special keys like math-symbols, greek letters, dead-keys and function keys which do not have a label by default. Therefore it is almost unusable.
For some keys this can be forced bey setting a text, but this also prints this text when pressing the key. For function keys and dead-keys this destrois the functionality of the key. In this case a custom label is needed.
Comment 4 Daiki Ueno 2014-11-04 02:50:14 UTC
(In reply to comment #3)
> Currently only a small subset of the needed labels is defined.

However, you defined labels for F1, ..., F12.  The number doesn't look small to me.  Also, Gdk.keyval_name/Gdk.keyval_from_name roundtrip for those keys:

  gjs> Gdk.keyval_name(Gdk.keyval_from_name('F11'))
  "F11"

so those labels are redundant, if we could use Gdk.keyval_name as a fallback.

> default keyboard has some missing labels. Of course it would be best to have as
> many labels as possible predefined. But I think it is good to have the option
> to set a custom label when it is needed.

I think there are two separate issues.  One is that the default keyboard is missing some labels, and another is a feature to allow custom labels.  I'd prefer to have two separate patches for them.

The patch for the former could be: extend label_map with Esc and Tab, which Gdk.keyval_name doesn't return usable labels, and use Gdk.keyval_name for the rest.  There's no dead keys defined in the default layout, no need to worry about them.

Then, for the latter "feature", you can propose whatever you like.
Comment 5 Raphael Freudiger 2014-11-06 07:37:50 UTC
Created attachment 290074 [details] [review]
Add label for all keys

Some keys do not have a label, so one has to guess what it does.

First, this tries to find a label for dead keys by looking for the label of the non-dead key.
Second, if no label is found the key name is used as a label. Every valid key should have a label now.
And last, keys with an invalid name are labeled with "invalid name"
Comment 6 Daiki Ueno 2014-11-06 09:41:49 UTC
Review of attachment 290074 [details] [review]:

Thanks, looks basically good to me.

::: libcaribou/key-model.vala
@@ +121,3 @@
+                        if (!uc.isspace () && uc != 0)
+                            label = uc.to_string ();
+                    }

The logic is becoming a bit complex; can you add some comment on each 'if'?

@@ +133,3 @@
+                        else
+                            label = "invalid\nname";
+                    }

Perhaps this block could be simplified as:

if (label == "") {
    if (_keyvals.length > 0)
        label = Gdk.keyval_name (_keyvals[0]);
    else
        label = "invalid\nname";
}
Comment 7 Raphael Freudiger 2014-11-06 14:06:59 UTC
Created attachment 290104 [details] [review]
Add label for all keys

I have split the keyval and label determination into two separate method, because the code got a bit long and complex.

And I have commented the steps in finding a label.
Comment 8 Daiki Ueno 2014-11-07 09:05:55 UTC
Created attachment 290137 [details] [review]
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.
--
Sorry, it looks too much to me.  Since some part of init_key_label depends on init_keyval, I think it's not a good idea to split them into separate methods.

I'd like to go with your second patch, with slight modification:
- Just use 'name' as a fallback label.  If the keyval was determined, the 'name' should already be the valid key name.
- Use "" as an invalid key name, since "invalid name" might not fit in a normal key.
Comment 9 Raphael Freudiger 2014-11-08 10:33:38 UTC
Review of attachment 290137 [details] [review]:

Thanks, looks good to me.
Comment 10 Raphael Freudiger 2014-11-08 10:33:38 UTC
Review of attachment 290137 [details] [review]:

Thanks, looks good to me.
Comment 11 Daiki Ueno 2014-11-09 06:23:57 UTC
Attachment 290137 [details] pushed as a86790a - Add label to all keys