[gitg] Added setting to show upstream tracking branch when selecting a local branch



commit 0bfbe143412795ff3145ec362a689c6f15d4a897
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sat Aug 22 13:55:04 2015 +0200

    Added setting to show upstream tracking branch when selecting a local branch

 data/org.gnome.gitg.gschema.xml.in.in          |    8 +++++
 gitg/history/gitg-history-refs-list.vala       |   36 +++++++++++++++++++++++-
 gitg/preferences/gitg-preferences-history.vala |    8 +++++
 gitg/resources/ui/gitg-preferences-history.ui  |   20 ++++++++++++-
 4 files changed, 69 insertions(+), 3 deletions(-)
---
diff --git a/data/org.gnome.gitg.gschema.xml.in.in b/data/org.gnome.gitg.gschema.xml.in.in
index 5dd3002..03ee81c 100644
--- a/data/org.gnome.gitg.gschema.xml.in.in
+++ b/data/org.gnome.gitg.gschema.xml.in.in
@@ -132,6 +132,14 @@
         The order by which references in the history sidebar should be sorted.
       </_description>
     </key>
+    <key name="show-upstream-with-branch" type="b">
+      <default>true</default>
+      <_summary>Show Upstream With Branch</_summary>
+      <_description>
+         Determines whether to also show the upstream (remote) tracking branch when
+         selecting a local branch in the history view.
+      </_description>
+    </key>
   </schema>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.commit" 
path="/org/gnome/gitg/preferences/commit/">
     <child name="message" schema="org.gnome.gitg.preferences.commit.message" />
diff --git a/gitg/history/gitg-history-refs-list.vala b/gitg/history/gitg-history-refs-list.vala
index ed09d87..a0249d9 100644
--- a/gitg/history/gitg-history-refs-list.vala
+++ b/gitg/history/gitg-history-refs-list.vala
@@ -553,6 +553,11 @@ 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
@@ -574,6 +579,24 @@ 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
@@ -1301,7 +1324,18 @@ public class RefsList : Gtk.ListBox
                                }
                                else
                                {
-                                       ret.add(ref_row.reference);
+                                       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 {}
+                                       }
                                }
                        }
                        else
diff --git a/gitg/preferences/gitg-preferences-history.vala b/gitg/preferences/gitg-preferences-history.vala
index 60ffe7f..d01da5c 100644
--- a/gitg/preferences/gitg-preferences-history.vala
+++ b/gitg/preferences/gitg-preferences-history.vala
@@ -53,6 +53,9 @@ public class PreferencesHistory : Gtk.Grid, GitgExt.Preferences
        [GtkChild (name = "sort_references_by_activity")]
        private Gtk.CheckButton d_sort_references_by_activity;
 
+       [GtkChild (name = "show_upstream_with_branch")]
+       private Gtk.CheckButton d_show_upstream_with_branch;
+
        private Gtk.RadioButton[] d_select_buttons;
        private string[] d_select_names;
 
@@ -151,6 +154,11 @@ public class PreferencesHistory : Gtk.Grid, GitgExt.Preferences
 
                    null, null
                );
+
+               settings.bind("show-upstream-with-branch",
+                             d_show_upstream_with_branch,
+                             "active",
+                             SettingsBindFlags.GET | SettingsBindFlags.SET);
        }
 
        public string default_selection
diff --git a/gitg/resources/ui/gitg-preferences-history.ui b/gitg/resources/ui/gitg-preferences-history.ui
index 202025e..03a8c65 100644
--- a/gitg/resources/ui/gitg-preferences-history.ui
+++ b/gitg/resources/ui/gitg-preferences-history.ui
@@ -131,6 +131,22 @@
           </packing>
         </child>
         <child>
+          <object class="GtkCheckButton" id="show_upstream_with_branch">
+            <property name="label" translatable="yes">Show upstream (remote) branch when selecting a local 
branch</property>
+            <property name="use_action_appearance">False</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="halign">start</property>
+            <property name="draw_indicator">True</property>
+            <property name="margin_start">12</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">4</property>
+          </packing>
+        </child>
+        <child>
           <object class="GtkLabel" id="label1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -143,7 +159,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">4</property>
+            <property name="top_attach">5</property>
           </packing>
         </child>
         <child>
@@ -254,7 +270,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">5</property>
+            <property name="top_attach">6</property>
           </packing>
         </child>
       </object>


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