padOsd: Move all coord/existence checks to _addLabel()
Drops some repetitive code. Also rely completely on the label/leader elements being found in order to find buttons/rings/strips. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1290
This commit is contained in:
parent
dac05c7e53
commit
c511c469fe
@ -345,29 +345,22 @@ var PadDiagram = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_initLabels() {
|
_initLabels() {
|
||||||
// FIXME: Fix num buttons.
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (i = 0; i < 50; i++) {
|
for (i = 0; ; i++) {
|
||||||
let [found] = this._getLabelCoords(Meta.PadActionType.BUTTON, i);
|
if (!this._addLabel(Meta.PadActionType.BUTTON, i))
|
||||||
if (!found)
|
|
||||||
break;
|
break;
|
||||||
this._addLabel(Meta.PadActionType.BUTTON, i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; ; i++) {
|
||||||
let [found] = this._getLabelCoords(Meta.PadActionType.RING, i, CW);
|
if (!this._addLabel(Meta.PadActionType.RING, i, CW) ||
|
||||||
if (!found)
|
!this._addLabel(Meta.PadActionType.RING, i, CCW))
|
||||||
break;
|
break;
|
||||||
this._addLabel(Meta.PadActionType.RING, i, CW);
|
|
||||||
this._addLabel(Meta.PadActionType.RING, i, CCW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; ; i++) {
|
||||||
let [found] = this._getLabelCoords(Meta.PadActionType.STRIP, i, UP);
|
if (!this._addLabel(Meta.PadActionType.STRIP, i, UP) ||
|
||||||
if (!found)
|
!this._addLabel(Meta.PadActionType.STRIP, i, DOWN))
|
||||||
break;
|
break;
|
||||||
this._addLabel(Meta.PadActionType.STRIP, i, UP);
|
|
||||||
this._addLabel(Meta.PadActionType.STRIP, i, DOWN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,9 +576,14 @@ var PadDiagram = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_addLabel(type, idx, dir) {
|
_addLabel(type, idx, dir) {
|
||||||
|
let [found] = this._getLabelCoords(type, idx, dir);
|
||||||
|
if (!found)
|
||||||
|
return false;
|
||||||
|
|
||||||
let label = new St.Label();
|
let label = new St.Label();
|
||||||
this._labels.push([label, type, idx, dir]);
|
this._labels.push([label, type, idx, dir]);
|
||||||
this.add_actor(label);
|
this.add_actor(label);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLabels(getText) {
|
updateLabels(getText) {
|
||||||
|
Loading…
Reference in New Issue
Block a user