[gtksourceview] gutterrenderer: allow opting out of query_data
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] gutterrenderer: allow opting out of query_data
- Date: Fri, 29 Apr 2022 04:25:21 +0000 (UTC)
commit fedaaa92ad1f7f6cf6df22035eb92c47eff799ba
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 d7d94107..44a2af79 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]