[gnome-builder] code-assist: try to fully render background line
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] code-assist: try to fully render background line
- Date: Thu, 23 Oct 2014 01:36:47 +0000 (UTC)
commit 3fab1f65086d401ae2c1de794abd7770621c0a93
Author: Christian Hergert <christian hergert me>
Date: Wed Oct 22 18:35:56 2014 -0700
code-assist: try to fully render background line
src/editor/gb-editor-code-assistant.c | 35 ++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/src/editor/gb-editor-code-assistant.c b/src/editor/gb-editor-code-assistant.c
index 3438636..52a232b 100644
--- a/src/editor/gb-editor-code-assistant.c
+++ b/src/editor/gb-editor-code-assistant.c
@@ -407,6 +407,7 @@ on_query_tooltip (GbSourceView *source_view,
static void
highlight_line (GbSourceView *source_view,
cairo_t *cr,
+ gint width,
guint line,
GcaSeverity severity)
{
@@ -449,8 +450,16 @@ highlight_line (GbSourceView *source_view,
GTK_TEXT_WINDOW_TEXT,
rect.x, rect.y, &rect.x, &rect.y);
- /* TODO: get proper width */
- rect.width = 2000;
+ /*
+ * WORKAROUND:
+ *
+ * Try to render outside the current area so that pixel cache picks up
+ * the line rendering. Probably a better way to do this, as I'm not sure
+ * this actually covers all the corner cases. In particular, if you have
+ * lots of non-visible space (>200px).
+ */
+ rect.x = -200;
+ rect.width = width + 400;
cairo_set_line_width (cr, 1.0);
@@ -473,8 +482,12 @@ on_draw_layer (GbSourceView *source_view,
GbEditorTab *tab)
{
GbEditorTabPrivate *priv = tab->priv;
+ GtkRequisition req;
+ GtkAllocation alloc;
GHashTableIter iter;
+ GdkWindow *window;
gpointer k, v;
+ gint width;
if (layer != GTK_TEXT_VIEW_LAYER_BELOW)
return;
@@ -482,6 +495,22 @@ on_draw_layer (GbSourceView *source_view,
if (!priv->gca_error_lines)
return;
+ window = gtk_text_view_get_window (GTK_TEXT_VIEW (source_view),
+ GTK_TEXT_WINDOW_TEXT);
+ if (!window)
+ return;
+
+ /*
+ * WORKAROUND:
+ *
+ * I'm not sure if there is a better way to do this, but we are trying to
+ * determine the size of the textview inside of the scrolled window.
+ * We need this to draw the highlight line wide enough.
+ */
+ gtk_widget_get_allocation (GTK_WIDGET (source_view), &alloc);
+ gtk_widget_get_preferred_size (GTK_WIDGET (source_view), NULL, &req);
+ width = MAX (alloc.width, req.width);
+
g_hash_table_iter_init (&iter, priv->gca_error_lines);
while (g_hash_table_iter_next (&iter, &k, &v))
@@ -489,7 +518,7 @@ on_draw_layer (GbSourceView *source_view,
guint line = GPOINTER_TO_INT (k);
GcaSeverity severity = GPOINTER_TO_INT (v);
- highlight_line (source_view, cr, line, severity);
+ highlight_line (source_view, cr, width, line, severity);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]