[repo] add a description property and use it as a tooltip in [statusicon]
This commit is contained in:
parent
747988e516
commit
ecebd2d33c
|
@ -35,6 +35,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public string Name;
|
public string Name;
|
||||||
public string Domain;
|
public string Domain;
|
||||||
|
public string Description;
|
||||||
public string LocalPath;
|
public string LocalPath;
|
||||||
public string RemoteOriginUrl;
|
public string RemoteOriginUrl;
|
||||||
public string CurrentHash;
|
public string CurrentHash;
|
||||||
|
@ -83,6 +84,7 @@ namespace SparkleLib {
|
||||||
RemoteOriginUrl = GetRemoteOriginUrl ();
|
RemoteOriginUrl = GetRemoteOriginUrl ();
|
||||||
CurrentHash = GetCurrentHash ();
|
CurrentHash = GetCurrentHash ();
|
||||||
Domain = GetDomain (RemoteOriginUrl);
|
Domain = GetDomain (RemoteOriginUrl);
|
||||||
|
Description = GetDescription ();
|
||||||
|
|
||||||
if (CurrentHash == null)
|
if (CurrentHash == null)
|
||||||
CreateInitialCommit ();
|
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
|
// Gets hash of the current commit
|
||||||
public string GetCurrentHash ()
|
public string GetCurrentHash ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -215,16 +215,23 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (SparkleUI.Repositories.Count > 0) {
|
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",
|
IconName = "folder",
|
||||||
IsImportant = true
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue