[gnome-builder/wip/gtk4-port: 325/1774] libide/sourceview: add simplified scroll to insert
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 325/1774] libide/sourceview: add simplified scroll to insert
- Date: Mon, 11 Jul 2022 22:31:07 +0000 (UTC)
commit 2129e251ddaaa273c1afc953dabe81dccbb48f1a
Author: Christian Hergert <chergert redhat com>
Date: Sat Apr 2 02:28:30 2022 -0700
libide/sourceview: add simplified scroll to insert
We want this abstracted from textview because we'll need our own margin
control for use with the "scroll offset" feature if it's to be ported
to GTK 4.
src/libide/sourceview/ide-source-view.c | 17 +++++++++++++++++
src/libide/sourceview/ide-source-view.h | 4 +++-
2 files changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/sourceview/ide-source-view.c b/src/libide/sourceview/ide-source-view.c
index 70270601b..dae1ed925 100644
--- a/src/libide/sourceview/ide-source-view.c
+++ b/src/libide/sourceview/ide-source-view.c
@@ -95,3 +95,20 @@ static void
ide_source_view_init (IdeSourceView *self)
{
}
+
+void
+ide_source_view_scroll_to_insert (IdeSourceView *self)
+{
+ GtkTextBuffer *buffer;
+ GtkTextView *view;
+ GtkTextMark *mark;
+
+ g_return_if_fail (IDE_IS_SOURCE_VIEW (self));
+
+ view = GTK_TEXT_VIEW (self);
+ buffer = gtk_text_view_get_buffer (view);
+ mark = gtk_text_buffer_get_insert (buffer);
+
+ /* TODO: use margin to implement "scroll offset" */
+ gtk_text_view_scroll_to_mark (view, mark, .5, FALSE, .0, .0);
+}
diff --git a/src/libide/sourceview/ide-source-view.h b/src/libide/sourceview/ide-source-view.h
index 445da7e7f..f2ebef5c3 100644
--- a/src/libide/sourceview/ide-source-view.h
+++ b/src/libide/sourceview/ide-source-view.h
@@ -32,6 +32,8 @@ IDE_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (IdeSourceView, ide_source_view, IDE, SOURCE_VIEW, GtkSourceView)
IDE_AVAILABLE_IN_ALL
-GtkWidget *ide_source_view_new (void);
+GtkWidget *ide_source_view_new (void);
+IDE_AVAILABLE_IN_ALL
+void ide_source_view_scroll_to_insert (IdeSourceView *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]