[gtksourceview] map: improve fallbacks when no hover color is specified



commit f66b31e602d7d3140e17b0be7f66f8bdce9fc32b
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jul 20 16:29:45 2021 -0700

    map: improve fallbacks when no hover color is specified

 gtksourceview/gtksourcemap.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/gtksourceview/gtksourcemap.c b/gtksourceview/gtksourcemap.c
index a94647a5..c9bc7795 100644
--- a/gtksourceview/gtksourcemap.c
+++ b/gtksourceview/gtksourcemap.c
@@ -33,6 +33,7 @@
 #include "gtksourcestyle-private.h"
 #include "gtksourcestylescheme.h"
 #include "gtksourceutils-private.h"
+#include "gtksourceview-private.h"
 
 #define SCRUBBER_MIN_HEIGHT 10
 #define DRAG_THRESHOLD      5.0
@@ -372,12 +373,11 @@ gtk_source_map_rebuild_css (GtkSourceMap *map)
 
        if (style_scheme != NULL)
        {
-
-               style = gtk_source_style_scheme_get_style (style_scheme, "map-overlay");
-
-               if (style == NULL)
+               if (!(style = gtk_source_style_scheme_get_style (style_scheme, "map-overlay")) &&
+                   !(style = gtk_source_style_scheme_get_style (style_scheme, "selection")) &&
+                   !(style = gtk_source_style_scheme_get_style (style_scheme, "current-line")))
                {
-                       style = gtk_source_style_scheme_get_style (style_scheme, "selection");
+                       /* Do Nothing */
                }
        }
 
@@ -403,6 +403,16 @@ gtk_source_map_rebuild_css (GtkSourceMap *map)
                        g_clear_pointer (&background, g_free);
                }
        }
+       else
+       {
+               GdkRGBA bg;
+
+               if (_gtk_source_view_get_current_line_background (priv->view, &bg))
+               {
+                       bg.alpha = 0.3;
+                       background = gdk_rgba_to_string (&bg);
+               }
+       }
 
        priv->had_color = background != NULL;
 


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