From 513e562939f41f3fc8d644610c591d879cc3937b Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 28 Sep 2021 14:37:41 -0400 Subject: [PATCH] A few more fix ups to the heads up extension This does some code clean ups and fixes a little log spew noticed during testing. Related: #2006985 --- ...-Add-extension-for-showing-persisten.patch | 167 ++++++++++++------ 1 file changed, 113 insertions(+), 54 deletions(-) diff --git a/0001-heads-up-display-Add-extension-for-showing-persisten.patch b/0001-heads-up-display-Add-extension-for-showing-persisten.patch index e28f47c..80c66a3 100644 --- a/0001-heads-up-display-Add-extension-for-showing-persisten.patch +++ b/0001-heads-up-display-Add-extension-for-showing-persisten.patch @@ -1,4 +1,4 @@ -From 147d364d0c27c1ab76c6826f619381b0e9f9ed77 Mon Sep 17 00:00:00 2001 +From 69f53c05798194c49ae897981c2fd37e0f15c489 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 24 Aug 2021 15:03:57 -0400 Subject: [PATCH] heads-up-display: Add extension for showing persistent heads @@ -6,14 +6,14 @@ Subject: [PATCH] heads-up-display: Add extension for showing persistent heads --- extensions/heads-up-display/extension.js | 436 ++++++++++++++++++ - extensions/heads-up-display/headsUpMessage.js | 165 +++++++ + extensions/heads-up-display/headsUpMessage.js | 170 +++++++ extensions/heads-up-display/meson.build | 8 + extensions/heads-up-display/metadata.json.in | 11 + ...ll.extensions.heads-up-display.gschema.xml | 54 +++ extensions/heads-up-display/prefs.js | 194 ++++++++ extensions/heads-up-display/stylesheet.css | 32 ++ meson.build | 1 + - 8 files changed, 901 insertions(+) + 8 files changed, 906 insertions(+) create mode 100644 extensions/heads-up-display/extension.js create mode 100644 extensions/heads-up-display/headsUpMessage.js create mode 100644 extensions/heads-up-display/meson.build @@ -24,7 +24,7 @@ Subject: [PATCH] heads-up-display: Add extension for showing persistent heads diff --git a/extensions/heads-up-display/extension.js b/extensions/heads-up-display/extension.js new file mode 100644 -index 0000000..574fb09 +index 0000000..7cebfa9 --- /dev/null +++ b/extensions/heads-up-display/extension.js @@ -0,0 +1,436 @@ @@ -89,7 +89,7 @@ index 0000000..574fb09 + if (actor.has_allocation()) + return; + -+ let workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex); ++ const workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex); + actorBox.init_rect(workArea.x, workArea.y + this.offset, workArea.width, workArea.height - this.offset); + } +}); @@ -167,8 +167,8 @@ index 0000000..574fb09 + } + + _onWindowMap(shellwm, actor) { -+ let windowObject = actor.meta_window; -+ let windowType = windowObject.get_window_type(); ++ const windowObject = actor.meta_window; ++ const windowType = windowObject.get_window_type(); + + if (windowType != Meta.WindowType.NORMAL) + return; @@ -176,8 +176,8 @@ index 0000000..574fb09 + if (!this._message || !this._message.visible) + return; + -+ let messageRect = new Meta.Rectangle({ x: this._message.x, y: this._message.y, width: this._message.width, height: this._message.height }); -+ let windowRect = windowObject.get_frame_rect(); ++ const messageRect = new Meta.Rectangle({ x: this._message.x, y: this._message.y, width: this._message.width, height: this._message.height }); ++ const windowRect = windowObject.get_frame_rect(); + + if (windowRect.intersect(messageRect)) { + windowObject.move_frame(false, windowRect.x, this._message.y + this._message.height); @@ -197,7 +197,7 @@ index 0000000..574fb09 + if (!Main.sessionMode.hasWindows) + this._messageInhibitedUntilIdle = false; + -+ let dialog = Main.screenShield._dialog; ++ const dialog = Main.screenShield._dialog; + if (!Main.sessionMode.isGreeter && dialog && !this._screenShieldVisibleId) { + this._screenShieldVisibleId = dialog._clock.connect('notify::visible', + this._updateMessage.bind(this)); @@ -234,7 +234,7 @@ index 0000000..574fb09 + _watchForIdle() { + this._stopWatchingForIdle(); + -+ let idleTimeout = this._settings.get_uint('idle-timeout'); ++ const idleTimeout = this._settings.get_uint('idle-timeout'); + + this._idleTimeoutChangedId = this._settings.connect('changed::idle-timeout', this._onIdleTimeoutChanged.bind(this)); + this._idleWatchId = this._idleMonitor.add_idle_watch(idleTimeout * 1000, this._onUserIdle.bind(this)); @@ -278,7 +278,7 @@ index 0000000..574fb09 + } + + if (Main.sessionMode.currentMode === 'unlock-dialog') { -+ let dialog = Main.screenShield._dialog; ++ const dialog = Main.screenShield._dialog; + if (!this._settings.get_boolean('show-when-locked')) { + if (dialog._clock.visible) { + this._dismissMessage(); @@ -294,8 +294,8 @@ index 0000000..574fb09 + } + } + -+ let heading = this._settings.get_string('message-heading'); -+ let body = this._settings.get_string('message-body'); ++ const heading = this._settings.get_string('message-heading'); ++ const body = this._settings.get_string('message-body'); + + if (!heading && !body) { + this._dismissMessage(); @@ -380,8 +380,8 @@ index 0000000..574fb09 + Main.messageTray.add_constraint(this._messageTrayConstraint); + } + -+ let panelBottom = Main.layoutManager.panelBox.y + Main.layoutManager.panelBox.height; -+ let messageBottom = this._message.y + this._message.height; ++ const panelBottom = Main.layoutManager.panelBox.y + Main.layoutManager.panelBox.height; ++ const messageBottom = this._message.y + this._message.height; + + this._messageTrayConstraint.offset = messageBottom - panelBottom; + global.stage.disconnect(this._updateMessageTrayId); @@ -396,7 +396,7 @@ index 0000000..574fb09 + if (!Main.screenShield || !Main.screenShield._dialog) + return; + -+ let dialog = Main.screenShield._dialog; ++ const dialog = Main.screenShield._dialog; + + if (this._authPromptAllocatedId) { + dialog.disconnect(this._authPromptAllocatedId); @@ -426,7 +426,7 @@ index 0000000..574fb09 + return; + } + -+ let dialog = Main.screenShield._dialog; ++ const dialog = Main.screenShield._dialog; + + if (this._updateLoginDialogId) + return; @@ -454,7 +454,7 @@ index 0000000..574fb09 + if (Main.sessionMode.isGreeter) { + this._adaptLoginDialogForMessage(); + if (!this._authPromptAllocatedId) { -+ let dialog = Main.screenShield._dialog; ++ const dialog = Main.screenShield._dialog; + this._authPromptAllocatedId = dialog._authPrompt.connect('notify::allocation', this._adaptLoginDialogForMessage.bind(this)); + } + } @@ -466,10 +466,10 @@ index 0000000..574fb09 +} diff --git a/extensions/heads-up-display/headsUpMessage.js b/extensions/heads-up-display/headsUpMessage.js new file mode 100644 -index 0000000..b1f3f65 +index 0000000..87a8c8b --- /dev/null +++ b/extensions/heads-up-display/headsUpMessage.js -@@ -0,0 +1,165 @@ +@@ -0,0 +1,170 @@ +const { Atk, Clutter, GLib, GObject, Pango, St } = imports.gi; +const Layout = imports.ui.layout; +const Main = imports.ui.main; @@ -483,8 +483,7 @@ index 0000000..b1f3f65 + this._widthCoverage = 0.75; + this._heightCoverage = 0.25; + -+ this._workAreasChangedId = global.display.connect('workareas-changed', -+ this._getWorkAreaAndMeasureLineHeight.bind(this)); ++ this._workAreasChangedId = global.display.connect('workareas-changed', this._getWorkAreaAndMeasureLineHeight.bind(this)); + } + + _getWorkAreaAndMeasureLineHeight() { @@ -507,7 +506,7 @@ index 0000000..b1f3f65 + } + + vfunc_get_preferred_width(forHeight) { -+ let maxWidth = this._widthCoverage * this._workArea.width ++ const maxWidth = this._widthCoverage * this._workArea.width + + let [labelMinimumWidth, labelNaturalWidth] = super.vfunc_get_preferred_width(forHeight); + @@ -518,11 +517,11 @@ index 0000000..b1f3f65 + } + + vfunc_get_preferred_height(forWidth) { -+ let labelHeightUpperBound = this._heightCoverage * this._workArea.height; -+ let numberOfLines = Math.floor(labelHeightUpperBound / this._lineHeight); ++ const labelHeightUpperBound = this._heightCoverage * this._workArea.height; ++ const numberOfLines = Math.floor(labelHeightUpperBound / this._lineHeight); + this._numberOfLines = Math.max(numberOfLines, 1); + -+ let maxHeight = this._lineHeight * this._numberOfLines; ++ const maxHeight = this._lineHeight * this._numberOfLines; + + let [labelMinimumHeight, labelNaturalHeight] = super.vfunc_get_preferred_height(forWidth); + @@ -533,8 +532,10 @@ index 0000000..b1f3f65 + } + + destroy() { -+ if (this._workAreasChangedId) ++ if (this._workAreasChangedId) { + global.display.disconnect(this._workAreasChangedId); ++ this._workAreasChangedId = 0; ++ } + + super.destroy(); + } @@ -557,9 +558,9 @@ index 0000000..b1f3f65 + this._panelAllocationId = Main.layoutManager.panelBox.connect('notify::allocation', this._alignWithPanel.bind(this)); + this.connect('notify::allocation', this._alignWithPanel.bind(this)); + -+ let contentsBox = new St.BoxLayout({ style_class: 'heads-up-message-content', -+ vertical: true, -+ x_align: Clutter.ActorAlign.CENTER }); ++ const contentsBox = new St.BoxLayout({ style_class: 'heads-up-message-content', ++ vertical: true, ++ x_align: Clutter.ActorAlign.CENTER }); + this.add_actor(contentsBox); + + this.headingLabel = new St.Label({ style_class: 'heads-up-message-heading', @@ -575,7 +576,6 @@ index 0000000..b1f3f65 + contentsBox.add_actor(this.bodyLabel); + + this.setBody(body); -+ this.bodyLabel.clutter_text.label = this.bodyLabel; + } + + vfunc_parent_set(oldParent) { @@ -603,7 +603,7 @@ index 0000000..b1f3f65 + + setHeading(text) { + if (text) { -+ let heading = text ? text.replace(/\n/g, ' ') : ''; ++ const heading = text ? text.replace(/\n/g, ' ') : ''; + this.headingLabel.text = heading; + this.headingLabel.visible = true; + } else { @@ -632,6 +632,11 @@ index 0000000..b1f3f65 + this._afterUpdateId = 0; + } + ++ if (this.bodyLabel) { ++ this.bodyLabel.destroy(); ++ this.bodyLabel = null; ++ } ++ + super.destroy(); + } +}); @@ -728,7 +733,7 @@ index 0000000..ea1f377 + diff --git a/extensions/heads-up-display/prefs.js b/extensions/heads-up-display/prefs.js new file mode 100644 -index 0000000..42b0efe +index 0000000..a7106e0 --- /dev/null +++ b/extensions/heads-up-display/prefs.js @@ -0,0 +1,194 @@ @@ -788,17 +793,17 @@ index 0000000..42b0efe + +function init() { + settings = ExtensionUtils.getSettings("org.gnome.shell.extensions.heads-up-display"); -+ let cssProvider = new Gtk.CssProvider(); ++ const cssProvider = new Gtk.CssProvider(); + cssProvider.load_from_data(cssData); + -+ let display = Gdk.Display.get_default(); ++ const display = Gdk.Display.get_default(); + Gtk.StyleContext.add_provider_for_display(display, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); +} + +function buildPrefsWidget() { + ExtensionUtils.initTranslations(); + -+ let contents = new Gtk.Box({ ++ const contents = new Gtk.Box({ + orientation: Gtk.Orientation.VERTICAL, + spacing: 10, + visible: true, @@ -810,14 +815,14 @@ index 0000000..42b0efe + contents.append(buildSpinButton('idle-timeout', _("Seconds after user goes idle before reshowing message"))); + contents.get_style_context().add_class("contents"); + -+ let outerMessageBox = new Gtk.Box({ ++ const outerMessageBox = new Gtk.Box({ + orientation: Gtk.Orientation.VERTICAL, + spacing: 5, + visible: true, + }); + contents.append(outerMessageBox); + -+ let messageLabel = new Gtk.Label({ ++ const messageLabel = new Gtk.Label({ + label: 'Message', + halign: Gtk.Align.START, + visible: true, @@ -825,7 +830,7 @@ index 0000000..42b0efe + messageLabel.get_style_context().add_class("message-label"); + outerMessageBox.append(messageLabel); + -+ let innerMessageBox = new Gtk.Box({ ++ const innerMessageBox = new Gtk.Box({ + orientation: Gtk.Orientation.VERTICAL, + spacing: 0, + visible: true, @@ -839,7 +844,7 @@ index 0000000..42b0efe +} + +function buildTextView(key, labelText) { -+ let textView = new Gtk.TextView({ ++ const textView = new Gtk.TextView({ + accepts_tab: false, + visible: true, + wrap_mode: Gtk.WrapMode.WORD, @@ -847,23 +852,23 @@ index 0000000..42b0efe + + settings.bind(key, textView.get_buffer(), 'text', Gio.SettingsBindFlags.DEFAULT); + -+ let scrolledWindow = new Gtk.ScrolledWindow({ ++ const scrolledWindow = new Gtk.ScrolledWindow({ + hexpand: true, + vexpand: true, + visible: true, + }); -+ let styleContext = scrolledWindow.get_style_context(); ++ const styleContext = scrolledWindow.get_style_context(); + styleContext.add_class("margins"); + + scrolledWindow.set_child(textView); + return scrolledWindow; +} +function buildEntry(key, labelText) { -+ let entry = new Gtk.Entry({ ++ const entry = new Gtk.Entry({ + placeholder_text: labelText, + visible: true, + }); -+ let styleContext = entry.get_style_context(); ++ const styleContext = entry.get_style_context(); + styleContext.add_class("no-border"); + settings.bind(key, entry, 'text', Gio.SettingsBindFlags.DEFAULT); + @@ -873,18 +878,18 @@ index 0000000..42b0efe +} + +function buildSpinButton(key, labelText) { -+ let hbox = new Gtk.Box({ ++ const hbox = new Gtk.Box({ + orientation: Gtk.Orientation.HORIZONTAL, + spacing: 10, + visible: true, + }); -+ let label = new Gtk.Label({ ++ const label = new Gtk.Label({ + hexpand: true, + label: labelText, + visible: true, + xalign: 0, + }); -+ let adjustment = new Gtk.Adjustment({ ++ const adjustment = new Gtk.Adjustment({ + value: 0, + lower: 0, + upper: 2147483647, @@ -892,7 +897,7 @@ index 0000000..42b0efe + page_increment: 60, + page_size: 60, + }); -+ let spinButton = new Gtk.SpinButton({ ++ const spinButton = new Gtk.SpinButton({ + adjustment: adjustment, + climb_rate: 1.0, + digits: 0, @@ -907,18 +912,18 @@ index 0000000..42b0efe +} + +function buildSwitch(key, labelText) { -+ let hbox = new Gtk.Box({ ++ const hbox = new Gtk.Box({ + orientation: Gtk.Orientation.HORIZONTAL, + spacing: 10, + visible: true, + }); -+ let label = new Gtk.Label({ ++ const label = new Gtk.Label({ + hexpand: true, + label: labelText, + visible: true, + xalign: 0, + }); -+ let switcher = new Gtk.Switch({ ++ const switcher = new Gtk.Switch({ + active: settings.get_boolean(key), + }); + settings.bind(key, switcher, 'active', Gio.SettingsBindFlags.DEFAULT); @@ -968,7 +973,34 @@ diff --git a/meson.build b/meson.build index 78dee5b..ad5949b 100644 --- a/meson.build +++ b/meson.build -@@ -38,6 +38,7 @@ classic_extensions = [ +@@ -11,60 +11,61 @@ gnome = import('gnome') + i18n = import('i18n') + + datadir = get_option('datadir') + + shelldir = join_paths(datadir, 'gnome-shell') + extensiondir = join_paths(shelldir, 'extensions') + modedir = join_paths(shelldir, 'modes') + themedir = join_paths(shelldir, 'theme') + + schemadir = join_paths(datadir, 'glib-2.0', 'schemas') + sessiondir = join_paths(datadir, 'gnome-session', 'sessions') + xsessiondir = join_paths(datadir, 'xsessions') + + ver_arr = meson.project_version().split('.') + shell_version = ver_arr[0] + + uuid_suffix = '@gnome-shell-extensions.gcampax.github.com' + + classic_extensions = [ + 'apps-menu', + 'desktop-icons', + 'places-menu', + 'launch-new-instance', + 'top-icons', + 'window-list' + ] + default_extensions = classic_extensions default_extensions += [ 'drive-menu', @@ -976,6 +1008,33 @@ index 78dee5b..ad5949b 100644 'screenshot-window-sizer', 'windowsNavigator', 'workspace-indicator' + ] + + all_extensions = default_extensions + all_extensions += [ + 'auto-move-windows', + 'dash-to-dock', + 'native-window-placement', + 'panel-favorites', + 'systemMonitor', + 'updates-dialog', + 'user-theme' + ] + + enabled_extensions = get_option('enable_extensions') + + if enabled_extensions.length() == 0 + set = get_option('extension_set') + + if set == 'classic' + enabled_extensions += classic_extensions + elif set == 'default' + enabled_extensions += default_extensions + elif set == 'all' + enabled_extensions += all_extensions + endif + endif + -- -2.32.0 +2.31.1