[gnome-text-editor/wip/chergert/fix-accent-colors: 3/4] recoloring: improve selection of accent colors




commit 1054e23d7f6d9ad401efb62577ddcd52f790b79b
Author: Christian Hergert <christian hergert me>
Date:   Mon Dec 27 10:33:46 2021 -0800

    recoloring: improve selection of accent colors
    
    Related #274

 src/editor-recoloring.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/editor-recoloring.c b/src/editor-recoloring.c
index b5c75b6..3ac2490 100644
--- a/src/editor-recoloring.c
+++ b/src/editor-recoloring.c
@@ -70,14 +70,14 @@ get_color (GtkSourceStyleScheme *scheme,
                 "background-set", &bg_set,
                 NULL);
 
-  if (kind == FOREGROUND && fg_set)
+  if (kind == FOREGROUND && fg && fg_set)
     gdk_rgba_parse (color, fg);
-  else if (kind == BACKGROUND && bg_set)
+  else if (kind == BACKGROUND && bg && bg_set)
     gdk_rgba_parse (color, bg);
   else
     return FALSE;
 
-  return color->alpha > 0.0;
+  return color->alpha >= .1;
 }
 
 static inline gboolean
@@ -272,7 +272,12 @@ _editor_recoloring_generate_css (GtkSourceStyleScheme *style_scheme)
       get_foreground (style_scheme, "selection", &color))
     define_color (str, "accent_fg_color", &color);
 
-  if (get_background (style_scheme, "selection", &color))
+  if (get_metadata_color (style_scheme, "accent_color", &color))
+    {
+      define_color (str, "accent_color", &color);
+    }
+  else if (get_metadata_color (style_scheme, "accent_bg_color", &color) ||
+           get_background (style_scheme, "selection", &color))
     {
       color.alpha = 1;
       define_color_mixed (str, "accent_color", &color, alt, .1);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]