[gitg/wip/actions: 23/26] Only select first ref unless multiselect



commit 698bffc28fc88d0841c91035dec8dacbc9e619d2
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sat Jul 12 10:34:50 2014 +0200

    Only select first ref unless multiselect

 gitg/history/gitg-history-refs-list.vala |   17 +++++++++++++++++
 gitg/history/gitg-history.vala           |   10 ++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/gitg/history/gitg-history-refs-list.vala b/gitg/history/gitg-history-refs-list.vala
index eae42ec..3231e80 100644
--- a/gitg/history/gitg-history-refs-list.vala
+++ b/gitg/history/gitg-history-refs-list.vala
@@ -765,6 +765,23 @@ public class RefsList : Gtk.ListBox
                }
        }
 
+       public bool is_all
+       {
+               get
+               {
+                       var row = get_selected_row();
+
+                       if (row == null)
+                       {
+                               return true;
+                       }
+
+                       var ref_row = get_ref_row(row);
+
+                       return (ref_row != null && ref_row.reference == null);
+               }
+       }
+
        [Notify]
        public Gee.List<Gitg.Ref> selection
        {
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index 153118b..4474866 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -137,9 +137,11 @@ namespace GitgHistory
                {
                        var commit = d_commit_list_model.commit_from_path(path);
 
+                       var sel = d_main.commit_list_view.get_selection();
+
                        if (d_selected.size == 0 || d_selected.remove(commit.get_id()))
                        {
-                               d_main.commit_list_view.get_selection().select_path(path);
+                               sel.select_path(path);
 
                                if (commit.get_id().equal(d_scroll_to))
                                {
@@ -153,8 +155,12 @@ namespace GitgHistory
                                }
                        }
 
-                       if (d_selected.size == 0)
+                       if (d_selected.size == 0 || (sel.count_selected_rows() != 0 &&
+                                                    (sel.mode == Gtk.SelectionMode.SINGLE ||
+                                                     sel.mode == Gtk.SelectionMode.BROWSE)))
                        {
+                               d_selected.clear();
+
                                d_commit_list_model.disconnect(d_insertsig);
                                d_insertsig = 0;
                        }


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