Added history of all branches

This commit is contained in:
Jesse van den Kieboom 2012-07-18 10:08:54 +02:00
parent b767be325d
commit fc0a8b72f5
2 changed files with 53 additions and 26 deletions

View file

@ -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; }

View file

@ -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();
}