Update prefs.js
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
// ------------------------------------------------------ //
|
// ------------------------------------------------------ //
|
||||||
// Extension Settings Menu for Simple Tiling - Version 2 //
|
// Extension Settings Menu for Simple Tiling - Version 4 //
|
||||||
// © 2025 domoel – MIT //
|
// © 2025 domoel – MIT //
|
||||||
// ------------------------------------------------------ //
|
// ------------------------------------------------------ //
|
||||||
|
|
||||||
// ---------------------------------------------------- //
|
// ---------------------------------------------------- //
|
||||||
// Global Imports //
|
// Global Imports //
|
||||||
// ---------------------------------------------------- //
|
// ---------------------------------------------------- //
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
const { Gtk, GObject, Gio } = imports.gi;
|
const { Gtk, GObject, Gio } = imports.gi;
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
|
|
||||||
const SCHEMA_NAME = 'org.gnome.shell.extensions.simple-tiling.domoel';
|
const SCHEMA_NAME = "org.gnome.shell.extensions.simple-tiling.domoel";
|
||||||
|
|
||||||
// ---------------------------------------------------- //
|
// ---------------------------------------------------- //
|
||||||
// Definition of Row Model //
|
// Definition of Row Model //
|
||||||
@@ -39,124 +39,233 @@ function buildPrefsWidget() {
|
|||||||
// ---------------------------------------------------- //
|
// ---------------------------------------------------- //
|
||||||
// Section for Keybindings //
|
// Section for Keybindings //
|
||||||
// ---------------------------------------------------- //
|
// ---------------------------------------------------- //
|
||||||
const keysTitle = new Gtk.Label({ label: '<b>Tastenkürzel</b>', use_markup: true, halign: Gtk.Align.START, visible: true });
|
const keysTitle = new Gtk.Label({
|
||||||
const keysFrame = new Gtk.Frame({ label_widget: keysTitle, shadow_type: Gtk.ShadowType.NONE, visible: true });
|
label: "<b>Tastenkürzel</b>",
|
||||||
let keysBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, margin: 12, spacing: 6, visible: true });
|
use_markup: true,
|
||||||
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
const keysFrame = new Gtk.Frame({
|
||||||
|
label_widget: keysTitle,
|
||||||
|
shadow_type: Gtk.ShadowType.NONE,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
let keysBox = new Gtk.Box({
|
||||||
|
orientation: Gtk.Orientation.VERTICAL,
|
||||||
|
margin: 12,
|
||||||
|
spacing: 6,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
keysFrame.add(keysBox);
|
keysFrame.add(keysBox);
|
||||||
|
|
||||||
let store = new Gtk.ListStore();
|
let store = new Gtk.ListStore();
|
||||||
store.set_column_types([ GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_INT, GObject.TYPE_INT ]);
|
store.set_column_types([
|
||||||
|
GObject.TYPE_STRING,
|
||||||
|
GObject.TYPE_STRING,
|
||||||
|
GObject.TYPE_INT,
|
||||||
|
GObject.TYPE_INT,
|
||||||
|
]);
|
||||||
|
|
||||||
addKeybinding(store, settings, 'swap-master-window', 'Master-Fenster tauschen');
|
addKeybinding(
|
||||||
addKeybinding(store, settings, 'swap-left-window', 'Fenster nach links tauschen');
|
store,
|
||||||
addKeybinding(store, settings, 'swap-right-window', 'Fenster nach rechts tauschen');
|
settings,
|
||||||
addKeybinding(store, settings, 'swap-up-window', 'Fenster nach oben tauschen');
|
"swap-master-window",
|
||||||
addKeybinding(store, settings, 'swap-down-window', 'Fenster nach unten tauschen');
|
"Master-Fenster tauschen"
|
||||||
|
);
|
||||||
|
addKeybinding(
|
||||||
|
store,
|
||||||
|
settings,
|
||||||
|
"swap-left-window",
|
||||||
|
"Fenster nach links tauschen"
|
||||||
|
);
|
||||||
|
addKeybinding(
|
||||||
|
store,
|
||||||
|
settings,
|
||||||
|
"swap-right-window",
|
||||||
|
"Fenster nach rechts tauschen"
|
||||||
|
);
|
||||||
|
addKeybinding(
|
||||||
|
store,
|
||||||
|
settings,
|
||||||
|
"swap-up-window",
|
||||||
|
"Fenster nach oben tauschen"
|
||||||
|
);
|
||||||
|
addKeybinding(
|
||||||
|
store,
|
||||||
|
settings,
|
||||||
|
"swap-down-window",
|
||||||
|
"Fenster nach unten tauschen"
|
||||||
|
);
|
||||||
|
|
||||||
let treeView = new Gtk.TreeView({ model: store, headers_visible: false, hexpand: true, visible: true });
|
addKeybinding(store, settings, "focus-left", "Fokus nach links wechseln");
|
||||||
|
addKeybinding(store, settings, "focus-right", "Fokus nach rechts wechseln");
|
||||||
|
addKeybinding(store, settings, "focus-up", "Fokus nach oben wechseln");
|
||||||
|
addKeybinding(store, settings, "focus-down", "Fokus nach unten wechseln");
|
||||||
|
|
||||||
|
let treeView = new Gtk.TreeView({
|
||||||
|
model: store,
|
||||||
|
headers_visible: false,
|
||||||
|
hexpand: true,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
keysBox.add(treeView);
|
keysBox.add(treeView);
|
||||||
|
|
||||||
let descRenderer = new Gtk.CellRendererText();
|
let descRenderer = new Gtk.CellRendererText();
|
||||||
let descColumn = new Gtk.TreeViewColumn({ expand: true });
|
let descColumn = new Gtk.TreeViewColumn({ expand: true });
|
||||||
descColumn.pack_start(descRenderer, true);
|
descColumn.pack_start(descRenderer, true);
|
||||||
descColumn.add_attribute(descRenderer, 'text', COLUMN_DESC);
|
descColumn.add_attribute(descRenderer, "text", COLUMN_DESC);
|
||||||
treeView.append_column(descColumn);
|
treeView.append_column(descColumn);
|
||||||
|
|
||||||
let accelRenderer = new Gtk.CellRendererAccel({ 'accel-mode': Gtk.CellRendererAccelMode.GTK, 'editable': true });
|
let accelRenderer = new Gtk.CellRendererAccel({
|
||||||
|
"accel-mode": Gtk.CellRendererAccelMode.GTK,
|
||||||
|
editable: true,
|
||||||
|
});
|
||||||
let accelColumn = new Gtk.TreeViewColumn();
|
let accelColumn = new Gtk.TreeViewColumn();
|
||||||
accelColumn.pack_end(accelRenderer, false);
|
accelColumn.pack_end(accelRenderer, false);
|
||||||
accelColumn.add_attribute(accelRenderer, 'accel-key', COLUMN_KEY);
|
accelColumn.add_attribute(accelRenderer, "accel-key", COLUMN_KEY);
|
||||||
accelColumn.add_attribute(accelRenderer, 'accel-mods', COLUMN_MODS);
|
accelColumn.add_attribute(accelRenderer, "accel-mods", COLUMN_MODS);
|
||||||
treeView.append_column(accelColumn);
|
treeView.append_column(accelColumn);
|
||||||
|
|
||||||
accelRenderer.connect('accel-edited', (renderer, path_string, key, mods, hw_code) => {
|
accelRenderer.connect("accel-edited", (r, path, key, mods) => {
|
||||||
let [ok, iter] = store.get_iter_from_string(path_string);
|
let [ok, iter] = store.get_iter_from_string(path);
|
||||||
if (!ok) return;
|
if (ok) {
|
||||||
store.set(iter, [COLUMN_KEY, COLUMN_MODS], [key, mods]);
|
store.set(iter, [COLUMN_KEY, COLUMN_MODS], [key, mods]);
|
||||||
let id = store.get_value(iter, COLUMN_ID);
|
settings.set_strv(store.get_value(iter, COLUMN_ID), [
|
||||||
let accelString = Gtk.accelerator_name(key, mods);
|
Gtk.accelerator_name(key, mods),
|
||||||
settings.set_strv(id, [accelString]);
|
]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
accelRenderer.connect('accel-cleared', (renderer, path_string) => {
|
accelRenderer.connect("accel-cleared", (r, path) => {
|
||||||
let [ok, iter] = store.get_iter_from_string(path_string);
|
let [ok, iter] = store.get_iter_from_string(path);
|
||||||
if (!ok) return;
|
if (ok) {
|
||||||
store.set(iter, [COLUMN_KEY, COLUMN_MODS], [0, 0]);
|
store.set(iter, [COLUMN_KEY, COLUMN_MODS], [0, 0]);
|
||||||
let id = store.get_value(iter, COLUMN_ID);
|
settings.set_strv(store.get_value(iter, COLUMN_ID), []);
|
||||||
settings.set_strv(id, []);
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
prefsWidget.add(keysFrame);
|
prefsWidget.add(keysFrame);
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------- //
|
// ---------------------------------------------------- //
|
||||||
// Section for Window Gaps //
|
// Section for Window Gaps //
|
||||||
// ---------------------------------------------------- //
|
// ---------------------------------------------------- //
|
||||||
const gapsTitle = new Gtk.Label({ label: '<b>Fensterabstände (Gaps)</b>', use_markup: true, halign: Gtk.Align.START, visible: true });
|
const gapsTitle = new Gtk.Label({
|
||||||
const gapsFrame = new Gtk.Frame({ label_widget: gapsTitle, shadow_type: Gtk.ShadowType.NONE, visible: true });
|
label: "<b>Fensterabstände (Gaps)</b>",
|
||||||
const gapsGrid = new Gtk.Grid({ margin: 12, column_spacing: 12, row_spacing: 12, visible: true });
|
use_markup: true,
|
||||||
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
const gapsFrame = new Gtk.Frame({
|
||||||
|
label_widget: gapsTitle,
|
||||||
|
shadow_type: Gtk.ShadowType.NONE,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
const gapsGrid = new Gtk.Grid({
|
||||||
|
margin: 12,
|
||||||
|
column_spacing: 12,
|
||||||
|
row_spacing: 12,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
gapsFrame.add(gapsGrid);
|
gapsFrame.add(gapsGrid);
|
||||||
|
|
||||||
addSpinButtonRow(gapsGrid, settings, "Innerer Abstand (zwischen Fenstern)", "inner-gap", 0);
|
addSpinButtonRow(gapsGrid, settings, "Innerer Abstand", "inner-gap", 0);
|
||||||
addSpinButtonRow(gapsGrid, settings, "Äußerer Abstand (horizontal)", "outer-gap-horizontal", 1);
|
addSpinButtonRow(
|
||||||
addSpinButtonRow(gapsGrid, settings, "Äußerer Abstand (vertikal)", "outer-gap-vertical", 2);
|
gapsGrid,
|
||||||
|
settings,
|
||||||
|
"Äußerer Abstand (horizontal)",
|
||||||
|
"outer-gap-horizontal",
|
||||||
|
1
|
||||||
|
);
|
||||||
|
addSpinButtonRow(
|
||||||
|
gapsGrid,
|
||||||
|
settings,
|
||||||
|
"Äußerer Abstand (vertikal)",
|
||||||
|
"outer-gap-vertical",
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
prefsWidget.add(gapsFrame);
|
prefsWidget.add(gapsFrame);
|
||||||
|
|
||||||
// ---------------------------------------------------- //
|
// ---------------------------------------------------- //
|
||||||
// Section for Window Behavior (Master vs. Stack) //
|
// Section for Window Behavior (Master vs. Stack) //
|
||||||
// ---------------------------------------------------- //
|
// ---------------------------------------------------- //
|
||||||
const behaviorTitle = new Gtk.Label({ label: '<b>Fensterverhalten</b>', use_markup: true, halign: Gtk.Align.START, visible: true });
|
const behaviorTitle = new Gtk.Label({
|
||||||
const behaviorFrame = new Gtk.Frame({ label_widget: behaviorTitle, shadow_type: Gtk.ShadowType.NONE, visible: true });
|
label: "<b>Fensterverhalten</b>",
|
||||||
const behaviorGrid = new Gtk.Grid({ margin: 12, column_spacing: 12, row_spacing: 12, visible: true });
|
use_markup: true,
|
||||||
behaviorFrame.add(behaviorGrid);
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
const comboLabel = new Gtk.Label({ label: "Neues Fenster öffnen als", halign: Gtk.Align.START, visible: true });
|
|
||||||
behaviorGrid.attach(comboLabel, 0, 0, 1, 1);
|
|
||||||
|
|
||||||
const comboBox = new Gtk.ComboBoxText({ visible: true, halign: Gtk.Align.END });
|
|
||||||
comboBox.append('stack', 'Stack-Fenster (Standard)');
|
|
||||||
comboBox.append('master', 'Master-Fenster');
|
|
||||||
|
|
||||||
comboBox.set_active_id(settings.get_string('new-window-behavior'));
|
|
||||||
|
|
||||||
comboBox.connect('changed', () => {
|
|
||||||
settings.set_string('new-window-behavior', comboBox.get_active_id());
|
|
||||||
});
|
});
|
||||||
|
const behaviorFrame = new Gtk.Frame({
|
||||||
behaviorGrid.attach(comboBox, 1, 0, 1, 1);
|
label_widget: behaviorTitle,
|
||||||
|
shadow_type: Gtk.ShadowType.NONE,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
const behaviorGrid = new Gtk.Grid({
|
||||||
|
margin: 12,
|
||||||
|
column_spacing: 12,
|
||||||
|
row_spacing: 12,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
behaviorFrame.add(behaviorGrid);
|
||||||
|
addComboBoxRow(
|
||||||
|
behaviorGrid,
|
||||||
|
settings,
|
||||||
|
"Neues Fenster öffnen als",
|
||||||
|
"new-window-behavior",
|
||||||
|
0
|
||||||
|
);
|
||||||
prefsWidget.add(behaviorFrame);
|
prefsWidget.add(behaviorFrame);
|
||||||
|
|
||||||
return prefsWidget;
|
return prefsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addKeybinding(model, settings, id, description) {
|
function addKeybinding(model, settings, id, desc) {
|
||||||
let [key, mods] = [0, 0];
|
let [key, mods] = [0, 0];
|
||||||
|
|
||||||
const strv = settings.get_strv(id);
|
const strv = settings.get_strv(id);
|
||||||
if (strv && strv.length > 0 && strv[0]) {
|
if (strv && strv[0]) {
|
||||||
[key, mods] = Gtk.accelerator_parse(strv[0]);
|
[key, mods] = Gtk.accelerator_parse(strv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let iter = model.append();
|
let iter = model.append();
|
||||||
model.set(iter,
|
model.set(
|
||||||
|
iter,
|
||||||
[COLUMN_ID, COLUMN_DESC, COLUMN_KEY, COLUMN_MODS],
|
[COLUMN_ID, COLUMN_DESC, COLUMN_KEY, COLUMN_MODS],
|
||||||
[id, description, key, mods]
|
[id, desc, key, mods]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
function addSpinButtonRow(grid, settings, desc, key, pos) {
|
||||||
function addSpinButtonRow(grid, settings, description, key, position) {
|
const label = new Gtk.Label({
|
||||||
const label = new Gtk.Label({ label: description, halign: Gtk.Align.START, visible: true });
|
label: desc,
|
||||||
grid.attach(label, 0, position, 1, 1);
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
const adjustment = new Gtk.Adjustment({ lower: 0, upper: 50, step_increment: 1 });
|
});
|
||||||
const spinButton = new Gtk.SpinButton({
|
grid.attach(label, 0, pos, 1, 1);
|
||||||
adjustment: adjustment,
|
const adj = new Gtk.Adjustment({ lower: 0, upper: 50, step_increment: 1 });
|
||||||
|
const spin = new Gtk.SpinButton({
|
||||||
|
adjustment: adj,
|
||||||
climb_rate: 1,
|
climb_rate: 1,
|
||||||
digits: 0,
|
digits: 0,
|
||||||
halign: Gtk.Align.END,
|
halign: Gtk.Align.END,
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
settings.bind(key, spinButton, 'value', Gio.SettingsBindFlags.DEFAULT);
|
settings.bind(key, spin, "value", Gio.SettingsBindFlags.DEFAULT);
|
||||||
grid.attach(spinButton, 1, position, 1, 1);
|
grid.attach(spin, 1, pos, 1, 1);
|
||||||
|
}
|
||||||
|
function addComboBoxRow(grid, settings, desc, key, pos) {
|
||||||
|
const label = new Gtk.Label({
|
||||||
|
label: desc,
|
||||||
|
halign: Gtk.Align.START,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
grid.attach(label, 0, pos, 1, 1);
|
||||||
|
const combo = new Gtk.ComboBoxText({
|
||||||
|
visible: true,
|
||||||
|
halign: Gtk.Align.END,
|
||||||
|
});
|
||||||
|
combo.append("stack", "Stack-Fenster (Standard)");
|
||||||
|
combo.append("master", "Master-Fenster");
|
||||||
|
combo.set_active_id(settings.get_string(key));
|
||||||
|
combo.connect("changed", () => {
|
||||||
|
settings.set_string(key, combo.get_active_id());
|
||||||
|
});
|
||||||
|
grid.attach(combo, 1, pos, 1, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user