statusicon updates, not working too well yet

This commit is contained in:
Hylke Bons 2010-05-08 21:06:59 +01:00
parent adc742d9e4
commit 0900dc2b67
2 changed files with 25 additions and 25 deletions

View file

@ -103,7 +103,7 @@ namespace SparkleShare {
// Fetch remote changes every 20 seconds // Fetch remote changes every 20 seconds
FetchTimer = new Timer (); FetchTimer = new Timer ();
FetchTimer.Interval = 20000; FetchTimer.Interval = 10000;
FetchTimer.Elapsed += delegate { FetchTimer.Elapsed += delegate {
Fetch (); Fetch ();
}; };
@ -182,7 +182,7 @@ namespace SparkleShare {
Console.WriteLine ("[Git][" + Name + "] Staging changes..."); Console.WriteLine ("[Git][" + Name + "] Staging changes...");
Process.StartInfo.Arguments = "add --all"; Process.StartInfo.Arguments = "add --all";
Process.Start(); Process.Start();
// SparkleUI.NotificationIcon.SetSyncingState ();
string Message = FormatCommitMessage (); string Message = FormatCommitMessage ();
if (!Message.Equals ("")) { if (!Message.Equals ("")) {
Commit (Message); Commit (Message);
@ -206,29 +206,27 @@ namespace SparkleShare {
// Fetches changes from the remote repo // Fetches changes from the remote repo
public void Fetch () { public void Fetch () {
// TODO: change status icon to sync
FetchTimer.Stop (); FetchTimer.Stop ();
SparkleUI.NotificationIcon.SetSyncingState (); SparkleUI.NotificationIcon.SetSyncingState ();
Console.WriteLine ("[Git][" + Name + "] Fetching changes..."); Console.WriteLine ("[Git][" + Name + "] Fetching changes... ");
Process.StartInfo.Arguments = "fetch"; Process.StartInfo.Arguments = "fetch";
Process.Start(); Process.Start();
Process.WaitForExit (); Process.WaitForExit ();
SparkleUI.NotificationIcon.SetIdleState (); Console.WriteLine ("[Git][" + Name + "] Done fetching changes ");
Merge (); Merge ();
SparkleUI.NotificationIcon.SetIdleState ();
FetchTimer.Start (); FetchTimer.Start ();
} }
// Merges the fetched changes // Merges the fetched changes
public void Merge () { public void Merge () {
Watcher.EnableRaisingEvents = false; Watcher.EnableRaisingEvents = false;
Console.WriteLine ("[Git][" + Name + "] Merging fetched changes... ");
Console.WriteLine ("[Git][" + Name + "] Merging fetched changes...");
Process.StartInfo.Arguments = "merge origin/master"; Process.StartInfo.Arguments = "merge origin/master";
Process.Start(); Process.Start();
Process.WaitForExit (); Process.WaitForExit ();
Console.WriteLine ("[Git][" + Name + "] Done merging changes ");
string Output = Process.StandardOutput.ReadToEnd().Trim (); string Output = Process.StandardOutput.ReadToEnd().Trim ();
// Show notification if there are updates // Show notification if there are updates
if (!Output.Equals ("Already up-to-date.")) { if (!Output.Equals ("Already up-to-date.")) {
@ -254,7 +252,7 @@ namespace SparkleShare {
} }
Watcher.EnableRaisingEvents = true; Watcher.EnableRaisingEvents = true;
// TODO: change status icon to normal
} }
// Pushes the changes to the remote repo // Pushes the changes to the remote repo
@ -264,6 +262,7 @@ namespace SparkleShare {
Process.StartInfo.Arguments = "push"; Process.StartInfo.Arguments = "push";
Process.Start(); Process.Start();
Process.WaitForExit (); Process.WaitForExit ();
// SparkleUI.NotificationIcon.SetIdleState ();
} }
// Ignores Repos, dotfiles, swap files and the like. // Ignores Repos, dotfiles, swap files and the like.

View file

@ -31,13 +31,13 @@ namespace SparkleShare {
public SparkleUI (bool HideUI) { public SparkleUI (bool HideUI) {
string SparklePath = SparklePaths.SparklePath;
Process Process = new Process(); Process Process = new Process();
Process.EnableRaisingEvents = false; Process.EnableRaisingEvents = false;
Process.StartInfo.RedirectStandardOutput = true; Process.StartInfo.RedirectStandardOutput = true;
Process.StartInfo.UseShellExecute = false; Process.StartInfo.UseShellExecute = false;
string SparklePath = SparklePaths.SparklePath;
// Create 'SparkleShare' folder in the user's home folder // Create 'SparkleShare' folder in the user's home folder
// if it's not there already // if it's not there already
if (!Directory.Exists (SparklePath)) { if (!Directory.Exists (SparklePath)) {
@ -66,19 +66,6 @@ namespace SparkleShare {
} }
// Create place to store configuration user's home folder
string ConfigPath = SparklePaths.SparkleConfigPath;
string AvatarPath = SparklePaths.SparkleAvatarPath;
if (!Directory.Exists (ConfigPath)) {
Directory.CreateDirectory (ConfigPath);
Console.WriteLine ("[Config] Created '" + ConfigPath + "'");
// Create a place to store the avatars
Directory.CreateDirectory (AvatarPath);
Console.WriteLine ("[Config] Created '" + AvatarPath + "avatars'");
}
// Get all the repos in ~/SparkleShare // Get all the repos in ~/SparkleShare
string [] Repos = Directory.GetDirectories (SparklePath); string [] Repos = Directory.GetDirectories (SparklePath);
@ -115,6 +102,20 @@ namespace SparkleShare {
} }
// Create place to store configuration user's home folder
string ConfigPath = SparklePaths.SparkleConfigPath;
string AvatarPath = SparklePaths.SparkleAvatarPath;
if (!Directory.Exists (ConfigPath)) {
Directory.CreateDirectory (ConfigPath);
Console.WriteLine ("[Config] Created '" + ConfigPath + "'");
// Create a place to store the avatars
Directory.CreateDirectory (AvatarPath);
Console.WriteLine ("[Config] Created '" + AvatarPath + "avatars'");
}
} }
// Closes the window // Closes the window