endSessionDialog: Use registered D-Bus error
Instead of returning ad-hoc errors, register a custom error domain and return appropriate GLib.Errors. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3159>
This commit is contained in:
parent
9e96e8495b
commit
8f03eec3a3
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-unused-vars */
|
|
||||||
import GLib from 'gi://GLib';
|
import GLib from 'gi://GLib';
|
||||||
import Gio from 'gi://Gio';
|
import Gio from 'gi://Gio';
|
||||||
|
|
||||||
@ -27,3 +26,11 @@ function createErrorEnum(errorNames) {
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const modalDialogErrorNames = [
|
||||||
|
'UnknownType',
|
||||||
|
'GrabFailed',
|
||||||
|
];
|
||||||
|
export const ModalDialogErrors =
|
||||||
|
registerErrorDomain('ModalDialog', modalDialogErrorNames);
|
||||||
|
export const ModalDialogError = createErrorEnum(modalDialogErrorNames);
|
||||||
|
@ -34,6 +34,8 @@ import * as LoginManager from '../misc/loginManager.js';
|
|||||||
import * as ModalDialog from './modalDialog.js';
|
import * as ModalDialog from './modalDialog.js';
|
||||||
import * as UserWidget from './userWidget.js';
|
import * as UserWidget from './userWidget.js';
|
||||||
|
|
||||||
|
import {ModalDialogErrors, ModalDialogError} from '../misc/dbusErrors.js';
|
||||||
|
|
||||||
import {loadInterfaceXML} from '../misc/fileUtils.js';
|
import {loadInterfaceXML} from '../misc/fileUtils.js';
|
||||||
|
|
||||||
const _ITEM_ICON_SIZE = 64;
|
const _ITEM_ICON_SIZE = 64;
|
||||||
@ -739,8 +741,8 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
|
|||||||
this._sessionSection.list.destroy_all_children();
|
this._sessionSection.list.destroy_all_children();
|
||||||
|
|
||||||
if (!(this._type in DialogContent)) {
|
if (!(this._type in DialogContent)) {
|
||||||
invocation.return_dbus_error(
|
invocation.return_error_literal(ModalDialogErrors,
|
||||||
'org.gnome.Shell.ModalDialog.TypeError',
|
ModalDialogError.UNKNOWN_TYPE,
|
||||||
'Unknown dialog type requested');
|
'Unknown dialog type requested');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -773,8 +775,8 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
|
|||||||
this._updateButtons();
|
this._updateButtons();
|
||||||
|
|
||||||
if (!this.open(timestamp)) {
|
if (!this.open(timestamp)) {
|
||||||
invocation.return_dbus_error(
|
invocation.return_error_literal(
|
||||||
'org.gnome.Shell.ModalDialog.GrabError',
|
ModalDialogError.GRAB_FAILED,
|
||||||
'Cannot grab pointer and keyboard');
|
'Cannot grab pointer and keyboard');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user