diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:19:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:19:51 +0000 |
commit | df7baa2644d541634825e28851c2bd8a47cd5233 (patch) | |
tree | 097c499ac161feb4345b18a4f6605e7199d6a635 /impatience | |
parent | Initial commit. (diff) | |
download | gnome-shell-extension-impatience-df7baa2644d541634825e28851c2bd8a47cd5233.tar.xz gnome-shell-extension-impatience-df7baa2644d541634825e28851c2bd8a47cd5233.zip |
Adding upstream version 0.4.8.upstream/0.4.8upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'impatience')
-rw-r--r-- | impatience/extension.js | 60 | ||||
-rw-r--r-- | impatience/metadata.json | 7 | ||||
-rw-r--r-- | impatience/prefs.js | 62 | ||||
-rw-r--r-- | impatience/schemas/gschemas.compiled | bin | 0 -> 332 bytes | |||
-rw-r--r-- | impatience/schemas/org.gnome.shell.extensions.net.gfxmonk.impatience.gschema.xml | 10 | ||||
-rw-r--r-- | impatience/settings.js | 17 |
6 files changed, 156 insertions, 0 deletions
diff --git a/impatience/extension.js b/impatience/extension.js new file mode 100644 index 0000000..8b54d3d --- /dev/null +++ b/impatience/extension.js @@ -0,0 +1,60 @@ +const St = imports.gi.St; +const Gio = imports.gi.Gio; +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); +}; +function Ext() { + this._init.apply(this, arguments); +}; +var noop = function() {}; + +Ext.prototype = {}; +Ext.prototype._init = function() { + this.enabled = false; + this.original_speed = St.Settings.get().slow_down_factor; + this.modified_speed = DEFAULT_SPEED; + this.unbind = noop; +}; + +Ext.prototype.enable = function() { + var self = this; + this.enabled = true; + var pref = (new Settings.Prefs()).SPEED; + LOG("enabled"); + var binding = pref.changed(function() { + self.set_speed(pref.get()); + }); + this.unbind = function() { + pref.disconnect(binding); + self.unbind = noop; + }; + this.set_speed(pref.get()); +}; + +Ext.prototype.disable = function() { + this.enabled = false; + this.unbind(); + St.Settings.get().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.Settings.get().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..e4753df --- /dev/null +++ b/impatience/metadata.json @@ -0,0 +1,7 @@ +{ + "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": [ "40", "41", "42" ] +} diff --git a/impatience/prefs.js b/impatience/prefs.js new file mode 100644 index 0000000..286599e --- /dev/null +++ b/impatience/prefs.js @@ -0,0 +1,62 @@ +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, + '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; +} diff --git a/impatience/schemas/gschemas.compiled b/impatience/schemas/gschemas.compiled Binary files differnew file mode 100644 index 0000000..8be15e0 --- /dev/null +++ b/impatience/schemas/gschemas.compiled 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..8d59838 --- /dev/null +++ b/impatience/settings.js @@ -0,0 +1,17 @@ +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 Prefs() { + var self = this; + var settings = this.settings = ExtensionUtils.getSettings(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); }, + }; +}; |