Skip to content

Commit

Permalink
Filter screenshot by environment (#2225)
Browse files Browse the repository at this point in the history
  • Loading branch information
edwood-grant authored Dec 9, 2024
1 parent 515b4d1 commit 5e99390
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Views/AppInfoView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,22 @@ 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 (environment_id != null) {
var environment_split = environment_id.split (":", 2);
if (prefer_dark_theme && environment_split.length != 2) {
return;
}

var color_scheme = AppStream.ColorSchemeKind.from_string (environment_split[1]);
if ((prefer_dark_theme && color_scheme != AppStream.ColorSchemeKind.DARK) ||
(!prefer_dark_theme && 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 5e99390

Please sign in to comment.