diff --git a/src/animation/icon_motion.vala b/src/animation/icon_motion.vala
index 0e81fce..6dcc3ef 100644
--- a/src/animation/icon_motion.vala
+++ b/src/animation/icon_motion.vala
@@ -4,6 +4,7 @@ namespace Singularity.Animation {
public const uint DOCK_LIMIT = 500;
private const string PLAYING = "singularity-icon-motion";
+ private const string ANIMATED_KEY = "animated-icons";
internal const string SOURCE = "singularity-icon-source";
public static void set_source(Gtk.Image image, GLib.File? file) {
@@ -28,6 +29,7 @@ namespace Singularity.Animation {
public static bool animated(Gtk.Image image) {
#if IRIDE
+ if (!animated_icons_enabled()) return false;
int size = image.pixel_size > 0 ? image.pixel_size : int.min(image.get_width(), image.get_height());
return size > 0 && IconPlayback.sibling_of(image, size, image.get_scale_factor()) != null;
#else
@@ -69,9 +71,30 @@ namespace Singularity.Animation {
private static bool allowed() {
if (Singularity.Motion.reduced()) return false;
+ if (!animated_icons_enabled()) return false;
return !GLib.PowerProfileMonitor.dup_default().power_saver_enabled;
}
#endif
+
+ // The "animated-icons" switch in the desktop settings. Read once and cached,
+ // like Motion reads reduce-motion: a missing schema or key means ON.
+ private static GLib.Settings? _animated_settings = null;
+
+ private static bool animated_icons_enabled() {
+ if (_animated_settings == null) {
+ var source = GLib.SettingsSchemaSource.get_default();
+ string schema_id = Singularity.Runtime.desktop_settings_schema;
+ var schema = source != null ? source.lookup(schema_id, true) : null;
+ if (schema != null && schema.has_key(ANIMATED_KEY)) {
+ _animated_settings = new GLib.Settings(schema_id);
+ }
+ }
+ return _animated_settings == null || _animated_settings.get_boolean(ANIMATED_KEY);
+ }
+
+ internal static bool animated_icons_enabled_for_test() {
+ return animated_icons_enabled();
+ }
}
#if IRIDE
diff --git a/tests/fixtures/motion/dev.sinty.motiontest.gschema.xml b/tests/fixtures/motion/dev.sinty.motiontest.gschema.xml
index 2d146d8..e7ad635 100644
--- a/tests/fixtures/motion/dev.sinty.motiontest.gschema.xml
+++ b/tests/fixtures/motion/dev.sinty.motiontest.gschema.xml
@@ -10,5 +10,9 @@
1.0
Animation duration multiplier
+
+ true
+ Animated Icons
+
diff --git a/tests/motion_test.vala b/tests/motion_test.vala
index 384a2c8..0a95272 100644
--- a/tests/motion_test.vala
+++ b/tests/motion_test.vala
@@ -1,3 +1,4 @@
+using Gtk;
using Singularity;
using Singularity.Animation;
@@ -354,6 +355,17 @@ void test_reduce_motion() {
assert("--motion-duration-scene: 600ms;" in motion.css());
}
+void test_animated_icons_gate() {
+ fresh_clock();
+ var settings = new GLib.Settings("dev.sinty.motiontest");
+ assert(settings.get_boolean("animated-icons") == true);
+ assert(IconMotion.animated_icons_enabled_for_test());
+ settings.set_boolean("animated-icons", false);
+ assert(!IconMotion.animated_icons_enabled_for_test());
+ settings.set_boolean("animated-icons", true);
+ assert(IconMotion.animated_icons_enabled_for_test());
+}
+
void test_reduce_motion_setting() {
fresh_clock();
var settings = new GLib.Settings("dev.sinty.motiontest");
@@ -526,6 +538,7 @@ int main(string[] args) {
Test.add_func("/motion/stagger", test_stagger);
Test.add_func("/motion/groups", test_groups);
Test.add_func("/motion/reduce-motion", test_reduce_motion);
+ Test.add_func("/motion/animated-icons-gate", test_animated_icons_gate);
Test.add_func("/motion/reduce-motion-setting", test_reduce_motion_setting);
Test.add_func("/motion/skip-all", test_skip_all);
Test.add_func("/motion/morph-math", test_morph_math);