[gtksourceview/gtksourceview-5-4] gutterrenderer: allow opting out of query_data
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gtksourceview-5-4] gutterrenderer: allow opting out of query_data
- Date: Sun, 12 Jun 2022 17:42:46 +0000 (UTC)
commit 49eb43b88b46777c266fcb8aaaffebb073000f2a
Author: Christian Hergert <chergert redhat com>
Date: Thu Apr 28 21:23:49 2022 -0700
gutterrenderer: allow opting out of query_data
That callback is not necessarily needed in many cases and will cause
signal emission (for better compatibility with older GtkSourceView).
So check for NULL and skip that in the hot path for cases where we know
it won't be used such as some high-priority subclasses.
gtksourceview/gtksourcegutterrenderer.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutterrenderer.c b/gtksourceview/gtksourcegutterrenderer.c
index a7a253f0..034ed302 100644
--- a/gtksourceview/gtksourcegutterrenderer.c
+++ b/gtksourceview/gtksourcegutterrenderer.c
@@ -192,12 +192,22 @@ gtk_source_gutter_renderer_snapshot (GtkWidget *widget,
first = gtk_source_gutter_lines_get_first (lines);
last = gtk_source_gutter_lines_get_last (lines);
- for (line = first; line <= last; line++)
+ if (klass->query_data)
{
- gtk_source_gutter_lines_get_line_yrange (lines, line, mode, &y, &h);
-
- klass->query_data (renderer, lines, line);
- klass->snapshot_line (renderer, snapshot, lines, line);
+ for (line = first; line <= last; line++)
+ {
+ gtk_source_gutter_lines_get_line_yrange (lines, line, mode, &y, &h);
+ klass->query_data (renderer, lines, line);
+ klass->snapshot_line (renderer, snapshot, lines, line);
+ }
+ }
+ else
+ {
+ for (line = first; line <= last; line++)
+ {
+ gtk_source_gutter_lines_get_line_yrange (lines, line, mode, &y, &h);
+ klass->snapshot_line (renderer, snapshot, lines, line);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]