Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing dominant color #2045

Merged
merged 3 commits into from
Aug 14, 2023
Merged

Conversation

jrom99
Copy link
Contributor

@jrom99 jrom99 commented Jun 16, 2023

This is the same attempt to fix #1493, in which we separate Gio.ThemedIcon from Gio.LoadableIcon but now with the const keyword and using list unpacking, as is done in similar pieces around the file.

I apologise for closing the previous merge request, GitHub asked to remove my previous commit when I clicked to sync my branch.

I read the documentation on how to cache and async it, but I couldn't make sense of the documentation, sorry.

When iconTexture is a Gio.ThemedIcon, it seems we can use choose_icon or lookup_icon, and the former is better suited as it's able to check for all possible names (which is useful as Papirus theme doesn't use the first name available for drive-harddisk).

There's also a fourth case that I have trouble replicating, in which the icon is an emblem (I don't know the icon type), such as when an external HD is mounted. This doesn't apply to other emblem-like icons, such as mounted network devices and the trash can. This emblem raises a iconTexture.load is not a function error.

Some icons are not `Gio.ThemedIcon`, but ` Gio.LoadableIcon`, so we can get their pixel buffer from memory. Updated with `const` and list unpacking as used elsewhere in the file.
If the dominant color is missing (icon cannot be loaded), then a sensible fallback is used so that a running dot is still displayed.
Replaced `lookup_icon` with `choose_icon`, since it keeps looking in the current theme for a themed icon using all of its available names instead of only one. While `Gio.ThemedIcon` offers a `iconTexture.load_icon()`, it only looks for the first name available and fails otherwise.

Also, `iconInfo` has been renamed to `iconBuffer` since `Gio.LoadableIcon` returns a stream/buffer (or should outright fail, which I could not observe yet).

Could not find an example of app that uses a `Gio.EmblemedIcon` or any other implementation (i.e.: lacking `iconTexture.load`) that would justify another branching.
@3v1n0
Copy link
Collaborator

3v1n0 commented Aug 14, 2023

Looks good, thanks a lot!

@3v1n0 3v1n0 merged commit cc089fe into micheleg:master Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dominant color CSS doesn't work for some apps
2 participants