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