mac, linux: Show a notification after trying to reopen the app twice
This commit is contained in:
parent
99ddc31652
commit
0ae1c77472
|
@ -54,10 +54,17 @@ namespace SparkleShare {
|
|||
private void ApplicationActivatedDelegate (object sender, EventArgs args)
|
||||
{
|
||||
if (this.application.Windows.Length > 0) {
|
||||
bool has_visible_windows = false;
|
||||
|
||||
foreach (Window window in this.application.Windows) {
|
||||
if (window.Visible)
|
||||
if (window.Visible) {
|
||||
window.Present ();
|
||||
has_visible_windows = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_visible_windows)
|
||||
Program.Controller.HandleReopen ();
|
||||
|
||||
} else {
|
||||
Setup = new SparkleSetup ();
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace SparkleShare {
|
|||
|
||||
public void Run ()
|
||||
{
|
||||
NSApplication.Main (new string [0]);
|
||||
NSApplication.Main (Program.Arguments);
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,5 +76,14 @@ namespace SparkleShare {
|
|||
{
|
||||
Program.Controller.Quit ();
|
||||
}
|
||||
|
||||
|
||||
public override bool ApplicationShouldHandleReopen (NSApplication sender, bool has_visible_windows)
|
||||
{
|
||||
if (!has_visible_windows)
|
||||
Program.Controller.HandleReopen ();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace SparkleShare {
|
|||
|
||||
public static SparkleController Controller;
|
||||
public static SparkleUI UI;
|
||||
public static string [] Arguments;
|
||||
|
||||
private static Mutex program_mutex = new Mutex (false, "SparkleShare");
|
||||
|
||||
|
@ -36,6 +37,8 @@ namespace SparkleShare {
|
|||
#endif
|
||||
public static void Main (string [] args)
|
||||
{
|
||||
Arguments = args;
|
||||
|
||||
if (args.Length != 0 && !args [0].Equals ("help") &&
|
||||
SparkleBackend.Platform != PlatformID.MacOSX &&
|
||||
SparkleBackend.Platform != PlatformID.Win32NT) {
|
||||
|
|
|
@ -232,6 +232,20 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
|
||||
private int reopen_attempt_counts = 0;
|
||||
|
||||
public void HandleReopen ()
|
||||
{
|
||||
reopen_attempt_counts++;
|
||||
|
||||
if (reopen_attempt_counts > 1) {
|
||||
AlertNotificationRaised ("Hello!", "SparkleShare sits right here, as a status icon.");
|
||||
reopen_attempt_counts = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UIHasLoaded ()
|
||||
{
|
||||
if (this.lost_folders_path) {
|
||||
|
|
Loading…
Reference in a new issue