[gnome-music/wip/cdavis/dark-style-opt-in] artstack: Don't animate transition for dark mode




commit 31179f8b9f8333e2943d4a19d05f7d4387f651dd
Author: Christopher Davis <christopherdavis gnome org>
Date:   Thu Dec 9 11:19:51 2021 -0800

    artstack: Don't animate transition for dark mode
    
    Special thanks to Alexander Mikhaylenko for figuring
    this bit out.

 gnomemusic/widgets/artstack.py | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/widgets/artstack.py b/gnomemusic/widgets/artstack.py
index 6d1e69ee6..08a8ac80a 100644
--- a/gnomemusic/widgets/artstack.py
+++ b/gnomemusic/widgets/artstack.py
@@ -65,8 +65,6 @@ class ArtStack(Gtk.Stack):
         self.add_named(self._cover_b, "B")
 
         self.props.size = size
-        self.props.transition_type = Gtk.StackTransitionType.CROSSFADE
-        self.props.visible_child_name = "A"
 
         self.connect("destroy", self._on_destroy)
         Handy.StyleManager.get_default().connect(
@@ -111,7 +109,7 @@ class ArtStack(Gtk.Stack):
         default_icon = DefaultIcon().get(
             self._art_type, self._size, self.props.scale_factor)
 
-        self._on_cache_result(None, default_icon)
+        self._swap_thumbnails(default_icon, False)
 
     @GObject.Property(type=object, default=None)
     def coreobject(self):
@@ -136,9 +134,9 @@ class ArtStack(Gtk.Stack):
 
         if self.coreobject:
             if self.coreobject.props.thumbnail == "generic":
-                self._on_cache_result(self, default_icon)
+                self._swap_thumbnails(default_icon, False)
         else:
-            self._on_cache_result(self, default_icon)
+            self._swap_thumbnails(default_icon, False)
 
     def _on_thumbnail_changed(self, coreobject, uri):
         self._disconnect_cache()
@@ -149,13 +147,24 @@ class ArtStack(Gtk.Stack):
         self._async_queue.queue(
             self._cache, coreobject, self._size, self.props.scale_factor)
 
-    def _on_cache_result(self, cache, surface):
+    def _swap_thumbnails(self, surface, animate):
         if self.props.visible_child_name == "B":
             self._cover_a.props.surface = surface
-            self.props.visible_child_name = "A"
+            if animate:
+                self.set_visible_child_full("A",
+                                            Gtk.StackTransitionType.CROSSFADE)
+            else:
+                self.props.visible_child_name = "A"
         else:
             self._cover_b.props.surface = surface
-            self.props.visible_child_name = "B"
+            if animate:
+                self.set_visible_child_full("B",
+                                            Gtk.StackTransitionType.CROSSFADE)
+            else:
+                self.props.visible_child_name = "B"
+
+    def _on_cache_result(self, cache, surface):
+        self._swap_thumbnails(surface, True)
 
     def _on_destroy(self, widget):
         # If the stack is destroyed while the art is updated, an error


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]