From e4283f6d48b98e764b988b43bbc86b9d52e6ec94 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:54:43 +0200 Subject: Adding upstream version 43.9. Signed-off-by: Daniel Baumann --- js/misc/gnomeSession.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 js/misc/gnomeSession.js (limited to 'js/misc/gnomeSession.js') diff --git a/js/misc/gnomeSession.js b/js/misc/gnomeSession.js new file mode 100644 index 0000000..487644f --- /dev/null +++ b/js/misc/gnomeSession.js @@ -0,0 +1,45 @@ +// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- +/* exported PresenceStatus, Presence, Inhibitor, SessionManager, InhibitFlags */ + +const Gio = imports.gi.Gio; + +const { loadInterfaceXML } = imports.misc.fileUtils; + +const PresenceIface = loadInterfaceXML('org.gnome.SessionManager.Presence'); + +var PresenceStatus = { + AVAILABLE: 0, + INVISIBLE: 1, + BUSY: 2, + IDLE: 3, +}; + +var PresenceProxy = Gio.DBusProxy.makeProxyWrapper(PresenceIface); +function Presence(initCallback, cancellable) { + return new PresenceProxy(Gio.DBus.session, 'org.gnome.SessionManager', + '/org/gnome/SessionManager/Presence', initCallback, cancellable); +} + +// Note inhibitors are immutable objects, so they don't +// change at runtime (changes always come in the form +// of new inhibitors) +const InhibitorIface = loadInterfaceXML('org.gnome.SessionManager.Inhibitor'); +var InhibitorProxy = Gio.DBusProxy.makeProxyWrapper(InhibitorIface); +function Inhibitor(objectPath, initCallback, cancellable) { + return new InhibitorProxy(Gio.DBus.session, 'org.gnome.SessionManager', objectPath, initCallback, cancellable); +} + +// Not the full interface, only the methods we use +const SessionManagerIface = loadInterfaceXML('org.gnome.SessionManager'); +var SessionManagerProxy = Gio.DBusProxy.makeProxyWrapper(SessionManagerIface); +function SessionManager(initCallback, cancellable) { + return new SessionManagerProxy(Gio.DBus.session, 'org.gnome.SessionManager', '/org/gnome/SessionManager', initCallback, cancellable); +} + +var InhibitFlags = { + LOGOUT: 1 << 0, + SWITCH: 1 << 1, + SUSPEND: 1 << 2, + IDLE: 1 << 3, + AUTOMOUNT: 1 << 4, +}; -- cgit v1.2.3