[gitg] diff-view-file: propagate has-selection property
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] diff-view-file: propagate has-selection property
- Date: Fri, 18 Dec 2015 16:54:59 +0000 (UTC)
commit 888db44f1e1e7298e2d9bb5a524411a139c64134
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri Dec 18 15:46:23 2015 +0100
diff-view-file: propagate has-selection property
libgitg/gitg-diff-view-file.vala | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/libgitg/gitg-diff-view-file.vala b/libgitg/gitg-diff-view-file.vala
index 430a2b2..617eeb9 100644
--- a/libgitg/gitg-diff-view-file.vala
+++ b/libgitg/gitg-diff-view-file.vala
@@ -80,6 +80,13 @@ class Gitg.DiffViewFile : Gtk.Grid
get; set;
}
+ private bool d_has_selection;
+
+ public bool has_selection
+ {
+ get { return d_has_selection; }
+ }
+
public Ggit.DiffDelta delta
{
get;
@@ -123,6 +130,26 @@ class Gitg.DiffViewFile : Gtk.Grid
d_expander.bind_property("expanded", this, "expanded", BindingFlags.BIDIRECTIONAL);
}
+ private void on_selection_changed()
+ {
+ bool something_selected = false;
+
+ foreach (var child in d_grid_hunks.get_children())
+ {
+ if ((child as Gitg.DiffViewHunk).has_selection)
+ {
+ something_selected = true;
+ break;
+ }
+ }
+
+ if (d_has_selection != something_selected)
+ {
+ d_has_selection = something_selected;
+ notify_property("has-selection");
+ }
+ }
+
public void add_hunk(Ggit.DiffHunk hunk, Gee.ArrayList<Ggit.DiffLine> lines)
{
var widget = new Gitg.DiffViewHunk(hunk, lines, handle_selection);
@@ -137,6 +164,8 @@ class Gitg.DiffViewFile : Gtk.Grid
this.bind_property("wrap", widget, "wrap", BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE);
this.bind_property("tab-width", widget, "tab-width", BindingFlags.DEFAULT |
BindingFlags.SYNC_CREATE);
+ widget.notify["has-selection"].connect(on_selection_changed);
+
sensitive = true;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]