From 4df818347bdf443a640844f495b15f1bafe9dd51 Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Thu, 6 Feb 2020 08:33:04 -0500 Subject: [PATCH] Added distance and delay to settings --- extension.js | 14 +-- prefs.js | 99 ++++++++++++++---- schemas/gschemas.compiled | Bin 512 -> 648 bytes ...gnome.shell.extensions.wintile.gschema.xml | 22 +++- 4 files changed, 104 insertions(+), 31 deletions(-) diff --git a/extension.js b/extension.js index 2b1e785..d05b29f 100644 --- a/extension.js +++ b/extension.js @@ -30,7 +30,7 @@ let config = { preview: { enabled: true, doubleWidth: true, - close: 75, + distance: 75, delay: 500 } } @@ -52,6 +52,8 @@ function updateSettings() { config.preview.doubleWidth = settings.get_value('double-width').deep_unpack(); config.useMaximize = settings.get_value('use-maximize').deep_unpack(); config.preview.enabled = settings.get_value('preview').deep_unpack(); + config.preview.distance = settings.get_value('distance').deep_unpack(); + config.preview.delay = settings.get_value('delay').deep_unpack(); config.debug = settings.get_value('debug').deep_unpack(); _log(JSON.stringify(config)); } @@ -63,8 +65,8 @@ let settingsChangedId = settings.connect('changed', updateSettings.bind()); const Config = imports.misc.config; window.gsconnect = { - extdatadir: imports.misc.extensionUtils.getCurrentExtension().path, - shell_version: parseInt(Config.PACKAGE_VERSION.split('.')[1], 10) + extdatadir: imports.misc.extensionUtils.getCurrentExtension().path, + shell_version: parseInt(Config.PACKAGE_VERSION.split('.')[1], 10) }; imports.searchPath.unshift(gsconnect.extdatadir); @@ -676,9 +678,9 @@ function changeBinding(settings, key, oldBinding, newBinding) { } function isClose(a, b) { - if (a <= b && a > b - config.preview.close) + if (a <= b && a > b - config.preview.distance) return true; - else if (a >= b && a < b + config.preview.close) + else if (a >= b && a < b + config.preview.distance) return true; else return false; @@ -808,7 +810,7 @@ function checkIfNearGrid(app) { } if (!close) hidePreview(); - Mainloop.timeout_add(500, function () { + Mainloop.timeout_add(config.preview.delay, function () { checkIfNearGrid(app); }); } diff --git a/prefs.js b/prefs.js index 02dc53b..fcd6aec 100644 --- a/prefs.js +++ b/prefs.js @@ -10,6 +10,17 @@ const Me = ExtensionUtils.getCurrentExtension(); const Gettext = imports.gettext; const _ = Gettext.domain('wintile').gettext; +let gschema = Gio.SettingsSchemaSource.new_from_directory( + Me.dir.get_child('schemas').get_path(), + Gio.SettingsSchemaSource.get_default(), + false +); + +const gsettings = new Gio.Settings({ + settings_schema: gschema.lookup('org.gnome.shell.extensions.wintile', true) +}); + + function init() { } @@ -30,17 +41,6 @@ function createColOptions(){ } function buildPrefsWidget() { - // Copy the same GSettings code from `extension.js` - let gschema = Gio.SettingsSchemaSource.new_from_directory( - Me.dir.get_child('schemas').get_path(), - Gio.SettingsSchemaSource.get_default(), - false - ); - - this.settings = new Gio.Settings({ - settings_schema: gschema.lookup('org.gnome.shell.extensions.wintile', true) - }); - let rendererText = new Gtk.CellRendererText(); // Create a parent widget that we'll return from this function @@ -86,7 +86,7 @@ function buildPrefsWidget() { halign: Gtk.Align.START }); let maximizeInput = new Gtk.Switch({ - active: this.settings.get_boolean ('use-maximize'), + active: gsettings.get_boolean ('use-maximize'), halign: Gtk.Align.END, visible: true }); @@ -94,7 +94,7 @@ function buildPrefsWidget() { layout.attach(maximizeInput, 1, row++, 1, 1); // Preview settings - let previewEnabled = this.settings.get_boolean ('preview'); + let previewEnabled = gsettings.get_boolean ('preview'); let previewLabel = new Gtk.Label({ label: _("Enable preview and snapping when dragging windows"), visible: true, @@ -117,13 +117,65 @@ function buildPrefsWidget() { halign: Gtk.Align.START }); let doubleWidthInput = new Gtk.Switch({ - active: this.settings.get_boolean ('double-width'), + active: gsettings.get_boolean ('double-width'), halign: Gtk.Align.END, visible: true }); layout.attach(doubleWidthLabel, 0, row, 1, 1); layout.attach(doubleWidthInput, 1, row++, 1, 1); + // Preview distance + let previewDistanceLabel = new Gtk.Label({ + label: _(" Pixels from edge to start preview"), + visible: true, + hexpand: true, + halign: Gtk.Align.START + }); + let previewDistanceInput = new Gtk.Box({ + orientation: Gtk.Orientation.HORIZONTAL, + visible: true + }); + let previewDistanceAdjustment = new Gtk.Adjustment({ + lower: 0, + upper: 150, + step_increment: 1 + }); + let previewDistanceSettingInt = new Gtk.SpinButton({ + adjustment: previewDistanceAdjustment, + snap_to_ticks: true, + visible: true + }); + previewDistanceSettingInt.set_value(gsettings.get_int('distance')); + previewDistanceInput.add(previewDistanceSettingInt); + layout.attach(previewDistanceLabel, 0, row, 1, 1); + layout.attach(previewDistanceInput, 1, row++, 1, 1); + + // Delay + let previewDelayLabel = new Gtk.Label({ + label: _(" Delay in ms before preview dislpays"), + visible: true, + hexpand: true, + halign: Gtk.Align.START + }); + let previewDelayInput = new Gtk.Box({ + orientation: Gtk.Orientation.HORIZONTAL, + visible: true + }); + let previewDelayAdjustment = new Gtk.Adjustment({ + lower: 100, + upper: 1000, + step_increment: 1 + }); + let previewDelaySettingInt = new Gtk.SpinButton({ + adjustment: previewDelayAdjustment, + snap_to_ticks: true, + visible: true + }); + previewDelaySettingInt.set_value(gsettings.get_int('delay')); + previewDelayInput.add(previewDelaySettingInt); + layout.attach(previewDelayLabel, 0, row, 1, 1); + layout.attach(previewDelayInput, 1, row++, 1, 1); + // Debug setting let debugLabel = new Gtk.Label({ label: _("Turn on debugging"), @@ -132,18 +184,25 @@ function buildPrefsWidget() { halign: Gtk.Align.START }); let debugInput = new Gtk.Switch({ - active: this.settings.get_boolean ('debug'), + active: gsettings.get_boolean ('debug'), halign: Gtk.Align.END, visible: true }); layout.attach(debugLabel, 0, row, 1, 1); layout.attach(debugInput, 1, row++, 1, 1); - this.settings.bind('cols', colsInput, 'active', Gio.SettingsBindFlags.DEFAULT); - this.settings.bind('double-width', doubleWidthInput, 'active', Gio.SettingsBindFlags.DEFAULT); - this.settings.bind('use-maximize', maximizeInput, 'active', Gio.SettingsBindFlags.DEFAULT); - this.settings.bind('preview', previewInput, 'active', Gio.SettingsBindFlags.DEFAULT); - this.settings.bind('debug', debugInput, 'active', Gio.SettingsBindFlags.DEFAULT); + gsettings.bind('cols', colsInput, 'active', Gio.SettingsBindFlags.DEFAULT); + gsettings.bind('use-maximize', maximizeInput, 'active', Gio.SettingsBindFlags.DEFAULT); + gsettings.bind('preview', previewInput, 'active', Gio.SettingsBindFlags.DEFAULT); + gsettings.bind('double-width', doubleWidthInput, 'active', Gio.SettingsBindFlags.DEFAULT); + previewDistanceSettingInt.connect('value-changed', function(entry) { + gsettings.set_int('distance', entry.value); + }); + previewDelaySettingInt.connect('value-changed', function(entry) { + gsettings.set_int('delay', entry.value); + }); + gsettings.bind('debug', debugInput, 'active', Gio.SettingsBindFlags.DEFAULT); + let setDoubleWidthWidgetsEnabled = function(enabled) { doubleWidthLabel.set_sensitive(enabled); diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index a142997d40a97a5c45d7fd99f36715a08c0d6ac7..9709bce0d797380b918ac98a411a5473e8700ae4 100644 GIT binary patch literal 648 zcmYLGze~eF7`&ax~?fZk@Q04d!gA@UZh+ZhwHO33Bhbe5E_t6 zkp~lxuTL(ScjiS)48SAc`TSyz_fu=|AHeUxaQC*)^VC`RAK-7G*t~wBPo0C$3pHT# zZGVA2HFFlh>%i#n_l7?8Jp66&4)B%hZPBNue*iuLHtv%gYUZ4QC3QL{Y9UI(0drPW z6-KsKk*jb6ZlQ);bftH7r3}L`8+PPa7^oEw)QSgcO$KVE1GR(*E4~}DJFanFeB~ss z5y+O3?c_{G=w+iSUAvon|6nfcs{)_XSSEeVP!{TTN7YqN;=S1CH_NUpv{f~7lJ?Y> Xg4;`1dyP7`N?jU5 zcVSq|L|=#xPSPfQGGk+wM_!a>iS%?&#<3@dg-o@|QteeLEmSPIo*diI{|~pA1vvL` zcr?%b&A(_sTS!*G+Resd6M5Da{A2J5@Me$J*=M}~e*(S)I_2pj`>bvFx8OTqdVbb? z{(JBfaJ~J0#`UbZ&olT1xM-h`*=OB^{|e^Wy}n=c;0p{c%;3TdF8&4=_27a?hcYN5 zlp~zL4YM+cWvf!5>A`M;{eCV7N>;yXh&hupS8VRc!n)M5mH0!IsF5`L_On>?raJPP P&3ih^IdGJ6UDvqZJxOH~ diff --git a/schemas/org.gnome.shell.extensions.wintile.gschema.xml b/schemas/org.gnome.shell.extensions.wintile.gschema.xml index f82c4e3..5527512 100644 --- a/schemas/org.gnome.shell.extensions.wintile.gschema.xml +++ b/schemas/org.gnome.shell.extensions.wintile.gschema.xml @@ -7,11 +7,6 @@ - - true - Use double width previews on sides in 4 column mode - When on, dragging a window to the side will preview 2 columns wide instead of 1. - true Turn on/off use of maximizing windows @@ -22,6 +17,23 @@ Turn on/off mouse positioning When on, dragging windows with the mouse will allow placement into the grid. + + true + Use double width previews on sides in 4 column mode + When on, dragging a window to the side will preview 2 columns wide instead of 1. + + + 25 + Pixels from edge to start preview + + + + + 500 + Delay in ms before preview dislpays + + + false Turn on/off debug output