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

Filter screenshots by style and environment (round 2) #2235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edwood-grant
Copy link
Contributor

Short summary

This aims for a second round to complete the work to complete #2210

This uses XDG_SESSION_DESKTOP and use either LIGHT or DARK ColorSchemeKind according to gtk_application_prefer_dark_theme.

Then it gets the screenshot environment metadata (described here: https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-screenshots) to filter screenshots that match according to priority of environment first, color scheme second.

This triggers every time you open the AppView, so you should be able to exit the Appview, then change the color scheme then go back and see changes.

The environment IDs that currently exist in AppStream can be found here: https://github.com/ximion/appstream/blob/main/data/desktop-style-ids.txt

Notice that dark style specific the :dark suffix, whereas light scheme simply does not. So I assign ColorSchemeKind.LIGHT instead of ColorSchemeKind.UNKNOWN

What I did was to get all screenshot in a temporary list and make two passes on the list:

  • The first one is to see if there are screenshots that fulfill either the desktop environment or the desktop color scheme. This is to keep some boolean to ask about this on the second pass.
  • The second pass asks questions around adding to the screenshot list class member if it passes the following criteria:
    • If the environment and style match, simply add them
    • If the environment does NOT match, but the style does AND there are no known screenshots that match style
    • If the environment does match, but the style does NOT, and there are no know screenshots that match the environment.
    • IF neither the environment nor the style match, and there are no screenshots that match neither the desktop environment nor the style
    • Null environments are automatically added, since it's impossible to assume if they fulfil the criteria or not.

The reason this is done this way is that the idea that any screenshot available is better than no screenshot. But of course we do want to have precedence on the matching desktop environment and the style, so we can technically get rid of screenshots that do not match if we know that there are existing matching ones in the list, hence the two passes.

I'm not sure if there is a better way to do this though, let me know if the PR makes sense or if it needs a better approach to the screenshots.

By the way I removed the filtering from the screenshots foreach loop and put everything in the constructor, so when it gets to that foreach loop everythig is already filtered out in screenshots. This should avoid clutter in the foreach loop and separates concerns.

Tests

Oddly enough, it's a bit difficult to test this, since there are not that many applications that use the environment tag. But doing a GitHub search, I could find some:


Harvey

Has the pantheon and pantheon:dark environment tags. It should match properly between light and dark setups.

Taxi

Has only one pantheon environment tag. It should show that one regardless of desktop color scheme.

Nicotine+

Nicotine+ has gnome and gnome:Dark screenshots. It will never match the pantheon environment, but should default to style and work with light/dark schemes.

Ruffle

Similar to Nicotine+, it has gnome and gnome:dark screenshots. There is only one gnome screenshot, so in light color scheme, it should show only one screenshot.

Synfig studio

This is the reverse of Ruffle, only one gnome:dark screenshot.

Euterpe

Has only gnome:dark screenshots. This means that it should always show the dark screenshots regardless of color scheme style.


These are the most representative applications that I could find, if you can find more, the better to test.

This use XDG_SESSION_DESKTOP and use either LIGHT or DARK ColorSchemeKind according to gtk_application_prefer_dark_theme to filter screenshots.
@edwood-grant edwood-grant force-pushed the italocapasso/issue-2210-round-2 branch from 540356c to 9edc850 Compare December 27, 2024 20:31
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.

1 participant