[gitg/vala] Added history of all branches
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/vala] Added history of all branches
- Date: Wed, 18 Jul 2012 08:09:05 +0000 (UTC)
commit fc0a8b72f5b9051359e4af42839fcc79491ab649
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Wed Jul 18 10:08:54 2012 +0200
Added history of all branches
plugins/history/gitg-history-navigation.vala | 17 +++++++-
plugins/history/gitg-history.vala | 62 +++++++++++++++----------
2 files changed, 53 insertions(+), 26 deletions(-)
---
diff --git a/plugins/history/gitg-history-navigation.vala b/plugins/history/gitg-history-navigation.vala
index 7ad5416..6fe8d37 100644
--- a/plugins/history/gitg-history-navigation.vala
+++ b/plugins/history/gitg-history-navigation.vala
@@ -25,8 +25,9 @@ namespace GitgHistory
private const string version = Gitg.Config.VERSION;
public GitgExt.Application? application { owned get; construct set; }
+ private List<Gitg.Ref> d_all;
- public signal void ref_activated(Gitg.Ref r);
+ public signal void ref_activated(Gitg.Ref? r);
public Navigation(GitgExt.Application app)
{
@@ -49,6 +50,7 @@ namespace GitgHistory
List<string> remotenames = new List<string>();
remotes = new HashTable<string, List<Gitg.Ref>>(str_hash, str_equal);
+ d_all = new List<Gitg.Ref>();
try
{
@@ -60,6 +62,8 @@ namespace GitgHistory
r = repo.lookup_reference(nm);
} catch { return 0; }
+ d_all.prepend(r);
+
if (r.parsed_name.rtype == Gitg.RefType.BRANCH)
{
branches.insert_sorted(r, sort_refs);
@@ -92,6 +96,8 @@ namespace GitgHistory
});
} catch {}
+ d_all.reverse();
+
Gitg.Ref? head = null;
try
@@ -125,6 +131,10 @@ namespace GitgHistory
}
}
+ model.separator();
+
+ model.append(_("All"), null, (nc) => ref_activated(null));
+
model.end_header();
// Remotes
@@ -161,6 +171,11 @@ namespace GitgHistory
}
}
+ public List<Gitg.Ref> all
+ {
+ get { return d_all; }
+ }
+
public GitgExt.NavigationSide navigation_side
{
get { return GitgExt.NavigationSide.LEFT; }
diff --git a/plugins/history/gitg-history.vala b/plugins/history/gitg-history.vala
index b82625b..8e60fb3 100644
--- a/plugins/history/gitg-history.vala
+++ b/plugins/history/gitg-history.vala
@@ -66,7 +66,7 @@ namespace GitgHistory
private void on_commit_model_started(Gitg.CommitModel model)
{
- if (d_selected.size > 0 && d_insertsig == 0)
+ if (d_insertsig == 0)
{
d_insertsig = d_model.row_inserted.connect(on_row_inserted_select);
}
@@ -76,15 +76,15 @@ namespace GitgHistory
{
var commit = d_model.commit_from_path(path);
- if (d_selected.remove(commit.get_id()))
+ if (d_selected.size == 0 || 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;
- }
+ if (d_selected.size == 0)
+ {
+ d_model.disconnect(d_insertsig);
+ d_insertsig = 0;
}
}
@@ -138,7 +138,7 @@ namespace GitgHistory
// filter the history
var ret = new Navigation(application);
- ret.ref_activated.connect(on_ref_activated);
+ ret.ref_activated.connect((r) => on_ref_activated(ret, r));
return ret;
}
@@ -149,9 +149,9 @@ namespace GitgHistory
return application.repository != null && action == GitgExt.ViewAction.HISTORY;
}
- private void on_ref_activated(Gitg.Ref r)
+ private void on_ref_activated(Navigation n, Gitg.Ref? r)
{
- update_walker(r);
+ update_walker(n, r);
}
private void build_ui()
@@ -168,7 +168,7 @@ namespace GitgHistory
d_main = ret["scrolled_window_commit_list"] as Gtk.Widget;
}
- private void update_walker(Gitg.Ref? head)
+ private void update_walker(Navigation n, Gitg.Ref? head)
{
Ggit.OId? id = null;
@@ -188,26 +188,38 @@ namespace GitgHistory
}
}
- if (id == null && application.repository != null)
- {
- try
- {
- Gitg.Ref? th = application.repository.get_head();
-
- if (th != null)
- {
- id = th.get_id();
- }
- } catch {}
- }
+ d_selected.clear();
if (id != null)
{
- d_selected.clear();
d_selected.add(id);
-
d_model.set_include(new Ggit.OId[] { id });
}
+ else
+ {
+ var included = new Ggit.OId[] {};
+
+ // Simply push all the refs
+ foreach (Gitg.Ref r in n.all)
+ {
+ try
+ {
+ var resolved = r.resolve();
+
+ try
+ {
+ var t = application.repository.lookup(resolved.get_id(), typeof(Ggit.Tag)) as Ggit.Tag;
+ included += t.get_target_id();
+ }
+ catch
+ {
+ included += resolved.get_id();
+ }
+ } catch {}
+ }
+
+ d_model.set_include(included);
+ }
d_model.reload();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]