[gtksourceview] GutterRenderer: fix coding style
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] GutterRenderer: fix coding style
- Date: Wed, 3 Dec 2014 18:18:33 +0000 (UTC)
commit fd210da357bae654347bb27c427ecfef0aca8ada
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Dec 3 19:11:08 2014 +0100
GutterRenderer: fix coding style
renderer->priv->view is a GtkTextView, so we check if it's a
GtkSourceView. Once we know we have a GtkSourceView, we can assume that
the buffer is a GtkSourceBuffer and that the style scheme is NULL or
has the right type.
Also, add curly braces around one-line blocks.
gtksourceview/gtksourcegutterrenderer.c | 25 ++++++++++---------------
1 files changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutterrenderer.c b/gtksourceview/gtksourcegutterrenderer.c
index 4c285f6..d49924a 100644
--- a/gtksourceview/gtksourcegutterrenderer.c
+++ b/gtksourceview/gtksourcegutterrenderer.c
@@ -478,33 +478,28 @@ renderer_draw_impl (GtkSourceGutterRenderer *renderer,
if (renderer->priv->background_set)
{
cairo_save (cr);
-
gdk_cairo_rectangle (cr, background_area);
gdk_cairo_set_source_rgba (cr, &renderer->priv->background_color);
-
cairo_fill (cr);
cairo_restore (cr);
}
- else if ((state & GTK_SOURCE_GUTTER_RENDERER_STATE_CURSOR) != 0)
+ else if ((state & GTK_SOURCE_GUTTER_RENDERER_STATE_CURSOR) != 0 &&
+ GTK_SOURCE_IS_VIEW (renderer->priv->view))
{
+ GtkSourceBuffer *buffer;
GtkSourceStyleScheme *style_scheme;
- GtkTextBuffer *buffer;
- GtkTextView *view;
GdkRGBA line_color;
- view = gtk_source_gutter_renderer_get_view (renderer);
- if (!gtk_source_view_get_highlight_current_line (GTK_SOURCE_VIEW (view)))
- return;
-
- buffer = gtk_text_iter_get_buffer (start);
- if (!GTK_SOURCE_IS_BUFFER (buffer))
+ if (!gtk_source_view_get_highlight_current_line (GTK_SOURCE_VIEW (renderer->priv->view)))
+ {
return;
+ }
- style_scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (buffer));
- if (!GTK_SOURCE_IS_STYLE_SCHEME (style_scheme))
- return;
+ buffer = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (renderer->priv->view));
+ style_scheme = gtk_source_buffer_get_style_scheme (buffer);
- if (_gtk_source_style_scheme_get_current_line_color (style_scheme, &line_color))
+ if (style_scheme != NULL &&
+ _gtk_source_style_scheme_get_current_line_color (style_scheme, &line_color))
{
cairo_save (cr);
gdk_cairo_rectangle (cr, background_area);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]