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>
This commit is contained in:
Abílio Costa 2024-04-21 09:40:57 +01:00 committed by GitHub
parent 8cb9be5970
commit af8ac2f7d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
}
}
}