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

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