about: simplify UI events
This commit is contained in:
parent
e22eb9417d
commit
895d17d057
|
@ -55,6 +55,7 @@ namespace SparkleShare {
|
|||
|
||||
CreateAbout ();
|
||||
|
||||
|
||||
Controller.HideWindowEvent += delegate {
|
||||
Application.Invoke (delegate {
|
||||
HideAll ();
|
||||
|
@ -68,29 +69,9 @@ namespace SparkleShare {
|
|||
});
|
||||
};
|
||||
|
||||
Controller.NewVersionEvent += delegate (string new_version) {
|
||||
Controller.UpdateLabelEvent += delegate (string text) {
|
||||
Application.Invoke (delegate {
|
||||
this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#8cc4ff'>{0}</span>",
|
||||
string.Format ("A newer version ({0}) is available!", new_version));
|
||||
|
||||
this.updates.ShowAll ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.VersionUpToDateEvent += delegate {
|
||||
Application.Invoke (delegate {
|
||||
this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#8cc4ff'>{0}</span>",
|
||||
"You are running the latest version.");
|
||||
|
||||
this.updates.ShowAll ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.CheckingForNewVersionEvent += delegate {
|
||||
Application.Invoke (delegate {
|
||||
this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#8cc4ff'>{0}</span>",
|
||||
"Checking for updates...");
|
||||
|
||||
this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#8cc4ff'>{0}</span>", text);
|
||||
this.updates.ShowAll ();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -59,9 +59,7 @@ namespace SparkleShare {
|
|||
CreateAbout ();
|
||||
|
||||
|
||||
this.hidden_close_button.Activated += delegate {
|
||||
Controller.WindowClosed ();
|
||||
};
|
||||
this.hidden_close_button.Activated += delegate { Controller.WindowClosed (); };
|
||||
|
||||
Controller.HideWindowEvent += delegate {
|
||||
Program.Controller.Invoke (() => PerformClose (this));
|
||||
|
@ -71,22 +69,8 @@ namespace SparkleShare {
|
|||
Program.Controller.Invoke (() => OrderFrontRegardless ());
|
||||
};
|
||||
|
||||
Controller.NewVersionEvent += delegate (string new_version) {
|
||||
Program.Controller.Invoke (() => {
|
||||
this.updates_text_field.StringValue = "A newer version (" + new_version + ") is available!";
|
||||
});
|
||||
};
|
||||
|
||||
Controller.VersionUpToDateEvent += delegate {
|
||||
Program.Controller.Invoke (() => {
|
||||
this.updates_text_field.StringValue = "You are running the latest version.";
|
||||
});
|
||||
};
|
||||
|
||||
Controller.CheckingForNewVersionEvent += delegate {
|
||||
Program.Controller.Invoke (() => {
|
||||
this.updates_text_field.StringValue = "Checking for updates...";
|
||||
});
|
||||
Controller.UpdateLabelEvent += delegate (string text) {
|
||||
Program.Controller.Invoke (() => { this.updates_text_field.StringValue = text; });
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -30,11 +30,10 @@ namespace SparkleShare {
|
|||
public SparkleBubbles ()
|
||||
{
|
||||
Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
|
||||
// Notification center was introduced in Mountain Lion
|
||||
if (Environment.OSVersion.Version.Major < 12)
|
||||
return;
|
||||
return; // The notification center was introduced in Mountain Lion
|
||||
|
||||
InvokeOnMainThread (delegate {
|
||||
InvokeOnMainThread (() => {
|
||||
NSUserNotification notification = new NSUserNotification () {
|
||||
Title = title,
|
||||
InformativeText = subtext,
|
||||
|
|
|
@ -25,11 +25,9 @@ namespace SparkleShare {
|
|||
|
||||
public event Action ShowWindowEvent = delegate { };
|
||||
public event Action HideWindowEvent = delegate { };
|
||||
public event Action VersionUpToDateEvent = delegate { };
|
||||
public event Action CheckingForNewVersionEvent = delegate { };
|
||||
|
||||
public event NewVersionEventDelegate NewVersionEvent = delegate { };
|
||||
public delegate void NewVersionEventDelegate (string new_version_string);
|
||||
public event UpdateLabelEventDelegate UpdateLabelEvent = delegate { };
|
||||
public delegate void UpdateLabelEventDelegate (string text);
|
||||
|
||||
public readonly string WebsiteLinkAddress = "http://www.sparkleshare.org/";
|
||||
public readonly string CreditsLinkAddress = "http://www.github.com/hbons/SparkleShare/tree/master/legal/AUTHORS";
|
||||
|
@ -60,7 +58,7 @@ namespace SparkleShare {
|
|||
|
||||
private void CheckForNewVersion ()
|
||||
{
|
||||
CheckingForNewVersionEvent ();
|
||||
UpdateLabelEvent ("Checking for updates...");
|
||||
Thread.Sleep (500);
|
||||
|
||||
WebClient web_client = new WebClient ();
|
||||
|
@ -70,9 +68,9 @@ namespace SparkleShare {
|
|||
string latest_version = web_client.DownloadString (uri);
|
||||
|
||||
if (new Version (latest_version) > new Version (RunningVersion))
|
||||
NewVersionEvent (latest_version);
|
||||
UpdateLabelEvent ("A newer version (" + latest_version + ") is available!");
|
||||
else
|
||||
VersionUpToDateEvent ();
|
||||
UpdateLabelEvent ("You are running the latest version.");
|
||||
|
||||
} catch {
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@ using IO = System.IO;
|
|||
|
||||
namespace SparkleShare {
|
||||
|
||||
public class SparklePlugin {
|
||||
public class SparklePlugin : XmlDocument {
|
||||
|
||||
public static string PluginsPath = "";
|
||||
|
||||
public static string LocalPluginsPath = IO.Path.Combine (
|
||||
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "sparkleshare", "plugins");
|
||||
|
||||
public string Name { get { return GetValue ("info", "name"); } }
|
||||
new public string Name { get { return GetValue ("info", "name"); } }
|
||||
public string Description { get { return GetValue ("info", "description"); } }
|
||||
public string Backend { get { return GetValue ("info", "backend"); } }
|
||||
public string Fingerprint { get { return GetValue ("info", "fingerprint"); } }
|
||||
|
@ -62,14 +62,13 @@ namespace SparkleShare {
|
|||
}
|
||||
}
|
||||
|
||||
private XmlDocument xml = new XmlDocument ();
|
||||
private string plugin_directory;
|
||||
|
||||
|
||||
public SparklePlugin (string plugin_path)
|
||||
{
|
||||
this.plugin_directory = System.IO.Path.GetDirectoryName (plugin_path);
|
||||
this.xml.Load (plugin_path);
|
||||
Load (plugin_path);
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,14 +106,13 @@ namespace SparkleShare {
|
|||
IO.Directory.CreateDirectory (LocalPluginsPath);
|
||||
|
||||
IO.File.WriteAllText (plugin_path, plugin_xml);
|
||||
|
||||
return new SparklePlugin (plugin_path);
|
||||
}
|
||||
|
||||
|
||||
private string GetValue (string a, string b)
|
||||
{
|
||||
XmlNode node = this.xml.SelectSingleNode ("/sparkleshare/plugin/" + a + "/" + b + "/text()");
|
||||
XmlNode node = SelectSingleNode ("/sparkleshare/plugin/" + a + "/" + b + "/text()");
|
||||
|
||||
if (node != null && !string.IsNullOrEmpty (node.Value))
|
||||
return node.Value;
|
||||
|
|
|
@ -56,28 +56,14 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
Controller.HideWindowEvent += delegate {
|
||||
Dispatcher.BeginInvoke((Action)delegate {
|
||||
Dispatcher.BeginInvoke ((Action) delegate {
|
||||
Hide ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.NewVersionEvent += delegate (string new_version) {
|
||||
Dispatcher.BeginInvoke((Action)delegate {
|
||||
this.updates.Content = "A newer version (" + new_version + ") is available!";
|
||||
this.updates.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.VersionUpToDateEvent += delegate {
|
||||
Controller.UpdateLabelEvent += delegate (string text) {
|
||||
Dispatcher.BeginInvoke ((Action) delegate {
|
||||
this.updates.Content = "You are running the latest version.";
|
||||
this.updates.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.CheckingForNewVersionEvent += delegate {
|
||||
Dispatcher.BeginInvoke ((Action) delegate {
|
||||
this.updates.Content = "Checking for updates...";
|
||||
this.updates.Content = text;
|
||||
this.updates.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue