Skip to content

Commit

Permalink
Filter screenshots by style if prefer dark mode (elementary#2210)
Browse files Browse the repository at this point in the history
If the environment (if any) does not match the prefer dark setup.
Won't consider null environments.
  • Loading branch information
italo-capasso committed Dec 8, 2024
1 parent 515b4d1 commit 5363daa
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 5363daa

Please sign in to comment.