[gitg] diff-view: propagate has-selection from the diff view files



commit 2f636af5a291376ba076861dbff62b2d4b8b0db7
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Dec 18 16:04:52 2015 +0100

    diff-view: propagate has-selection from the diff view files

 libgitg/gitg-diff-view.vala |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index f21efec..2f46f7c 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -47,10 +47,11 @@ public class Gitg.DiffView : Gtk.Grid
                }
        }
 
-       // TODO
+       private bool d_has_selection;
+
        public bool has_selection
        {
-               get { return false; }
+               get { return d_has_selection; }
        }
 
        private Cancellable d_cancellable;
@@ -282,6 +283,26 @@ public class Gitg.DiffView : Gtk.Grid
                SignalHandler.unblock(d_commit_details, d_expanded_notify);
        }
 
+       private void on_selection_changed()
+       {
+               bool something_selected = false;
+
+               foreach (var file in d_grid_files.get_children())
+               {
+                       if ((file as Gitg.DiffViewFile).has_selection)
+                       {
+                               something_selected = true;
+                               break;
+                       }
+               }
+
+               if (d_has_selection != something_selected)
+               {
+                       d_has_selection = something_selected;
+                       notify_property("has-selection");
+               }
+       }
+
        private void update_diff(Ggit.Diff diff, Cancellable? cancellable)
        {
                var files = new Gee.ArrayList<Gitg.DiffViewFile>();
@@ -313,6 +334,7 @@ public class Gitg.DiffView : Gtk.Grid
                        if (current_file != null)
                        {
                                current_file.show();
+                               current_file.notify["has-selection"].connect(on_selection_changed);     
 
                                files.add(current_file);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]