citadel-realms/js/model/RealmFS.js
2024-11-12 17:12:37 -05:00

70 lines
2.3 KiB
JavaScript

var _a;
import GObject from 'gi://GObject';
const OBJECT_PREFIX = "/com/subgraph/Realms2/RealmFS";
export class RealmFS extends GObject.Object {
constructor(proxy) {
super();
this._proxy = proxy;
this._proxy.connect('g-properties-changed', (_proxy, _changed, _invalidated) => {
this._sync();
});
this._sync();
}
index() {
let path = this._proxy.get_object_path();
if (path.startsWith(OBJECT_PREFIX)) {
const tail = path.substring(OBJECT_PREFIX.length);
let index = Number.parseInt(tail);
if (!Number.isNaN(index)) {
return index;
}
}
return -1;
}
get name() {
return this._name;
}
get in_use() {
return this._in_use;
}
get activated() {
return this._activated;
}
get mountpoint() {
return this._mountpoint;
}
get path() {
return this._path;
}
get free_space() {
return this._free_space;
}
get allocated_space() {
return this._allocated_space;
}
_sync() {
this._name = this._proxy.Name;
this._in_use = this._proxy.InUse;
this._activated = this._proxy.Activated;
this._mountpoint = this._proxy.Mountpoint;
this._path = this._proxy.Path;
this._free_space = this._proxy.FreeSpace;
this._allocated_space = this._proxy.AllocatedSpace;
}
}
_a = RealmFS;
(() => {
GObject.registerClass({
GTypeName: 'RealmFS',
Properties: {
'name': GObject.ParamSpec.string('name', '', '', GObject.ParamFlags.READWRITE, ''),
'in-use': GObject.ParamSpec.boolean('in-use', '', '', GObject.ParamFlags.READWRITE, false),
'activated': GObject.ParamSpec.boolean('activated', '', '', GObject.ParamFlags.READWRITE, false),
'mountpoint': GObject.ParamSpec.string('mountpoint', '', '', GObject.ParamFlags.READWRITE, ''),
'path': GObject.ParamSpec.string('path', '', '', GObject.ParamFlags.READWRITE, ''),
'free-space': GObject.ParamSpec.uint64('free-space', '', '', GObject.ParamFlags.READWRITE, 0, Number.MAX_SAFE_INTEGER, 0),
'allocated-space': GObject.ParamSpec.uint64('allocated-space', '', '', GObject.ParamFlags.READWRITE, 0, Number.MAX_SAFE_INTEGER, 0),
},
}, _a);
})();