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.
This commit is contained in:
abakkk
2020-12-20 06:11:40 +01:00
parent e4a71fa014
commit 8796899526
3 changed files with 521 additions and 7 deletions

View File

@@ -2,6 +2,310 @@
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkBox" id="animate_appicon_hover_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkListBox" id="animate_appicon_hover_options_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<child>
<object class="GtkListBoxRow" id="animate_appicon_hover_options_type_listboxrow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox" id="animate_appicon_hover_options_type_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="spacing">32</property>
<child>
<object class="GtkLabel" id="animate_appicon_hover_options_type_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Animation type</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="animate_appicon_hover_options_type_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<items>
<item id="SIMPLE" translatable="yes">Simple</item>
<item id="RIPPLE" translatable="yes">Ripple</item>
<item id="PLANK" translatable="yes">Plank</item>
</items>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="animate_appicon_hover_options_params_listboxrow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkGrid" id="animate_appicon_hover_options_params_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="row_spacing">24</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkLabel" id="animate_appicon_hover_options_duration_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">12</property>
<property name="label" translatable="yes">Duration</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
<property name="valign">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="animate_appicon_hover_options_duration_scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="adjustment">animate_appicon_hover_options_duration_adjustment</property>
<property name="round_digits">0</property>
<property name="digits">0</property>
<property name="value_pos">right</property>
<signal name="format-value" handler="animate_appicon_hover_options_duration_scale_format_value_cb" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="animate_appicon_hover_options_extent_rotation">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Rotation</property>
<property name="xalign">0</property>
<property name="valign">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkScale" id="animate_appicon_hover_options_rotation_scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="adjustment">animate_appicon_hover_options_rotation_adjustment</property>
<property name="round_digits">0</property>
<property name="digits">0</property>
<property name="value_pos">right</property>
<signal name="format-value" handler="animate_appicon_hover_options_rotation_scale_format_value_cb" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="animate_appicon_hover_options_travel_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Travel</property>
<property name="xalign">0</property>
<property name="valign">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkScale" id="animate_appicon_hover_options_travel_scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="adjustment">animate_appicon_hover_options_travel_adjustment</property>
<property name="round_digits">0</property>
<property name="digits">0</property>
<property name="value_pos">right</property>
<signal name="format-value" handler="animate_appicon_hover_options_travel_scale_format_value_cb" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="animate_appicon_hover_options_zoom_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Zoom</property>
<property name="xalign">0</property>
<property name="valign">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkScale" id="animate_appicon_hover_options_zoom_scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="adjustment">animate_appicon_hover_options_zoom_adjustment</property>
<property name="round_digits">0</property>
<property name="digits">0</property>
<property name="value_pos">right</property>
<signal name="format-value" handler="animate_appicon_hover_options_zoom_scale_format_value_cb" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="animate_appicon_hover_options_convexity_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Convexity</property>
<property name="xalign">0</property>
<property name="valign">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkScale" id="animate_appicon_hover_options_convexity_scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="adjustment">animate_appicon_hover_options_convexity_adjustment</property>
<property name="round_digits">1</property>
<property name="digits">1</property>
<property name="value_pos">right</property>
<signal name="format-value" handler="animate_appicon_hover_options_convexity_scale_format_value_cb" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="animate_appicon_hover_options_extent_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Extent</property>
<property name="xalign">0</property>
<property name="valign">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkScale" id="animate_appicon_hover_options_extent_scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="adjustment">animate_appicon_hover_options_extent_adjustment</property>
<property name="round_digits">0</property>
<property name="digits">0</property>
<property name="value_pos">right</property>
<signal name="format-value" handler="animate_appicon_hover_options_extent_scale_format_value_cb" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<object class="GtkAdjustment" id="animate_appicon_hover_options_duration_adjustment">
<property name="lower">0</property>
<property name="upper">300</property>
<property name="step_increment">1</property>
<property name="page_increment">5</property>
</object>
<object class="GtkAdjustment" id="animate_appicon_hover_options_rotation_adjustment">
<property name="lower">-30</property>
<property name="upper">30</property>
<property name="step_increment">1</property>
<property name="page_increment">5</property>
</object>
<object class="GtkAdjustment" id="animate_appicon_hover_options_travel_adjustment">
<property name="lower">0</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">5</property>
</object>
<object class="GtkAdjustment" id="animate_appicon_hover_options_zoom_adjustment">
<property name="lower">100</property>
<property name="upper">250</property>
<property name="step_increment">1</property>
<property name="page_increment">5</property>
</object>
<object class="GtkAdjustment" id="animate_appicon_hover_options_convexity_adjustment">
<property name="lower">0</property>
<property name="upper">3</property>
<property name="step_increment">0.1</property>
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="animate_appicon_hover_options_extent_adjustment">
<property name="lower">1</property>
<property name="upper">10</property>
<property name="step_increment">0.1</property>
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="appicon_margin_adjustment">
<property name="lower">0.33</property>
<property name="upper">1</property>
@@ -7212,6 +7516,66 @@
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="animate_appicon_hover_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Animate hovering app icons</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="animate_appicon_hover_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkButton" id="animate_appicon_hover_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<child>
<object class="GtkImage" id="animate_appicon_hover_options_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">emblem-system-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="animate_appicon_hover_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>
</child>
</object>

