[gnome-builder] vcs: add IdeVcs::changed signal



commit 4617429d9ca9292075eedd5a5beed1e7231187e0
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 23 19:31:22 2016 +0300

    vcs: add IdeVcs::changed signal
    
    This signal should be emitted by VCS implementations when the underlying
    storage is changed (such as after a git commit).

 libide/ide-vcs.c          |   29 +++++++++++++++++++++++++++++
 libide/ide-vcs.h          |    2 ++
 plugins/git/ide-git-vcs.c |    3 +++
 3 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-vcs.c b/libide/ide-vcs.c
index dee854c..d32b637 100644
--- a/libide/ide-vcs.c
+++ b/libide/ide-vcs.c
@@ -23,6 +23,13 @@
 
 G_DEFINE_INTERFACE (IdeVcs, ide_vcs, IDE_TYPE_OBJECT)
 
+enum {
+  CHANGED,
+  N_SIGNALS
+};
+
+static guint signals [N_SIGNALS];
+
 static void
 ide_vcs_default_init (IdeVcsInterface *iface)
 {
@@ -32,6 +39,20 @@ ide_vcs_default_init (IdeVcsInterface *iface)
                                                             "Context",
                                                             IDE_TYPE_CONTEXT,
                                                             (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | 
G_PARAM_STATIC_STRINGS)));
+
+  /**
+   * IdeVcs::changed:
+   *
+   * The "changed" signal should be emitted when the VCS has detected a change
+   * to the underlying VCS storage. This can be used by consumers to reload
+   * their respective data structures.
+   */
+  signals [CHANGED] =
+    g_signal_new ("changed",
+                  G_TYPE_FROM_INTERFACE (iface),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (IdeVcsInterface, changed),
+                  NULL, NULL, NULL, G_TYPE_NONE, 0);
 }
 
 gboolean
@@ -153,3 +174,11 @@ ide_vcs_new_finish (GAsyncResult  *result,
 
   return IDE_VCS (ret);
 }
+
+void
+ide_vcs_emit_changed (IdeVcs *self)
+{
+  g_return_if_fail (IDE_IS_VCS (self));
+
+  g_signal_emit (self, signals [CHANGED], 0);
+}
diff --git a/libide/ide-vcs.h b/libide/ide-vcs.h
index edca435..76ae359 100644
--- a/libide/ide-vcs.h
+++ b/libide/ide-vcs.h
@@ -40,6 +40,7 @@ struct _IdeVcsInterface
                                                         GFile      *file,
                                                         GError    **error);
   gint                    (*get_priority)              (IdeVcs     *self);
+  void                    (*changed)                   (IdeVcs     *self);
 };
 
 IdeBufferChangeMonitor *ide_vcs_get_buffer_change_monitor (IdeVcs               *self,
@@ -56,6 +57,7 @@ gboolean                ide_vcs_is_ignored                (IdeVcs
                                                            GFile                *file,
                                                            GError              **error);
 gint                    ide_vcs_get_priority              (IdeVcs               *self);
+void                    ide_vcs_emit_changed              (IdeVcs               *self);
 
 G_END_DECLS
 
diff --git a/plugins/git/ide-git-vcs.c b/plugins/git/ide-git-vcs.c
index afc44a8..95eca51 100644
--- a/plugins/git/ide-git-vcs.c
+++ b/plugins/git/ide-git-vcs.c
@@ -286,7 +286,10 @@ ide_git_vcs_reload_finish (IdeGitVcs     *self,
   g_return_val_if_fail (IDE_IS_GIT_VCS (self), FALSE);
 
   self->reloading = FALSE;
+
   g_signal_emit (self, signals [RELOADED], 0, self->change_monitor_repository);
+  ide_vcs_emit_changed (IDE_VCS (self));
+
   ret = g_task_propagate_boolean (task, error);
 
   IDE_RETURN (ret);


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