mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-08-27 20:09:23 +00:00
Automatically select branch in history
This commit is contained in:
parent
5aa2577aa4
commit
eff97b8a12
|
@ -315,6 +315,7 @@ public class CommitModel : Object
|
|||
try
|
||||
{
|
||||
d_cancellable.reset();
|
||||
emit_started();
|
||||
d_thread = new Thread<void*>.try("gitg-history-walk", run);
|
||||
yield;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace GitgHistory
|
|||
|
||||
private Gtk.TreeView d_view;
|
||||
private GitgGtk.CommitModel? d_model;
|
||||
private Gee.HashSet<Ggit.OId> d_selected;
|
||||
private ulong d_insertsig;
|
||||
|
||||
private Gtk.Widget d_main;
|
||||
|
||||
|
@ -54,10 +56,47 @@ namespace GitgHistory
|
|||
construct
|
||||
{
|
||||
d_model = new GitgGtk.CommitModel(application.repository);
|
||||
d_selected = new Gee.HashSet<Ggit.OId>(Ggit.OId.hash, (EqualFunc<Ggit.OId>)Ggit.OId.equal);
|
||||
|
||||
d_model.started.connect(on_commit_model_started);
|
||||
d_model.finished.connect(on_commit_model_finished);
|
||||
|
||||
application.bind_property("repository", d_model, "repository", BindingFlags.DEFAULT);
|
||||
}
|
||||
|
||||
private void on_commit_model_started(Gitg.CommitModel model)
|
||||
{
|
||||
if (d_selected.size > 0 && d_insertsig == 0)
|
||||
{
|
||||
d_insertsig = d_model.row_inserted.connect(on_row_inserted_select);
|
||||
}
|
||||
}
|
||||
|
||||
private void on_row_inserted_select(Gtk.TreeModel model, Gtk.TreePath path, Gtk.TreeIter iter)
|
||||
{
|
||||
var commit = d_model.commit_from_path(path);
|
||||
|
||||
if (d_selected.remove(commit.get_id()))
|
||||
{
|
||||
d_view.get_selection().select_path(path);
|
||||
|
||||
if (d_selected.size == 0)
|
||||
{
|
||||
d_model.disconnect(d_insertsig);
|
||||
d_insertsig = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void on_commit_model_finished(Gitg.CommitModel model)
|
||||
{
|
||||
if (d_insertsig != 0)
|
||||
{
|
||||
d_model.disconnect(d_insertsig);
|
||||
d_insertsig = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool available
|
||||
{
|
||||
get
|
||||
|
@ -164,6 +203,9 @@ namespace GitgHistory
|
|||
|
||||
if (id != null)
|
||||
{
|
||||
d_selected.clear();
|
||||
d_selected.add(id);
|
||||
|
||||
d_model.set_include(new Ggit.OId[] { id });
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue