Bind commit details parent button

This commit is contained in:
Jesse van den Kieboom 2015-11-08 20:54:48 +01:00
parent a88d4d1697
commit 321310bb23
2 changed files with 31 additions and 9 deletions

View file

@ -203,19 +203,29 @@ class Gitg.DiffViewCommitDetails : Gtk.Grid
var parents = commit.get_parents();
var first_parent = parents.size == 0 ? null : parents.get(0);
d_parent_commit = first_parent;
parent_commit = first_parent;
if (parents.size > 1)
{
d_grid_parents_container.show();
var grp = new SList<Gtk.RadioButton>();
Gtk.RadioButton? first = null;
foreach (var parent in parents)
{
var pid = parent.get_id().to_string().substring(0, 6);
var psubj = parent.get_subject();
var button = new Gtk.RadioButton.with_label(grp, @"$pid: $psubj");
if (first == null)
{
first = button;
}
button.group = first;
d_parents_map[parent.get_id()] = button;
button.show();
@ -223,8 +233,10 @@ class Gitg.DiffViewCommitDetails : Gtk.Grid
var par = parent;
button.activate.connect(() => {
d_parent_commit = par;
button.toggled.connect(() => {
if (button.active) {
parent_commit = par;
}
});
}
}

View file

@ -33,7 +33,6 @@ public class Gitg.DiffView : Gtk.Grid
private Commit? d_commit;
private Ggit.DiffOptions? d_options;
private Ggit.OId? d_parent;
public Ggit.DiffOptions options
{
@ -64,7 +63,6 @@ public class Gitg.DiffView : Gtk.Grid
d_diff = value;
d_commit = null;
d_parent = null;
update();
}
@ -79,7 +77,6 @@ public class Gitg.DiffView : Gtk.Grid
{
d_commit = value;
d_diff = null;
d_parent = null;
}
update();
@ -187,10 +184,18 @@ public class Gitg.DiffView : Gtk.Grid
}
private ulong d_expanded_notify;
private ulong d_parent_commit_notify;
protected override void constructed()
{
d_expanded_notify = d_commit_details.notify["expanded"].connect(update_expanded_files);
d_parent_commit_notify = d_commit_details.notify["parent-commit"].connect(parent_commit_changed);
}
private void parent_commit_changed()
{
update();
}
private void update_expanded_files()
@ -223,16 +228,22 @@ public class Gitg.DiffView : Gtk.Grid
if (d_commit != null)
{
SignalHandler.block(d_commit_details, d_parent_commit_notify);
d_commit_details.commit = d_commit;
SignalHandler.unblock(d_commit_details, d_parent_commit_notify);
int parent = 0;
var parents = d_commit.get_parents();
if (d_parent != null)
var parent_commit = d_commit_details.parent_commit;
if (parent_commit != null)
{
for (var i = 0; i < parents.size; i++)
{
var id = parents.get_id(i);
if (id.equal(d_parent))
if (id.equal(parent_commit.get_id()))
{
parent = i;
break;
@ -241,7 +252,6 @@ public class Gitg.DiffView : Gtk.Grid
}
d_diff = d_commit.get_diff(options, parent);
d_commit_details.commit = d_commit;
d_commit_details.show();
}
else