[gnome-music/wip/jfelder/album-cover-editordialog: 1/2] coverstack: Factor out surface change



commit f402298e4d4e7059e9e0da641a2027be718f43e8
Author: Jean Felder <jfelder src gnome org>
Date:   Tue Jan 29 23:51:10 2019 +0100

    coverstack: Factor out surface change
    
    Surface update can now be called from outside the class. It will be
    used by AlbumEditorDialog.

 gnomemusic/widgets/coverstack.py | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/widgets/coverstack.py b/gnomemusic/widgets/coverstack.py
index 4a981193..de0a1d42 100644
--- a/gnomemusic/widgets/coverstack.py
+++ b/gnomemusic/widgets/coverstack.py
@@ -117,6 +117,22 @@ class CoverStack(Gtk.Stack):
         self._handler_id = self._art.connect('finished', self._art_retrieved)
         self._art.lookup()
 
+    @log
+    def update_from_surface(self, surface):
+        """Update CoverStack surface
+
+        :param cairo.ImageSurface surface: the new surface
+        """
+        if self._active_child == "B":
+            self._cover_a.props.surface = surface
+            self.props.visible_child_name = "A"
+        else:
+            self._cover_b.props.surface = surface
+            self.props.visible_child_name = "B"
+        self._active_child = self.props.visible_child_name
+
+        self.emit('updated')
+
     @log
     def _set_loading_child(self):
         self.props.visible_child_name = "loading"
@@ -131,14 +147,5 @@ class CoverStack(Gtk.Stack):
             GLib.source_remove(self._timeout)
             self._timeout = None
 
-        if self._active_child == "B":
-            self._cover_a.props.surface = klass.surface
-            self.props.visible_child_name = "A"
-        else:
-            self._cover_b.props.surface = klass.surface
-            self.props.visible_child_name = "B"
-
-        self._active_child = self.props.visible_child_name
+        self.update_from_surface(klass.surface)
         self._art = None
-
-        self.emit('updated')


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