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:
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);
|
||||
|
||||
Reference in New Issue
Block a user