cleanup: Use non-deprecated key symbols

Clutter originally cluttered its namespace with key symbols, before
prefixing all symbols with KEY. We still use the unprefixed symbols
occasionally, replace them so mutter can drop the deprecated symbols.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/808
This commit is contained in:
Florian Müllner 2019-11-05 20:37:28 +01:00
parent 1e203f4631
commit d3d165243c
21 changed files with 56 additions and 56 deletions

View File

@ -180,25 +180,25 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup {
this._select(this._next()); this._select(this._next());
} else if (action == Meta.KeyBindingAction.SWITCH_APPLICATIONS_BACKWARD) { } else if (action == Meta.KeyBindingAction.SWITCH_APPLICATIONS_BACKWARD) {
this._select(this._previous()); this._select(this._previous());
} else if (keysym == Clutter.q) { } else if (keysym === Clutter.KEY_q) {
this._quitApplication(this._selectedIndex); this._quitApplication(this._selectedIndex);
} else if (this._thumbnailsFocused) { } else if (this._thumbnailsFocused) {
if (keysym == Clutter.Left) if (keysym === Clutter.KEY_Left)
this._select(this._selectedIndex, this._previousWindow()); this._select(this._selectedIndex, this._previousWindow());
else if (keysym == Clutter.Right) else if (keysym === Clutter.KEY_Right)
this._select(this._selectedIndex, this._nextWindow()); this._select(this._selectedIndex, this._nextWindow());
else if (keysym == Clutter.Up) else if (keysym === Clutter.KEY_Up)
this._select(this._selectedIndex, null, true); this._select(this._selectedIndex, null, true);
else if (keysym == Clutter.w || keysym == Clutter.F4) else if (keysym === Clutter.KEY_w || keysym === Clutter.KEY_F4)
this._closeAppWindow(this._selectedIndex, this._currentWindow); this._closeAppWindow(this._selectedIndex, this._currentWindow);
else else
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} else { } else {
if (keysym == Clutter.Left) if (keysym === Clutter.KEY_Left)
this._select(this._previous()); this._select(this._previous());
else if (keysym == Clutter.Right) else if (keysym === Clutter.KEY_Right)
this._select(this._next()); this._select(this._next());
else if (keysym == Clutter.Down) else if (keysym === Clutter.KEY_Down)
this._select(this._selectedIndex, 0); this._select(this._selectedIndex, 0);
else else
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
@ -596,11 +596,11 @@ class WindowSwitcherPopup extends SwitcherPopup.SwitcherPopup {
} else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD) { } else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD) {
this._select(this._previous()); this._select(this._previous());
} else { } else {
if (keysym == Clutter.Left) if (keysym === Clutter.KEY_Left)
this._select(this._previous()); this._select(this._previous());
else if (keysym == Clutter.Right) else if (keysym === Clutter.KEY_Right)
this._select(this._next()); this._select(this._next());
else if (keysym == Clutter.w || keysym == Clutter.F4) else if (keysym === Clutter.KEY_w || keysym === Clutter.KEY_F4)
this._closeWindow(this._selectedIndex); this._closeWindow(this._selectedIndex);
else else
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;

View File

@ -660,10 +660,10 @@ var AllView = GObject.registerClass({
if (this._displayingPopup) if (this._displayingPopup)
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
if (event.get_key_symbol() == Clutter.Page_Up) { if (event.get_key_symbol() === Clutter.KEY_Page_Up) {
this.goToPage(this._grid.currentPage - 1); this.goToPage(this._grid.currentPage - 1);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (event.get_key_symbol() == Clutter.Page_Down) { } else if (event.get_key_symbol() === Clutter.KEY_Page_Down) {
this.goToPage(this._grid.currentPage + 1); this.goToPage(this._grid.currentPage + 1);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
@ -1960,18 +1960,18 @@ var AppFolderPopup = GObject.registerClass({
let direction; let direction;
let isLtr = Clutter.get_default_text_direction() == Clutter.TextDirection.LTR; let isLtr = Clutter.get_default_text_direction() == Clutter.TextDirection.LTR;
switch (keyEvent.keyval) { switch (keyEvent.keyval) {
case Clutter.Down: case Clutter.KEY_Down:
direction = St.DirectionType.TAB_FORWARD; direction = St.DirectionType.TAB_FORWARD;
break; break;
case Clutter.Right: case Clutter.KEY_Right:
direction = isLtr direction = isLtr
? St.DirectionType.TAB_FORWARD ? St.DirectionType.TAB_FORWARD
: St.DirectionType.TAB_BACKWARD; : St.DirectionType.TAB_BACKWARD;
break; break;
case Clutter.Up: case Clutter.KEY_Up:
direction = St.DirectionType.TAB_BACKWARD; direction = St.DirectionType.TAB_BACKWARD;
break; break;
case Clutter.Left: case Clutter.KEY_Left:
direction = isLtr direction = isLtr
? St.DirectionType.TAB_BACKWARD ? St.DirectionType.TAB_BACKWARD
: St.DirectionType.TAB_FORWARD; : St.DirectionType.TAB_FORWARD;

View File

@ -54,7 +54,7 @@ var AudioDeviceSelectionDialog = GObject.registerClass({
label: _("Sound Settings") }); label: _("Sound Settings") });
this.addButton({ action: this.close.bind(this), this.addButton({ action: this.close.bind(this),
label: _("Cancel"), label: _("Cancel"),
key: Clutter.Escape }); key: Clutter.KEY_Escape });
} }
_getDeviceLabel(device) { _getDeviceLabel(device) {

View File

@ -73,7 +73,7 @@ var CloseDialog = GObject.registerClass({
default: true }); default: true });
this._dialog.addButton({ label: _('Wait'), this._dialog.addButton({ label: _('Wait'),
action: this._onWait.bind(this), action: this._onWait.bind(this),
key: Clutter.Escape }); key: Clutter.KEY_Escape });
global.focus_manager.add_group(this._dialog); global.focus_manager.add_group(this._dialog);

View File

@ -33,7 +33,7 @@ class KeyringDialog extends ModalDialog.ModalDialog {
this._cancelButton = this.addButton({ label: '', this._cancelButton = this.addButton({ label: '',
action: this._onCancelButton.bind(this), action: this._onCancelButton.bind(this),
key: Clutter.Escape }); key: Clutter.KEY_Escape });
this._continueButton = this.addButton({ label: '', this._continueButton = this.addButton({ label: '',
action: this._onContinueButton.bind(this), action: this._onContinueButton.bind(this),
default: true }); default: true });

View File

@ -136,7 +136,7 @@ var AuthenticationDialog = GObject.registerClass({
this._cancelButton = this.addButton({ label: _("Cancel"), this._cancelButton = this.addButton({ label: _("Cancel"),
action: this.cancel.bind(this), action: this.cancel.bind(this),
key: Clutter.Escape }); key: Clutter.KEY_Escape });
this._okButton = this.addButton({ label: _("Authenticate"), this._okButton = this.addButton({ label: _("Authenticate"),
action: this._onAuthenticateButtonPressed.bind(this), action: this._onAuthenticateButtonPressed.bind(this),
reactive: false }); reactive: false });

View File

@ -143,9 +143,9 @@ class CtrlAltTabPopup extends SwitcherPopup.SwitcherPopup {
this._select(this._next()); this._select(this._next());
else if (action == Meta.KeyBindingAction.SWITCH_PANELS_BACKWARD) else if (action == Meta.KeyBindingAction.SWITCH_PANELS_BACKWARD)
this._select(this._previous()); this._select(this._previous());
else if (keysym == Clutter.Left) else if (keysym == Clutter.KEY_Left)
this._select(this._previous()); this._select(this._previous());
else if (keysym == Clutter.Right) else if (keysym == Clutter.KEY_Right)
this._select(this._next()); this._select(this._next());
else else
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;

View File

@ -267,7 +267,7 @@ var _Draggable = class _Draggable {
// dragging and ignore all other key presses. // dragging and ignore all other key presses.
} else if (event.type() == Clutter.EventType.KEY_PRESS && this._dragState == DragState.DRAGGING) { } else if (event.type() == Clutter.EventType.KEY_PRESS && this._dragState == DragState.DRAGGING) {
let symbol = event.get_key_symbol(); let symbol = event.get_key_symbol();
if (symbol == Clutter.Escape) { if (symbol == Clutter.KEY_Escape) {
this._cancelDrag(event.get_time()); this._cancelDrag(event.get_time());
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }

View File

@ -443,7 +443,7 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
let dialogContent = DialogContent[this._type]; let dialogContent = DialogContent[this._type];
let buttons = [{ action: this.cancel.bind(this), let buttons = [{ action: this.cancel.bind(this),
label: _("Cancel"), label: _("Cancel"),
key: Clutter.Escape }]; key: Clutter.KEY_Escape }];
for (let i = 0; i < dialogContent.confirmButtons.length; i++) { for (let i = 0; i < dialogContent.confirmButtons.length; i++) {
let signal = dialogContent.confirmButtons[i].signal; let signal = dialogContent.confirmButtons[i].signal;

View File

@ -189,7 +189,7 @@ class InstallExtensionDialog extends ModalDialog.ModalDialog {
this.setButtons([{ this.setButtons([{
label: _("Cancel"), label: _("Cancel"),
action: this._onCancelButtonPressed.bind(this), action: this._onCancelButtonPressed.bind(this),
key: Clutter.Escape, key: Clutter.KEY_Escape,
}, { }, {
label: _("Install"), label: _("Install"),
action: this._onInstallButtonPressed.bind(this), action: this._onInstallButtonPressed.bind(this),

View File

@ -61,7 +61,7 @@ class KbdA11yDialog extends GObject.Object {
dialog.close(); dialog.close();
}, },
default: enabled, default: enabled,
key: !enabled ? Clutter.Escape : null }); key: !enabled ? Clutter.KEY_Escape : null });
dialog.addButton({ label: enabled ? _("Turn Off") : _("Leave Off"), dialog.addButton({ label: enabled ? _("Turn Off") : _("Leave Off"),
action: () => { action: () => {
@ -69,7 +69,7 @@ class KbdA11yDialog extends GObject.Object {
dialog.close(); dialog.close();
}, },
default: !enabled, default: !enabled,
key: enabled ? Clutter.Escape : null }); key: enabled ? Clutter.KEY_Escape : null });
dialog.open(); dialog.open();
} }

View File

@ -81,7 +81,7 @@ var AutoComplete = class AutoComplete {
if (cursorPos != -1) { if (cursorPos != -1) {
text = text.slice(0, cursorPos); text = text.slice(0, cursorPos);
} }
if (event.get_key_symbol() == Clutter.Tab) { if (event.get_key_symbol() === Clutter.KEY_Tab) {
let [completions, attrHead] = JsParse.getCompletions(text, commandHeader, AUTO_COMPLETE_GLOBAL_KEYWORDS); let [completions, attrHead] = JsParse.getCompletions(text, commandHeader, AUTO_COMPLETE_GLOBAL_KEYWORDS);
let currTime = global.get_current_time(); let currTime = global.get_current_time();
if ((currTime - this._lastTabTime) < AUTO_COMPLETE_DOUBLE_TAB_DELAY) { if ((currTime - this._lastTabTime) < AUTO_COMPLETE_DOUBLE_TAB_DELAY) {
@ -565,7 +565,7 @@ var Inspector = GObject.registerClass({
} }
_onKeyPressEvent(actor, event) { _onKeyPressEvent(actor, event) {
if (event.get_key_symbol() == Clutter.Escape) if (event.get_key_symbol() === Clutter.KEY_Escape)
this._close(); this._close();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
@ -1096,7 +1096,7 @@ class LookingGlass extends St.BoxLayout {
// Handle key events which are relevant for all tabs of the LookingGlass // Handle key events which are relevant for all tabs of the LookingGlass
vfunc_key_press_event(keyPressEvent) { vfunc_key_press_event(keyPressEvent) {
let symbol = keyPressEvent.keyval; let symbol = keyPressEvent.keyval;
if (symbol == Clutter.Escape) { if (symbol === Clutter.KEY_Escape) {
if (this._objInspector.visible) { if (this._objInspector.visible) {
this._objInspector.close(); this._objInspector.close();
} else { } else {

View File

@ -797,7 +797,7 @@ var PadOsd = GObject.registerClass({
this._padDiagram.deactivateButton(event.get_button()); this._padDiagram.deactivateButton(event.get_button());
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (event.type() == Clutter.EventType.KEY_PRESS && } else if (event.type() == Clutter.EventType.KEY_PRESS &&
(!this._editionMode || event.get_key_symbol() == Clutter.Escape)) { (!this._editionMode || event.get_key_symbol() === Clutter.KEY_Escape)) {
if (this._editedAction != null) if (this._editedAction != null)
this._endActionEdition(); this._endActionEdition();
else else

View File

@ -95,7 +95,7 @@ class RunDialog extends ModalDialog.ModalDialog {
this.setButtons([{ this.setButtons([{
action: this.close.bind(this), action: this.close.bind(this),
label: _("Close"), label: _("Close"),
key: Clutter.Escape, key: Clutter.KEY_Escape,
}]); }]);
this._pathCompleter = new Gio.FilenameCompleter(); this._pathCompleter = new Gio.FilenameCompleter();
@ -112,7 +112,7 @@ class RunDialog extends ModalDialog.ModalDialog {
}); });
this._entryText.connect('key-press-event', (o, e) => { this._entryText.connect('key-press-event', (o, e) => {
let symbol = e.get_key_symbol(); let symbol = e.get_key_symbol();
if (symbol == Clutter.Tab) { if (symbol === Clutter.KEY_Tab) {
let text = o.get_text(); let text = o.get_text();
let prefix; let prefix;
if (text.lastIndexOf(' ') == -1) if (text.lastIndexOf(' ') == -1)

View File

@ -394,7 +394,7 @@ var ShellMountPasswordDialog = GObject.registerClass({
this._defaultButtons = [{ this._defaultButtons = [{
label: _("Cancel"), label: _("Cancel"),
action: this._onCancelButton.bind(this), action: this._onCancelButton.bind(this),
key: Clutter.Escape, key: Clutter.KEY_Escape,
}, { }, {
label: _("Unlock"), label: _("Unlock"),
action: this._onUnlockButton.bind(this), action: this._onUnlockButton.bind(this),
@ -404,7 +404,7 @@ var ShellMountPasswordDialog = GObject.registerClass({
this._usesKeyfilesButtons = [{ this._usesKeyfilesButtons = [{
label: _("Cancel"), label: _("Cancel"),
action: this._onCancelButton.bind(this), action: this._onCancelButton.bind(this),
key: Clutter.Escape, key: Clutter.KEY_Escape,
}, { }, {
/* Translators: %s is the Disks application */ /* Translators: %s is the Disks application */
label: _("Open %s").format(disksApp.get_name()), label: _("Open %s").format(disksApp.get_name()),

View File

@ -87,9 +87,9 @@ class InputSourcePopup extends SwitcherPopup.SwitcherPopup {
this._select(this._next()); this._select(this._next());
else if (action == this._actionBackward) else if (action == this._actionBackward)
this._select(this._previous()); this._select(this._previous());
else if (keysym == Clutter.Left) else if (keysym == Clutter.KEY_Left)
this._select(this._previous()); this._select(this._previous());
else if (keysym == Clutter.Right) else if (keysym == Clutter.KEY_Right)
this._select(this._next()); this._select(this._next());
else else
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;

View File

@ -908,10 +908,10 @@ class NMWirelessDialog extends ModalDialog.ModalDialog {
this._disconnectButton = this.addButton({ action: this.close.bind(this), this._disconnectButton = this.addButton({ action: this.close.bind(this),
label: _("Cancel"), label: _("Cancel"),
key: Clutter.Escape }); key: Clutter.KEY_Escape });
this._connectButton = this.addButton({ action: this._connect.bind(this), this._connectButton = this.addButton({ action: this._connect.bind(this),
label: _("Connect"), label: _("Connect"),
key: Clutter.Return }); key: Clutter.KEY_Return });
} }
_connect() { _connect() {

View File

@ -52,9 +52,9 @@ class SwitchMonitorPopup extends SwitcherPopup.SwitcherPopup {
_keyPressHandler(keysym, action) { _keyPressHandler(keysym, action) {
if (action == Meta.KeyBindingAction.SWITCH_MONITOR) if (action == Meta.KeyBindingAction.SWITCH_MONITOR)
this._select(this._next()); this._select(this._next());
else if (keysym == Clutter.Left) else if (keysym == Clutter.KEY_Left)
this._select(this._previous()); this._select(this._previous());
else if (keysym == Clutter.Right) else if (keysym == Clutter.KEY_Right)
this._select(this._next()); this._select(this._next());
else else
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;

View File

@ -172,7 +172,7 @@ var SwitcherPopup = GObject.registerClass({
// Note: pressing one of the below keys will destroy the popup only if // Note: pressing one of the below keys will destroy the popup only if
// that key is not used by the active popup's keyboard shortcut // that key is not used by the active popup's keyboard shortcut
if (keysym == Clutter.Escape || keysym == Clutter.Tab) if (keysym === Clutter.KEY_Escape || keysym === Clutter.KEY_Tab)
this.fadeAndDestroy(); this.fadeAndDestroy();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;

View File

@ -406,7 +406,7 @@ var ViewSelector = GObject.registerClass({
let symbol = event.get_key_symbol(); let symbol = event.get_key_symbol();
if (symbol == Clutter.Escape) { if (symbol === Clutter.KEY_Escape) {
if (this._searchActive) if (this._searchActive)
this.reset(); this.reset();
else if (this._showAppsButton.checked) else if (this._showAppsButton.checked)
@ -417,10 +417,10 @@ var ViewSelector = GObject.registerClass({
} else if (this._shouldTriggerSearch(symbol)) { } else if (this._shouldTriggerSearch(symbol)) {
this.startSearch(event); this.startSearch(event);
} else if (!this._searchActive && !global.stage.key_focus) { } else if (!this._searchActive && !global.stage.key_focus) {
if (symbol == Clutter.Tab || symbol == Clutter.Down) { if (symbol === Clutter.KEY_Tab || symbol === Clutter.KEY_Down) {
this._activePage.navigate_focus(null, St.DirectionType.TAB_FORWARD, false); this._activePage.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == Clutter.ISO_Left_Tab) { } else if (symbol === Clutter.KEY_ISO_Left_Tab) {
this._activePage.navigate_focus(null, St.DirectionType.TAB_BACKWARD, false); this._activePage.navigate_focus(null, St.DirectionType.TAB_BACKWARD, false);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
@ -485,10 +485,10 @@ var ViewSelector = GObject.registerClass({
} }
_shouldTriggerSearch(symbol) { _shouldTriggerSearch(symbol) {
if (symbol == Clutter.Multi_key) if (symbol === Clutter.KEY_Multi_key)
return true; return true;
if (symbol == Clutter.BackSpace && this._searchActive) if (symbol === Clutter.KEY_BackSpace && this._searchActive)
return true; return true;
let unicode = Clutter.keysym_to_unicode(symbol); let unicode = Clutter.keysym_to_unicode(symbol);
@ -541,7 +541,7 @@ var ViewSelector = GObject.registerClass({
_onKeyPress(entry, event) { _onKeyPress(entry, event) {
let symbol = event.get_key_symbol(); let symbol = event.get_key_symbol();
if (symbol == Clutter.Escape) { if (symbol === Clutter.KEY_Escape) {
if (this._isActivated()) { if (this._isActivated()) {
this.reset(); this.reset();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
@ -549,28 +549,28 @@ var ViewSelector = GObject.registerClass({
} else if (this._searchActive) { } else if (this._searchActive) {
let arrowNext, nextDirection; let arrowNext, nextDirection;
if (entry.get_text_direction() == Clutter.TextDirection.RTL) { if (entry.get_text_direction() == Clutter.TextDirection.RTL) {
arrowNext = Clutter.Left; arrowNext = Clutter.KEY_Left;
nextDirection = St.DirectionType.LEFT; nextDirection = St.DirectionType.LEFT;
} else { } else {
arrowNext = Clutter.Right; arrowNext = Clutter.KEY_Right;
nextDirection = St.DirectionType.RIGHT; nextDirection = St.DirectionType.RIGHT;
} }
if (symbol == Clutter.Tab) { if (symbol === Clutter.KEY_Tab) {
this._searchResults.navigateFocus(St.DirectionType.TAB_FORWARD); this._searchResults.navigateFocus(St.DirectionType.TAB_FORWARD);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == Clutter.ISO_Left_Tab) { } else if (symbol === Clutter.KEY_ISO_Left_Tab) {
this._focusTrap.can_focus = false; this._focusTrap.can_focus = false;
this._searchResults.navigateFocus(St.DirectionType.TAB_BACKWARD); this._searchResults.navigateFocus(St.DirectionType.TAB_BACKWARD);
this._focusTrap.can_focus = true; this._focusTrap.can_focus = true;
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == Clutter.Down) { } else if (symbol === Clutter.KEY_Down) {
this._searchResults.navigateFocus(St.DirectionType.DOWN); this._searchResults.navigateFocus(St.DirectionType.DOWN);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == arrowNext && this._text.position == -1) { } else if (symbol == arrowNext && this._text.position == -1) {
this._searchResults.navigateFocus(nextDirection); this._searchResults.navigateFocus(nextDirection);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (symbol == Clutter.Return || symbol == Clutter.KP_Enter) { } else if (symbol === Clutter.KEY_Return || symbol === Clutter.KEY_KP_Enter) {
this._searchResults.activateDefault(); this._searchResults.activateDefault();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }

View File

@ -69,7 +69,7 @@ class DisplayChangeDialog extends ModalDialog.ModalDialog {
*/ */
this._cancelButton = this.addButton({ label: _("Revert Settings"), this._cancelButton = this.addButton({ label: _("Revert Settings"),
action: this._onFailure.bind(this), action: this._onFailure.bind(this),
key: Clutter.Escape }); key: Clutter.KEY_Escape });
this._okButton = this.addButton({ label: _("Keep Changes"), this._okButton = this.addButton({ label: _("Keep Changes"),
action: this._onSuccess.bind(this), action: this._onSuccess.bind(this),
default: true }); default: true });