From af8ac2f7d7b728aca6ba5c7e986adfe614f377e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ab=C3=ADlio=20Costa?= Date: Sun, 21 Apr 2024 09:40:57 +0100 Subject: [PATCH] Add MPRIS background blur for app icons (#369) * Fix default mpris icon size The widget was was using the .ui size instead of the user config size in the following situations: - there was no media player app - the media player app icon was used - the audio-x-generic-symbolic icon was used This fix sets the default size for the album art icon according to the user's config. set_from_gicon and set_from_icon_name receive a Gtk.IconSize enum value, not an int, so we need to call set_pixel_size to set the proper size. * Add MPRIS background blur for app icons --------- Co-authored-by: Erik Reider <35975961+ErikReider@users.noreply.github.com> --- .../widgets/mpris/mpris_player.vala | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/controlCenter/widgets/mpris/mpris_player.vala b/src/controlCenter/widgets/mpris/mpris_player.vala index 50f5cdb7..be78b284 100644 --- a/src/controlCenter/widgets/mpris/mpris_player.vala +++ b/src/controlCenter/widgets/mpris/mpris_player.vala @@ -380,12 +380,28 @@ namespace SwayNotificationCenter.Widgets.Mpris { if (desktop_entry is DesktopAppInfo) { icon = desktop_entry.get_icon (); } + Gtk.IconInfo ? icon_info = null; if (icon != null) { album_art.set_from_gicon (icon, Gtk.IconSize.INVALID); + icon_info = Gtk.IconTheme.get_default ().lookup_by_gicon (icon, + mpris_config.image_size, + Gtk.IconLookupFlags.USE_BUILTIN); } else { // Default icon - album_art.set_from_icon_name ("audio-x-generic-symbolic", + string icon_name = "audio-x-generic-symbolic"; + album_art.set_from_icon_name (icon_name, Gtk.IconSize.INVALID); + icon_info = Gtk.IconTheme.get_default ().lookup_icon (icon_name, + mpris_config.image_size, + Gtk.IconLookupFlags.USE_BUILTIN); + } + + if (icon_info != null) { + try { + this.album_art_pixbuf = icon_info.load_icon (); + } catch (Error e) { + warning ("Could not load icon: %s", e.message); + } } }