Handle showing upstream in history instead of selection

This commit is contained in:
Jesse van den Kieboom 2015-08-22 14:22:46 +02:00
parent 316d46c3ce
commit 01ce13d1a4
2 changed files with 22 additions and 35 deletions

View file

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

View file

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