Implemented filtering of history based on history navigation selection

This commit is contained in:
Jesse van den Kieboom 2012-07-06 18:50:16 +02:00
parent 53d41e0321
commit c79872a8c1
2 changed files with 32 additions and 5 deletions

View file

@ -23,6 +23,8 @@ namespace GitgHistory
{
public GitgExt.Application? application { owned get; construct; }
public signal void ref_activated(Gitg.Ref r);
public Navigation(GitgExt.Application app)
{
Object(application: app);
@ -99,15 +101,19 @@ namespace GitgHistory
foreach (var item in branches)
{
var it = item;
if (head != null && item.get_id().equal(head.get_id()))
{
model.append_default(item.parsed_name.shortname,
"object-select-symbolic",
null);
(nc) => ref_activated(it));
}
else
{
model.append(item.parsed_name.shortname, null, null);
model.append(item.parsed_name.shortname,
null,
(nc) => ref_activated(it));
}
}
@ -122,7 +128,11 @@ namespace GitgHistory
foreach (var rref in remotes.lookup(rname))
{
model.append(rref.parsed_name.remote_branch, null, null);
var it = rref;
model.append(rref.parsed_name.remote_branch,
null,
(nc) => ref_activated(it));
}
model.end_header();
@ -135,7 +145,11 @@ namespace GitgHistory
foreach (var item in tags)
{
model.append(item.parsed_name.shortname, null, null);
var it = item;
model.append(item.parsed_name.shortname,
null,
(nc) => ref_activated(it));
}
}

View file

@ -22,6 +22,9 @@ namespace GitgHistory
// Do this to pull in config.h before glib.h (for gettext...)
private const string version = Gitg.Config.VERSION;
/* The main history view. This view shows the equivalent of git log, but
* in a nice way with lanes, merges, ref labels etc.
*/
public class View : Object, GitgExt.View
{
public GitgExt.Application? application { owned get; construct; }
@ -39,6 +42,7 @@ namespace GitgHistory
construct
{
d_model = new GitgGtk.CommitModel(application.repository);
application.bind_property("repository", d_model, "repository", BindingFlags.DEFAULT);
}
@ -75,8 +79,13 @@ namespace GitgHistory
{
owned get
{
// Create the sidebar navigation for the history. This navigation
// will show branches, remotes and tags which can be used to
// filter the history
var ret = new Navigation(application);
ret.ref_activated.connect(on_ref_activated);
return ret;
}
}
@ -86,6 +95,11 @@ namespace GitgHistory
return application.repository != null && action == GitgExt.ViewAction.HISTORY;
}
private void on_ref_activated(Gitg.Ref r)
{
update_walker(r);
}
private void build_ui()
{
var ret = from_builder("view-history.ui", {"scrolled_window_commit_list", "commit_list_view"});
@ -93,7 +107,6 @@ namespace GitgHistory
d_view = ret["commit_list_view"] as Gtk.TreeView;
d_view.model = d_model;
update_walker(null);
d_main = ret["scrolled_window_commit_list"] as Gtk.Widget;
}