summaryrefslogtreecommitdiffstats
path: root/impatience
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 14:59:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 14:59:21 +0000
commitd8d06026cb993d02e6ab2304fabbda3b60d940b2 (patch)
treeba4d8c052c5ba93cbef35b46060e61fd737ed9af /impatience
parentInitial commit. (diff)
downloadgnome-shell-extension-impatience-d8d06026cb993d02e6ab2304fabbda3b60d940b2.tar.xz
gnome-shell-extension-impatience-d8d06026cb993d02e6ab2304fabbda3b60d940b2.zip
Adding upstream version 0.4.5.upstream/0.4.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'impatience')
-rw-r--r--impatience/extension.js61
-rw-r--r--impatience/metadata.json8
-rw-r--r--impatience/prefs.js54
-rw-r--r--impatience/schemas/gschemas.compiledbin0 -> 336 bytes
-rw-r--r--impatience/schemas/org.gnome.shell.extensions.net.gfxmonk.impatience.gschema.xml10
-rw-r--r--impatience/settings.js41
6 files changed, 174 insertions, 0 deletions
diff --git a/impatience/extension.js b/impatience/extension.js
new file mode 100644
index 0000000..2dde979
--- /dev/null
+++ b/impatience/extension.js
@@ -0,0 +1,61 @@
+const St = imports.gi.St;
+const Gio = imports.gi.Gio;
+const Lang = imports.lang;
+const DEFAULT_SPEED = 0.75;
+const ExtensionUtils = imports.misc.extensionUtils;
+const Extension = ExtensionUtils.getCurrentExtension();
+const Settings = Extension.imports.settings;
+
+function LOG(m){
+ global.log("[impatience] " + m);
+ log("[impatience] " + m);
+};
+function Ext() {
+ this._init.apply(this, arguments);
+};
+var noop = function() {};
+
+Ext.prototype = {};
+Ext.prototype._init = function() {
+ this.enabled = false;
+ this.original_speed = St.get_slow_down_factor();
+ this.modified_speed = DEFAULT_SPEED;
+ this.unbind = noop;
+};
+
+Ext.prototype.enable = function() {
+ this.enabled = true;
+ var pref = (new Settings.Prefs()).SPEED;
+ LOG("enabled");
+ var binding = pref.changed(Lang.bind(this, function() {
+ this.set_speed(pref.get());
+ }));
+ this.unbind = function() {
+ pref.disconnect(binding);
+ this.unbind = noop;
+ };
+ this.set_speed(pref.get());
+};
+
+Ext.prototype.disable = function() {
+ this.enabled = false;
+ this.unbind();
+ St.set_slow_down_factor(this.original_speed);
+};
+
+Ext.prototype.set_speed = function(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.set_slow_down_factor(this.modified_speed);
+};
+
+function init() {
+ return new Ext();
+};
+
diff --git a/impatience/metadata.json b/impatience/metadata.json
new file mode 100644
index 0000000..84e871b
--- /dev/null
+++ b/impatience/metadata.json
@@ -0,0 +1,8 @@
+{
+ "uuid": "impatience@gfxmonk.net",
+ "name": "Impatience",
+ "description": "Speed up the gnome-shell animation speed",
+ "url": "http://gfxmonk.net/dist/0install/gnome-shell-impatience.xml",
+ "shell-version": [ "3.4", "3.6", "3.8", "3.10", "3.12", "3.14", "3.16",
+ "3.18", "3.20", "3.22", "3.24" ]
+}
diff --git a/impatience/prefs.js b/impatience/prefs.js
new file mode 100644
index 0000000..d394a8f
--- /dev/null
+++ b/impatience/prefs.js
@@ -0,0 +1,54 @@
+const Gtk = imports.gi.Gtk;
+
+let Extension = imports.misc.extensionUtils.getCurrentExtension();
+let Settings = Extension.imports.settings;
+
+function init() {
+}
+
+function buildPrefsWidget() {
+ let config = new Settings.Prefs();
+ let frame = new Gtk.Box({
+ orientation: Gtk.Orientation.VERTICAL,
+ border_width: 10
+ });
+
+ (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.HScale({
+ digits:2,
+ adjustment: adjustment,
+ value_pos: Gtk.PositionType.RIGHT
+ });
+
+ hbox.add(label);
+ hbox.pack_end(scale, true, true, 0);
+ frame.add(hbox);
+
+ var pref = config.SPEED;
+ scale.set_value(pref.get());
+ scale.connect('value-changed', function(sw) {
+ var oldval = pref.get();
+ var newval = sw.get_value();
+ if (newval != pref.get()) {
+ pref.set(newval);
+ }
+ });
+ })();
+
+ frame.show_all();
+ return frame;
+}
diff --git a/impatience/schemas/gschemas.compiled b/impatience/schemas/gschemas.compiled
new file mode 100644
index 0000000..f909d13
--- /dev/null
+++ b/impatience/schemas/gschemas.compiled
Binary files differ
diff --git a/impatience/schemas/org.gnome.shell.extensions.net.gfxmonk.impatience.gschema.xml b/impatience/schemas/org.gnome.shell.extensions.net.gfxmonk.impatience.gschema.xml
new file mode 100644
index 0000000..ffd0c93
--- /dev/null
+++ b/impatience/schemas/org.gnome.shell.extensions.net.gfxmonk.impatience.gschema.xml
@@ -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>
diff --git a/impatience/settings.js b/impatience/settings.js
new file mode 100644
index 0000000..c4f6815
--- /dev/null
+++ b/impatience/settings.js
@@ -0,0 +1,41 @@
+const Gio = imports.gi.Gio;
+const ExtensionUtils = imports.misc.extensionUtils;
+const Extension = ExtensionUtils.getCurrentExtension();
+
+const SCHEMA_PATH = 'org.gnome.shell.extensions.net.gfxmonk.impatience';
+
+function get_local_gsettings(schema_path) {
+ const GioSSS = Gio.SettingsSchemaSource;
+
+ let schemaDir = Extension.dir.get_child('schemas');
+
+ let schemaSource = GioSSS.get_default();
+ if (schemaDir.query_exists(null)) {
+ schemaSource = GioSSS.new_from_directory(
+ schemaDir.get_path(),
+ schemaSource,
+ false);
+ }
+
+ let schemaObj = schemaSource.lookup(schema_path, true);
+ if (!schemaObj) {
+ throw new Error(
+ 'Schema ' + schema_path +
+ ' could not be found for extension ' +
+ Extension.metadata.uuid
+ );
+ }
+ return new Gio.Settings({ settings_schema: schemaObj });
+};
+
+function Prefs() {
+ var self = this;
+ var settings = this.settings = get_local_gsettings(SCHEMA_PATH);
+ 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); },
+ };
+};