mirror of
https://github.com/FranP-code/wintile.git
synced 2025-10-13 00:33:46 +00:00
Added settings
This commit is contained in:
1
build.sh
1
build.sh
@@ -1,3 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
glib-compile-schemas schemas/
|
||||||
zip -xdemo.gif -xREADME.md -xbuild.sh wintile.zip *
|
zip -xdemo.gif -xREADME.md -xbuild.sh wintile.zip *
|
||||||
|
|||||||
47
extension.js
47
extension.js
@@ -3,11 +3,12 @@ const Main = imports.ui.main
|
|||||||
const Mainloop = imports.mainloop;
|
const Mainloop = imports.mainloop;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
|
|
||||||
let config = {
|
const ModalDialog = imports.ui.modalDialog;
|
||||||
cols: 2,
|
const PanelMenu = imports.ui.panelMenu;
|
||||||
useMaximize: true,
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
debug: true
|
|
||||||
}
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
// View logs with `journalctl -qf |grep WinTile`
|
// View logs with `journalctl -qf |grep WinTile`
|
||||||
var _log = function(str) {
|
var _log = function(str) {
|
||||||
@@ -16,6 +17,40 @@ var _log = function(str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let config = {
|
||||||
|
cols: 2,
|
||||||
|
useMaximize: true,
|
||||||
|
debug: true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the GSchema for our settings
|
||||||
|
let gschema = Gio.SettingsSchemaSource.new_from_directory(
|
||||||
|
Me.dir.get_child('schemas').get_path(),
|
||||||
|
Gio.SettingsSchemaSource.get_default(),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create a new settings object
|
||||||
|
let settings = new Gio.Settings({
|
||||||
|
settings_schema: gschema.lookup('org.gnome.shell.extensions.wintile', true)
|
||||||
|
});
|
||||||
|
|
||||||
|
function updateSettings() {
|
||||||
|
// 0 = 2 cols, 1 = 4 cols
|
||||||
|
if (settings.get_value('cols').deep_unpack() == 0)
|
||||||
|
config.cols = 2;
|
||||||
|
else
|
||||||
|
config.cols = 4;
|
||||||
|
config.useMaximize = settings.get_value('use-maximize').deep_unpack();
|
||||||
|
config.debug = settings.get_value('debug').deep_unpack();
|
||||||
|
_log(JSON.stringify(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSettings();
|
||||||
|
|
||||||
|
// Watch the settings for changes
|
||||||
|
let settingsChangedId = settings.connect('changed', updateSettings.bind());
|
||||||
|
|
||||||
const Config = imports.misc.config;
|
const Config = imports.misc.config;
|
||||||
window.gsconnect = {
|
window.gsconnect = {
|
||||||
extdatadir: imports.misc.extensionUtils.getCurrentExtension().path,
|
extdatadir: imports.misc.extensionUtils.getCurrentExtension().path,
|
||||||
@@ -34,6 +69,8 @@ var oldbindings = {
|
|||||||
|
|
||||||
function moveApp(app, loc) {
|
function moveApp(app, loc) {
|
||||||
_log("moveApp: " + JSON.stringify(loc));
|
_log("moveApp: " + JSON.stringify(loc));
|
||||||
|
//let ws = new Gio.Settings({ schema_id: 'org.gnome.shell.extensions.wintile' });
|
||||||
|
//_log(ws.get_strv('cols'));
|
||||||
var space = app.get_work_area_current_monitor()
|
var space = app.get_work_area_current_monitor()
|
||||||
colWidth = Math.floor(space.width/config.cols)
|
colWidth = Math.floor(space.width/config.cols)
|
||||||
rowHeight = Math.floor(space.height/2)
|
rowHeight = Math.floor(space.height/2)
|
||||||
|
|||||||
114
prefs.js
Normal file
114
prefs.js
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const Gio = imports.gi.Gio;
|
||||||
|
const Gtk = imports.gi.Gtk;
|
||||||
|
const GObject = imports.gi.GObject;
|
||||||
|
|
||||||
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
const Gettext = imports.gettext;
|
||||||
|
const _ = Gettext.domain('wintile').gettext;
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function createColOptions(){
|
||||||
|
let options = [
|
||||||
|
{ name: _("2") },
|
||||||
|
{ name: _("4"),}
|
||||||
|
];
|
||||||
|
let liststore = new Gtk.ListStore();
|
||||||
|
liststore.set_column_types([GObject.TYPE_STRING])
|
||||||
|
for (let i = 0; i < options.length; i++ ) {
|
||||||
|
let option = options[i];
|
||||||
|
let iter = liststore.append();
|
||||||
|
liststore.set (iter, [0], [option.name]);
|
||||||
|
}
|
||||||
|
return liststore;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
let layout = new Gtk.Grid({
|
||||||
|
margin: 18,
|
||||||
|
column_spacing: 12,
|
||||||
|
row_spacing: 12,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add a simple title and add it to the layout
|
||||||
|
let title = new Gtk.Label({
|
||||||
|
label: `<b>${Me.metadata.name} Extension Preferences</b>`,
|
||||||
|
halign: Gtk.Align.CENTER,
|
||||||
|
use_markup: true,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
layout.attach(title, 0, 0, 2, 1);
|
||||||
|
|
||||||
|
// Column setting
|
||||||
|
let colsLabel = new Gtk.Label({
|
||||||
|
label: _("Number of columns"),
|
||||||
|
visible: true,
|
||||||
|
hexpand: true,
|
||||||
|
halign: Gtk.Align.START
|
||||||
|
});
|
||||||
|
let colsInput = new Gtk.ComboBox({
|
||||||
|
model: createColOptions(),
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
colsInput.pack_start (rendererText, false);
|
||||||
|
colsInput.add_attribute (rendererText, "text", 0);
|
||||||
|
layout.attach(colsLabel, 0, 1, 1, 1);
|
||||||
|
layout.attach(colsInput, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
// Maximize setting
|
||||||
|
let maximizeLabel = new Gtk.Label({
|
||||||
|
label: _("Use true maximizing of windows"),
|
||||||
|
visible: true,
|
||||||
|
hexpand: true,
|
||||||
|
halign: Gtk.Align.START
|
||||||
|
});
|
||||||
|
let maximizeInput = new Gtk.Switch({
|
||||||
|
active: this.settings.get_boolean ('use-maximize'),
|
||||||
|
halign: Gtk.Align.END,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
layout.attach(maximizeLabel, 0, 2, 1, 1);
|
||||||
|
layout.attach(maximizeInput, 1, 2, 1, 1);
|
||||||
|
|
||||||
|
// Debug setting
|
||||||
|
let debugLabel = new Gtk.Label({
|
||||||
|
label: _("Turn on debugging"),
|
||||||
|
visible: true,
|
||||||
|
hexpand: true,
|
||||||
|
halign: Gtk.Align.START
|
||||||
|
});
|
||||||
|
let debugInput = new Gtk.Switch({
|
||||||
|
active: this.settings.get_boolean ('debug'),
|
||||||
|
halign: Gtk.Align.END,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
layout.attach(debugLabel, 0, 3, 1, 1);
|
||||||
|
layout.attach(debugInput, 1, 3, 1, 1);
|
||||||
|
|
||||||
|
this.settings.bind('cols', colsInput, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
this.settings.bind('use-maximize', maximizeInput, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
this.settings.bind('debug', debugInput, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
|
// Return our widget which will be added to the window
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
BIN
schemas/gschemas.compiled
Normal file
BIN
schemas/gschemas.compiled
Normal file
Binary file not shown.
21
schemas/org.gnome.shell.extensions.wintile.gschema.xml
Normal file
21
schemas/org.gnome.shell.extensions.wintile.gschema.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<schemalist>
|
||||||
|
<schema id="org.gnome.shell.extensions.wintile" path="/org/gnome/shell/extensions/wintile/">
|
||||||
|
<key name="cols" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
<summary>Number of columns (2 or 4 only)</summary>
|
||||||
|
<description></description>
|
||||||
|
<range min="0" max="1"/>
|
||||||
|
</key>
|
||||||
|
<key name="use-maximize" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Turn on/off use of maximizing windows</summary>
|
||||||
|
<description>When on, certain windows that won't resize full screen like Terminal will, however animations may occur between tile shifts.</description>
|
||||||
|
</key>
|
||||||
|
<key name="debug" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>Turn on/off debug output</summary>
|
||||||
|
<description></description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
</schemalist>
|
||||||
Reference in New Issue
Block a user