Place cover at vertical center
All checks were successful
PostmarketOS Build / Prepare (push) Successful in 5s
PostmarketOS Build / Build for aarch64 (push) Successful in 2m30s
PostmarketOS Build / Build for x86_64 (push) Successful in 55s

Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
Vasiliy Doylov 2025-07-11 01:30:01 +03:00
parent aebae5ef4c
commit 0952dbaf81
2 changed files with 18 additions and 2 deletions

View file

@ -64,7 +64,6 @@ public class MediaPlayer.Player : Gtk.Box {
background-color: $hover;
}
";
message ("%s", data);
try {
css_provider.load_from_data (data);
} catch (Error err) {
@ -138,7 +137,9 @@ public class MediaPlayer.Player : Gtk.Box {
// Start background generator
run_color_thred (pixbuff.scale_simple (64, 64, Gdk.InterpType.BILINEAR));
return Utils.round_pixbuff (pixbuff, (110.0 - 10.0) /* pixel-size - padding :TODO: REMOVE WHEN PHOSH MOVES TO GTK4 */ / 10 / 100);
// TODO: REMOVE WHEN PHOSH MOVES TO GTK4
pixbuff = Utils.round_pixbuff (pixbuff, (110.0 - 10.0 /* pixel-size - padding */) / 10 / 100);
return Utils.rect_pixbuff (pixbuff);
}
public void bind_to_player (Gtk.Box player) {

View file

@ -65,6 +65,21 @@ namespace Utils {
return Gdk.pixbuf_get_from_surface (surface, 0, 0, width, height);
}
public Gdk.Pixbuf rect_pixbuff (Gdk.Pixbuf source) {
// That's a hack for GTK3. TODO: Remove when phosh will be moved to gtk4
var width = source.width;
var height = source.height;
if (width == height)
return source;
var max_dim = int.max (width, height);
var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, max_dim, max_dim);
var cr = new Cairo.Context (surface);
Gdk.cairo_set_source_pixbuf (cr, source, 0, (width - height) / 2);
cr.paint ();
return Gdk.pixbuf_get_from_surface (surface, 0, 0, max_dim, max_dim);
}
public double deg (double deg) {
return Math.PI / 180.0 * deg;
}