[gitg] Bind commit details parent button
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Bind commit details parent button
- Date: Sun, 8 Nov 2015 19:55:07 +0000 (UTC)
commit 321310bb2300e9e3e60a8e10850a0561e4ef31b4
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sun Nov 8 20:54:48 2015 +0100
Bind commit details parent button
libgitg/gitg-diff-view-commit-details.vala | 18 +++++++++++++++---
libgitg/gitg-diff-view.vala | 22 ++++++++++++++++------
2 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/libgitg/gitg-diff-view-commit-details.vala b/libgitg/gitg-diff-view-commit-details.vala
index def2bb9..eec09ca 100644
--- a/libgitg/gitg-diff-view-commit-details.vala
+++ b/libgitg/gitg-diff-view-commit-details.vala
@@ -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;
+ }
});
}
}
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index 770d73e..407c167 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]