|
|
b19d38 |
From 69f53c05798194c49ae897981c2fd37e0f15c489 Mon Sep 17 00:00:00 2001
|
|
|
b19d38 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
b19d38 |
Date: Tue, 24 Aug 2021 15:03:57 -0400
|
|
|
b19d38 |
Subject: [PATCH] heads-up-display: Add extension for showing persistent heads
|
|
|
b19d38 |
up display message
|
|
|
b19d38 |
|
|
|
b19d38 |
---
|
|
|
b19d38 |
extensions/heads-up-display/extension.js | 436 ++++++++++++++++++
|
|
|
b19d38 |
extensions/heads-up-display/headsUpMessage.js | 170 +++++++
|
|
|
b19d38 |
extensions/heads-up-display/meson.build | 8 +
|
|
|
b19d38 |
extensions/heads-up-display/metadata.json.in | 11 +
|
|
|
b19d38 |
...ll.extensions.heads-up-display.gschema.xml | 54 +++
|
|
|
b19d38 |
extensions/heads-up-display/prefs.js | 194 ++++++++
|
|
|
b19d38 |
extensions/heads-up-display/stylesheet.css | 32 ++
|
|
|
b19d38 |
meson.build | 1 +
|
|
|
b19d38 |
8 files changed, 906 insertions(+)
|
|
|
b19d38 |
create mode 100644 extensions/heads-up-display/extension.js
|
|
|
b19d38 |
create mode 100644 extensions/heads-up-display/headsUpMessage.js
|
|
|
b19d38 |
create mode 100644 extensions/heads-up-display/meson.build
|
|
|
b19d38 |
create mode 100644 extensions/heads-up-display/metadata.json.in
|
|
|
b19d38 |
create mode 100644 extensions/heads-up-display/org.gnome.shell.extensions.heads-up-display.gschema.xml
|
|
|
b19d38 |
create mode 100644 extensions/heads-up-display/prefs.js
|
|
|
b19d38 |
create mode 100644 extensions/heads-up-display/stylesheet.css
|
|
|
b19d38 |
|
|
|
b19d38 |
diff --git a/extensions/heads-up-display/extension.js b/extensions/heads-up-display/extension.js
|
|
|
b19d38 |
new file mode 100644
|
|
|
b19d38 |
index 0000000..7cebfa9
|
|
|
b19d38 |
--- /dev/null
|
|
|
b19d38 |
+++ b/extensions/heads-up-display/extension.js
|
|
|
b19d38 |
@@ -0,0 +1,436 @@
|
|
|
b19d38 |
+/* exported init enable disable */
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+const Signals = imports.signals;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+const {
|
|
|
b19d38 |
+ Atk, Clutter, Gio, GLib, GObject, Gtk, Meta, Shell, St,
|
|
|
b19d38 |
+} = imports.gi;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+const ExtensionUtils = imports.misc.extensionUtils;
|
|
|
b19d38 |
+const Me = ExtensionUtils.getCurrentExtension();
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+const Main = imports.ui.main;
|
|
|
b19d38 |
+const Layout = imports.ui.layout;
|
|
|
b19d38 |
+const HeadsUpMessage = Me.imports.headsUpMessage;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+const _ = ExtensionUtils.gettext;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+var HeadsUpConstraint = GObject.registerClass({
|
|
|
b19d38 |
+ Properties: {
|
|
|
b19d38 |
+ 'offset': GObject.ParamSpec.int('offset',
|
|
|
b19d38 |
+ 'Offset', 'offset',
|
|
|
b19d38 |
+ GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
|
|
|
b19d38 |
+ -1, 0, -1),
|
|
|
b19d38 |
+ 'active': GObject.ParamSpec.boolean('active',
|
|
|
b19d38 |
+ 'Active', 'active',
|
|
|
b19d38 |
+ GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
|
|
|
b19d38 |
+ true),
|
|
|
b19d38 |
+ },
|
|
|
b19d38 |
+}, class HeadsUpConstraint extends Layout.MonitorConstraint {
|
|
|
b19d38 |
+ _init(props) {
|
|
|
b19d38 |
+ super._init(props);
|
|
|
b19d38 |
+ this._offset = 0;
|
|
|
b19d38 |
+ this._active = true;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ get offset() {
|
|
|
b19d38 |
+ return this._offset;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ set offset(o) {
|
|
|
b19d38 |
+ this._offset = o
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ get active() {
|
|
|
b19d38 |
+ return this._active;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ set active(a) {
|
|
|
b19d38 |
+ this._active = a;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ vfunc_update_allocation(actor, actorBox) {
|
|
|
b19d38 |
+ if (!Main.layoutManager.primaryMonitor)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!this.active)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (actor.has_allocation())
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
|
|
|
b19d38 |
+ actorBox.init_rect(workArea.x, workArea.y + this.offset, workArea.width, workArea.height - this.offset);
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+});
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+class Extension {
|
|
|
b19d38 |
+ constructor() {
|
|
|
b19d38 |
+ ExtensionUtils.initTranslations();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ enable() {
|
|
|
b19d38 |
+ this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.heads-up-display');
|
|
|
b19d38 |
+ this._settingsChangedId = this._settings.connect('changed', this._updateMessage.bind(this));
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._idleMonitor = Meta.IdleMonitor.get_core();
|
|
|
b19d38 |
+ this._messageInhibitedUntilIdle = false;
|
|
|
b19d38 |
+ this._oldMapWindow = Main.wm._mapWindow;
|
|
|
b19d38 |
+ Main.wm._mapWindow = this._mapWindow;
|
|
|
b19d38 |
+ this._windowManagerMapId = global.window_manager.connect('map', this._onWindowMap.bind(this));
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (Main.layoutManager._startingUp)
|
|
|
b19d38 |
+ this._startupCompleteId = Main.layoutManager.connect('startup-complete', this._onStartupComplete.bind(this));
|
|
|
b19d38 |
+ else
|
|
|
b19d38 |
+ this._onStartupComplete(this);
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ disable() {
|
|
|
b19d38 |
+ this._dismissMessage();
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._stopWatchingForIdle();
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._sessionModeUpdatedId) {
|
|
|
b19d38 |
+ Main.sessionMode.disconnect(this._sessionModeUpdatedId);
|
|
|
b19d38 |
+ this._sessionModeUpdatedId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._overviewShowingId) {
|
|
|
b19d38 |
+ Main.overview.disconnect(this._overviewShowingId);
|
|
|
b19d38 |
+ this._overviewShowingId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._overviewHiddenId) {
|
|
|
b19d38 |
+ Main.overview.disconnect(this._overviewHiddenId);
|
|
|
b19d38 |
+ this._overviewHiddenId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._screenShieldVisibleId) {
|
|
|
b19d38 |
+ Main.screenShield._dialog._clock.disconnect(this._screenShieldVisibleId);
|
|
|
b19d38 |
+ this._screenShieldVisibleId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._panelConnectionId) {
|
|
|
b19d38 |
+ Main.layoutManager.panelBox.disconnect(this._panelConnectionId);
|
|
|
b19d38 |
+ this._panelConnectionId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._oldMapWindow) {
|
|
|
b19d38 |
+ Main.wm._mapWindow = this._oldMapWindow;
|
|
|
b19d38 |
+ this._oldMapWindow = null;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._windowManagerMapId) {
|
|
|
b19d38 |
+ global.window_manager.disconnect(this._windowManagerMapId);
|
|
|
b19d38 |
+ this._windowManagerMapId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._startupCompleteId) {
|
|
|
b19d38 |
+ Main.layoutManager.disconnect(this._startupCompleteId);
|
|
|
b19d38 |
+ this._startupCompleteId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._settingsChangedId) {
|
|
|
b19d38 |
+ this._settings.disconnect(this._settingsChangedId);
|
|
|
b19d38 |
+ this._settingsChangedId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _onWindowMap(shellwm, actor) {
|
|
|
b19d38 |
+ const windowObject = actor.meta_window;
|
|
|
b19d38 |
+ const windowType = windowObject.get_window_type();
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (windowType != Meta.WindowType.NORMAL)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!this._message || !this._message.visible)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const messageRect = new Meta.Rectangle({ x: this._message.x, y: this._message.y, width: this._message.width, height: this._message.height });
|
|
|
b19d38 |
+ const windowRect = windowObject.get_frame_rect();
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (windowRect.intersect(messageRect)) {
|
|
|
b19d38 |
+ windowObject.move_frame(false, windowRect.x, this._message.y + this._message.height);
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _onStartupComplete() {
|
|
|
b19d38 |
+ this._overviewShowingId = Main.overview.connect('showing', this._updateMessage.bind(this));
|
|
|
b19d38 |
+ this._overviewHiddenId = Main.overview.connect('hidden', this._updateMessage.bind(this));
|
|
|
b19d38 |
+ this._panelConnectionId = Main.layoutManager.panelBox.connect('notify::visible', this._updateMessage.bind(this));
|
|
|
b19d38 |
+ this._sessionModeUpdatedId = Main.sessionMode.connect('updated', this._onSessionModeUpdated.bind(this));
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._updateMessage();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _onSessionModeUpdated() {
|
|
|
b19d38 |
+ if (!Main.sessionMode.hasWindows)
|
|
|
b19d38 |
+ this._messageInhibitedUntilIdle = false;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const dialog = Main.screenShield._dialog;
|
|
|
b19d38 |
+ if (!Main.sessionMode.isGreeter && dialog && !this._screenShieldVisibleId) {
|
|
|
b19d38 |
+ this._screenShieldVisibleId = dialog._clock.connect('notify::visible',
|
|
|
b19d38 |
+ this._updateMessage.bind(this));
|
|
|
b19d38 |
+ this._screenShieldDestroyId = dialog._clock.connect('destroy', () => {
|
|
|
b19d38 |
+ this._screenShieldVisibleId = 0;
|
|
|
b19d38 |
+ this._screenShieldDestroyId = 0;
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ this._updateMessage();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _stopWatchingForIdle() {
|
|
|
b19d38 |
+ if (this._idleWatchId) {
|
|
|
b19d38 |
+ this._idleMonitor.remove_watch(this._idleWatchId);
|
|
|
b19d38 |
+ this._idleWatchId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._idleTimeoutChangedId) {
|
|
|
b19d38 |
+ this._settings.disconnect(this._idleTimeoutChangedId);
|
|
|
b19d38 |
+ this._idleTimeoutChangedId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _onIdleTimeoutChanged() {
|
|
|
b19d38 |
+ this._stopWatchingForIdle();
|
|
|
b19d38 |
+ this._messageInhibitedUntilIdle = false;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _onUserIdle() {
|
|
|
b19d38 |
+ this._messageInhibitedUntilIdle = false;
|
|
|
b19d38 |
+ this._updateMessage();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _watchForIdle() {
|
|
|
b19d38 |
+ this._stopWatchingForIdle();
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const idleTimeout = this._settings.get_uint('idle-timeout');
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._idleTimeoutChangedId = this._settings.connect('changed::idle-timeout', this._onIdleTimeoutChanged.bind(this));
|
|
|
b19d38 |
+ this._idleWatchId = this._idleMonitor.add_idle_watch(idleTimeout * 1000, this._onUserIdle.bind(this));
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _updateMessage() {
|
|
|
b19d38 |
+ if (this._messageInhibitedUntilIdle) {
|
|
|
b19d38 |
+ if (this._message)
|
|
|
b19d38 |
+ this._dismissMessage();
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._stopWatchingForIdle();
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (Main.sessionMode.hasOverview && Main.overview.visible) {
|
|
|
b19d38 |
+ this._dismissMessage();
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!Main.layoutManager.panelBox.visible) {
|
|
|
b19d38 |
+ this._dismissMessage();
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ let supportedModes = [];
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._settings.get_boolean('show-when-unlocked'))
|
|
|
b19d38 |
+ supportedModes.push('user');
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._settings.get_boolean('show-when-unlocking') ||
|
|
|
b19d38 |
+ this._settings.get_boolean('show-when-locked'))
|
|
|
b19d38 |
+ supportedModes.push('unlock-dialog');
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._settings.get_boolean('show-on-login-screen'))
|
|
|
b19d38 |
+ supportedModes.push('gdm');
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!supportedModes.includes(Main.sessionMode.currentMode) &&
|
|
|
b19d38 |
+ !supportedModes.includes(Main.sessionMode.parentMode)) {
|
|
|
b19d38 |
+ this._dismissMessage();
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (Main.sessionMode.currentMode === 'unlock-dialog') {
|
|
|
b19d38 |
+ const dialog = Main.screenShield._dialog;
|
|
|
b19d38 |
+ if (!this._settings.get_boolean('show-when-locked')) {
|
|
|
b19d38 |
+ if (dialog._clock.visible) {
|
|
|
b19d38 |
+ this._dismissMessage();
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!this._settings.get_boolean('show-when-unlocking')) {
|
|
|
b19d38 |
+ if (!dialog._clock.visible) {
|
|
|
b19d38 |
+ this._dismissMessage();
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const heading = this._settings.get_string('message-heading');
|
|
|
b19d38 |
+ const body = this._settings.get_string('message-body');
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!heading && !body) {
|
|
|
b19d38 |
+ this._dismissMessage();
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!this._message) {
|
|
|
b19d38 |
+ this._message = new HeadsUpMessage.HeadsUpMessage(heading, body);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._message.connect('notify::allocation', this._adaptSessionForMessage.bind(this));
|
|
|
b19d38 |
+ this._message.connect('clicked', this._onMessageClicked.bind(this));
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._message.reactive = true;
|
|
|
b19d38 |
+ this._message.track_hover = true;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._message.setHeading(heading);
|
|
|
b19d38 |
+ this._message.setBody(body);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!Main.sessionMode.hasWindows) {
|
|
|
b19d38 |
+ this._message.track_hover = false;
|
|
|
b19d38 |
+ this._message.reactive = false;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _onMessageClicked() {
|
|
|
b19d38 |
+ if (!Main.sessionMode.hasWindows)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._watchForIdle();
|
|
|
b19d38 |
+ this._messageInhibitedUntilIdle = true;
|
|
|
b19d38 |
+ this._updateMessage();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _dismissMessage() {
|
|
|
b19d38 |
+ if (!this._message) {
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._message.visible = false;
|
|
|
b19d38 |
+ this._message.destroy();
|
|
|
b19d38 |
+ this._message = null;
|
|
|
b19d38 |
+ this._resetMessageTray();
|
|
|
b19d38 |
+ this._resetLoginDialog();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _resetMessageTray() {
|
|
|
b19d38 |
+ if (!Main.messageTray)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._updateMessageTrayId) {
|
|
|
b19d38 |
+ global.stage.disconnect(this._updateMessageTrayId);
|
|
|
b19d38 |
+ this._updateMessageTrayId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._messageTrayConstraint) {
|
|
|
b19d38 |
+ Main.messageTray.remove_constraint(this._messageTrayConstraint);
|
|
|
b19d38 |
+ this._messageTrayConstraint = null;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _alignMessageTray() {
|
|
|
b19d38 |
+ if (!Main.messageTray)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!this._message || !this._message.visible) {
|
|
|
b19d38 |
+ this._resetMessageTray()
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._updateMessageTrayId)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._updateMessageTrayId = global.stage.connect('before-update', () => {
|
|
|
b19d38 |
+ if (!this._messageTrayConstraint) {
|
|
|
b19d38 |
+ this._messageTrayConstraint = new HeadsUpConstraint({ primary: true });
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ Main.layoutManager.panelBox.bind_property('visible',
|
|
|
b19d38 |
+ this._messageTrayConstraint, 'active',
|
|
|
b19d38 |
+ GObject.BindingFlags.SYNC_CREATE);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ Main.messageTray.add_constraint(this._messageTrayConstraint);
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const panelBottom = Main.layoutManager.panelBox.y + Main.layoutManager.panelBox.height;
|
|
|
b19d38 |
+ const messageBottom = this._message.y + this._message.height;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._messageTrayConstraint.offset = messageBottom - panelBottom;
|
|
|
b19d38 |
+ global.stage.disconnect(this._updateMessageTrayId);
|
|
|
b19d38 |
+ this._updateMessageTrayId = 0;
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _resetLoginDialog() {
|
|
|
b19d38 |
+ if (!Main.sessionMode.isGreeter)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!Main.screenShield || !Main.screenShield._dialog)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const dialog = Main.screenShield._dialog;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._authPromptAllocatedId) {
|
|
|
b19d38 |
+ dialog.disconnect(this._authPromptAllocatedId);
|
|
|
b19d38 |
+ this._authPromptAllocatedId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._updateLoginDialogId) {
|
|
|
b19d38 |
+ global.stage.disconnect(this._updateLoginDialogId);
|
|
|
b19d38 |
+ this._updateLoginDialogId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._loginDialogConstraint) {
|
|
|
b19d38 |
+ dialog.remove_constraint(this._loginDialogConstraint);
|
|
|
b19d38 |
+ this._loginDialogConstraint = null;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _adaptLoginDialogForMessage() {
|
|
|
b19d38 |
+ if (!Main.sessionMode.isGreeter)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!Main.screenShield || !Main.screenShield._dialog)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!this._message || !this._message.visible) {
|
|
|
b19d38 |
+ this._resetLoginDialog()
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const dialog = Main.screenShield._dialog;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._updateLoginDialogId)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._updateLoginDialogId = global.stage.connect('before-update', () => {
|
|
|
b19d38 |
+ let messageHeight = this._message.y + this._message.height;
|
|
|
b19d38 |
+ if (dialog._logoBin.visible)
|
|
|
b19d38 |
+ messageHeight -= dialog._logoBin.height;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (!this._logindDialogConstraint) {
|
|
|
b19d38 |
+ this._loginDialogConstraint = new HeadsUpConstraint({ primary: true });
|
|
|
b19d38 |
+ dialog.add_constraint(this._loginDialogConstraint);
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._loginDialogConstraint.offset = messageHeight;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ global.stage.disconnect(this._updateLoginDialogId);
|
|
|
b19d38 |
+ this._updateLoginDialogId = 0;
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _adaptSessionForMessage() {
|
|
|
b19d38 |
+ this._alignMessageTray();
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (Main.sessionMode.isGreeter) {
|
|
|
b19d38 |
+ this._adaptLoginDialogForMessage();
|
|
|
b19d38 |
+ if (!this._authPromptAllocatedId) {
|
|
|
b19d38 |
+ const dialog = Main.screenShield._dialog;
|
|
|
b19d38 |
+ this._authPromptAllocatedId = dialog._authPrompt.connect('notify::allocation', this._adaptLoginDialogForMessage.bind(this));
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+function init() {
|
|
|
b19d38 |
+ return new Extension();
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
diff --git a/extensions/heads-up-display/headsUpMessage.js b/extensions/heads-up-display/headsUpMessage.js
|
|
|
b19d38 |
new file mode 100644
|
|
|
b19d38 |
index 0000000..87a8c8b
|
|
|
b19d38 |
--- /dev/null
|
|
|
b19d38 |
+++ b/extensions/heads-up-display/headsUpMessage.js
|
|
|
b19d38 |
@@ -0,0 +1,170 @@
|
|
|
b19d38 |
+const { Atk, Clutter, GLib, GObject, Pango, St } = imports.gi;
|
|
|
b19d38 |
+const Layout = imports.ui.layout;
|
|
|
b19d38 |
+const Main = imports.ui.main;
|
|
|
b19d38 |
+const Signals = imports.signals;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+var HeadsUpMessageBodyLabel = GObject.registerClass({
|
|
|
b19d38 |
+}, class HeadsUpMessageBodyLabel extends St.Label {
|
|
|
b19d38 |
+ _init(params) {
|
|
|
b19d38 |
+ super._init(params);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._widthCoverage = 0.75;
|
|
|
b19d38 |
+ this._heightCoverage = 0.25;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._workAreasChangedId = global.display.connect('workareas-changed', this._getWorkAreaAndMeasureLineHeight.bind(this));
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _getWorkAreaAndMeasureLineHeight() {
|
|
|
b19d38 |
+ if (!this.get_parent())
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this.clutter_text.single_line_mode = true;
|
|
|
b19d38 |
+ this.clutter_text.line_wrap = false;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._lineHeight = super.vfunc_get_preferred_height(-1)[0];
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this.clutter_text.single_line_mode = false;
|
|
|
b19d38 |
+ this.clutter_text.line_wrap = true;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ vfunc_parent_set(oldParent) {
|
|
|
b19d38 |
+ this._getWorkAreaAndMeasureLineHeight();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ vfunc_get_preferred_width(forHeight) {
|
|
|
b19d38 |
+ const maxWidth = this._widthCoverage * this._workArea.width
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ let [labelMinimumWidth, labelNaturalWidth] = super.vfunc_get_preferred_width(forHeight);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ labelMinimumWidth = Math.min(labelMinimumWidth, maxWidth);
|
|
|
b19d38 |
+ labelNaturalWidth = Math.min(labelNaturalWidth, maxWidth);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ return [labelMinimumWidth, labelNaturalWidth];
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ vfunc_get_preferred_height(forWidth) {
|
|
|
b19d38 |
+ const labelHeightUpperBound = this._heightCoverage * this._workArea.height;
|
|
|
b19d38 |
+ const numberOfLines = Math.floor(labelHeightUpperBound / this._lineHeight);
|
|
|
b19d38 |
+ this._numberOfLines = Math.max(numberOfLines, 1);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const maxHeight = this._lineHeight * this._numberOfLines;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ let [labelMinimumHeight, labelNaturalHeight] = super.vfunc_get_preferred_height(forWidth);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ labelMinimumHeight = Math.min(labelMinimumHeight, maxHeight);
|
|
|
b19d38 |
+ labelNaturalHeight = Math.min(labelNaturalHeight, maxHeight);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ return [labelMinimumHeight, labelNaturalHeight];
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ destroy() {
|
|
|
b19d38 |
+ if (this._workAreasChangedId) {
|
|
|
b19d38 |
+ global.display.disconnect(this._workAreasChangedId);
|
|
|
b19d38 |
+ this._workAreasChangedId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ super.destroy();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+});
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+var HeadsUpMessage = GObject.registerClass({
|
|
|
b19d38 |
+}, class HeadsUpMessage extends St.Button {
|
|
|
b19d38 |
+ _init(heading, body) {
|
|
|
b19d38 |
+ super._init({
|
|
|
b19d38 |
+ style_class: 'message',
|
|
|
b19d38 |
+ accessible_role: Atk.Role.NOTIFICATION,
|
|
|
b19d38 |
+ can_focus: false,
|
|
|
b19d38 |
+ opacity: 0,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ Main.layoutManager.addChrome(this, { affectsInputRegion: true });
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this.add_style_class_name('heads-up-display-message');
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._panelAllocationId = Main.layoutManager.panelBox.connect('notify::allocation', this._alignWithPanel.bind(this));
|
|
|
b19d38 |
+ this.connect('notify::allocation', this._alignWithPanel.bind(this));
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const contentsBox = new St.BoxLayout({ style_class: 'heads-up-message-content',
|
|
|
b19d38 |
+ vertical: true,
|
|
|
b19d38 |
+ x_align: Clutter.ActorAlign.CENTER });
|
|
|
b19d38 |
+ this.add_actor(contentsBox);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this.headingLabel = new St.Label({ style_class: 'heads-up-message-heading',
|
|
|
b19d38 |
+ x_expand: true,
|
|
|
b19d38 |
+ x_align: Clutter.ActorAlign.CENTER });
|
|
|
b19d38 |
+ this.setHeading(heading);
|
|
|
b19d38 |
+ contentsBox.add_actor(this.headingLabel);
|
|
|
b19d38 |
+ this.contentsBox = contentsBox;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this.bodyLabel = new HeadsUpMessageBodyLabel({ style_class: 'heads-up-message-body',
|
|
|
b19d38 |
+ x_expand: true,
|
|
|
b19d38 |
+ y_expand: true });
|
|
|
b19d38 |
+ contentsBox.add_actor(this.bodyLabel);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this.setBody(body);
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ vfunc_parent_set(oldParent) {
|
|
|
b19d38 |
+ this._alignWithPanel();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ _alignWithPanel() {
|
|
|
b19d38 |
+ if (this._afterUpdateId)
|
|
|
b19d38 |
+ return;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ this._afterUpdateId = global.stage.connect('before-update', () => {
|
|
|
b19d38 |
+ let x = Main.panel.x;
|
|
|
b19d38 |
+ let y = Main.panel.y + Main.panel.height;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ x += Main.panel.width / 2;
|
|
|
b19d38 |
+ x -= this.width / 2;
|
|
|
b19d38 |
+ x = Math.floor(x);
|
|
|
b19d38 |
+ this.set_position(x,y);
|
|
|
b19d38 |
+ this.opacity = 255;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ global.stage.disconnect(this._afterUpdateId);
|
|
|
b19d38 |
+ this._afterUpdateId = 0;
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ setHeading(text) {
|
|
|
b19d38 |
+ if (text) {
|
|
|
b19d38 |
+ const heading = text ? text.replace(/\n/g, ' ') : '';
|
|
|
b19d38 |
+ this.headingLabel.text = heading;
|
|
|
b19d38 |
+ this.headingLabel.visible = true;
|
|
|
b19d38 |
+ } else {
|
|
|
b19d38 |
+ this.headingLabel.text = text;
|
|
|
b19d38 |
+ this.headingLabel.visible = false;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ setBody(text) {
|
|
|
b19d38 |
+ this.bodyLabel.text = text;
|
|
|
b19d38 |
+ if (text) {
|
|
|
b19d38 |
+ this.bodyLabel.visible = true;
|
|
|
b19d38 |
+ } else {
|
|
|
b19d38 |
+ this.bodyLabel.visible = false;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ destroy() {
|
|
|
b19d38 |
+ if (this._panelAllocationId) {
|
|
|
b19d38 |
+ Main.layoutManager.panelBox.disconnect(this._panelAllocationId);
|
|
|
b19d38 |
+ this._panelAllocationId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this._afterUpdateId) {
|
|
|
b19d38 |
+ global.stage.disconnect(this._afterUpdateId);
|
|
|
b19d38 |
+ this._afterUpdateId = 0;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ if (this.bodyLabel) {
|
|
|
b19d38 |
+ this.bodyLabel.destroy();
|
|
|
b19d38 |
+ this.bodyLabel = null;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ super.destroy();
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+});
|
|
|
b19d38 |
diff --git a/extensions/heads-up-display/meson.build b/extensions/heads-up-display/meson.build
|
|
|
b19d38 |
new file mode 100644
|
|
|
b19d38 |
index 0000000..40c3de0
|
|
|
b19d38 |
--- /dev/null
|
|
|
b19d38 |
+++ b/extensions/heads-up-display/meson.build
|
|
|
b19d38 |
@@ -0,0 +1,8 @@
|
|
|
b19d38 |
+extension_data += configure_file(
|
|
|
b19d38 |
+ input: metadata_name + '.in',
|
|
|
b19d38 |
+ output: metadata_name,
|
|
|
b19d38 |
+ configuration: metadata_conf
|
|
|
b19d38 |
+)
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+extension_sources += files('headsUpMessage.js', 'prefs.js')
|
|
|
b19d38 |
+extension_schemas += files(metadata_conf.get('gschemaname') + '.gschema.xml')
|
|
|
b19d38 |
diff --git a/extensions/heads-up-display/metadata.json.in b/extensions/heads-up-display/metadata.json.in
|
|
|
b19d38 |
new file mode 100644
|
|
|
b19d38 |
index 0000000..e7ab71a
|
|
|
b19d38 |
--- /dev/null
|
|
|
b19d38 |
+++ b/extensions/heads-up-display/metadata.json.in
|
|
|
b19d38 |
@@ -0,0 +1,11 @@
|
|
|
b19d38 |
+{
|
|
|
b19d38 |
+"extension-id": "@extension_id@",
|
|
|
b19d38 |
+"uuid": "@uuid@",
|
|
|
b19d38 |
+"gettext-domain": "@gettext_domain@",
|
|
|
b19d38 |
+"name": "Heads-up Display Message",
|
|
|
b19d38 |
+"description": "Add a message to be displayed on screen always above all windows and chrome.",
|
|
|
b19d38 |
+"original-authors": [ "rstrode@redhat.com" ],
|
|
|
b19d38 |
+"shell-version": [ "@shell_current@" ],
|
|
|
b19d38 |
+"url": "@url@",
|
|
|
b19d38 |
+"session-modes": [ "gdm", "lock-screen", "unlock-dialog", "user" ]
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
diff --git a/extensions/heads-up-display/org.gnome.shell.extensions.heads-up-display.gschema.xml b/extensions/heads-up-display/org.gnome.shell.extensions.heads-up-display.gschema.xml
|
|
|
b19d38 |
new file mode 100644
|
|
|
b19d38 |
index 0000000..ea1f377
|
|
|
b19d38 |
--- /dev/null
|
|
|
b19d38 |
+++ b/extensions/heads-up-display/org.gnome.shell.extensions.heads-up-display.gschema.xml
|
|
|
b19d38 |
@@ -0,0 +1,54 @@
|
|
|
b19d38 |
+<schemalist gettext-domain="gnome-shell-extensions">
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ path="/org/gnome/shell/extensions/heads-up-display/">
|
|
|
b19d38 |
+ <key name="idle-timeout" type="u">
|
|
|
b19d38 |
+ <default>30</default>
|
|
|
b19d38 |
+ <summary>Idle Timeout</summary>
|
|
|
b19d38 |
+ <description>
|
|
|
b19d38 |
+ Number of seconds until message is reshown after user goes idle.
|
|
|
b19d38 |
+ </description>
|
|
|
b19d38 |
+ </key>
|
|
|
b19d38 |
+ <key name="message-heading" type="s">
|
|
|
b19d38 |
+ <default>""</default>
|
|
|
b19d38 |
+ <summary>Message to show at top of display</summary>
|
|
|
b19d38 |
+ <description>
|
|
|
b19d38 |
+ The top line of the heads up display message.
|
|
|
b19d38 |
+ </description>
|
|
|
b19d38 |
+ </key>
|
|
|
b19d38 |
+ <key name="message-body" type="s">
|
|
|
b19d38 |
+ <default>""</default>
|
|
|
b19d38 |
+ <summary>Banner message</summary>
|
|
|
b19d38 |
+ <description>
|
|
|
b19d38 |
+ A message to always show at the top of the screen.
|
|
|
b19d38 |
+ </description>
|
|
|
b19d38 |
+ </key>
|
|
|
b19d38 |
+ <key name="show-on-login-screen" type="b">
|
|
|
b19d38 |
+ <default>true</default>
|
|
|
b19d38 |
+ <summary>Show on login screen</summary>
|
|
|
b19d38 |
+ <description>
|
|
|
b19d38 |
+ Whether or not the message should display on the login screen
|
|
|
b19d38 |
+ </description>
|
|
|
b19d38 |
+ </key>
|
|
|
b19d38 |
+ <key name="show-when-locked" type="b">
|
|
|
b19d38 |
+ <default>false</default>
|
|
|
b19d38 |
+ <summary>Show on screen shield</summary>
|
|
|
b19d38 |
+ <description>
|
|
|
b19d38 |
+ Whether or not the message should display when the screen is locked
|
|
|
b19d38 |
+ </description>
|
|
|
b19d38 |
+ </key>
|
|
|
b19d38 |
+ <key name="show-when-unlocking" type="b">
|
|
|
b19d38 |
+ <default>false</default>
|
|
|
b19d38 |
+ <summary>Show on unlock screen</summary>
|
|
|
b19d38 |
+ <description>
|
|
|
b19d38 |
+ Whether or not the message should display on the unlock screen.
|
|
|
b19d38 |
+ </description>
|
|
|
b19d38 |
+ </key>
|
|
|
b19d38 |
+ <key name="show-when-unlocked" type="b">
|
|
|
b19d38 |
+ <default>false</default>
|
|
|
b19d38 |
+ <summary>Show in user session</summary>
|
|
|
b19d38 |
+ <description>
|
|
|
b19d38 |
+ Whether or not the message should display when the screen is unlocked.
|
|
|
b19d38 |
+ </description>
|
|
|
b19d38 |
+ </key>
|
|
|
b19d38 |
+ </schema>
|
|
|
b19d38 |
+</schemalist>
|
|
|
b19d38 |
diff --git a/extensions/heads-up-display/prefs.js b/extensions/heads-up-display/prefs.js
|
|
|
b19d38 |
new file mode 100644
|
|
|
b19d38 |
index 0000000..a7106e0
|
|
|
b19d38 |
--- /dev/null
|
|
|
b19d38 |
+++ b/extensions/heads-up-display/prefs.js
|
|
|
b19d38 |
@@ -0,0 +1,194 @@
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+/* Desktop Icons GNOME Shell extension
|
|
|
b19d38 |
+ *
|
|
|
b19d38 |
+ * Copyright (C) 2017 Carlos Soriano <csoriano@redhat.com>
|
|
|
b19d38 |
+ *
|
|
|
b19d38 |
+ * This program is free software: you can redistribute it and/or modify
|
|
|
b19d38 |
+ * it under the terms of the GNU General Public License as published by
|
|
|
b19d38 |
+ * the Free Software Foundation, either version 3 of the License, or
|
|
|
b19d38 |
+ * (at your option) any later version.
|
|
|
b19d38 |
+ *
|
|
|
b19d38 |
+ * This program is distributed in the hope that it will be useful,
|
|
|
b19d38 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b19d38 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
b19d38 |
+ * GNU General Public License for more details.
|
|
|
b19d38 |
+ *
|
|
|
b19d38 |
+ * You should have received a copy of the GNU General Public License
|
|
|
b19d38 |
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
b19d38 |
+ */
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+const { Gio, GObject, Gdk, Gtk } = imports.gi;
|
|
|
b19d38 |
+const ExtensionUtils = imports.misc.extensionUtils;
|
|
|
b19d38 |
+const Gettext = imports.gettext.domain('gnome-shell-extensions');
|
|
|
b19d38 |
+const _ = Gettext.gettext;
|
|
|
b19d38 |
+const N_ = e => e;
|
|
|
b19d38 |
+const cssData = `
|
|
|
b19d38 |
+ .no-border {
|
|
|
b19d38 |
+ border: none;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ .border {
|
|
|
b19d38 |
+ border: 1px solid;
|
|
|
b19d38 |
+ border-radius: 3px;
|
|
|
b19d38 |
+ border-color: #b6b6b3;
|
|
|
b19d38 |
+ box-shadow: inset 0 0 0 1px rgba(74, 144, 217, 0);
|
|
|
b19d38 |
+ background-color: white;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ .margins {
|
|
|
b19d38 |
+ padding-left: 8px;
|
|
|
b19d38 |
+ padding-right: 8px;
|
|
|
b19d38 |
+ padding-bottom: 8px;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ .contents {
|
|
|
b19d38 |
+ padding: 20px;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ .message-label {
|
|
|
b19d38 |
+ font-weight: bold;
|
|
|
b19d38 |
+ }
|
|
|
b19d38 |
+`;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+var settings;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+function init() {
|
|
|
b19d38 |
+ settings = ExtensionUtils.getSettings("org.gnome.shell.extensions.heads-up-display");
|
|
|
b19d38 |
+ const cssProvider = new Gtk.CssProvider();
|
|
|
b19d38 |
+ cssProvider.load_from_data(cssData);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const display = Gdk.Display.get_default();
|
|
|
b19d38 |
+ Gtk.StyleContext.add_provider_for_display(display, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+function buildPrefsWidget() {
|
|
|
b19d38 |
+ ExtensionUtils.initTranslations();
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const contents = new Gtk.Box({
|
|
|
b19d38 |
+ orientation: Gtk.Orientation.VERTICAL,
|
|
|
b19d38 |
+ spacing: 10,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ contents.append(buildSwitch('show-when-locked', _("Show message when screen is locked")));
|
|
|
b19d38 |
+ contents.append(buildSwitch('show-when-unlocking', _("Show message on unlock screen")));
|
|
|
b19d38 |
+ contents.append(buildSwitch('show-when-unlocked', _("Show message when screen is unlocked")));
|
|
|
b19d38 |
+ contents.append(buildSpinButton('idle-timeout', _("Seconds after user goes idle before reshowing message")));
|
|
|
b19d38 |
+ contents.get_style_context().add_class("contents");
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const outerMessageBox = new Gtk.Box({
|
|
|
b19d38 |
+ orientation: Gtk.Orientation.VERTICAL,
|
|
|
b19d38 |
+ spacing: 5,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ contents.append(outerMessageBox);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const messageLabel = new Gtk.Label({
|
|
|
b19d38 |
+ label: 'Message',
|
|
|
b19d38 |
+ halign: Gtk.Align.START,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ messageLabel.get_style_context().add_class("message-label");
|
|
|
b19d38 |
+ outerMessageBox.append(messageLabel);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const innerMessageBox = new Gtk.Box({
|
|
|
b19d38 |
+ orientation: Gtk.Orientation.VERTICAL,
|
|
|
b19d38 |
+ spacing: 0,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ innerMessageBox.get_style_context().add_class("border");
|
|
|
b19d38 |
+ outerMessageBox.append(innerMessageBox);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ innerMessageBox.append(buildEntry('message-heading', _("Message Heading")));
|
|
|
b19d38 |
+ innerMessageBox.append(buildTextView('message-body', _("Message Body")));
|
|
|
b19d38 |
+ return contents;
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+function buildTextView(key, labelText) {
|
|
|
b19d38 |
+ const textView = new Gtk.TextView({
|
|
|
b19d38 |
+ accepts_tab: false,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ wrap_mode: Gtk.WrapMode.WORD,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ settings.bind(key, textView.get_buffer(), 'text', Gio.SettingsBindFlags.DEFAULT);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ const scrolledWindow = new Gtk.ScrolledWindow({
|
|
|
b19d38 |
+ hexpand: true,
|
|
|
b19d38 |
+ vexpand: true,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ const styleContext = scrolledWindow.get_style_context();
|
|
|
b19d38 |
+ styleContext.add_class("margins");
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ scrolledWindow.set_child(textView);
|
|
|
b19d38 |
+ return scrolledWindow;
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+function buildEntry(key, labelText) {
|
|
|
b19d38 |
+ const entry = new Gtk.Entry({
|
|
|
b19d38 |
+ placeholder_text: labelText,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ const styleContext = entry.get_style_context();
|
|
|
b19d38 |
+ styleContext.add_class("no-border");
|
|
|
b19d38 |
+ settings.bind(key, entry, 'text', Gio.SettingsBindFlags.DEFAULT);
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ entry.get_settings()['gtk-entry-select-on-focus'] = false;
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+ return entry;
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+function buildSpinButton(key, labelText) {
|
|
|
b19d38 |
+ const hbox = new Gtk.Box({
|
|
|
b19d38 |
+ orientation: Gtk.Orientation.HORIZONTAL,
|
|
|
b19d38 |
+ spacing: 10,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ const label = new Gtk.Label({
|
|
|
b19d38 |
+ hexpand: true,
|
|
|
b19d38 |
+ label: labelText,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ xalign: 0,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ const adjustment = new Gtk.Adjustment({
|
|
|
b19d38 |
+ value: 0,
|
|
|
b19d38 |
+ lower: 0,
|
|
|
b19d38 |
+ upper: 2147483647,
|
|
|
b19d38 |
+ step_increment: 1,
|
|
|
b19d38 |
+ page_increment: 60,
|
|
|
b19d38 |
+ page_size: 60,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ const spinButton = new Gtk.SpinButton({
|
|
|
b19d38 |
+ adjustment: adjustment,
|
|
|
b19d38 |
+ climb_rate: 1.0,
|
|
|
b19d38 |
+ digits: 0,
|
|
|
b19d38 |
+ max_width_chars: 3,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ width_chars: 3,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ settings.bind(key, spinButton, 'value', Gio.SettingsBindFlags.DEFAULT);
|
|
|
b19d38 |
+ hbox.append(label);
|
|
|
b19d38 |
+ hbox.append(spinButton);
|
|
|
b19d38 |
+ return hbox;
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+function buildSwitch(key, labelText) {
|
|
|
b19d38 |
+ const hbox = new Gtk.Box({
|
|
|
b19d38 |
+ orientation: Gtk.Orientation.HORIZONTAL,
|
|
|
b19d38 |
+ spacing: 10,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ const label = new Gtk.Label({
|
|
|
b19d38 |
+ hexpand: true,
|
|
|
b19d38 |
+ label: labelText,
|
|
|
b19d38 |
+ visible: true,
|
|
|
b19d38 |
+ xalign: 0,
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ const switcher = new Gtk.Switch({
|
|
|
b19d38 |
+ active: settings.get_boolean(key),
|
|
|
b19d38 |
+ });
|
|
|
b19d38 |
+ settings.bind(key, switcher, 'active', Gio.SettingsBindFlags.DEFAULT);
|
|
|
b19d38 |
+ hbox.append(label);
|
|
|
b19d38 |
+ hbox.append(switcher);
|
|
|
b19d38 |
+ return hbox;
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
diff --git a/extensions/heads-up-display/stylesheet.css b/extensions/heads-up-display/stylesheet.css
|
|
|
b19d38 |
new file mode 100644
|
|
|
b19d38 |
index 0000000..9303446
|
|
|
b19d38 |
--- /dev/null
|
|
|
b19d38 |
+++ b/extensions/heads-up-display/stylesheet.css
|
|
|
b19d38 |
@@ -0,0 +1,32 @@
|
|
|
b19d38 |
+.heads-up-display-message {
|
|
|
b19d38 |
+ background-color: rgba(0.24, 0.24, 0.24, 0.80);
|
|
|
b19d38 |
+ border: 1px solid black;
|
|
|
b19d38 |
+ border-radius: 6px;
|
|
|
b19d38 |
+ color: #eeeeec;
|
|
|
b19d38 |
+ font-size: 11pt;
|
|
|
b19d38 |
+ margin-top: 0.5em;
|
|
|
b19d38 |
+ margin-bottom: 0.5em;
|
|
|
b19d38 |
+ padding: 0.9em;
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+.heads-up-display-message:insensitive {
|
|
|
b19d38 |
+ background-color: rgba(0.24, 0.24, 0.24, 0.33);
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+.heads-up-display-message:hover {
|
|
|
b19d38 |
+ background-color: rgba(0.24, 0.24, 0.24, 0.2);
|
|
|
b19d38 |
+ border: 1px solid rgba(0.0, 0.0, 0.0, 0.5);
|
|
|
b19d38 |
+ color: #4d4d4d;
|
|
|
b19d38 |
+ transition-duration: 250ms;
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+.heads-up-message-heading {
|
|
|
b19d38 |
+ height: 1.75em;
|
|
|
b19d38 |
+ font-size: 1.25em;
|
|
|
b19d38 |
+ font-weight: bold;
|
|
|
b19d38 |
+ text-align: center;
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
+
|
|
|
b19d38 |
+.heads-up-message-body {
|
|
|
b19d38 |
+ text-align: center;
|
|
|
b19d38 |
+}
|
|
|
b19d38 |
diff --git a/meson.build b/meson.build
|
|
|
b19d38 |
index 78dee5b..ad5949b 100644
|
|
|
b19d38 |
--- a/meson.build
|
|
|
b19d38 |
+++ b/meson.build
|
|
|
b19d38 |
@@ -11,60 +11,61 @@ gnome = import('gnome')
|
|
|
b19d38 |
i18n = import('i18n')
|
|
|
b19d38 |
|
|
|
b19d38 |
datadir = get_option('datadir')
|
|
|
b19d38 |
|
|
|
b19d38 |
shelldir = join_paths(datadir, 'gnome-shell')
|
|
|
b19d38 |
extensiondir = join_paths(shelldir, 'extensions')
|
|
|
b19d38 |
modedir = join_paths(shelldir, 'modes')
|
|
|
b19d38 |
themedir = join_paths(shelldir, 'theme')
|
|
|
b19d38 |
|
|
|
b19d38 |
schemadir = join_paths(datadir, 'glib-2.0', 'schemas')
|
|
|
b19d38 |
sessiondir = join_paths(datadir, 'gnome-session', 'sessions')
|
|
|
b19d38 |
xsessiondir = join_paths(datadir, 'xsessions')
|
|
|
b19d38 |
|
|
|
b19d38 |
ver_arr = meson.project_version().split('.')
|
|
|
b19d38 |
shell_version = ver_arr[0]
|
|
|
b19d38 |
|
|
|
b19d38 |
uuid_suffix = '@gnome-shell-extensions.gcampax.github.com'
|
|
|
b19d38 |
|
|
|
b19d38 |
classic_extensions = [
|
|
|
b19d38 |
'apps-menu',
|
|
|
b19d38 |
'desktop-icons',
|
|
|
b19d38 |
'places-menu',
|
|
|
b19d38 |
'launch-new-instance',
|
|
|
b19d38 |
'top-icons',
|
|
|
b19d38 |
'window-list'
|
|
|
b19d38 |
]
|
|
|
b19d38 |
|
|
|
b19d38 |
default_extensions = classic_extensions
|
|
|
b19d38 |
default_extensions += [
|
|
|
b19d38 |
'drive-menu',
|
|
|
b19d38 |
+ 'heads-up-display',
|
|
|
b19d38 |
'screenshot-window-sizer',
|
|
|
b19d38 |
'windowsNavigator',
|
|
|
b19d38 |
'workspace-indicator'
|
|
|
b19d38 |
]
|
|
|
b19d38 |
|
|
|
b19d38 |
all_extensions = default_extensions
|
|
|
b19d38 |
all_extensions += [
|
|
|
b19d38 |
'auto-move-windows',
|
|
|
b19d38 |
'dash-to-dock',
|
|
|
b19d38 |
'native-window-placement',
|
|
|
b19d38 |
'panel-favorites',
|
|
|
b19d38 |
'systemMonitor',
|
|
|
b19d38 |
'updates-dialog',
|
|
|
b19d38 |
'user-theme'
|
|
|
b19d38 |
]
|
|
|
b19d38 |
|
|
|
b19d38 |
enabled_extensions = get_option('enable_extensions')
|
|
|
b19d38 |
|
|
|
b19d38 |
if enabled_extensions.length() == 0
|
|
|
b19d38 |
set = get_option('extension_set')
|
|
|
b19d38 |
|
|
|
b19d38 |
if set == 'classic'
|
|
|
b19d38 |
enabled_extensions += classic_extensions
|
|
|
b19d38 |
elif set == 'default'
|
|
|
b19d38 |
enabled_extensions += default_extensions
|
|
|
b19d38 |
elif set == 'all'
|
|
|
b19d38 |
enabled_extensions += all_extensions
|
|
|
b19d38 |
endif
|
|
|
b19d38 |
endif
|
|
|
b19d38 |
|
|
|
b19d38 |
--
|
|
|
b19d38 |
2.31.1
|
|
|
b19d38 |
|