[gitg/gnome-3-20] Update history when commit is added without relying on file monitor
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/gnome-3-20] Update history when commit is added without relying on file monitor
- Date: Thu, 25 Aug 2016 14:54:29 +0000 (UTC)
commit 6a638b01ecd0ef169ddff4451b06caa18fe25f9d
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Thu Aug 18 19:28:00 2016 +0200
Update history when commit is added without relying on file monitor
https://bugzilla.gnome.org/show_bug.cgi?id=755762
gitg/commit/gitg-commit.vala | 2 ++
gitg/history/gitg-history.vala | 30 ++++++++++++++++++++++++++++--
libgitg-ext/gitg-ext-application.vala | 1 +
3 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index 28d28a0..9e86030 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -1098,6 +1098,8 @@ namespace GitgCommit
{
stage.commit.end(res);
reload();
+
+ application.repository_commits_changed();
}
catch (Error e)
{
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index 2093226..6625956 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -47,6 +47,8 @@ namespace GitgHistory
private ulong d_refs_list_selection_id;
private ulong d_refs_list_changed_id;
private ulong d_externally_changed_id;
+ private ulong d_commits_changed_id;
+
private Gitg.WhenMapped? d_reload_when_mapped;
private Paned d_main;
@@ -155,20 +157,38 @@ namespace GitgHistory
reload_mainline();
d_externally_changed_id =
application.repository_changed_externally.connect(repository_changed_externally);
+ d_commits_changed_id =
application.repository_commits_changed.connect(repository_commits_changed);
}
private void repository_changed_externally(GitgExt.ExternalChangeHint hint)
{
if (d_main != null && (hint & GitgExt.ExternalChangeHint.REFS) != 0 &&
!d_ignore_external)
{
+ reload_when_mapped();
+ }
+
+ d_ignore_external = false;
+ }
+
+ private void repository_commits_changed()
+ {
+ if (d_main != null)
+ {
+ d_ignore_external = true;
+ reload_when_mapped();
+ }
+ }
+
+ private void reload_when_mapped()
+ {
+ if (d_main != null)
+ {
d_reload_when_mapped = new Gitg.WhenMapped(d_main);
d_reload_when_mapped.update(() => {
reload();
}, this);
}
-
- d_ignore_external = false;
}
public override void dispose()
@@ -197,6 +217,12 @@ namespace GitgHistory
d_externally_changed_id = 0;
}
+ if (d_commits_changed_id != 0)
+ {
+ application.disconnect(d_commits_changed_id);
+ d_commits_changed_id = 0;
+ }
+
d_commit_list_model.repository = null;
base.dispose();
}
diff --git a/libgitg-ext/gitg-ext-application.vala b/libgitg-ext/gitg-ext-application.vala
index 3269d5e..d47ea6a 100644
--- a/libgitg-ext/gitg-ext-application.vala
+++ b/libgitg-ext/gitg-ext-application.vala
@@ -36,6 +36,7 @@ public interface Application : Object
public abstract Gitg.Repository? repository { owned get; set; }
public signal void repository_changed_externally(ExternalChangeHint hint);
+ public signal void repository_commits_changed();
/**
* An application wide message bus over which plugins can communicate.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]