popov895
(Eugene Popov)
September 7, 2024, 10:00am
1
Hi there.
Do you think it is wrong to use Gio.DBusProxy.makeProxyWrapper
in the global scope of the extension? In other words, is the code below incorrect?
const { Gio } = imports.gi;
const BrightnessInterface = loadInterfaceXML(`org.gnome.SettingsDaemon.Power.Screen`);
const BrightnessProxy = Gio.DBusProxy.makeProxyWrapper(BrightnessInterface);
As stated in the documentation , Gio.DBusProxy.makeProxyWrapper
creates a reusable class that can be used to create a proxy, but it doesn’t create any objects. Therefore, in my opinion, the code above is correct. Or am I wrong somewhere?
andyholmes
(Andy Holmes)
September 7, 2024, 4:20pm
2
Well, even Function
s are objects in JavaScript. Is this in reference to a review you received for your extension?
popov895
(Eugene Popov)
September 7, 2024, 4:27pm
3
Yes. My extension was rejected during review.
andyholmes
(Andy Holmes)
September 7, 2024, 4:43pm
4
I guess it might be a gray area, but there’s really no downside to making the call in enable()
and dropping it in disable()
.
popov895
(Eugene Popov)
September 7, 2024, 5:43pm
5
Hmm, okay. So how do I do it correctly?
enable() {
const ProxyWrapper = Gio.DBusProxy.makeProxyWrapper(BrightnessInterface);
this._proxy = new Proxy(...);
}
disable() {
delete this._proxy;
}
or
enable() {
this._proxyWrapper = Gio.DBusProxy.makeProxyWrapper(BrightnessInterface);
this._proxy = new this._proxyWrapper(...);
}
disable() {
delete this._proxy;
delete this._proxyWrapper;
}
andyholmes
(Andy Holmes)
September 7, 2024, 6:54pm
6
The first is pretty much how I would do it. I usually assign null
instead of using delete
, but I don’t think that matters.
system
(system)
Closed
October 7, 2024, 6:54pm
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.