var _a; import Gio from 'gi://Gio'; import GObject from 'gi://GObject'; import { Realm } from './model/Realm.js'; import { RealmManager } from "./model/RealmManager.js"; export class RealmModel extends GObject.Object { constructor() { super(); this._realms = []; this._realmManager = RealmManager.instance(); this._realmManager.connect('realm-added', (_manager, realm) => { let pos = this._realms.length; this._realms.push(realm); // @ts-ignore this.items_changed(pos, 0, 1); }); this._realmManager.connect('realm-removed', (_manager, realm) => { let pos = this._realms.findIndex(r => r === realm); if (pos >= 0) { this._realms.splice(pos, 1); // @ts-ignore this.items_changed(pos, 1, 0); } }); } vfunc_get_item_type() { return Realm; } vfunc_get_item(position) { return this._realms[position] || null; } vfunc_get_n_items() { return this._realms.length; } } _a = RealmModel; (() => { GObject.registerClass({ GTypeName: 'RealmModel', Implements: [Gio.ListModel], }, _a); })();