[gitg/vala] Automatically select branch in history
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/vala] Automatically select branch in history
- Date: Wed, 18 Jul 2012 07:36:14 +0000 (UTC)
commit eff97b8a1209a876be8908c57c0e730905098be0
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Wed Jul 18 09:35:53 2012 +0200
Automatically select branch in history
libgitg/gitg-commit-model.vala | 1 +
plugins/history/gitg-history.vala | 42 +++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/libgitg/gitg-commit-model.vala b/libgitg/gitg-commit-model.vala
index a0db933..56f679e 100644
--- a/libgitg/gitg-commit-model.vala
+++ b/libgitg/gitg-commit-model.vala
@@ -315,6 +315,7 @@ public class CommitModel : Object
try
{
d_cancellable.reset();
+ emit_started();
d_thread = new Thread<void*>.try("gitg-history-walk", run);
yield;
}
diff --git a/plugins/history/gitg-history.vala b/plugins/history/gitg-history.vala
index 5bb34b9..b82625b 100644
--- a/plugins/history/gitg-history.vala
+++ b/plugins/history/gitg-history.vala
@@ -31,6 +31,8 @@ namespace GitgHistory
private Gtk.TreeView d_view;
private GitgGtk.CommitModel? d_model;
+ private Gee.HashSet<Ggit.OId> d_selected;
+ private ulong d_insertsig;
private Gtk.Widget d_main;
@@ -54,10 +56,47 @@ namespace GitgHistory
construct
{
d_model = new GitgGtk.CommitModel(application.repository);
+ d_selected = new Gee.HashSet<Ggit.OId>(Ggit.OId.hash, (EqualFunc<Ggit.OId>)Ggit.OId.equal);
+
+ d_model.started.connect(on_commit_model_started);
+ d_model.finished.connect(on_commit_model_finished);
application.bind_property("repository", d_model, "repository", BindingFlags.DEFAULT);
}
+ private void on_commit_model_started(Gitg.CommitModel model)
+ {
+ if (d_selected.size > 0 && d_insertsig == 0)
+ {
+ d_insertsig = d_model.row_inserted.connect(on_row_inserted_select);
+ }
+ }
+
+ private void on_row_inserted_select(Gtk.TreeModel model, Gtk.TreePath path, Gtk.TreeIter iter)
+ {
+ var commit = d_model.commit_from_path(path);
+
+ if (d_selected.remove(commit.get_id()))
+ {
+ d_view.get_selection().select_path(path);
+
+ if (d_selected.size == 0)
+ {
+ d_model.disconnect(d_insertsig);
+ d_insertsig = 0;
+ }
+ }
+ }
+
+ private void on_commit_model_finished(Gitg.CommitModel model)
+ {
+ if (d_insertsig != 0)
+ {
+ d_model.disconnect(d_insertsig);
+ d_insertsig = 0;
+ }
+ }
+
public bool available
{
get
@@ -164,6 +203,9 @@ namespace GitgHistory
if (id != null)
{
+ d_selected.clear();
+ d_selected.add(id);
+
d_model.set_include(new Ggit.OId[] { id });
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]