Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a046da30f2 |
+17
-23
@@ -555,31 +555,19 @@ class MonitorWidget extends PanelMenu.Button {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// From https://github.com/ubuntu/gnome-shell-extension-appindicator/blob/master/interfaces.js
|
async function loadInterfaceXml(extension, filename) {
|
||||||
// loads a xml file into an in-memory string
|
|
||||||
function loadInterfaceXml(extension, filename) {
|
|
||||||
const interfacesDir = extension.dir.get_child('.');
|
const interfacesDir = extension.dir.get_child('.');
|
||||||
|
|
||||||
const file = interfacesDir.get_child(filename);
|
const file = interfacesDir.get_child(filename);
|
||||||
|
const fd = Gio.File.new_for_path(file.get_path());
|
||||||
|
const [contents, etag] = await fd.load_contents_async(null);
|
||||||
|
|
||||||
let [result, contents] = GLib.file_get_contents(file.get_path());
|
const decoder = new TextDecoder('utf-8');
|
||||||
|
const decoded_content = decoder.decode(contents);
|
||||||
|
|
||||||
if (result) {
|
const res = `<node>${decoded_content}</node>`;
|
||||||
// HACK: The "" + trick is important as hell because file_get_contents returns
|
|
||||||
// an object (WTF?) but Gio.makeProxyWrapper requires `typeof() == "string"`
|
return res;
|
||||||
// Otherwise, it will try to check `instanceof XML` and fail miserably because there
|
|
||||||
// is no `XML` on very recent SpiderMonkey releases (or, if SpiderMonkey is old enough,
|
|
||||||
// will spit out a TypeError soon).
|
|
||||||
if (contents instanceof Uint8Array)
|
|
||||||
{
|
|
||||||
const decoder = new TextDecoder();
|
|
||||||
contents = decoder.decode(contents);
|
|
||||||
}
|
|
||||||
const res = `<node>${contents}</node>`;
|
|
||||||
return res;
|
|
||||||
} else {
|
|
||||||
throw new Error(`Generic monitor: Could not load file: ${filename}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class GenericMonitorDBUS {
|
class GenericMonitorDBUS {
|
||||||
@@ -588,9 +576,15 @@ class GenericMonitorDBUS {
|
|||||||
this.monitor_groups = {};
|
this.monitor_groups = {};
|
||||||
this.actor_clicked = {};
|
this.actor_clicked = {};
|
||||||
this.ClutterSettings = Clutter.Settings.get_default();
|
this.ClutterSettings = Clutter.Settings.get_default();
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(loadInterfaceXml(extension, 'dbus.xml'), this);
|
this._dbusImpl = null;
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/com/soutade/GenericMonitor');
|
loadInterfaceXml(extension, 'dbus.xml')
|
||||||
this._dbusImpl.emit_signal('onActivate', null);
|
.then( (xml) =>
|
||||||
|
{
|
||||||
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(xml, this);
|
||||||
|
this._dbusImpl.export(Gio.DBus.session, '/com/soutade/GenericMonitor');
|
||||||
|
this._dbusImpl.emit_signal('onActivate', null);
|
||||||
|
})
|
||||||
|
.catch((e) => { this.logger.error(e); });
|
||||||
}
|
}
|
||||||
|
|
||||||
emitSignal(name, value) {
|
emitSignal(name, value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user