[gnome-builder] buffer-change-monitor: add reload vfunc



commit 5e250d2703025b3dbe5c070d63150e8bde7f6e6b
Author: Christian Hergert <chergert redhat com>
Date:   Mon Aug 15 12:33:46 2016 +0200

    buffer-change-monitor: add reload vfunc
    
    This is a generic way for buffers to force a reload of the change monitor.

 libide/buffers/ide-buffer-change-monitor.c  |    9 +++++++++
 libide/buffers/ide-buffer-change-monitor.h  |   14 ++++++++++++--
 plugins/git/ide-git-buffer-change-monitor.c |   21 +++++++++++++++++----
 3 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/libide/buffers/ide-buffer-change-monitor.c b/libide/buffers/ide-buffer-change-monitor.c
index 183752a..5fd17d5 100644
--- a/libide/buffers/ide-buffer-change-monitor.c
+++ b/libide/buffers/ide-buffer-change-monitor.c
@@ -123,3 +123,12 @@ static void
 ide_buffer_change_monitor_init (IdeBufferChangeMonitor *self)
 {
 }
+
+void
+ide_buffer_change_monitor_reload (IdeBufferChangeMonitor *self)
+{
+  g_return_if_fail (IDE_IS_BUFFER_CHANGE_MONITOR (self));
+
+  if (IDE_BUFFER_CHANGE_MONITOR_GET_CLASS (self)->reload)
+    IDE_BUFFER_CHANGE_MONITOR_GET_CLASS (self)->reload (self);
+}
diff --git a/libide/buffers/ide-buffer-change-monitor.h b/libide/buffers/ide-buffer-change-monitor.h
index c90c40d..6f7c200 100644
--- a/libide/buffers/ide-buffer-change-monitor.h
+++ b/libide/buffers/ide-buffer-change-monitor.h
@@ -27,8 +27,7 @@ G_BEGIN_DECLS
 
 #define IDE_TYPE_BUFFER_CHANGE_MONITOR (ide_buffer_change_monitor_get_type())
 
-G_DECLARE_DERIVABLE_TYPE (IdeBufferChangeMonitor, ide_buffer_change_monitor,
-                          IDE, BUFFER_CHANGE_MONITOR, IdeObject)
+G_DECLARE_DERIVABLE_TYPE (IdeBufferChangeMonitor, ide_buffer_change_monitor, IDE, BUFFER_CHANGE_MONITOR, 
IdeObject)
 
 typedef enum
 {
@@ -46,11 +45,22 @@ struct _IdeBufferChangeMonitorClass
                                      IdeBuffer              *buffer);
   IdeBufferLineChange (*get_change) (IdeBufferChangeMonitor *self,
                                      const GtkTextIter      *iter);
+  void                (*reload)     (IdeBufferChangeMonitor *self);
+
+  gpointer _reserved1;
+  gpointer _reserved2;
+  gpointer _reserved3;
+  gpointer _reserved4;
+  gpointer _reserved5;
+  gpointer _reserved6;
+  gpointer _reserved7;
+  gpointer _reserved8;
 };
 
 IdeBufferLineChange ide_buffer_change_monitor_get_change   (IdeBufferChangeMonitor *self,
                                                             const GtkTextIter      *iter);
 void                ide_buffer_change_monitor_emit_changed (IdeBufferChangeMonitor *self);
+void                ide_buffer_change_monitor_reload       (IdeBufferChangeMonitor *self);
 
 G_END_DECLS
 
diff --git a/plugins/git/ide-git-buffer-change-monitor.c b/plugins/git/ide-git-buffer-change-monitor.c
index 421ce31..51fc896 100644
--- a/plugins/git/ide-git-buffer-change-monitor.c
+++ b/plugins/git/ide-git-buffer-change-monitor.c
@@ -397,6 +397,21 @@ ide_git_buffer_change_monitor__buffer_changed_after_cb (IdeGitBufferChangeMonito
 }
 
 static void
+ide_git_buffer_change_monitor_reload (IdeBufferChangeMonitor *monitor)
+{
+  IdeGitBufferChangeMonitor *self = (IdeGitBufferChangeMonitor *)monitor;
+
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_GIT_BUFFER_CHANGE_MONITOR (self));
+
+  g_clear_object (&self->cached_blob);
+  ide_git_buffer_change_monitor_recalculate (self);
+
+  IDE_EXIT;
+}
+
+static void
 ide_git_buffer_change_monitor__vcs_reloaded_cb (IdeGitBufferChangeMonitor *self,
                                                 GgitRepository            *new_repository,
                                                 IdeGitVcs                 *vcs)
@@ -408,10 +423,7 @@ ide_git_buffer_change_monitor__vcs_reloaded_cb (IdeGitBufferChangeMonitor *self,
 
   g_set_object (&self->repository, new_repository);
 
-  /* force reload of the git object on next calculation */
-  g_clear_object (&self->cached_blob);
-
-  ide_git_buffer_change_monitor_recalculate (self);
+  ide_buffer_change_monitor_reload (IDE_BUFFER_CHANGE_MONITOR (self));
 
   IDE_EXIT;
 }
@@ -709,6 +721,7 @@ ide_git_buffer_change_monitor_class_init (IdeGitBufferChangeMonitorClass *klass)
 
   parent_class->set_buffer = ide_git_buffer_change_monitor_set_buffer;
   parent_class->get_change = ide_git_buffer_change_monitor_get_change;
+  parent_class->reload = ide_git_buffer_change_monitor_reload;
 
   properties [PROP_REPOSITORY] =
     g_param_spec_object ("repository",


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