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

This commit is contained in:
Jesse van den Kieboom 2015-08-22 13:55:04 +02:00
parent fb293e8920
commit 0bfbe14341
4 changed files with 69 additions and 3 deletions

View file

@ -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" />

View file

@ -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

View file

@ -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

View file

@ -130,6 +130,22 @@
<property name="top_attach">3</property>
</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>
@ -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>