[gnome-builder] editor: get warning/error color from current style scheme
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: get warning/error color from current style scheme
- Date: Tue, 18 Nov 2014 05:42:56 +0000 (UTC)
commit b01b98cf85af4ca676f1b0d51b8c0ff57cf03581
Author: Christian Hergert <christian hergert me>
Date: Mon Nov 17 21:42:01 2014 -0800
editor: get warning/error color from current style scheme
src/editor/gb-editor-code-assistant.c | 49 ++++++++++++++++++++++-----------
1 files changed, 33 insertions(+), 16 deletions(-)
---
diff --git a/src/editor/gb-editor-code-assistant.c b/src/editor/gb-editor-code-assistant.c
index 04586f6..87837fa 100644
--- a/src/editor/gb-editor-code-assistant.c
+++ b/src/editor/gb-editor-code-assistant.c
@@ -409,36 +409,60 @@ highlight_line (GbSourceView *source_view,
guint line,
GcaSeverity severity)
{
+ GtkSourceStyleScheme *scheme;
+ GtkSourceStyle *style;
GtkAllocation alloc;
GtkTextBuffer *buffer;
GtkTextIter iter;
GdkRectangle rect;
GdkRGBA color;
- GdkRGBA shaded;
+ gchar *bg = NULL;
+
+ /*
+ * TODO: Move all this style parsing into outer function to save on
+ * useless overhead.
+ */
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (source_view));
+ if (!GTK_SOURCE_IS_BUFFER (buffer))
+ return;
+
+ scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (buffer));
+ if (!scheme)
+ return;
+
+ style = gtk_source_style_scheme_get_style (scheme, "def:error");
+ if (!style)
+ return;
+
switch (severity)
{
case GCA_SEVERITY_DEPRECATED:
case GCA_SEVERITY_WARNING:
- gdk_rgba_parse (&color, "#fce94f");
- color.alpha = 0.125;
+ style = gtk_source_style_scheme_get_style (scheme, "def:warning");
+ if (!style)
+ return;
+ g_object_get (style, "background", &bg, NULL);
+ gdk_rgba_parse (&color, bg);
break;
case GCA_SEVERITY_FATAL:
case GCA_SEVERITY_ERROR:
- gdk_rgba_parse (&color, "#cc0000");
- color.alpha = 0.125;
+ style = gtk_source_style_scheme_get_style (scheme, "def:error");
+ if (!style)
+ return;
+ g_object_get (style, "background", &bg, NULL);
+ gdk_rgba_parse (&color, bg);
break;
case GCA_SEVERITY_INFO:
case GCA_SEVERITY_NONE:
default:
- gdk_rgba_parse (&color, "#ffffff");
- color.alpha = 0.0;
- break;
+ return;
}
- gb_rgba_shade (&color, &shaded, 0.8);
+ g_free (bg);
gtk_widget_get_allocation (GTK_WIDGET (source_view), &alloc);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (source_view));
@@ -464,13 +488,6 @@ highlight_line (GbSourceView *source_view,
cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
gdk_cairo_set_source_rgba (cr, &color);
cairo_fill (cr);
-
- cairo_move_to (cr, rect.x, rect.y);
- cairo_line_to (cr, rect.x + rect.width, rect.y);
- cairo_move_to (cr, rect.x, rect.y + rect.height);
- cairo_line_to (cr, rect.x + rect.width, rect.y + rect.height);
- gdk_cairo_set_source_rgba (cr, &shaded);
- cairo_stroke (cr);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]