From 1506b6b294f53608ebb2cd96f90d1da0020c93eb Mon Sep 17 00:00:00 2001 From: italo-capasso Date: Sun, 8 Dec 2024 21:58:43 -0500 Subject: [PATCH] Parse all branding colors from appstream (elementary#2140) This will attempt to find if the package branding has a scheme_preference attribute, then select the appropiate primary color matching the prefer dark theme or not. --- src/Core/Package.vala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Core/Package.vala b/src/Core/Package.vala index 295c25385..08cf6bce9 100644 --- a/src/Core/Package.vala +++ b/src/Core/Package.vala @@ -754,7 +754,16 @@ public class AppCenterCore.Package : Object { } else { var branding = component.get_branding (); if (branding != null) { - color_primary = branding.get_color (AppStream.ColorKind.PRIMARY, AppStream.ColorSchemeKind.UNKNOWN); + var gtk_settings = Gtk.Settings.get_default (); + if (gtk_settings.gtk_application_prefer_dark_theme){ + color_primary = branding.get_color (AppStream.ColorKind.PRIMARY, AppStream.ColorSchemeKind.DARK); + } else { + color_primary = branding.get_color (AppStream.ColorKind.PRIMARY, AppStream.ColorSchemeKind.LIGHT); + } + + if (color_primary == null){ + color_primary = branding.get_color (AppStream.ColorKind.PRIMARY, AppStream.ColorSchemeKind.UNKNOWN); + } } if (color_primary == null) {