[gnome-builder/wip/libide] libide: add ide_vcs_get_change_monitor()



commit 6c5a9b543c4ee41bf5af3e3860f40ba07e120e81
Author: Christian Hergert <christian hergert me>
Date:   Thu Feb 26 16:43:10 2015 -0800

    libide: add ide_vcs_get_change_monitor()
    
    This function retrieves a change monitor that can be used for a given
    file. The change monitor may be vcs implementation specific.

 libide/ide-vcs.c |   29 ++++++++++++++++++++++++++++-
 libide/ide-vcs.h |   22 +++++++++++++---------
 2 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/libide/ide-vcs.c b/libide/ide-vcs.c
index 38d8818..f49e163 100644
--- a/libide/ide-vcs.c
+++ b/libide/ide-vcs.c
@@ -16,6 +16,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "ide-buffer.h"
+#include "ide-buffer-change-monitor.h"
 #include "ide-vcs.h"
 
 G_DEFINE_ABSTRACT_TYPE (IdeVcs, ide_vcs, IDE_TYPE_OBJECT)
@@ -32,7 +34,7 @@ ide_vcs_init (IdeVcs *self)
 
 /**
  * ide_vcs_get_working_directory:
- * @vcs: An #IdeVcs.
+ * @self: An #IdeVcs.
  *
  * Retrieves the working directory for the context. This is the root of where
  * the project files exist.
@@ -50,6 +52,31 @@ ide_vcs_get_working_directory (IdeVcs *self)
   return NULL;
 }
 
+/**
+ * ide_vcs_get_buffer_change_monitor:
+ *
+ * Gets an #IdeBufferChangeMonitor for the buffer provided. If the #IdeVcs implementation does not
+ * support change monitoring, or cannot for the current file, then %NULL is returned.
+ *
+ * Returns: (transfer full) (nullable): An #IdeBufferChangeMonitor or %NULL.
+ */
+IdeBufferChangeMonitor *
+ide_vcs_get_buffer_change_monitor (IdeVcs    *self,
+                                   IdeBuffer *buffer)
+{
+  IdeBufferChangeMonitor *ret = NULL;
+
+  g_return_val_if_fail (IDE_IS_VCS (self), NULL);
+  g_return_val_if_fail (IDE_IS_BUFFER (buffer), NULL);
+
+  if (IDE_VCS_GET_CLASS (self)->get_buffer_change_monitor)
+    ret = IDE_VCS_GET_CLASS (self)->get_buffer_change_monitor (self, buffer);
+
+  g_return_val_if_fail (!ret || IDE_IS_BUFFER_CHANGE_MONITOR (ret), NULL);
+
+  return ret;
+}
+
 void
 ide_vcs_new_async (IdeContext           *context,
                    int                   io_priority,
diff --git a/libide/ide-vcs.h b/libide/ide-vcs.h
index 91c89e1..103b72d 100644
--- a/libide/ide-vcs.h
+++ b/libide/ide-vcs.h
@@ -34,17 +34,21 @@ struct _IdeVcsClass
 {
   IdeObjectClass parent;
 
-  GFile *(*get_working_directory) (IdeVcs *vcs);
+  GFile                  *(*get_working_directory)     (IdeVcs    *self);
+  IdeBufferChangeMonitor *(*get_buffer_change_monitor) (IdeVcs    *self,
+                                                        IdeBuffer *buffer);
 };
 
-GFile  *ide_vcs_get_working_directory (IdeVcs               *self);
-void    ide_vcs_new_async             (IdeContext           *context,
-                                       int                   io_priority,
-                                       GCancellable         *cancellable,
-                                       GAsyncReadyCallback   callback,
-                                       gpointer              user_data);
-IdeVcs *ide_vcs_new_finish            (GAsyncResult         *result,
-                                       GError              **error);
+IdeBufferChangeMonitor *ide_vcs_get_buffer_change_monitor (IdeVcs               *self,
+                                                           IdeBuffer            *buffer);
+GFile                  *ide_vcs_get_working_directory     (IdeVcs               *self);
+void                    ide_vcs_new_async                 (IdeContext           *context,
+                                                           int                   io_priority,
+                                                           GCancellable         *cancellable,
+                                                           GAsyncReadyCallback   callback,
+                                                           gpointer              user_data);
+IdeVcs                 *ide_vcs_new_finish                (GAsyncResult         *result,
+                                                           GError              **error);
 
 G_END_DECLS
 


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