Skip to content

Commit

Permalink
Add MPRIS background blur for app icons (#369)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
abmantis and ErikReider authored Apr 21, 2024
1 parent 8cb9be5 commit af8ac2f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/controlCenter/widgets/mpris/mpris_player.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit af8ac2f

Please sign in to comment.