[gnome-builder] GbEditorFrame: only scroll to iter on search if it is not visible
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbEditorFrame: only scroll to iter on search if it is not visible
- Date: Wed, 31 Dec 2014 23:09:11 +0000 (UTC)
commit 2221d9e018482095d8c81bfffa50343ca1b1908e
Author: Christian Hergert <christian hergert me>
Date: Wed Dec 31 15:08:28 2014 -0800
GbEditorFrame: only scroll to iter on search if it is not visible
https://bugzilla.gnome.org/show_bug.cgi?id=742166
src/editor/gb-editor-frame.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index dd997ff..5d5cf3c 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -76,18 +76,21 @@ gb_editor_frame_link (GbEditorFrame *src,
static void
gb_editor_frame_restore_position (GbEditorFrame *self)
{
+ GtkTextView *text_view;
GtkTextIter iter;
GtkTextBuffer *buffer;
g_return_if_fail (GB_IS_EDITOR_FRAME (self));
- buffer = GTK_TEXT_BUFFER (self->priv->document);
+ text_view = GTK_TEXT_VIEW (self->priv->source_view);
+ buffer = gtk_text_view_get_buffer (text_view);
+
gb_gtk_text_buffer_get_iter_at_line_and_offset (buffer, &iter,
self->priv->saved_line,
self->priv->saved_line_offset);
gtk_text_buffer_select_range (buffer, &iter, &iter);
- gb_gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (self->priv->source_view),
- &iter, 0.25, TRUE, 0.0, 0.5);
+ if (!gb_gtk_text_view_get_iter_visible (text_view, &iter))
+ gb_gtk_text_view_scroll_to_iter (text_view, &iter, 0.25, TRUE, 0.0, 0.5);
}
static void
@@ -176,8 +179,11 @@ gb_editor_frame_move_next_match (GbEditorFrame *self,
found_match:
gtk_text_buffer_select_range (GTK_TEXT_BUFFER (priv->document),
&match_begin, &match_end);
- gb_gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (priv->source_view),
- &match_begin, 0.0, TRUE, 0.5, 0.5);
+
+ if (!gb_gtk_text_view_get_iter_visible (GTK_TEXT_VIEW (priv->source_view),
+ &match_begin))
+ gb_gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (priv->source_view),
+ &match_begin, 0.0, TRUE, 0.5, 0.5);
EXIT;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]