[repo] add a description property and use it as a tooltip in [statusicon]

This commit is contained in:
Hylke Bons 2010-08-14 21:02:00 +01:00
parent 9a846bfc44
commit 9c6c6aacae
2 changed files with 34 additions and 4 deletions

View file

@ -35,6 +35,7 @@ namespace SparkleLib {
public string Name;
public string Domain;
public string Description;
public string LocalPath;
public string RemoteOriginUrl;
public string CurrentHash;
@ -83,6 +84,7 @@ namespace SparkleLib {
RemoteOriginUrl = GetRemoteOriginUrl ();
CurrentHash = GetCurrentHash ();
Domain = GetDomain (RemoteOriginUrl);
Description = GetDescription ();
if (CurrentHash == null)
CreateInitialCommit ();
@ -487,6 +489,27 @@ namespace SparkleLib {
}
// Gets the repository's description
public string GetDescription ()
{
string description_file_path = SparkleHelpers.CombineMore (LocalPath, ".git", "description");
if (!File.Exists (description_file_path))
return null;
StreamReader reader = new StreamReader (description_file_path);
string description = reader.ReadToEnd ();
reader.Close ();
if (description.StartsWith ("Unnamed"))
description = null;
return description;
}
// Gets hash of the current commit
public string GetCurrentHash ()
{

View file

@ -215,16 +215,23 @@ namespace SparkleShare {
if (SparkleUI.Repositories.Count > 0) {
foreach (SparkleRepo SparkleRepo in SparkleUI.Repositories) {
foreach (SparkleRepo repo in SparkleUI.Repositories) {
FolderAction = new Gtk.Action ("", SparkleRepo.Name) {
FolderAction = new Gtk.Action ("", repo.Name) {
IconName = "folder",
IsImportant = true
};
FolderAction.Activated += CreateWindowDelegate (SparkleRepo);
FolderAction.Activated += CreateWindowDelegate (repo);
Menu.Add (FolderAction.CreateMenuItem ());
MenuItem menu_item = (MenuItem) FolderAction.CreateMenuItem ();
if (repo.Description != null)
menu_item.TooltipText = repo.Description;
else
menu_item.TooltipText = "No description";
Menu.Add (menu_item);
}