keyboard: Simplify key width handling

We do not need to store the key width in the Key object
itself when constructing the layout, and can attach it
to the grid from the model data right away.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3162>
This commit is contained in:
Carlos Garnacho 2024-01-26 12:02:30 +01:00
parent 7a409bfffc
commit a93858b862

View File

@ -437,7 +437,6 @@ const Key = GObject.registerClass({
button.set_label(commitString);
}
button.keyWidth = 1;
button.connect('button-press-event', () => {
this._press(button, commitString);
button.add_style_pseudo_class('active');
@ -505,10 +504,6 @@ const Key = GObject.registerClass({
return this._boxPointer;
}
setWidth(width) {
this.keyButton.keyWidth = width;
}
setLatched(latched) {
if (latched)
this.keyButton.add_style_pseudo_class('latched');
@ -1528,9 +1523,6 @@ export const Keyboard = GObject.registerClass({
keyval: key.keyval,
}, strings);
if (key.width !== null)
button.setWidth(key.width);
if (key.action !== 'modifier') {
button.connect('commit', (_actor, keyval, str) => {
this._commitAction(keyval, str).then(() => {
@ -1590,7 +1582,7 @@ export const Keyboard = GObject.registerClass({
if (key.action || key.keyval)
button.keyButton.add_style_class_name('default-key');
layout.appendKey(button, button.keyButton.keyWidth);
layout.appendKey(button, key.width);
}
}