[osx] Pop up a warning when the backend (git) isn't found.
This commit is contained in:
parent
be2edd8866
commit
d79fcce3a2
|
@ -21,54 +21,31 @@ using Mono.Unix;
|
||||||
|
|
||||||
namespace SparkleLib {
|
namespace SparkleLib {
|
||||||
|
|
||||||
public static class SparklePaths
|
public static class Backend {
|
||||||
{
|
|
||||||
|
|
||||||
public static string GitPath = SystemGitPath;
|
public static string Name = "Git";
|
||||||
|
|
||||||
public static string HomePath = new UnixUserInfo (UnixEnvironment.UserName).HomeDirectory;
|
public static string Path {
|
||||||
|
|
||||||
public static string SparklePath = Path.Combine (HomePath ,"SparkleShare");
|
|
||||||
|
|
||||||
public static string SparkleTmpPath = Path.Combine (SparklePath, ".tmp");
|
|
||||||
|
|
||||||
public static string SparkleConfigPath = SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare");
|
|
||||||
|
|
||||||
public static string SparkleKeysPath = SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare");
|
|
||||||
|
|
||||||
public static string SparkleInstallPath = SparkleHelpers.CombineMore (Defines.PREFIX, "sparkleshare");
|
|
||||||
|
|
||||||
public static string SparkleLocalIconPath = SparkleHelpers.CombineMore (SparkleConfigPath, "icons", "hicolor");
|
|
||||||
|
|
||||||
public static string SparkleIconPath = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare",
|
|
||||||
"icons");
|
|
||||||
|
|
||||||
|
|
||||||
private static string SystemGitPath
|
|
||||||
{
|
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
||||||
Process process = new Process ();
|
Process process = new Process ();
|
||||||
|
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
process.StartInfo.FileName = "which";
|
process.StartInfo.FileName = "which";
|
||||||
process.StartInfo.Arguments = "git";
|
process.StartInfo.Arguments = Backend.Name.ToLower ();
|
||||||
process.Start ();
|
process.Start ();
|
||||||
|
|
||||||
string git_path = process.StandardOutput.ReadToEnd ();
|
string path = process.StandardOutput.ReadToEnd ();
|
||||||
git_path = git_path.Trim ();
|
path = path.Trim ();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty (git_path)) {
|
if (!string.IsNullOrEmpty (path)) {
|
||||||
|
|
||||||
return git_path;
|
return path;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Console.WriteLine ("Sorry, SparkleShare needs Git to run, but it wasn't found.");
|
Console.WriteLine ("Sorry, SparkleShare needs " + Backend.Name + " to run, but it wasn't found.");
|
||||||
Environment.Exit (-1);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,6 +54,42 @@ namespace SparkleLib {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static bool IsPresent {
|
||||||
|
|
||||||
|
get {
|
||||||
|
|
||||||
|
Process process = new Process ();
|
||||||
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
|
process.StartInfo.UseShellExecute = false;
|
||||||
|
process.StartInfo.FileName = "which";
|
||||||
|
process.StartInfo.Arguments = Backend.Name.ToLower ();
|
||||||
|
process.Start ();
|
||||||
|
|
||||||
|
string path = process.StandardOutput.ReadToEnd ();
|
||||||
|
path = path.Trim ();
|
||||||
|
|
||||||
|
return !string.IsNullOrEmpty (path);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class SparklePaths {
|
||||||
|
|
||||||
|
public static string GitPath = Backend.Path;
|
||||||
|
public static string HomePath = new UnixUserInfo (UnixEnvironment.UserName).HomeDirectory;
|
||||||
|
public static string SparklePath = Path.Combine (HomePath ,"SparkleShare");
|
||||||
|
public static string SparkleTmpPath = Path.Combine (SparklePath, ".tmp");
|
||||||
|
public static string SparkleConfigPath = SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare");
|
||||||
|
public static string SparkleKeysPath = SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare");
|
||||||
|
public static string SparkleInstallPath = SparkleHelpers.CombineMore (Defines.PREFIX, "sparkleshare");
|
||||||
|
public static string SparkleLocalIconPath = SparkleHelpers.CombineMore (SparkleConfigPath, "icons", "hicolor");
|
||||||
|
public static string SparkleIconPath = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare", "icons");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
65
SparkleShare/Mac/SparkleAlert.cs
Normal file
65
SparkleShare/Mac/SparkleAlert.cs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
// SparkleShare, an instant update workflow to Git.
|
||||||
|
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using MonoMac.Foundation;
|
||||||
|
using MonoMac.AppKit;
|
||||||
|
using MonoMac.ObjCRuntime;
|
||||||
|
using MonoMac.WebKit;
|
||||||
|
using Mono.Unix;
|
||||||
|
|
||||||
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
public class SparkleAlert : NSAlert {
|
||||||
|
|
||||||
|
public SparkleAlert () : base ()
|
||||||
|
{
|
||||||
|
|
||||||
|
MessageText = "SparkleShare couldn't find Git on your system. Do you want to download it?";
|
||||||
|
InformativeText = "Git is required to run SparkleShare.";
|
||||||
|
|
||||||
|
Icon = NSImage.ImageNamed ("sparkleshare.icns");
|
||||||
|
|
||||||
|
AddButton ("Download");
|
||||||
|
AddButton ("Cancel");
|
||||||
|
|
||||||
|
Buttons [0].Activated += delegate {
|
||||||
|
|
||||||
|
NSUrl url = new NSUrl ("http://code.google.com/p/git-osx-installer/downloads/list");
|
||||||
|
NSWorkspace.SharedWorkspace.OpenUrl (url);
|
||||||
|
Environment.Exit (0);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Buttons [1].Activated += delegate {
|
||||||
|
|
||||||
|
(Window as NSWindow).OrderOut (this);
|
||||||
|
Environment.Exit (-1);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
RunModal ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -102,6 +102,7 @@
|
||||||
<Link>SparkleShare.cs</Link>
|
<Link>SparkleShare.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="SparkleAbout.cs" />
|
<Compile Include="SparkleAbout.cs" />
|
||||||
|
<Compile Include="SparkleAlert.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Include="MainMenu.xib" />
|
<Page Include="MainMenu.xib" />
|
||||||
|
|
|
@ -41,7 +41,9 @@ namespace SparkleShare {
|
||||||
public static int NewEvents;
|
public static int NewEvents;
|
||||||
public static SparkleIntro Intro;
|
public static SparkleIntro Intro;
|
||||||
public static NSFont Font;
|
public static NSFont Font;
|
||||||
public SparkleAbout About;
|
|
||||||
|
private SparkleAbout About;
|
||||||
|
private NSAlert Alert;
|
||||||
|
|
||||||
public SparkleUI ()
|
public SparkleUI ()
|
||||||
{
|
{
|
||||||
|
@ -55,16 +57,22 @@ namespace SparkleShare {
|
||||||
= NSImage.ImageNamed ("sparkleshare.icns");
|
= NSImage.ImageNamed ("sparkleshare.icns");
|
||||||
|
|
||||||
|
|
||||||
|
if (!SparkleShare.Controller.BackendIsPresent) {
|
||||||
|
|
||||||
|
Alert = new SparkleAlert ();
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Font = NSFontManager.SharedFontManager.FontWithFamily
|
Font = NSFontManager.SharedFontManager.FontWithFamily
|
||||||
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
|
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
|
||||||
|
|
||||||
|
|
||||||
OpenLogs = new List <SparkleLog> ();
|
OpenLogs = new List <SparkleLog> ();
|
||||||
StatusIcon = new SparkleStatusIcon ();
|
StatusIcon = new SparkleStatusIcon ();
|
||||||
|
|
||||||
NewEvents = 0;
|
NewEvents = 0;
|
||||||
|
|
||||||
|
|
||||||
SparkleShare.Controller.NotificationRaised += delegate {
|
SparkleShare.Controller.NotificationRaised += delegate {
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
|
|
|
@ -19,6 +19,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
using MonoMac.Foundation;
|
using MonoMac.Foundation;
|
||||||
using MonoMac.AppKit;
|
using MonoMac.AppKit;
|
||||||
using MonoMac.ObjCRuntime;
|
using MonoMac.ObjCRuntime;
|
||||||
|
|
|
@ -746,6 +746,17 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool BackendIsPresent {
|
||||||
|
|
||||||
|
get {
|
||||||
|
|
||||||
|
return SparkleLib.Backend.IsPresent;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Looks up the user's name from the global configuration
|
// Looks up the user's name from the global configuration
|
||||||
public string UserName
|
public string UserName
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue