add sparkleplatform class to check for the user's platform

This commit is contained in:
Hylke Bons 2010-05-11 10:41:09 +01:00
parent d107fd692d
commit 5667a7cf52
2 changed files with 39 additions and 11 deletions

View file

@ -0,0 +1,28 @@
// 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;
namespace SparkleShare {
public static class SparklePlatform {
// Detect OSX, Windows, GNOME or KDE here
public static string Name = "GNOME";
}
}

View file

@ -31,13 +31,13 @@ namespace SparkleShare {
public SparkleUI (bool HideUI) {
string SparklePath = SparklePaths.SparklePath;
Process Process = new Process();
Process.EnableRaisingEvents = false;
Process.StartInfo.RedirectStandardOutput = true;
Process.StartInfo.UseShellExecute = false;
string SparklePath = SparklePaths.SparklePath;
// Create 'SparkleShare' folder in the user's home folder
// if it's not there already
if (!Directory.Exists (SparklePath)) {
@ -54,19 +54,19 @@ namespace SparkleShare {
"folder-sparkleshare.png";
Process.Start();
// Linux/GNOME specific: add the SparkleShare
// folder to the bookmarks
string BookmarksFileName =
Path.Combine (SparklePaths.HomePath, ".gtk-bookmarks");
if (File.Exists (BookmarksFileName)) {
TextWriter TextWriter = File.AppendText (BookmarksFileName);
TextWriter.WriteLine ("file://" + SparklePath + " SparkleShare");
TextWriter.Close();
// Add the SparkleShare folder to the bookmarks
if (SparklePlatform.Name.Equals ("GNOME")) {
string BookmarksFileName =
Path.Combine (SparklePaths.HomePath, ".gtk-bookmarks");
if (File.Exists (BookmarksFileName)) {
TextWriter TextWriter = File.AppendText (BookmarksFileName);
TextWriter.WriteLine ("file://" + SparklePath + " SparkleShare");
TextWriter.Close();
}
}
}
// Get all the repos in ~/SparkleShare
string [] Repos = Directory.GetDirectories (SparklePath);
Repositories = new SparkleRepo [Repos.Length];