mirror of
https://github.com/FranP-code/wintile.git
synced 2025-10-13 00:33:46 +00:00
Added distance and delay to settings
This commit is contained in:
14
extension.js
14
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);
|
||||
});
|
||||
}
|
||||
|
||||
99
prefs.js
99
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);
|
||||
|
||||
Binary file not shown.
@@ -7,11 +7,6 @@
|
||||
<description></description>
|
||||
<range min="0" max="2"/>
|
||||
</key>
|
||||
<key name="double-width" type="b">
|
||||
<default>true</default>
|
||||
<summary>Use double width previews on sides in 4 column mode</summary>
|
||||
<description>When on, dragging a window to the side will preview 2 columns wide instead of 1.</description>
|
||||
</key>
|
||||
<key name="use-maximize" type="b">
|
||||
<default>true</default>
|
||||
<summary>Turn on/off use of maximizing windows</summary>
|
||||
@@ -22,6 +17,23 @@
|
||||
<summary>Turn on/off mouse positioning</summary>
|
||||
<description>When on, dragging windows with the mouse will allow placement into the grid.</description>
|
||||
</key>
|
||||
<key name="double-width" type="b">
|
||||
<default>true</default>
|
||||
<summary>Use double width previews on sides in 4 column mode</summary>
|
||||
<description>When on, dragging a window to the side will preview 2 columns wide instead of 1.</description>
|
||||
</key>
|
||||
<key name="distance" type="i">
|
||||
<default>25</default>
|
||||
<summary>Pixels from edge to start preview</summary>
|
||||
<description></description>
|
||||
<range min="0" max="150"/>
|
||||
</key>
|
||||
<key name="delay" type="i">
|
||||
<default>500</default>
|
||||
<summary>Delay in ms before preview dislpays</summary>
|
||||
<description></description>
|
||||
<range min="100" max="1000"/>
|
||||
</key>
|
||||
<key name="debug" type="b">
|
||||
<default>false</default>
|
||||
<summary>Turn on/off debug output</summary>
|
||||
|
||||
Reference in New Issue
Block a user