[repo] Add an error state icon and [repo] don't commit empty change sets

This commit is contained in:
Hylke Bons 2010-08-28 19:56:19 +01:00
parent 343daaa614
commit 5ca135f3f6
6 changed files with 2954 additions and 2331 deletions

View file

@ -56,6 +56,7 @@ namespace SparkleLib {
public delegate void NewCommitEventHandler (object o, NewCommitArgs args);
public delegate void ConflictDetectedEventHandler (object o, SparkleEventArgs args);
public delegate void ChangesDetectedEventHandler (object o, SparkleEventArgs args);
public delegate void CommitEndedUpEmptyEventHandler (object o, SparkleEventArgs args);
public event AddedEventHandler Added;
public event CommitedEventHandler Commited;
@ -67,6 +68,7 @@ namespace SparkleLib {
public event NewCommitEventHandler NewCommit;
public event ConflictDetectedEventHandler ConflictDetected;
public event ChangesDetectedEventHandler ChangesDetected;
public event CommitEndedUpEmptyEventHandler CommitEndedUpEmpty;
public SparkleRepo (string path)
@ -198,9 +200,12 @@ namespace SparkleLib {
TimeSpan changed = new TimeSpan (now.Ticks - LastChange.Ticks);
if (changed.TotalMilliseconds > 5000) {
HasChanged = false;
SparkleHelpers.DebugInfo ("Local", "[" + Name + "] Changes have settled, adding files...");
HasChanged = false;
AddCommitAndPush ();
}
}
@ -223,7 +228,7 @@ namespace SparkleLib {
if (!HasChanged) {
SparkleEventArgs args = new SparkleEventArgs ("ChangesDetected");
Console.WriteLine ("test");
if (ChangesDetected != null)
ChangesDetected (this, args);
@ -245,7 +250,7 @@ Console.WriteLine ("test");
}
// When there are changes we generally want to Add, Commit and Push
// When there are changes we generally want to Add, Commit and Push,
// so this method does them all with appropriate timers, etc. switched off
public void AddCommitAndPush ()
{
@ -265,6 +270,13 @@ Console.WriteLine ("test");
CheckForRemoteChanges ();
Push ();
} else {
SparkleEventArgs args = new SparkleEventArgs ("CommitEndedUpEmpty");
if (CommitEndedUpEmpty != null)
CommitEndedUpEmpty (this, args);
}
} finally {

View file

@ -329,6 +329,14 @@ namespace SparkleShare {
public void ShowState ()
{
ShowState (false);
}
public void ShowState (bool error)
{
UpdateFolderSize ();
@ -339,10 +347,18 @@ namespace SparkleShare {
if (SyncingReposCount > SparkleUI.Repositories.Count)
SyncingReposCount = SparkleUI.Repositories.Count;
if (SyncingReposCount > 0)
SetSyncingState ();
else
SetIdleState ();
if (error) {
SetErrorState ();
} else {
if (SyncingReposCount > 0)
SetSyncingState ();
else
SetIdleState ();
}
UpdateStatusMenuItem ();
@ -374,15 +390,12 @@ namespace SparkleShare {
// Changes the state to indicate there was an error syncing
public void ShowErrorState ()
public void SetErrorState ()
{
Pixbuf = SparkleHelpers.GetIcon ("image-missing", 24);
StateText = _("Failed to sync your changes");
UpdateStatusMenuItem ();
SparkleHelpers.DebugInfo ("Status", "Number of repos syncing: " + SyncingReposCount);
Timer.Stop ();
Application.Invoke (delegate { Pixbuf = SparkleHelpers.GetIcon ("sparkleshare-syncing-error", 24); });
StateText = _("Failed to sync changes");
}

View file

@ -359,7 +359,7 @@ namespace SparkleShare {
{
NotificationIcon.SyncingReposCount--;
NotificationIcon.ShowErrorState ();
NotificationIcon.ShowState (true);
}
@ -410,6 +410,10 @@ namespace SparkleShare {
Application.Invoke (UpdateStatusIconToIdle);
};
repo.CommitEndedUpEmpty += delegate {
Application.Invoke (UpdateStatusIconToIdle);
};
repo.PushingFailed += delegate {
Application.Invoke (UpdateStatusIconToError);
};

View file

@ -19,6 +19,7 @@ app_theme_icons = \
places,folder-sparkleshare-256.png \
places,folder-sparkleshare-32.png \
places,folder-sparkleshare-48.png \
status,sparkleshare-syncing-error-24.png \
status,avatar-default-16.png \
status,avatar-default-22.png \
status,avatar-default-24.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 844 KiB

After

Width:  |  Height:  |  Size: 868 KiB