citadel-realms/js/Application.js
2024-11-12 17:26:26 -05:00

90 lines
4.0 KiB
JavaScript

var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Application_instances, _a, _Application_setupAccelerators, _Application_setupActions, _Application_onQuit, _Application_onRealmConfig, _Application_onShowHelp, _Application_onAbout;
import Adw from 'gi://Adw';
import Gtk from 'gi://Gtk?version=4.0';
import Gio from 'gi://Gio';
import GObject from 'gi://GObject';
import './model/RealmManager.js';
import './model/Realm.js';
import './RealmsView.js';
import './RealmRow.js';
import './RealmInfo.js';
import './RealmModel.js';
import './ConfigureRealm.js';
import { Window } from './Window.js';
export class Application extends Adw.Application {
constructor() {
super({
application_id: 'com.subgraph.citadel.Realms',
flags: Gio.ApplicationFlags.DEFAULT_FLAGS,
});
_Application_instances.add(this);
}
vfunc_activate() {
let { activeWindow } = this;
if (!activeWindow) {
activeWindow = new Window(this);
activeWindow.set_hide_on_close(true);
}
activeWindow.present();
}
vfunc_startup() {
super.vfunc_startup();
__classPrivateFieldGet(this, _Application_instances, "m", _Application_setupActions).call(this);
__classPrivateFieldGet(this, _Application_instances, "m", _Application_setupAccelerators).call(this);
// this.#loadStyleSheet();
const styleManager = Adw.StyleManager.get_default();
styleManager.colorScheme = Adw.ColorScheme.FORCE_DARK;
}
}
_a = Application, _Application_instances = new WeakSet(), _Application_setupAccelerators = function _Application_setupAccelerators() {
this.set_accels_for_action('app.quit', ['q']);
this.set_accels_for_action('app.realmConfig', ['c']);
this.set_accels_for_action('app.showHelp', ['h', 'question']);
}, _Application_setupActions = function _Application_setupActions() {
this.add_action_entries([
// @ts-ignore
{ name: 'quit', activate: __classPrivateFieldGet(this, _Application_instances, "m", _Application_onQuit).bind(this) },
// @ts-ignore
{ name: 'realmConfig', activate: __classPrivateFieldGet(this, _Application_instances, "m", _Application_onRealmConfig).bind(this) },
// @ts-ignore
{ name: 'showHelp', activate: __classPrivateFieldGet(this, _Application_instances, "m", _Application_onShowHelp).bind(this) },
// @ts-ignore
{ name: 'about', activate: __classPrivateFieldGet(this, _Application_instances, "m", _Application_onAbout).bind(this) },
]);
}, _Application_onQuit = function _Application_onQuit() {
let { activeWindow } = this;
if (activeWindow) {
activeWindow.close();
}
}, _Application_onRealmConfig = function _Application_onRealmConfig() {
let { activeWindow } = this;
if (activeWindow) {
let window = activeWindow;
const realm = window.realms_view.selectedRealm;
if (realm) {
window.configureRealm(realm);
}
}
}, _Application_onShowHelp = function _Application_onShowHelp() {
const help = Gtk.Builder.new_from_resource('/com/subgraph/citadel/Realms/ui/HelpWindow.ui').get_object('helpWindow');
help.set_transient_for(this._window);
help.present();
}, _Application_onAbout = function _Application_onAbout() {
const dialog = new Adw.AboutDialog({
application_icon: 'face-smile',
application_name: 'Realms',
developer_name: "Subgraph",
});
dialog.present(this._window);
};
(() => {
GObject.registerClass({
GTypeName: 'RealmsApplication'
}, _a);
})();