[gnome] Fix version for gjsosk and gsconnect, add impatience

This commit is contained in:
2024-11-01 09:35:38 -04:00
parent 66e76c2764
commit 1bd891f30a
78 changed files with 804 additions and 1226 deletions

View File

@ -0,0 +1,52 @@
import St from 'gi://St';
const DEFAULT_SPEED = 0.75;
import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
import * as Settings from './settings.js';
function LOG(m){
console.log("[impatience] " + m);
};
var noop = function() {};
export default class Impatience extends Extension {
constructor(metadata) {
super(metadata);
this.enabled = false;
this.original_speed = St.Settings.get().slow_down_factor;
this.modified_speed = DEFAULT_SPEED;
this.unbind = noop;
};
enable() {
this.enabled = true;
var pref = (new Settings.Prefs(this)).SPEED;
LOG("enabled");
var binding = pref.changed(() => {
this.set_speed(pref.get());
});
this.unbind = () => {
pref.disconnect(binding);
this.unbind = noop;
};
this.set_speed(pref.get());
};
disable() {
this.enabled = false;
this.unbind();
St.Settings.get().slow_down_factor = this.original_speed;
};
set_speed(new_speed) {
if(!this.enabled) {
LOG("NOT setting new speed, since the extension is disabled.");
return;
}
if(new_speed !== undefined) {
this.modified_speed = new_speed;
}
LOG("setting new speed: " + this.modified_speed);
St.Settings.get().slow_down_factor = this.modified_speed;
};
}

View File

@ -0,0 +1,14 @@
{
"_generated": "Generated by SweetTooth, do not edit",
"description": "Speed up the gnome-shell animation speed",
"name": "Impatience",
"settings-schema": "org.gnome.shell.extensions.net.gfxmonk.impatience",
"shell-version": [
"45",
"46",
"47"
],
"url": "http://gfxmonk.net/dist/0install/gnome-shell-impatience.xml",
"uuid": "impatience@gfxmonk.net",
"version": 27
}

View File

@ -0,0 +1,61 @@
import Gtk from 'gi://Gtk';
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import * as Settings from './settings.js';
export default class ImpatiencePrefs extends ExtensionPreferences {
getPreferencesWidget() {
let config = new Settings.Prefs(this);
let frame = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
'margin-top': 20,
'margin-bottom': 20,
'margin-start': 20,
'margin-end': 20
});
(function() {
let hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 20
});
let label = new Gtk.Label({
label: "Speed scaling\n<small>(1 = normal, 0.5 = twice as fast)</small>",
use_markup: true,
});
let adjustment = new Gtk.Adjustment({
lower: 0,
upper: 2,
step_increment: 0.05
});
let scale = new Gtk.Scale({
orientation: Gtk.Orientation.HORIZONTAL,
digits:2,
adjustment: adjustment,
hexpand: true,
value_pos: Gtk.PositionType.RIGHT
});
hbox.append(label);
hbox.append(scale);
frame.append(hbox);
var pref = config.SPEED;
scale.set_value(pref.get());
[0.25, 0.5, 1.0, 2.0].forEach(
mark => scale.add_mark(mark, Gtk.PositionType.TOP, "<small>" + mark + "</small>")
);
scale.connect('value-changed', function(sw) {
var oldval = pref.get();
var newval = sw.get_value();
if (newval != pref.get()) {
pref.set(newval);
}
});
})();
frame.show();
return frame;
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="org.gnome.shell.extensions.net.gfxmonk.impatience" path="/org/gnome/shell/extensions/net/gfxmonk/impatience/">
<key type="d" name="speed-factor">
<default>0.75</default>
<summary>speed factor</summary>
<description/>
</key>
</schema>
</schemalist>

View File

@ -0,0 +1,10 @@
export function Prefs(extension) {
var settings = this.settings = extension.getSettings();
this.SPEED = {
key: 'speed-factor',
get: function() { return settings.get_double(this.key); },
set: function(v) { settings.set_double(this.key, v); },
changed: function(cb) { return settings.connect('changed::' + this.key, cb); },
disconnect: function() { return settings.disconnect.apply(settings, arguments); },
};
};