[gnome-music/wip/jfelder/gtk4-v3: 53/110] albumsview: Use CoverPaintable
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/gtk4-v3: 53/110] albumsview: Use CoverPaintable
- Date: Wed, 2 Feb 2022 23:43:36 +0000 (UTC)
commit f77ea60442b5d674eb12fe33f9cfc988cdcd4f1e
Author: Marinus Schraal <mschraal gnome org>
Date: Sat May 15 15:31:39 2021 +0200
albumsview: Use CoverPaintable
gnomemusic/artcache.py | 11 ++++++++++-
gnomemusic/views/albumsview.py | 17 ++++++++++-------
2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/artcache.py b/gnomemusic/artcache.py
index 060cfbc12..3502b139d 100644
--- a/gnomemusic/artcache.py
+++ b/gnomemusic/artcache.py
@@ -114,6 +114,14 @@ class ArtCache(GObject.GObject):
stream.close_async(
GLib.PRIORITY_DEFAULT_IDLE, None, self._close_stream, None)
+ texture = Gdk.Texture.new_for_pixbuf(pixbuf)
+
+ if (texture
+ and (isinstance(self._coreobject, CoreAlbum)
+ or isinstance(self._coreobject, CoreSong))):
+ paintable = CoverPaintable(self._size, texture)
+ # surface = _make_icon_frame(surface, self._size, self._scale)
+
# surface = Gdk.cairo_surface_create_from_pixbuf(
# pixbuf, self._scale, None)
# if isinstance(self._coreobject, CoreArtist):
@@ -122,7 +130,8 @@ class ArtCache(GObject.GObject):
# elif (isinstance(self._coreobject, CoreAlbum)
# or isinstance(self._coreobject, CoreSong)):
# surface = make_icon_frame(surface, self._size, self._scale)
- paintable = CoverPaintable(self._size)
+ else:
+ paintable = CoverPaintable(self._size)
self._surface = paintable
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index dcfe943b4..53c3e4c6b 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -122,22 +122,25 @@ class AlbumsView(Gtk.Stack):
if first_cover is None:
return GLib.SOURCE_REMOVE
- cover_size, _ = first_cover.get_allocated_size()
- if cover_size.width == 0 or cover_size.height == 0:
+ cover_w = first_cover.get_allocated_width()
+ cover_h = first_cover.get_allocated_height()
+
+ if cover_w == 0 or cover_h == 0:
return GLib.SOURCE_REMOVE
- viewport_size, _ = self._viewport.get_allocated_size()
+ viewport_w = self._viewport.get_allocated_width()
+ viewport_h = self._viewport.get_allocated_height()
h_space = self._flowbox.get_column_spacing()
v_space = self._flowbox.get_row_spacing()
nr_cols = (
- (viewport_size.width + h_space) // (cover_size.width + h_space))
+ (viewport_w + h_space) // (cover_w + h_space))
top_left_cover = self._flowbox.get_child_at_index(
- nr_cols * (adjustment // (cover_size.height + v_space)))
+ nr_cols * (adjustment // (cover_h + v_space)))
- covers_col = math.ceil(viewport_size.width / cover_size.width)
- covers_row = math.ceil(viewport_size.height / cover_size.height)
+ covers_col = math.ceil(viewport_w / cover_w)
+ covers_row = math.ceil(viewport_h / cover_h)
children = self._flowbox.get_children()
retrieve_list = []
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]