[gtksourceview/wip/gutter-draw-refactoring: 2/3] gutter: better variable name for the renderer widths
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/gutter-draw-refactoring: 2/3] gutter: better variable name for the renderer widths
- Date: Sun, 23 Nov 2014 17:15:22 +0000 (UTC)
commit 71fa45607d94a43243df3c680dea2ac9bc24a7c5
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Nov 23 17:55:33 2014 +0100
gutter: better variable name for the renderer widths
gtksourceview/gtksourcegutter.c | 57 ++++++++++++++++++++++++--------------
1 files changed, 36 insertions(+), 21 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutter.c b/gtksourceview/gtksourcegutter.c
index a0c9f01..65451cc 100644
--- a/gtksourceview/gtksourcegutter.c
+++ b/gtksourceview/gtksourcegutter.c
@@ -353,8 +353,8 @@ do_redraw (GtkSourceGutter *gutter)
}
static gint
-calculate_gutter_size (GtkSourceGutter *gutter,
- GArray *sizes)
+calculate_gutter_size (GtkSourceGutter *gutter,
+ GArray *sizes)
{
GList *item;
gint total_width = 0;
@@ -966,7 +966,7 @@ apply_style (GtkSourceGutter *gutter,
*/
static void
begin_draw (GtkSourceGutter *gutter,
- GArray *sizes,
+ GArray *renderer_widths,
GdkRectangle background_area,
GtkTextIter *start,
GtkTextIter *end,
@@ -974,32 +974,33 @@ begin_draw (GtkSourceGutter *gutter,
{
GdkRectangle cell_area;
GList *l;
- gint idx;
+ gint renderer_num;
cell_area = background_area;
- for (l = gutter->priv->renderers, idx = 0;
+ for (l = gutter->priv->renderers, renderer_num = 0;
l != NULL;
- l = l->next, idx++)
+ l = l->next, renderer_num++)
{
Renderer *renderer = l->data;
gint width;
gint xpad;
+ width = g_array_index (renderer_widths, gint, renderer_num);
+
if (!gtk_source_gutter_renderer_get_visible (renderer->renderer))
{
+ g_assert_cmpint (width, ==, 0);
continue;
}
- width = g_array_index (sizes, gint, idx);
-
gtk_source_gutter_renderer_get_padding (renderer->renderer,
&xpad,
NULL);
background_area.width = width;
- cell_area.width = width - 2 * xpad;
+ cell_area.width = background_area.width - 2 * xpad;
cell_area.x = background_area.x + xpad;
cairo_save (cr);
@@ -1023,7 +1024,7 @@ begin_draw (GtkSourceGutter *gutter,
static void
draw_cells (GtkSourceGutter *gutter,
GtkTextView *view,
- GArray *sizes,
+ GArray *renderer_widths,
GArray *pixels,
GArray *heights,
GArray *numbers,
@@ -1075,8 +1076,8 @@ draw_cells (GtkSourceGutter *gutter,
GdkRectangle background_area;
gint pos;
gint line_to_paint;
+ gint renderer_num;
GList *l;
- gint idx;
end = start;
@@ -1098,9 +1099,9 @@ draw_cells (GtkSourceGutter *gutter,
background_area.height = g_array_index (heights, gint, i);
background_area.x = 0;
- for (l = gutter->priv->renderers, idx = 0;
+ for (l = gutter->priv->renderers, renderer_num = 0;
l != NULL;
- l = l->next, idx++)
+ l = l->next, renderer_num++)
{
Renderer *renderer;
GdkRectangle cell_area;
@@ -1110,10 +1111,11 @@ draw_cells (GtkSourceGutter *gutter,
gint ypad;
renderer = l->data;
- width = g_array_index (sizes, gint, idx);
+ width = g_array_index (renderer_widths, gint, renderer_num);
if (!gtk_source_gutter_renderer_get_visible (renderer->renderer))
{
+ g_assert_cmpint (width, ==, 0);
continue;
}
@@ -1204,7 +1206,7 @@ on_view_draw (GtkSourceView *view,
GtkTextView *text_view;
gint y1;
gint y2;
- GArray *sizes;
+ GArray *renderer_widths;
GArray *pixels;
GArray *heights;
GArray *numbers;
@@ -1241,8 +1243,8 @@ on_view_draw (GtkSourceView *view,
NULL,
&y2);
- sizes = g_array_new (FALSE, FALSE, sizeof (gint));
- calculate_gutter_size (gutter, sizes);
+ renderer_widths = g_array_new (FALSE, FALSE, sizeof (gint));
+ calculate_gutter_size (gutter, renderer_widths);
pixels = g_array_new (FALSE, FALSE, sizeof (gint));
heights = g_array_new (FALSE, FALSE, sizeof (gint));
@@ -1270,9 +1272,22 @@ on_view_draw (GtkSourceView *view,
gtk_style_context_save (style_context);
apply_style (gutter, view, style_context, cr);
- begin_draw (gutter, sizes, background_area, &start, &end, cr);
-
- draw_cells (gutter, text_view, sizes, pixels, heights, numbers, count, &start, cr);
+ begin_draw (gutter,
+ renderer_widths,
+ background_area,
+ &start,
+ &end,
+ cr);
+
+ draw_cells (gutter,
+ text_view,
+ renderer_widths,
+ pixels,
+ heights,
+ numbers,
+ count,
+ &start,
+ cr);
/* Allow to call queue_redraw() in ::end. */
gutter->priv->is_drawing = FALSE;
@@ -1281,7 +1296,7 @@ on_view_draw (GtkSourceView *view,
gtk_style_context_restore (style_context);
- g_array_free (sizes, TRUE);
+ g_array_free (renderer_widths, TRUE);
g_array_free (pixels, TRUE);
g_array_free (heights, TRUE);
g_array_free (numbers, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]