[gitg] Set header bar title
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Set header bar title
- Date: Sun, 24 Mar 2013 11:38:47 +0000 (UTC)
commit 1ec60b3c84558631a82279dbe1a9677a0a94fa42
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Mar 24 12:32:48 2013 +0100
Set header bar title
Set the header title to the current repo name and also refactor code to
avoid duplication with the dash
gitg/gitg-window.vala | 16 ++++++++++++++++
libgitg-gtk/gitg-gtk-dash-view.vala | 19 +++++++++----------
libgitg/gitg-repository.vala | 7 +++++++
3 files changed, 32 insertions(+), 10 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 1e8f111..a907634 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -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();
diff --git a/libgitg-gtk/gitg-gtk-dash-view.vala b/libgitg-gtk/gitg-gtk-dash-view.vala
index 9ae1d6f..abeb0cb 100644
--- a/libgitg-gtk/gitg-gtk-dash-view.vala
+++ b/libgitg-gtk/gitg-gtk-dash-view.vala
@@ -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)
diff --git a/libgitg/gitg-repository.vala b/libgitg/gitg-repository.vala
index d182db7..950b845 100644
--- a/libgitg/gitg-repository.vala
+++ b/libgitg/gitg-repository.vala
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]