[gnome-builder] libide: add IdeSourceView::scroll-offset



commit d048e2a08656b2061b2d7b3fb4f54d46726b45ae
Author: Christian Hergert <christian hergert me>
Date:   Thu Mar 5 21:40:31 2015 -0800

    libide: add IdeSourceView::scroll-offset
    
    Nothing is respecting this yet, but we will start applying that in the
    near future based on this parameter. Some movements (such as screen
    positions will need to take this into account).

 libide/ide-source-view.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++
 libide/ide-source-view.h |    3 ++
 2 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index ed8dd9a..f7bec5a 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -77,6 +77,8 @@ typedef struct
   gulong                       buffer_notify_highlight_diagnostics_handler;
   gulong                       buffer_notify_language_handler;
 
+  guint                        scroll_offset;
+
   guint                        saved_line;
   guint                        saved_line_offset;
 
@@ -99,6 +101,7 @@ enum {
   PROP_FONT_DESC,
   PROP_INSERT_MATCHING_BRACE,
   PROP_OVERWRITE_BRACES,
+  PROP_SCROLL_OFFSET,
   PROP_SHOW_GRID_LINES,
   PROP_SHOW_LINE_CHANGES,
   PROP_SNIPPET_COMPLETION,
@@ -2208,6 +2211,10 @@ ide_source_view_get_property (GObject    *object,
       g_value_set_boolean (value, ide_source_view_get_overwrite_braces (self));
       break;
 
+    case PROP_SCROLL_OFFSET:
+      g_value_set_uint (value, ide_source_view_get_scroll_offset (self));
+      break;
+
     case PROP_SHOW_GRID_LINES:
       g_value_set_boolean (value, ide_source_view_get_show_grid_lines (self));
       break;
@@ -2257,6 +2264,10 @@ ide_source_view_set_property (GObject      *object,
       ide_source_view_set_overwrite_braces (self, g_value_get_boolean (value));
       break;
 
+    case PROP_SCROLL_OFFSET:
+      ide_source_view_set_scroll_offset (self, g_value_get_uint (value));
+      break;
+
     case PROP_SHOW_GRID_LINES:
       ide_source_view_set_show_grid_lines (self, g_value_get_boolean (value));
       break;
@@ -2346,6 +2357,17 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
   g_object_class_install_property (object_class, PROP_OVERWRITE_BRACES,
                                    gParamSpecs [PROP_OVERWRITE_BRACES]);
 
+  gParamSpecs [PROP_SCROLL_OFFSET] =
+    g_param_spec_uint ("scroll-offset",
+                       _("Scroll Offset"),
+                       _("The number of lines between the insertion cursor and screen boundary."),
+                       0,
+                       G_MAXUINT,
+                       0,
+                       (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_SCROLL_OFFSET,
+                                   gParamSpecs [PROP_SCROLL_OFFSET]);
+
   gParamSpecs [PROP_SHOW_GRID_LINES] =
     g_param_spec_boolean ("show-grid-lines",
                           _("Show Grid Lines"),
@@ -2973,3 +2995,41 @@ ide_source_view_jump (IdeSourceView     *self,
 
   g_signal_emit (self, gSignals [JUMP], 0, location);
 }
+
+/**
+ * ide_source_view_get_scroll_offset:
+ *
+ * Gets the #IdeSourceView:scroll-offset property. This property contains the number of lines
+ * that should be kept above or below the line containing the insertion cursor relative to the
+ * top and bottom of the visible text window.
+ */
+guint
+ide_source_view_get_scroll_offset (IdeSourceView *self)
+{
+  IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+
+  g_return_val_if_fail (IDE_IS_SOURCE_VIEW (self), 0);
+
+  return priv->scroll_offset;
+}
+
+/**
+ * ide_source_view_set_scroll_offset:
+ *
+ * Sets the #IdeSourceView:scroll-offset property. See ide_source_view_get_scroll_offset() for
+ * more information. Set to 0 to unset this property.
+ */
+void
+ide_source_view_set_scroll_offset (IdeSourceView *self,
+                                   guint          scroll_offset)
+{
+  IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+
+  g_return_if_fail (IDE_IS_SOURCE_VIEW (self));
+
+  if (scroll_offset != priv->scroll_offset)
+    {
+      priv->scroll_offset = scroll_offset;
+      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_SCROLL_OFFSET]);
+    }
+}
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index ef91aa0..345f12d 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -228,6 +228,7 @@ IdeBackForwardList         *ide_source_view_get_back_forward_list     (IdeSource
 const PangoFontDescription *ide_source_view_get_font_desc             (IdeSourceView              *self);
 gboolean                    ide_source_view_get_insert_matching_brace (IdeSourceView              *self);
 gboolean                    ide_source_view_get_overwrite_braces      (IdeSourceView              *self);
+guint                       ide_source_view_get_scroll_offset         (IdeSourceView              *self);
 gboolean                    ide_source_view_get_show_grid_lines       (IdeSourceView              *self);
 gboolean                    ide_source_view_get_show_line_changes     (IdeSourceView              *self);
 gboolean                    ide_source_view_get_snippet_completion    (IdeSourceView              *self);
@@ -243,6 +244,8 @@ void                        ide_source_view_set_insert_matching_brace (IdeSource
                                                                        gboolean                    
insert_matching_brace);
 void                        ide_source_view_set_overwrite_braces      (IdeSourceView              *self,
                                                                        gboolean                    
overwrite_braces);
+void                        ide_source_view_set_scroll_offset         (IdeSourceView              *self,
+                                                                       guint                       
scroll_offset);
 void                        ide_source_view_set_show_grid_lines       (IdeSourceView              *self,
                                                                        gboolean                    
show_grid_lines);
 void                        ide_source_view_set_show_line_changes     (IdeSourceView              *self,


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