[gnome-builder] navigation: preserve line offset in editor navigation items.



commit 125951fc67cf04d10c86d0ab9647ea8d9b4e659c
Author: Christian Hergert <christian hergert me>
Date:   Wed Sep 24 19:48:37 2014 -0700

    navigation: preserve line offset in editor navigation items.

 src/editor/gb-editor-navigation-item.c |    6 +++++-
 src/editor/gb-editor-tab.c             |    4 +++-
 src/editor/gb-editor-tab.h             |    3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/editor/gb-editor-navigation-item.c b/src/editor/gb-editor-navigation-item.c
index 1323b90..ef3df8f 100644
--- a/src/editor/gb-editor-navigation-item.c
+++ b/src/editor/gb-editor-navigation-item.c
@@ -16,6 +16,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#define G_LOG_DOMAIN "editor-navigation"
+
 #include <glib/gi18n.h>
 
 #include "gb-editor-navigation-item.h"
@@ -177,7 +179,9 @@ gb_editor_navigation_item_activate (GbNavigationItem *item)
                                    "position", &page,
                                    NULL);
           gtk_notebook_set_current_page (GTK_NOTEBOOK (parent), page);
-          gb_editor_tab_scroll_to_line (self->priv->tab, self->priv->line);
+          gb_editor_tab_scroll_to_line (self->priv->tab,
+                                        self->priv->line,
+                                        self->priv->line_offset);
           gtk_widget_grab_focus (GTK_WIDGET (self->priv->tab));
         }
     }
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 16d9e0e..adc01aa 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -854,7 +854,8 @@ on_source_view_push_snippet (GbSourceView           *source_view,
 
 void
 gb_editor_tab_scroll_to_line (GbEditorTab *tab,
-                              guint        line)
+                              guint        line,
+                              guint        line_offset)
 {
   GtkTextIter iter;
 
@@ -862,6 +863,7 @@ gb_editor_tab_scroll_to_line (GbEditorTab *tab,
 
   gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (tab->priv->document),
                                     &iter, line);
+  gtk_text_iter_set_line_offset (&iter, line_offset);
   gtk_text_buffer_select_range (GTK_TEXT_BUFFER (tab->priv->document),
                                 &iter, &iter);
   gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (tab->priv->source_view), &iter,
diff --git a/src/editor/gb-editor-tab.h b/src/editor/gb-editor-tab.h
index 2db26b3..61961f8 100644
--- a/src/editor/gb-editor-tab.h
+++ b/src/editor/gb-editor-tab.h
@@ -61,7 +61,8 @@ void              gb_editor_tab_set_font_desc  (GbEditorTab                *tab,
                                                 const PangoFontDescription *font_desc);
 gboolean          gb_editor_tab_get_is_default (GbEditorTab                *tab);
 void              gb_editor_tab_scroll_to_line (GbEditorTab                *tab,
-                                                guint                       line);
+                                                guint                       line,
+                                                guint                       line_offset);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]