Skip to content

Commit

Permalink
Filter screenshot by environment (#2210)
Browse files Browse the repository at this point in the history
Will read the environment property of the
screenshot and will only show them if prefer dark
mode is enabled in the system and the screenshot
has a dark mode environment (i.e. has ':dark' in
the environment id). Won't consider null
environments in the screenshots.
  • Loading branch information
italo-capasso committed Dec 8, 2024
1 parent 515b4d1 commit d118d0a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Views/AppInfoView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,21 @@ public class AppCenter.Views.AppInfoView : Adw.NavigationPage {
var scale = get_scale_factor ();
var min_screenshot_width = MAX_WIDTH * scale;

var prefer_dark_theme = Gtk.Settings.get_default ().gtk_application_prefer_dark_theme;
screenshots.foreach ((screenshot) => {
var environment_id = screenshot.get_environment ();
if (prefer_dark_theme && environment_id != null) {
var environment_split = environment_id.split (":", 2);
if (environment_split.length != 2) {
return;
}

var color_scheme = AppStream.ColorSchemeKind.from_string (environment_split[1]);
if (color_scheme != AppStream.ColorSchemeKind.DARK) {
return;
}
}

AppStream.Image? best_image = null;
screenshot.get_images ().foreach ((image) => {
// Image is better than no image
Expand Down

0 comments on commit d118d0a

Please sign in to comment.