Move placeholders to Gdk.Texture
This commit is contained in:
@@ -9,5 +9,6 @@
|
||||
<file alias="style.css">gtk/style.css</file>
|
||||
<file alias="style-dark.css">gtk/style-dark.css</file>
|
||||
<file>library_placeholder.svg</file>
|
||||
<file>library_placeholder_small.svg</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
1
data/library_placeholder_small.svg
Normal file
1
data/library_placeholder_small.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="2" height="2" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="url(#a)" d="M0 0h2v2H0z"/><defs><linearGradient id="a" x1="1" y1="0" x2="1" y2="2" gradientUnits="userSpaceOnUse"><stop stop-color="#9A9996"/><stop offset="1" stop-color="#5E5C64"/></linearGradient></defs></svg>
|
||||
|
After Width: | Height: | Size: 296 B |
@@ -17,7 +17,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from gi.repository import GdkPixbuf, Gio, GLib
|
||||
from gi.repository import Gdk, GdkPixbuf, Gio, GLib
|
||||
from PIL import Image, ImageFilter, ImageStat
|
||||
|
||||
from src import shared
|
||||
@@ -31,8 +31,11 @@ class GameCover:
|
||||
animation = None
|
||||
anim_iter = None
|
||||
|
||||
placeholder_pixbuf = GdkPixbuf.Pixbuf.new_from_resource_at_scale(
|
||||
shared.PREFIX + "/library_placeholder.svg", 400, 600, False
|
||||
placeholder = Gdk.Texture.new_from_resource(
|
||||
shared.PREFIX + "/library_placeholder.svg"
|
||||
)
|
||||
placeholder_small = Gdk.Texture.new_from_resource(
|
||||
shared.PREFIX + "/library_placeholder_small.svg"
|
||||
)
|
||||
|
||||
def __init__(self, pictures, path=None):
|
||||
@@ -82,7 +85,7 @@ class GameCover:
|
||||
tmp_path = Gio.File.new_tmp(None)[0].get_path()
|
||||
image.save(tmp_path, "tiff", compression=None)
|
||||
|
||||
self.blurred = GdkPixbuf.Pixbuf.new_from_file(tmp_path)
|
||||
self.blurred = Gdk.Texture.new_from_filename(tmp_path)
|
||||
|
||||
stat = ImageStat.Stat(image.convert("L"))
|
||||
|
||||
@@ -92,11 +95,8 @@ class GameCover:
|
||||
(stat.mean[0] + stat.extrema[0][1]) / 510,
|
||||
)
|
||||
else:
|
||||
self.blurred = GdkPixbuf.Pixbuf.new_from_resource_at_scale(
|
||||
shared.PREFIX + "/library_placeholder.svg", 2, 2, False
|
||||
)
|
||||
|
||||
self.luminance = (0.1, 0.8)
|
||||
self.blurred = self.placeholder_small
|
||||
self.luminance = (0.3, 0.5)
|
||||
|
||||
return self.blurred
|
||||
|
||||
@@ -113,9 +113,10 @@ class GameCover:
|
||||
self.animation = None
|
||||
else:
|
||||
for picture in self.pictures:
|
||||
if not pixbuf:
|
||||
pixbuf = self.placeholder_pixbuf
|
||||
picture.set_pixbuf(pixbuf)
|
||||
if pixbuf:
|
||||
picture.set_pixbuf(pixbuf)
|
||||
else:
|
||||
picture.set_paintable(self.placeholder)
|
||||
|
||||
def update_animation(self, data):
|
||||
if self.animation == data[1]:
|
||||
|
||||
@@ -179,7 +179,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
||||
self.details_view_game_cover = game.game_cover
|
||||
self.details_view_game_cover.add_picture(self.details_view_cover)
|
||||
|
||||
self.details_view_blurred_cover.set_pixbuf(
|
||||
self.details_view_blurred_cover.set_paintable(
|
||||
self.details_view_game_cover.get_blurred()
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user