introspect: Add AnimationsEnabled property
While the gsetting is available for all who needs it, the Shell might override it given various hueristics. Expose the decision made by the Shell via a new property. Intended to be used by gsd-xsettings as well as xdg-desktop-portal-gtk. This also add a version property to the API, so that semi external services (xdg-desktop-portal-gtk) can detect what API is expected to be present. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
/* exported IntrospectService */
|
||||
const { Gio, GLib, Meta, Shell } = imports.gi;
|
||||
const { Gio, GLib, Meta, Shell, St } = imports.gi;
|
||||
|
||||
const INTROSPECT_SCHEMA = 'org.gnome.shell';
|
||||
const INTROSPECT_KEY = 'introspect';
|
||||
const APP_WHITELIST = ['org.freedesktop.impl.portal.desktop.gtk'];
|
||||
|
||||
const INTROSPECT_DBUS_API_VERSION = 2;
|
||||
|
||||
const { loadInterfaceXML } = imports.misc.fileUtils;
|
||||
|
||||
const IntrospectDBusIface = loadInterfaceXML('org.gnome.Shell.Introspect');
|
||||
@ -22,6 +24,7 @@ var IntrospectService = class {
|
||||
this._runningApplicationsDirty = true;
|
||||
this._activeApplication = null;
|
||||
this._activeApplicationDirty = true;
|
||||
this._animationsEnabled = true;
|
||||
|
||||
this._appSystem = Shell.AppSystem.get_default();
|
||||
this._appSystem.connect('app-state-changed',
|
||||
@ -51,6 +54,11 @@ var IntrospectService = class {
|
||||
(conn, name, owner) => this._whitelistMap.set(name, owner),
|
||||
(conn, name) => this._whitelistMap.delete(name));
|
||||
});
|
||||
|
||||
this._settings = St.Settings.get();
|
||||
this._settings.connect('notify::enable-animations',
|
||||
this._syncAnimationsEnabled.bind(this));
|
||||
this._syncAnimationsEnabled();
|
||||
}
|
||||
|
||||
_isStandaloneApp(app) {
|
||||
@ -191,4 +199,21 @@ var IntrospectService = class {
|
||||
}
|
||||
invocation.return_value(new GLib.Variant('(a{ta{sv}})', [windowsList]));
|
||||
}
|
||||
|
||||
_syncAnimationsEnabled() {
|
||||
let wasAnimationsEnabled = this._animationsEnabled;
|
||||
this._animationsEnabled = this._settings.enable_animations;
|
||||
if (wasAnimationsEnabled !== this._animationsEnabled) {
|
||||
let variant = new GLib.Variant('b', this._animationsEnabled);
|
||||
this._dbusImpl.emit_property_changed('AnimationsEnabled', variant);
|
||||
}
|
||||
}
|
||||
|
||||
get AnimationsEnabled() {
|
||||
return this._animationsEnabled;
|
||||
}
|
||||
|
||||
get version() {
|
||||
return INTROSPECT_DBUS_API_VERSION;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user