127
prefs.js
View File

@@ -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);
},

View File

@@ -57,6 +57,11 @@
<value value='1' nick='NUM_KEYPAD'/>
<value value='2' nick='BOTH'/>
</enum>
<enum id='org.gnome.shell.extensions.dash-to-panel.appIconHoverAnimationType'>
<value value='0' nick='SIMPLE'/>
<value value='1' nick='RIPPLE'/>
<value value='2' nick='PLANK'/>
</enum>
<schema path="/org/gnome/shell/extensions/dash-to-panel/" id="org.gnome.shell.extensions.dash-to-panel">
<key type="b" name="check-update">
<default>false</default>
@@ -747,6 +752,38 @@
<default>true</default>
<summary>Animate when new window launched</summary>
</key>
<key type="b" name="animate-appicon-hover">
<default>false</default>
<summary>Animate app icon on hover</summary>
</key>
<key name="animate-appicon-hover-animation-type" enum="org.gnome.shell.extensions.dash-to-panel.appIconHoverAnimationType">
<default>'SIMPLE'</default>
<summary>App icon hover animation type</summary>
</key>
<key type="a{sd}" name="animate-appicon-hover-animation-convexity">
<default>{'RIPPLE':2,'PLANK':1}</default>
<summary>App icon hover animation curve convexity (1 is linear, more is convex, less is concave)</summary>
</key>
<key type="a{su}" name="animate-appicon-hover-animation-duration">
<default>{'SIMPLE':160,'RIPPLE':130,'PLANK':100}</default>
<summary>App icon hover animation duration in milliseconds</summary>
</key>
<key type="a{si}" name="animate-appicon-hover-animation-extent">
<default>{'RIPPLE':4,'PLANK':4}</default>
<summary>App icon hover animation extent (maximum number of animated icons)</summary>
</key>
<key type="a{si}" name="animate-appicon-hover-animation-rotation">
<default>{'SIMPLE':0,'RIPPLE':10,'PLANK':0}</default>
<summary>App icon hover animation rotation in degrees</summary>
</key>
<key type="a{sd}" name="animate-appicon-hover-animation-travel">
<default>{'SIMPLE':0.30,'RIPPLE':0.40,'PLANK':0}</default>
<summary>App icon hover animation travel translation in relation to the app icon size</summary>
</key>
<key type="a{sd}" name="animate-appicon-hover-animation-zoom">
<default>{'SIMPLE':1,'RIPPLE':1.25,'PLANK':2}</default>
<summary>App icon hover animation zoom scale in relation to the app icon size</summary>
</key>
<key type="b" name="secondarymenu-contains-appmenu">
<default>true</default>
<summary>Integrate items from the gnome appmenu into the right click menu</summary>