2024-01-31 16:28:24 +01:00
|
|
|
import GLib from 'gi://GLib';
|
|
|
|
import Gio from 'gi://Gio';
|
|
|
|
|
2024-02-01 20:37:45 +01:00
|
|
|
function camelcase(str) {
|
|
|
|
const words = str.toLowerCase().split('_');
|
|
|
|
return words.map(w => `${w.at(0).toUpperCase()}${w.substring(1)}`).join('');
|
2024-01-31 16:28:24 +01:00
|
|
|
}
|
|
|
|
|
2024-02-01 20:37:45 +01:00
|
|
|
function decamelcase(str) {
|
|
|
|
return str.replace(/(.)([A-Z])/g, '$1-$2');
|
|
|
|
}
|
|
|
|
|
|
|
|
function registerErrorDomain(domain, errorEnum, prefix = 'org.gnome.Shell') {
|
2024-01-31 16:28:24 +01:00
|
|
|
const domainName =
|
2024-02-01 20:37:45 +01:00
|
|
|
`shell-${decamelcase(domain).toLowerCase()}-error`;
|
2024-01-31 16:28:24 +01:00
|
|
|
const quark = GLib.quark_from_string(domainName);
|
|
|
|
|
2024-02-01 20:37:45 +01:00
|
|
|
for (const [name, code] of Object.entries(errorEnum)) {
|
2024-01-31 16:28:24 +01:00
|
|
|
Gio.dbus_error_register_error(quark,
|
2024-02-01 20:37:45 +01:00
|
|
|
code, `${prefix}.${domain}.Error.${camelcase(name)}`);
|
2024-01-31 16:28:24 +01:00
|
|
|
}
|
|
|
|
return quark;
|
|
|
|
}
|
|
|
|
|
2024-02-01 20:37:45 +01:00
|
|
|
export const ModalDialogError = {
|
|
|
|
UNKNOWN_TYPE: 0,
|
|
|
|
GRAB_FAILED: 1,
|
|
|
|
};
|
2024-01-31 17:44:05 +01:00
|
|
|
export const ModalDialogErrors =
|
2024-02-01 20:37:45 +01:00
|
|
|
registerErrorDomain('ModalDialog', ModalDialogError);
|
2024-01-31 18:32:15 +01:00
|
|
|
|
2024-02-01 20:37:45 +01:00
|
|
|
export const NotificationError = {
|
|
|
|
INVALID_APP: 0,
|
|
|
|
};
|
2024-01-31 18:32:15 +01:00
|
|
|
export const NotificationErrors =
|
2024-02-01 20:37:45 +01:00
|
|
|
registerErrorDomain('Notifications', NotificationError, 'org.gtk');
|
|
|
|
|
|
|
|
export const ExtensionError = {
|
|
|
|
INFO_DOWNLOAD_FAILED: 0,
|
|
|
|
DOWNLOAD_FAILED: 1,
|
|
|
|
EXTRACT_FAILED: 2,
|
|
|
|
ENABLE_FAILED: 3,
|
2024-02-10 00:58:27 +01:00
|
|
|
NOT_ALLOWED: 4,
|
2024-02-01 20:37:45 +01:00
|
|
|
};
|
2024-01-31 17:44:10 +01:00
|
|
|
export const ExtensionErrors =
|
2024-02-01 20:37:45 +01:00
|
|
|
registerErrorDomain('Extensions', ExtensionError);
|
2023-10-01 20:10:33 +02:00
|
|
|
|
|
|
|
export const ScreencastError = {
|
|
|
|
ALL_PIPELINES_FAILED: 0,
|
|
|
|
PIPELINE_ERROR: 1,
|
|
|
|
SAVE_TO_DISK_DISABLED: 2,
|
|
|
|
ALREADY_RECORDING: 3,
|
|
|
|
RECORDER_ERROR: 4,
|
|
|
|
SERVICE_CRASH: 5,
|
2023-10-02 14:00:45 +02:00
|
|
|
OUT_OF_DISK_SPACE: 6,
|
2023-10-01 20:10:33 +02:00
|
|
|
};
|
|
|
|
export const ScreencastErrors =
|
|
|
|
registerErrorDomain('Screencast', ScreencastError);
|