[gnome-builder/wip/libide] libide: add stub implementation for ide_buffer_get_line_flags()



commit 7fce872646efd04a27d9bcb569c94cfb0489ed26
Author: Christian Hergert <christian hergert me>
Date:   Tue Feb 24 14:30:27 2015 -0800

    libide: add stub implementation for ide_buffer_get_line_flags()
    
    This function will eventually track the changes in a buffer based on the
    response from the Vcs. Doing so will give us a bit better abstraction
    over the current git implementation.
    
    We'll probably implement the lookup hash independently though, so it can
    be resused based on diff callbacks from the VCS implementation.

 libide/ide-buffer.c |  124 ++++++++++++++++++++++++++++++++-------------------
 libide/ide-buffer.h |   22 +++++++--
 2 files changed, 95 insertions(+), 51 deletions(-)
---
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index dbe734f..7f46519 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -48,21 +48,6 @@ enum {
 
 static GParamSpec *gParamSpecs [LAST_PROP];
 
-/**
- * ide_buffer_get_context:
- *
- * Gets the #IdeBuffer:context property. This is the #IdeContext that owns the buffer.
- *
- * Returns: (transfer none): An #IdeContext.
- */
-IdeContext *
-ide_buffer_get_context (IdeBuffer *self)
-{
-  g_return_val_if_fail (IDE_IS_BUFFER (self), NULL);
-
-  return self->context;
-}
-
 static void
 ide_buffer_set_context (IdeBuffer  *self,
                         IdeContext *context)
@@ -74,37 +59,6 @@ ide_buffer_set_context (IdeBuffer  *self,
   ide_set_weak_pointer (&self->context, context);
 }
 
-/**
- * ide_buffer_get_file:
- *
- * Gets the underlying file behind the buffer.
- *
- * Returns: (transfer none): An #IdeFile.
- */
-IdeFile *
-ide_buffer_get_file (IdeBuffer *self)
-{
-  g_return_val_if_fail (IDE_IS_BUFFER (self), NULL);
-
-  return self->file;
-}
-
-/**
- * ide_buffer_set_file:
- *
- * Sets the underlying file to use when saving and loading @self to and and from storage.
- */
-void
-ide_buffer_set_file (IdeBuffer *self,
-                     IdeFile   *file)
-{
-  g_return_if_fail (IDE_IS_BUFFER (self));
-  g_return_if_fail (IDE_IS_FILE (file));
-
-  if (g_set_object (&self->file, file))
-    g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_FILE]);
-}
-
 static void
 ide_buffer_finalize (GObject *object)
 {
@@ -195,3 +149,81 @@ static void
 ide_buffer_init (IdeBuffer *self)
 {
 }
+
+GType
+ide_buffer_line_flags_get_type (void)
+{
+  static gsize type_id;
+
+  if (g_once_init_enter (&type_id))
+    {
+      GType _type_id;
+      const static GFlagsValue values[] = {
+        { IDE_BUFFER_LINE_FLAGS_NONE, "IDE_BUFFER_LINE_FLAGS_NONE", "NONE" },
+        { IDE_BUFFER_LINE_FLAGS_ADDED, "IDE_BUFFER_LINE_FLAGS_ADDED", "ADDED" },
+        { IDE_BUFFER_LINE_FLAGS_CHANGED, "IDE_BUFFER_LINE_FLAGS_CHANGED", "CHANGED" },
+        { IDE_BUFFER_LINE_FLAGS_ERROR, "IDE_BUFFER_LINE_FLAGS_ERROR", "ERROR" },
+        { IDE_BUFFER_LINE_FLAGS_WARNING, "IDE_BUFFER_LINE_FLAGS_WARNING", "WARNING" },
+        { 0 }
+      };
+
+      _type_id = g_flags_register_static ("IdeBufferLineFlags", values);
+      g_once_init_leave (&type_id, _type_id);
+    }
+
+  return type_id;
+}
+
+/**
+ * ide_buffer_get_file:
+ *
+ * Gets the underlying file behind the buffer.
+ *
+ * Returns: (transfer none): An #IdeFile.
+ */
+IdeFile *
+ide_buffer_get_file (IdeBuffer *self)
+{
+  g_return_val_if_fail (IDE_IS_BUFFER (self), NULL);
+
+  return self->file;
+}
+
+/**
+ * ide_buffer_set_file:
+ *
+ * Sets the underlying file to use when saving and loading @self to and and from storage.
+ */
+void
+ide_buffer_set_file (IdeBuffer *self,
+                     IdeFile   *file)
+{
+  g_return_if_fail (IDE_IS_BUFFER (self));
+  g_return_if_fail (IDE_IS_FILE (file));
+
+  if (g_set_object (&self->file, file))
+    g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_FILE]);
+}
+
+/**
+ * ide_buffer_get_context:
+ *
+ * Gets the #IdeBuffer:context property. This is the #IdeContext that owns the buffer.
+ *
+ * Returns: (transfer none): An #IdeContext.
+ */
+IdeContext *
+ide_buffer_get_context (IdeBuffer *self)
+{
+  g_return_val_if_fail (IDE_IS_BUFFER (self), NULL);
+
+  return self->context;
+}
+
+IdeBufferLineFlags
+ide_buffer_get_line_flags (IdeBuffer *self,
+                           guint      line)
+{
+  /* TODO: Coordinate with Vcs */
+  return IDE_BUFFER_LINE_FLAGS_ADDED;
+}
diff --git a/libide/ide-buffer.h b/libide/ide-buffer.h
index d6dafa6..3314b08 100644
--- a/libide/ide-buffer.h
+++ b/libide/ide-buffer.h
@@ -35,13 +35,25 @@ G_BEGIN_DECLS
 
 typedef struct _IdeBufferClass  IdeBufferClass;
 
+typedef enum
+{
+  IDE_BUFFER_LINE_FLAGS_NONE     = 0,
+  IDE_BUFFER_LINE_FLAGS_ADDED    = 1 << 0,
+  IDE_BUFFER_LINE_FLAGS_CHANGED  = 1 << 1,
+  IDE_BUFFER_LINE_FLAGS_ERROR    = 1 << 2,
+  IDE_BUFFER_LINE_FLAGS_WARNING  = 1 << 3,
+} IdeBufferLineFlags;
+
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (IdeBuffer, g_object_unref)
 
-GType       ide_buffer_get_type    (void);
-IdeContext *ide_buffer_get_context (IdeBuffer *self);
-IdeFile    *ide_buffer_get_file    (IdeBuffer *self);
-void        ide_buffer_set_file    (IdeBuffer *self,
-                                    IdeFile   *file);
+GType               ide_buffer_line_flags_get_type (void);
+GType               ide_buffer_get_type            (void);
+IdeContext         *ide_buffer_get_context         (IdeBuffer *self);
+IdeFile            *ide_buffer_get_file            (IdeBuffer *self);
+void                ide_buffer_set_file            (IdeBuffer *self,
+                                                    IdeFile   *file);
+IdeBufferLineFlags  ide_buffer_get_line_flags      (IdeBuffer *buffer,
+                                                    guint      line);
 
 G_END_DECLS
 


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