Skip to content

Commit

Permalink
Ensure there's always a cover, using a placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
lainsce committed Aug 7, 2024
1 parent 5e475db commit e8fbf25
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions data/app.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

<file alias="style.css">style.css</file>
<file alias="style-dark.css">style-dark.css</file>

<file alias="cover.png">assets/cover.png</file>
</gresource>
<gresource prefix="/com/fyralabs/Victrola/icons">
<file alias="scalable/actions/show-lyrics-symbolic.svg">icons/hicolor/symbolic/actions/show-lyrics-symbolic.svg</file>
Expand Down
Binary file added data/assets/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 19 additions & 2 deletions src/window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,16 @@ namespace Victrola {
buffer?.unmap ((!) info);
}
} catch (Error e) {
// w/e lol lmao even
var pixbuf = new Gdk.Pixbuf.from_resource ("/com/fyralabs/Victrola/cover.png");
var width = pixbuf.width; var height = pixbuf.height;
if (size > 0 && width > size && height > size) {
var scale = width > height ? (size / (double) height) : (size / (double) width);
var dx = (int) (width * scale + 0.5); var dy = (int) (height * scale + 0.5);
var newbuf = pixbuf.scale_simple (dx, dy, Gdk.InterpType.TILES);
if (newbuf != null)
return ((!) newbuf);
buffer?.unmap ((!) info);
}
}
}
return null;
Expand All @@ -401,7 +410,15 @@ namespace Victrola {
return ((!) newbuf);
}
} catch (Error e) {
// w/e lol lmao even
var pixbuf = new Gdk.Pixbuf.from_resource ("/com/fyralabs/Victrola/cover.png");
var width = pixbuf.width; var height = pixbuf.height;
if (size > 0 && width > size && height > size) {
var scale = width > height ? (size / (double) height) : (size / (double) width);
var dx = (int) (width * scale + 0.5); var dy = (int) (height * scale + 0.5);
var newbuf = pixbuf.scale_simple (dx, dy, Gdk.InterpType.TILES);
if (newbuf != null)
return ((!) newbuf);
}
}
return null;
}
Expand Down

0 comments on commit e8fbf25

Please sign in to comment.