Blame SOURCES/0001-heads-up-display-Add-extension-for-showing-persisten.patch

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