[gitg] Handle showing upstream in history instead of selection



commit 01ce13d1a4de3427a848ea71cb3c2afe80e0b69f
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sat Aug 22 14:22:46 2015 +0200

    Handle showing upstream in history instead of selection

 gitg/history/gitg-history-refs-list.vala |   36 +-----------------------------
 gitg/history/gitg-history.vala           |   21 +++++++++++++++++
 2 files changed, 22 insertions(+), 35 deletions(-)
---
diff --git a/gitg/history/gitg-history-refs-list.vala b/gitg/history/gitg-history-refs-list.vala
index 25073c4..c92b110 100644
--- a/gitg/history/gitg-history-refs-list.vala
+++ b/gitg/history/gitg-history-refs-list.vala
@@ -590,11 +590,6 @@ public class RefsList : Gtk.ListBox
                              this,
                              "reference-sort-order",
                              SettingsBindFlags.GET | SettingsBindFlags.SET);
-
-               settings.bind("show-upstream-with-branch",
-                             this,
-                             "show-upstream-with-branch",
-                             SettingsBindFlags.GET | SettingsBindFlags.SET);
        }
 
        public Gee.List<Gitg.Ref> references
@@ -616,24 +611,6 @@ public class RefsList : Gtk.ListBox
                }
        }
 
-       private bool d_show_upstream_with_branch;
-
-       public bool show_upstream_with_branch
-       {
-               get
-               {
-                       return d_show_upstream_with_branch;
-               }
-               set
-               {
-                       if (d_show_upstream_with_branch != value)
-                       {
-                               d_show_upstream_with_branch = value;
-                               changed();
-                       }
-               }
-       }
-
        public string reference_sort_order
        {
                get
@@ -1361,18 +1338,7 @@ public class RefsList : Gtk.ListBox
                                }
                                else
                                {
-                                       var rref = ref_row.reference;
-                                       ret.add(rref);
-
-                                       if (d_show_upstream_with_branch && rref.is_branch())
-                                       {
-                                               var branch = rref as Gitg.Branch;
-
-                                               try
-                                               {
-                                                       ret.add(branch.get_upstream());
-                                               } catch {}
-                                       }
+                                       ret.add(ref_row.reference);
                                }
                        }
                        else
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index b2e3836..07c1c1d 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -134,6 +134,10 @@ namespace GitgHistory
                                update_walker();
                        });
 
+                       d_settings.changed["show-upstream-with-branch"].connect((s, k) => {
+                               update_walker();
+                       });
+
                        d_selected = new Gee.HashSet<Ggit.OId>((Gee.HashDataFunc<Ggit.OId>)Ggit.OId.hash,
                                                               (Gee.EqualDataFunc<Ggit.OId>)Ggit.OId.equal);
 
@@ -924,6 +928,8 @@ namespace GitgHistory
                                }
                        }
 
+                       var show_upstream_with_branch = d_settings.get_boolean("show-upstream-with-branch");
+
                        foreach (var r in d_main.refs_list.selection)
                        {
                                var id = id_for_ref(r);
@@ -941,6 +947,21 @@ namespace GitgHistory
                                                        permanent += id;
                                                }
                                        }
+
+                                       if (show_upstream_with_branch && r.is_branch())
+                                       {
+                                               var branch = r as Gitg.Branch;
+
+                                               try
+                                               {
+                                                       var upid = id_for_ref(branch.get_upstream());
+
+                                                       if (upid != null)
+                                                       {
+                                                               include.add(upid);
+                                                       }
+                                               } catch {}
+                                       }
                                }
                        }
 


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