diff --git a/lib/AnimationsSettings.vala b/lib/AnimationsSettings.vala index 46522dff..e3247cb0 100644 --- a/lib/AnimationsSettings.vala +++ b/lib/AnimationsSettings.vala @@ -22,4 +22,11 @@ namespace AnimationsSettings { return enable_animations; } + + /** + * Utility that returns the given duration or 0 if animations are disabled. + */ + public uint get_animation_duration (uint duration) { + return get_enable_animations () ? duration : 0; + } } diff --git a/plugins/pip/PopupWindow.vala b/plugins/pip/PopupWindow.vala index f7099446..61f16711 100644 --- a/plugins/pip/PopupWindow.vala +++ b/plugins/pip/PopupWindow.vala @@ -142,7 +142,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { opacity = 0; save_easing_state (); - set_easing_duration (AnimationsSettings.get_enable_animations () ? 200 : 0); + set_easing_duration (AnimationsSettings.get_animation_duration (200)); opacity = 255; restore_easing_state (); } @@ -150,7 +150,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { public override void hide () { opacity = 255; - var duration = AnimationsSettings.get_enable_animations () ? 200 : 0; + var duration = AnimationsSettings.get_animation_duration (200); save_easing_state (); set_easing_duration (duration); opacity = 0; @@ -172,7 +172,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { #else public override bool enter_event (Clutter.CrossingEvent event) { #endif - var duration = AnimationsSettings.get_enable_animations () ? 300 : 0; + var duration = AnimationsSettings.get_animation_duration (300); close_button.save_easing_state (); close_button.set_easing_duration (duration); @@ -192,7 +192,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { #else public override bool leave_event (Clutter.CrossingEvent event) { #endif - var duration = AnimationsSettings.get_enable_animations () ? 300 : 0; + var duration = AnimationsSettings.get_animation_duration (300); close_button.save_easing_state (); close_button.set_easing_duration (duration); @@ -314,7 +314,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { } private void on_close_click_clicked () { - var duration = AnimationsSettings.get_enable_animations () ? FADE_OUT_TIMEOUT : 0; + var duration = AnimationsSettings.get_animation_duration (FADE_OUT_TIMEOUT); save_easing_state (); set_easing_duration (duration); @@ -448,7 +448,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { var screen_limit_start_y = SCREEN_MARGIN + monitor_y; var screen_limit_end_y = monitor_height + monitor_y - SCREEN_MARGIN - height; - var duration = AnimationsSettings.get_enable_animations () ? 300 : 0; + var duration = AnimationsSettings.get_animation_duration (300); save_easing_state (); set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK); @@ -461,7 +461,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { private bool place_window_off_screen () { off_screen = false; - var duration = AnimationsSettings.get_enable_animations () ? 300 : 0; + var duration = AnimationsSettings.get_animation_duration (300); save_easing_state (); set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK); diff --git a/src/Widgets/IconGroup.vala b/src/Widgets/IconGroup.vala index 6765846f..886c9a0d 100644 --- a/src/Widgets/IconGroup.vala +++ b/src/Widgets/IconGroup.vala @@ -165,7 +165,7 @@ namespace Gala { if (animate) { icon.save_easing_state (); icon.set_easing_mode (Clutter.AnimationMode.LINEAR); - icon.set_easing_duration (AnimationsSettings.get_enable_animations () ? 200 : 0); + icon.set_easing_duration (AnimationsSettings.get_animation_duration (200)); icon.opacity = 0; icon.restore_easing_state (); diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index 8997f545..4f58707e 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -871,7 +871,7 @@ namespace Gala { dock.save_easing_state (); dock.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); - dock.set_easing_duration (AnimationsSettings.get_enable_animations () ? ANIMATION_DURATION : 0); + dock.set_easing_duration (AnimationsSettings.get_animation_duration (ANIMATION_DURATION)); dock.y = target_y; dock.restore_easing_state (); }; diff --git a/src/Widgets/WindowClone.vala b/src/Widgets/WindowClone.vala index 39580698..b984dad2 100644 --- a/src/Widgets/WindowClone.vala +++ b/src/Widgets/WindowClone.vala @@ -47,7 +47,7 @@ public class Gala.WindowClone : Clutter.Actor { public bool active { set { active_shape.save_easing_state (); - active_shape.set_easing_duration (AnimationsSettings.get_enable_animations () ? FADE_ANIMATION_DURATION : 0); + active_shape.set_easing_duration (AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION)); active_shape.opacity = value ? 255 : 0; active_shape.restore_easing_state (); } @@ -399,7 +399,7 @@ public class Gala.WindowClone : Clutter.Actor { return; } - var duration = AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0; + var duration = AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION); save_easing_state (); set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); @@ -484,7 +484,7 @@ public class Gala.WindowClone : Clutter.Actor { return Clutter.EVENT_PROPAGATE; } - var duration = AnimationsSettings.get_enable_animations () ? FADE_ANIMATION_DURATION : 0; + var duration = AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION); close_button.save_easing_state (); close_button.set_easing_mode (Clutter.AnimationMode.LINEAR); @@ -506,7 +506,7 @@ public class Gala.WindowClone : Clutter.Actor { #else public override bool leave_event (Clutter.CrossingEvent event) { #endif - var duration = AnimationsSettings.get_enable_animations () ? FADE_ANIMATION_DURATION : 0; + var duration = AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION); close_button.save_easing_state (); close_button.set_easing_mode (Clutter.AnimationMode.LINEAR); @@ -642,7 +642,7 @@ public class Gala.WindowClone : Clutter.Actor { active_shape.hide (); var scale = window_icon.width / clone.width; - var duration = AnimationsSettings.get_enable_animations () ? FADE_ANIMATION_DURATION : 0; + var duration = AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION); clone.get_transformed_position (out abs_x, out abs_y); clone.save_easing_state (); @@ -700,8 +700,8 @@ public class Gala.WindowClone : Clutter.Actor { var scale = hovered ? 0.4 : 1.0; var opacity = hovered ? 0 : 255; - var duration = hovered && insert_thumb != null ? insert_thumb.delay : 100; - duration = AnimationsSettings.get_enable_animations () ? duration : 0; + uint duration = hovered && insert_thumb != null ? insert_thumb.delay : 100; + duration = AnimationsSettings.get_animation_duration (duration); window_icon.save_easing_state (); @@ -809,7 +809,7 @@ public class Gala.WindowClone : Clutter.Actor { get_parent ().remove_child (this); prev_parent.insert_child_at_index (this, prev_index); - var duration = AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0; + var duration = AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION); clone.set_pivot_point (0.0f, 0.0f); clone.save_easing_state (); diff --git a/src/Widgets/WindowIconActor.vala b/src/Widgets/WindowIconActor.vala index 8ab5b6f5..4abd60da 100644 --- a/src/Widgets/WindowIconActor.vala +++ b/src/Widgets/WindowIconActor.vala @@ -146,7 +146,7 @@ namespace Gala { new_icon.save_easing_state (); new_icon.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); - new_icon.set_easing_duration (AnimationsSettings.get_enable_animations () ? 500 : 0); + new_icon.set_easing_duration (AnimationsSettings.get_animation_duration (500)); new_icon.restore_easing_state (); if (icon == null) { diff --git a/src/Widgets/WindowSwitcher/WindowSwitcher.vala b/src/Widgets/WindowSwitcher/WindowSwitcher.vala index f1435713..ef59c7e8 100644 --- a/src/Widgets/WindowSwitcher/WindowSwitcher.vala +++ b/src/Widgets/WindowSwitcher/WindowSwitcher.vala @@ -414,7 +414,7 @@ public class Gala.WindowSwitcher : CanvasActor { } save_easing_state (); - set_easing_duration (AnimationsSettings.get_enable_animations () ? ANIMATION_DURATION : 0); + set_easing_duration (AnimationsSettings.get_animation_duration (ANIMATION_DURATION)); opacity = show ? 255 : 0; restore_easing_state (); } diff --git a/src/Widgets/WorkspaceClone.vala b/src/Widgets/WorkspaceClone.vala index b3000a2f..e72e081e 100644 --- a/src/Widgets/WorkspaceClone.vala +++ b/src/Widgets/WorkspaceClone.vala @@ -387,13 +387,13 @@ namespace Gala { save_easing_state (); set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); - set_easing_duration (AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0); + set_easing_duration (AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION)); set_x (target_x); restore_easing_state (); background.save_easing_state (); background.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); - background.set_easing_duration (AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0); + background.set_easing_duration (AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION)); background.set_scale (scale, scale); background.restore_easing_state (); }; @@ -463,13 +463,13 @@ namespace Gala { save_easing_state (); set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); - set_easing_duration (AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0); + set_easing_duration (AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION)); set_x (target_x); restore_easing_state (); background.save_easing_state (); background.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); - background.set_easing_duration (AnimationsSettings.get_enable_animations () ? MultitaskingView.ANIMATION_DURATION : 0); + background.set_easing_duration (AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION)); background.set_scale (1, 1); background.restore_easing_state (); }; diff --git a/src/Widgets/WorkspaceInsertThumb.vala b/src/Widgets/WorkspaceInsertThumb.vala index 8e326b77..94b377a6 100644 --- a/src/Widgets/WorkspaceInsertThumb.vala +++ b/src/Widgets/WorkspaceInsertThumb.vala @@ -82,7 +82,7 @@ public class Gala.WorkspaceInsertThumb : Clutter.Actor { private new void transform (bool expand) { save_easing_state (); set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); - set_easing_duration (AnimationsSettings.get_enable_animations () ? 200 : 0); + set_easing_duration (AnimationsSettings.get_animation_duration (200)); if (!expand) { remove_transition ("pulse");