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 a142997..9709bce 100644
Binary files a/schemas/gschemas.compiled and b/schemas/gschemas.compiled differ
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