Let current view handle reloading when repository changes

This way is really cheap and quick without going throhgh all the user
interface rebuilding process, just let the view handle the reloading
itself, the view should know what is best.
This commit is contained in:
Techlive Zheng 2013-05-23 22:23:15 +08:00 committed by Ignacio Casal Quinteiro
parent dd1cfbe730
commit ed3e11efc3
3 changed files with 13 additions and 2 deletions

View file

@ -205,8 +205,10 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
private void on_reload_activated()
{
this.repository = new Gitg.Repository(this.repository.get_location(),
null);
d_repository = new Gitg.Repository(this.repository.get_location(),
null);
notify_property("repository");
d_views.current.reload();
}
private void on_clone_repository()

View file

@ -56,6 +56,8 @@ public enum ViewAction
*/
public interface View : Object, UIElement
{
public abstract void reload();
/**
* Give the view itself a chance to perform some actions after being
* activated.

View file

@ -170,6 +170,13 @@ namespace GitgHistory
d_navigation.select_first();
}
public void reload()
{
d_navigation.model.reload();
d_navigation.expand_all();
d_navigation.select_first();
}
private void build_ui()
{
var ret = GitgExt.UI.from_builder("history/view-history.ui",