Set header bar title

Set the header title to the current repo name and also refactor code to
avoid duplication with the dash
This commit is contained in:
Paolo Borelli 2013-03-24 12:32:48 +01:00
parent ed4a488ce5
commit 1ec60b3c84
3 changed files with 32 additions and 10 deletions

View file

@ -114,6 +114,19 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
title = "(%s) - gitg".printf(workdir.get_parse_name());
}
d_header_bar.set_title(d_repository.name);
string? head_name = null;
try
{
var head = repository.get_head();
head_name = head.parsed_name.shortname;
}
catch {}
d_header_bar.set_subtitle(Markup.escape_text(head_name));
d_main_stack.transition_type = Gd.StackTransitionType.SLIDE_LEFT;
d_main_stack.set_visible_child(d_paned_views);
d_commit_view_switcher.show();
@ -125,6 +138,9 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
{
title = "gitg";
d_header_bar.set_title(_("Projects"));
d_header_bar.set_subtitle(null);
d_main_stack.transition_type = Gd.StackTransitionType.SLIDE_RIGHT;
d_main_stack.set_visible_child(d_dash_scrolled_window);
d_commit_view_switcher.hide();

View file

@ -225,23 +225,19 @@ namespace GitgGtk
public void add_repository(Gitg.Repository repository)
{
RepositoryData? data = get_data_for_repository(repository);
File? workdir = repository.get_workdir();
File? repo_file = repository.get_location();
if (data == null)
{
var name = (workdir != null) ? workdir.get_basename() : repo_file.get_basename();
Gitg.Ref? head = null;
string branch_name = "";
string head_name = "";
try
{
head = repository.get_head();
branch_name = head.parsed_name.shortname;
var head = repository.get_head();
head_name = head.parsed_name.shortname;
}
catch {}
data = create_repository_data(name, branch_name, false);
data = create_repository_data(repository.name, head_name, false);
data.repository = repository;
}
else
@ -251,8 +247,11 @@ namespace GitgGtk
d_listbox.resort();
}
var uri = (workdir != null) ? workdir.get_uri() : repo_file.get_uri();
add_repository_to_recent_manager(uri);
var f = repository.workdir != null ? repository.workdir : repository.location;
if (f != null)
{
add_repository_to_recent_manager(f.get_uri());
}
}
private async Gitg.Repository? clone(string url, File location)

View file

@ -24,6 +24,13 @@ public class Repository : Ggit.Repository
{
private HashTable<Ggit.OId, SList<Gitg.Ref>> d_refs;
public string? name {
owned get {
var f = workdir != null ? workdir : location;
return f != null ? f.get_basename() : null;
}
}
public Repository(File location, File? workdir) throws Error
{
Object(location: location,