From 8055f29499c239cd0830775817950b8efbd1be6f Mon Sep 17 00:00:00 2001 From: franglais125 Date: Fri, 26 May 2017 17:03:57 -0400 Subject: [PATCH 1/5] Move setShortcut function to prefs.js. This again prevents unnecessary writing to settings when activating the extension. --- overview.js | 23 +---------------------- prefs.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/overview.js b/overview.js index 899b06e..4fcc026 100644 --- a/overview.js +++ b/overview.js @@ -231,10 +231,6 @@ const dtpOverview = new Lang.Class({ this._dtpSettings, 'changed::hotkeys-overlay', Lang.bind(this, this._checkHotkeysOptions) - ], [ - this._dtpSettings, - 'changed::shortcut-text', - Lang.bind(this, this._checkHotkeysOptions) ]); }, @@ -246,9 +242,7 @@ const dtpOverview = new Lang.Class({ }, _enableExtraShortcut: function() { - let shortcut_is_valid = this._setShortcut(); - - if (shortcut_is_valid && !this._shortcutIsSet) { + if (!this._shortcutIsSet) { Main.wm.addKeybinding('shortcut', this._dtpSettings, Meta.KeyBindingFlags.NONE, Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, @@ -260,21 +254,6 @@ const dtpOverview = new Lang.Class({ } }, - _setShortcut: function() { - let shortcut_text = this._dtpSettings.get_string('shortcut-text'); - let [key, mods] = Gtk.accelerator_parse(shortcut_text); - - if (Gtk.accelerator_valid(key, mods)) { - let shortcut = Gtk.accelerator_name(key, mods); - this._dtpSettings.set_strv('shortcut', [shortcut]); - return true; - } - else { - this._dtpSettings.set_strv('shortcut', []); - return false; - } - }, - _disableExtraShortcut: function() { if (this._shortcutIsSet) { Main.wm.removeKeybinding('shortcut'); diff --git a/prefs.js b/prefs.js index 60353d0..a86f0ea 100644 --- a/prefs.js +++ b/prefs.js @@ -74,6 +74,19 @@ function cssHexString(css) { return rrggbb; } +function setShortcut(settings) { + let shortcut_text = settings.get_string('shortcut-text'); + let [key, mods] = Gtk.accelerator_parse(shortcut_text); + + if (Gtk.accelerator_valid(key, mods)) { + let shortcut = Gtk.accelerator_name(key, mods); + settings.set_strv('shortcut', [shortcut]); + } + else { + settings.set_strv('shortcut', []); + } +} + function checkHotkeyPrefix(settings) { settings.delay(); @@ -597,6 +610,7 @@ const Settings = new Lang.Class({ this._builder.get_object('shortcut_entry'), 'text', Gio.SettingsBindFlags.DEFAULT); + this._settings.connect('changed::shortcut-text', Lang.bind(this, function() {setShortcut(this._settings);})); dialog.connect('response', Lang.bind(this, function(dialog, id) { if (id == 1) { From eef0982e6d58c094ee043747b0ec18591b6c1a56 Mon Sep 17 00:00:00 2001 From: franglais125 Date: Fri, 26 May 2017 18:22:06 -0400 Subject: [PATCH 2/5] New Number Overlay option --- Settings.ui | 12 ++++--- prefs.js | 31 +++++++++++++------ ...shell.extensions.dash-to-panel.gschema.xml | 10 ++++++ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Settings.ui b/Settings.ui index 97fa7b6..c7baa2b 100644 --- a/Settings.ui +++ b/Settings.ui @@ -1378,11 +1378,15 @@ 12 32 - + True - True - end + False center + + Never + Show temporarily + Always visible + 1 @@ -1485,7 +1489,7 @@ 32 - False + True center 12 diff --git a/prefs.js b/prefs.js index a86f0ea..ff4090d 100644 --- a/prefs.js +++ b/prefs.js @@ -562,6 +562,10 @@ const Settings = new Lang.Class({ 'sensitive', Gio.SettingsBindFlags.DEFAULT); + this._builder.get_object('overlay_combo').connect('changed', Lang.bind (this, function(widget) { + this._settings.set_string('hotkeys-overlay-combo', widget.get_active_id()); + })); + // Create dialog for number overlay options this._builder.get_object('overlay_button').connect('clicked', Lang.bind(this, function() { @@ -577,8 +581,6 @@ const Settings = new Lang.Class({ let box = this._builder.get_object('box_overlay_shortcut'); dialog.get_content_area().add(box); - this._builder.get_object('overlay_switch').set_active(this._settings.get_boolean('hotkeys-overlay')); - this._settings.bind('hotkey-prefix-text', this._builder.get_object('hotkey_prefix_combo'), 'text', @@ -593,18 +595,27 @@ const Settings = new Lang.Class({ 'active-id', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('hotkeys-overlay', - this._builder.get_object('overlay_switch'), - 'active', + this._builder.get_object('overlay_combo').set_active_id(this._settings.get_string('hotkeys-overlay-combo')); + + this._settings.bind('hotkeys-overlay-combo', + this._builder.get_object('overlay_combo'), + 'active-id', Gio.SettingsBindFlags.DEFAULT); + this._settings.bind('overlay-timeout', this._builder.get_object('timeout_spinbutton'), 'value', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('hotkeys-overlay', - this._builder.get_object('timeout_spinbutton'), - 'sensitive', - Gio.SettingsBindFlags.DEFAULT); + if (this._settings.get_string('hotkeys-overlay-combo') !== 'TEMPORARILY') { + this._builder.get_object('timeout_spinbutton').set_sensitive(false); + } + + this._settings.connect('changed::hotkeys-overlay-combo', Lang.bind(this, function() { + if (this._settings.get_string('hotkeys-overlay-combo') !== 'TEMPORARILY') + this._builder.get_object('timeout_spinbutton').set_sensitive(false); + else + this._builder.get_object('timeout_spinbutton').set_sensitive(true); + })); this._settings.bind('shortcut-text', this._builder.get_object('shortcut_entry'), @@ -615,7 +626,7 @@ const Settings = new Lang.Class({ dialog.connect('response', Lang.bind(this, function(dialog, id) { if (id == 1) { // restore default settings for the relevant keys - let keys = ['hotkey-prefix-text', 'shortcut-text', 'hotkeys-overlay', 'overlay-timeout']; + let keys = ['hotkey-prefix-text', 'shortcut-text', 'hotkeys-overlay-combo', 'overlay-timeout']; keys.forEach(function(val) { this._settings.set_value(val, this._settings.get_default_value(val)); }, this); diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index d01bf89..3db1893 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -26,6 +26,11 @@ + + + + + @@ -291,6 +296,11 @@ Show the dock when using the hotkeys The dock will be quickly shown so that the number-overlay is visible and app activation is easier + + 'TEMPORARILY' + Transitivity of the number overlay + You can choose between NEVER, TEMPORARILY and ALWAYS. + false Super Hot-Keys From 6d6b37e2ee11a54da33bff607ce49bcbc291874e Mon Sep 17 00:00:00 2001 From: franglais125 Date: Fri, 26 May 2017 19:50:56 -0400 Subject: [PATCH 3/5] Use the new options for number overlay: - NEVER - TEMPORARILY - AWLAYS --- overview.js | 26 +++++++++++++++++++++----- taskbar.js | 3 +++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/overview.js b/overview.js index 4fcc026..d9a8001 100644 --- a/overview.js +++ b/overview.js @@ -201,6 +201,9 @@ const dtpOverview = new Lang.Class({ }, this); this._hotKeysEnabled = true; + + if (this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + this.taskbar.toggleNumberOverlay(true); }, _disableHotKeys: function() { @@ -215,6 +218,8 @@ const dtpOverview = new Lang.Class({ }, this); this._hotKeysEnabled = false; + + this.taskbar.toggleNumberOverlay(false); }, _optionalNumberOverlay: function() { @@ -229,8 +234,13 @@ const dtpOverview = new Lang.Class({ Lang.bind(this, this._checkHotkeysOptions) ], [ this._dtpSettings, - 'changed::hotkeys-overlay', - Lang.bind(this, this._checkHotkeysOptions) + 'changed::hotkeys-overlay-combo', + Lang.bind(this, function() { + if (this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + this.taskbar.toggleNumberOverlay(true); + else + this.taskbar.toggleNumberOverlay(false); + }) ]); }, @@ -262,15 +272,21 @@ const dtpOverview = new Lang.Class({ }, _showOverlay: function() { - if (this._dtpSettings.get_boolean('hotkeys-overlay') || this._overlayFromShortcut) - this.taskbar.toggleNumberOverlay(true); - // Restart the counting if the shortcut is pressed again if (this._numberOverlayTimeoutId) { Mainloop.source_remove(this._numberOverlayTimeoutId); this._numberOverlayTimeoutId = 0; } + let hotkey_option = this._dtpSettings.get_string('hotkeys-overlay-combo'); + + // Set to true and exit if the overlay is always visible + if (hotkey_option === 'ALWAYS') + return; + + if (hotkey_option === 'TEMPORARILY' || this._overlayFromShortcut) + this.taskbar.toggleNumberOverlay(true); + let timeout = this._dtpSettings.get_int('overlay-timeout'); if (this._overlayFromShortcut) { timeout = this._dtpSettings.get_int('shortcut-timeout'); diff --git a/taskbar.js b/taskbar.js index fde02d9..b25fa11 100644 --- a/taskbar.js +++ b/taskbar.js @@ -865,6 +865,9 @@ const taskbar = new Lang.Class({ icon.updateNumberOverlay(); }); + if (this._dtpSettings.get_boolean('hot-keys') && + this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + this.toggleNumberOverlay(true); }, toggleNumberOverlay: function(activate) { From a6b9ab9f50deb63e649d970d1ab3469206f013c9 Mon Sep 17 00:00:00 2001 From: franglais125 Date: Fri, 26 May 2017 19:53:41 -0400 Subject: [PATCH 4/5] Remove deprecated key from the schema. --- schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 3db1893..b46f8f5 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -291,11 +291,6 @@ Timeout to hide the dock, in seconds Sets the time duration before the dock is hidden again. - - true - Show the dock when using the hotkeys - The dock will be quickly shown so that the number-overlay is visible and app activation is easier - 'TEMPORARILY' Transitivity of the number overlay From c4080cb607f5d5d714ae44c010052fd5b51b77c3 Mon Sep 17 00:00:00 2001 From: franglais125 Date: Tue, 30 May 2017 11:53:48 -0400 Subject: [PATCH 5/5] Number overlay: consider scale factor (HiDPI). --- appIcons.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appIcons.js b/appIcons.js index e3e0c21..8dc5c94 100644 --- a/appIcons.js +++ b/appIcons.js @@ -719,10 +719,14 @@ const taskbarAppIcon = new Lang.Class({ }, updateNumberOverlay: function() { + // We apply an overall scale factor that might come from a HiDPI monitor. + // Clutter dimensions are in physical pixels, but CSS measures are in logical + // pixels, so make sure to consider the scale. + let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; // Set the font size to something smaller than the whole icon so it is // still visible. The border radius is large to make the shape circular let [minWidth, natWidth] = this._iconContainer.get_preferred_width(-1); - let font_size = Math.round(Math.max(12, 0.3*natWidth)); + let font_size = Math.round(Math.max(12, 0.3*natWidth) / scaleFactor); let size = Math.round(font_size*1.2); this._numberOverlayLabel.set_style( this._numberOverlayStyle +