statusicon: hook up to controller on linux too
This commit is contained in:
parent
2af684bf4c
commit
d7c4df1fba
|
@ -117,9 +117,6 @@ namespace SparkleShare {
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -568,16 +568,7 @@ namespace SparkleShare {
|
|||
if (backend == null)
|
||||
return;
|
||||
|
||||
SparkleRepoBase repo = null;
|
||||
|
||||
/* if (backend.Equals ("Hg"))
|
||||
repo = new SparkleRepoHg (folder_path, new SparkleBackendHg ());
|
||||
|
||||
else if (backend.Equals ("Scp"))
|
||||
repo = new SparkleRepoScp (folder_path, new SparkleBackendScp ());
|
||||
|
||||
else */
|
||||
repo = new SparkleRepoGit (folder_path, SparkleBackend.DefaultBackend);
|
||||
SparkleRepoBase repo = new SparkleRepoGit (folder_path, SparkleBackend.DefaultBackend);
|
||||
|
||||
repo.NewChangeSet += delegate (SparkleChangeSet change_set) {
|
||||
string message = FormatMessage (change_set);
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace SparkleShare {
|
|||
// user's notification area
|
||||
public class SparkleStatusIcon {
|
||||
|
||||
public SparkleStatusIconController Controller = new SparkleStatusIconController ();
|
||||
|
||||
private Timer Animation;
|
||||
private Gdk.Pixbuf [] AnimationFrames;
|
||||
private int FrameNumber;
|
||||
|
@ -66,45 +68,60 @@ namespace SparkleShare {
|
|||
|
||||
this.status_icon.Activate += ShowMenu; // Primary mouse button click
|
||||
this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
|
||||
this.status_icon.Pixbuf = AnimationFrames [0];
|
||||
#endif
|
||||
|
||||
SetNormalState ();
|
||||
StateText = _("Up to date") + " (" + Controller.FolderSize + ")";
|
||||
|
||||
CreateMenu ();
|
||||
|
||||
SparkleShare.Controller.FolderSizeChanged += delegate {
|
||||
Controller.UpdateMenuEvent += delegate (IconState state) {
|
||||
Application.Invoke (delegate {
|
||||
switch (state) {
|
||||
case IconState.Idle:
|
||||
|
||||
Animation.Stop ();
|
||||
|
||||
if (Controller.Folders.Length == 0)
|
||||
StateText = _("Welcome to SparkleShare!");
|
||||
else
|
||||
StateText = _("Up to date") + " (" + Controller.FolderSize + ")";
|
||||
|
||||
#if HAVE_APP_INDICATOR
|
||||
this.indicator.IconName = "process-syncing-sparkleshare-i";
|
||||
#else
|
||||
this.status_icon.Pixbuf = AnimationFrames [0];
|
||||
#endif
|
||||
|
||||
UpdateStateText ();
|
||||
CreateMenu ();
|
||||
|
||||
break;
|
||||
|
||||
case IconState.Syncing:
|
||||
|
||||
StateText = _("Syncing…");
|
||||
UpdateStateText (); // TODO
|
||||
|
||||
if (!Animation.Enabled)
|
||||
SetNormalState ();
|
||||
Animation.Start ();
|
||||
|
||||
UpdateMenu ();
|
||||
});
|
||||
};
|
||||
break;
|
||||
|
||||
SparkleShare.Controller.FolderListChanged += delegate {
|
||||
Application.Invoke (delegate {
|
||||
SetNormalState ();
|
||||
case IconState.Error:
|
||||
|
||||
StateText = _("Not everything is synced");
|
||||
UpdateStateText ();
|
||||
CreateMenu ();
|
||||
});
|
||||
};
|
||||
|
||||
SparkleShare.Controller.OnIdle += delegate {
|
||||
Application.Invoke (delegate {
|
||||
SetNormalState ();
|
||||
UpdateMenu ();
|
||||
});
|
||||
};
|
||||
#if HAVE_APP_INDICATOR
|
||||
this.indicator.IconName = "sparkleshare-syncing-error";
|
||||
#else
|
||||
this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
|
||||
#endif
|
||||
|
||||
SparkleShare.Controller.OnSyncing += delegate {
|
||||
Application.Invoke (delegate {
|
||||
SetAnimationState ();
|
||||
UpdateMenu ();
|
||||
});
|
||||
};
|
||||
|
||||
SparkleShare.Controller.OnError += delegate {
|
||||
Application.Invoke (delegate {
|
||||
SetNormalState (true);
|
||||
UpdateMenu ();
|
||||
break;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -313,7 +330,7 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public void UpdateMenu ()
|
||||
public void UpdateStateText ()
|
||||
{
|
||||
((Menu.Children [0] as MenuItem).Child as Label).Text = StateText;
|
||||
Menu.ShowAll ();
|
||||
|
@ -333,63 +350,6 @@ namespace SparkleShare {
|
|||
StatusIcon.PositionMenu (menu, out x, out y, out push_in, this.status_icon.Handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
// The state when there's nothing going on
|
||||
private void SetNormalState ()
|
||||
{
|
||||
SetNormalState (false);
|
||||
}
|
||||
|
||||
|
||||
// The state when there's nothing going on
|
||||
private void SetNormalState (bool error)
|
||||
{
|
||||
Animation.Stop ();
|
||||
|
||||
if (SparkleShare.Controller.Folders.Count == 0) {
|
||||
StateText = _("Welcome to SparkleShare!");
|
||||
|
||||
Application.Invoke (delegate {
|
||||
#if HAVE_APP_INDICATOR
|
||||
this.indicator.IconName = "process-syncing-sparkleshare-i";
|
||||
#else
|
||||
this.status_icon.Pixbuf = AnimationFrames [0];
|
||||
#endif
|
||||
});
|
||||
|
||||
} else {
|
||||
if (error) {
|
||||
StateText = _("Not everything is synced");
|
||||
|
||||
Application.Invoke (delegate {
|
||||
#if HAVE_APP_INDICATOR
|
||||
this.indicator.IconName = "sparkleshare-syncing-error";
|
||||
#else
|
||||
this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
|
||||
#endif
|
||||
});
|
||||
} else {
|
||||
StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")";
|
||||
Application.Invoke (delegate {
|
||||
#if HAVE_APP_INDICATOR
|
||||
this.indicator.IconName = "process-syncing-sparkleshare-i";
|
||||
#else
|
||||
this.status_icon.Pixbuf = AnimationFrames [0];
|
||||
#endif
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The state when animating
|
||||
private void SetAnimationState ()
|
||||
{
|
||||
StateText = _("Syncing…");
|
||||
|
||||
if (!Animation.Enabled)
|
||||
Animation.Start ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue