From 8796899526554f28407e7f54c853203c986d340d Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 20 Dec 2020 06:11:40 +0100 Subject: [PATCH] Add animate-appicon-hover settings Each animation type has its own duration, rotation, travel and zoom settings. Each multi-icon animation has its own convexity and extent settings. It is achieved by using "{ type: value, ... }" dictionaries. --- Settings.ui | 364 ++++++++++++++++++ prefs.js | 127 +++++- ...shell.extensions.dash-to-panel.gschema.xml | 37 ++ 3 files changed, 521 insertions(+), 7 deletions(-) diff --git a/Settings.ui b/Settings.ui index 551085b..3790516 100644 --- a/Settings.ui +++ b/Settings.ui @@ -2,6 +2,310 @@ + + True + False + vertical + + + True + False + none + + + True + True + False + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + True + Animation type + 0 + + + False + True + 0 + + + + + True + False + center + + Simple + Ripple + Plank + + + + False + False + end + 1 + + + + + + + + + True + True + False + + + True + False + 12 + 12 + 12 + 12 + 24 + 32 + + + True + False + 12 + Duration + True + 0 + end + + + 0 + 0 + + + + + True + True + end + True + animate_appicon_hover_options_duration_adjustment + 0 + 0 + right + + + + 1 + 0 + + + + + True + False + Rotation + 0 + end + + + 0 + 1 + + + + + True + True + end + True + animate_appicon_hover_options_rotation_adjustment + 0 + 0 + right + + + + 1 + 1 + + + + + True + False + Travel + 0 + end + + + 0 + 2 + + + + + True + True + end + True + animate_appicon_hover_options_travel_adjustment + 0 + 0 + right + + + + 1 + 2 + + + + + True + False + Zoom + 0 + end + + + 0 + 3 + + + + + True + True + end + True + animate_appicon_hover_options_zoom_adjustment + 0 + 0 + right + + + + 1 + 3 + + + + + True + False + Convexity + 0 + end + + + 0 + 4 + + + + + True + True + end + True + animate_appicon_hover_options_convexity_adjustment + 1 + 1 + right + + + + 1 + 4 + + + + + True + False + Extent + 0 + end + + + 0 + 5 + + + + + True + True + end + True + animate_appicon_hover_options_extent_adjustment + 0 + 0 + right + + + + 1 + 5 + + + + + + + + + False + True + 0 + + + + + 0 + 300 + 1 + 5 + + + -30 + 30 + 1 + 5 + + + 0 + 100 + 1 + 5 + + + 100 + 250 + 1 + 5 + + + 0 + 3 + 0.1 + 1 + + + 1 + 10 + 0.1 + 1 + 0.33 1 @@ -7212,6 +7516,66 @@ 1 + + + True + False + True + Animate hovering app icons + 0 + + + 0 + 2 + + + + + True + False + 6 + + + True + True + True + center + + + True + False + emblem-system-symbolic + + + + + + False + True + 0 + + + + + True + True + end + center + + + False + True + 1 + + + + + 1 + 2 + + diff --git a/prefs.js b/prefs.js index 99bdd36..1cdc88b 100644 --- a/prefs.js +++ b/prefs.js @@ -1878,14 +1878,104 @@ const Settings = new Lang.Class({ } this._settings.bind('animate-app-switch', - this._builder.get_object('animate_app_switch_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); + this._builder.get_object('animate_app_switch_switch'), + 'active', + Gio.SettingsBindFlags.DEFAULT); this._settings.bind('animate-window-launch', - this._builder.get_object('animate_window_launch_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); + this._builder.get_object('animate_window_launch_switch'), + 'active', + Gio.SettingsBindFlags.DEFAULT); + + this._settings.bind('animate-appicon-hover', + this._builder.get_object('animate_appicon_hover_switch'), + 'active', + Gio.SettingsBindFlags.DEFAULT); + + this._settings.bind('animate-appicon-hover', + this._builder.get_object('animate_appicon_hover_button'), + 'sensitive', + Gio.SettingsBindFlags.DEFAULT); + + { + this._settings.bind('animate-appicon-hover-animation-type', + this._builder.get_object('animate_appicon_hover_options_type_combo'), + 'active-id', + Gio.SettingsBindFlags.DEFAULT); + + let scales = [ + ['animate_appicon_hover_options_duration_scale', 'animate-appicon-hover-animation-duration', 1], + ['animate_appicon_hover_options_rotation_scale', 'animate-appicon-hover-animation-rotation', 1], + ['animate_appicon_hover_options_travel_scale', 'animate-appicon-hover-animation-travel', 100], + ['animate_appicon_hover_options_zoom_scale', 'animate-appicon-hover-animation-zoom', 100], + ['animate_appicon_hover_options_convexity_scale', 'animate-appicon-hover-animation-convexity', 1], + ['animate_appicon_hover_options_extent_scale', 'animate-appicon-hover-animation-extent', 1], + ]; + + let updateScale = scale => { + let [id, key, factor] = scale; + let type = this._settings.get_string('animate-appicon-hover-animation-type'); + let value = this._settings.get_value(key).deep_unpack()[type]; + let defaultValue = this._settings.get_default_value(key).deep_unpack()[type]; + this._builder.get_object(id).sensitive = defaultValue !== undefined; + this._builder.get_object(id).set_value(value * factor || 0); + this._builder.get_object(id).clear_marks(); + this._builder.get_object(id).add_mark(defaultValue * factor, Gtk.PositionType.TOP, + defaultValue !== undefined ? (defaultValue * factor).toString() : ' '); + }; + + scales.forEach(scale => { + let [id, key, factor] = scale; + this._settings.connect('changed::' + key, () => updateScale(scale)); + this._builder.get_object(id).connect('value-changed', widget => { + let type = this._settings.get_string('animate-appicon-hover-animation-type'); + let variant = this._settings.get_value(key); + let unpacked = variant.deep_unpack(); + if (unpacked[type] != widget.get_value() / factor) { + unpacked[type] = widget.get_value() / factor; + this._settings.set_value(key, new GLib.Variant(variant.get_type_string(), unpacked)); + } + }); + }); + + this._settings.connect('changed::animate-appicon-hover-animation-type', () => scales.forEach(updateScale)); + scales.forEach(updateScale); + } + + this._builder.get_object('animate_appicon_hover_button').connect('clicked', Lang.bind(this, function() { + let dialog = new Gtk.Dialog({ title: _('App icon animation options'), + transient_for: this.widget.get_toplevel(), + use_header_bar: true, + modal: true }); + + // GTK+ leaves positive values for application-defined response ids. + // Use +1 for the reset action + dialog.add_button(_('Reset to defaults'), 1); + + let box = this._builder.get_object('animate_appicon_hover_options'); + dialog.get_content_area().add(box); + + dialog.connect('response', Lang.bind(this, function(dialog, id) { + if (id == 1) { + // restore default settings + this._settings.set_value('animate-appicon-hover-animation-type', this._settings.get_default_value('animate-appicon-hover-animation-type')); + this._settings.set_value('animate-appicon-hover-animation-duration', this._settings.get_default_value('animate-appicon-hover-animation-duration')); + this._settings.set_value('animate-appicon-hover-animation-rotation', this._settings.get_default_value('animate-appicon-hover-animation-rotation')); + this._settings.set_value('animate-appicon-hover-animation-travel', this._settings.get_default_value('animate-appicon-hover-animation-travel')); + this._settings.set_value('animate-appicon-hover-animation-zoom', this._settings.get_default_value('animate-appicon-hover-animation-zoom')); + this._settings.set_value('animate-appicon-hover-animation-convexity', this._settings.get_default_value('animate-appicon-hover-animation-convexity')); + this._settings.set_value('animate-appicon-hover-animation-extent', this._settings.get_default_value('animate-appicon-hover-animation-extent')); + } else { + // remove the settings box so it doesn't get destroyed; + dialog.get_content_area().remove(box); + dialog.destroy(); + } + return; + })); + + dialog.show_all(); + + })); this._settings.bind('stockgs-keep-dash', this._builder.get_object('stockgs_dash_switch'), @@ -2014,7 +2104,30 @@ const Settings = new Lang.Class({ * Object containing all signals defined in the glade file */ _SignalHandler: { - + animate_appicon_hover_options_duration_scale_format_value_cb: function(scale, value) { + return _("%d ms").format(value); + }, + + animate_appicon_hover_options_rotation_scale_format_value_cb: function(scale, value) { + return _("%d °").format(value); + }, + + animate_appicon_hover_options_travel_scale_format_value_cb: function(scale, value) { + return _("%d %%").format(value); + }, + + animate_appicon_hover_options_zoom_scale_format_value_cb: function(scale, value) { + return _("%d %%").format(value); + }, + + animate_appicon_hover_options_convexity_scale_format_value_cb: function(scale, value) { + return _("%.1f").format(value); + }, + + animate_appicon_hover_options_extent_scale_format_value_cb: function(scale, value) { + return Gettext.ngettext("%d icon", "%d icons", value).format(value); + }, + position_bottom_button_clicked_cb: function(button) { if (!this._ignorePositionRadios && button.get_active()) this._setPanelPosition(Pos.BOTTOM); }, diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 5cf666d..645e434 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -57,6 +57,11 @@ + + + + + false @@ -747,6 +752,38 @@ true Animate when new window launched + + false + Animate app icon on hover + + + 'SIMPLE' + App icon hover animation type + + + {'RIPPLE':2,'PLANK':1} + App icon hover animation curve convexity (1 is linear, more is convex, less is concave) + + + {'SIMPLE':160,'RIPPLE':130,'PLANK':100} + App icon hover animation duration in milliseconds + + + {'RIPPLE':4,'PLANK':4} + App icon hover animation extent (maximum number of animated icons) + + + {'SIMPLE':0,'RIPPLE':10,'PLANK':0} + App icon hover animation rotation in degrees + + + {'SIMPLE':0.30,'RIPPLE':0.40,'PLANK':0} + App icon hover animation travel translation in relation to the app icon size + + + {'SIMPLE':1,'RIPPLE':1.25,'PLANK':2} + App icon hover animation zoom scale in relation to the app icon size + true Integrate items from the gnome appmenu into the right click menu