fix coding style

This commit is contained in:
Hylke Bons 2010-05-31 21:24:42 +02:00
parent 7367aa8c73
commit afdcb58c83
8 changed files with 202 additions and 52 deletions

View file

@ -123,7 +123,7 @@ namespace SparkleShare {
new SparkleBubble (_("Syncing folder ") + RepoName + "",
_("SparkleShare will notify you when this is done."));
Process Process = new Process();
Process Process = new Process ();
Process.EnableRaisingEvents = true;
Process.StartInfo.RedirectStandardOutput = true;
Process.StartInfo.UseShellExecute = false;
@ -152,7 +152,7 @@ namespace SparkleShare {
Process.StartInfo.Arguments =
SparkleHelpers.CombineMore
(SparklePaths.SparklePath, RepoName);
Process.Start();
Process.Start ();
}
);
@ -185,7 +185,7 @@ namespace SparkleShare {
Process.StartInfo.Arguments =
SparkleHelpers.CombineMore (
SparklePaths.SparklePath, RepoName);
Process.Start();
Process.Start ();
}
);

View file

@ -75,7 +75,7 @@ namespace SparkleShare {
MD5 md5 = new MD5CryptoServiceProvider ();
Byte[] Bytes = ASCIIEncoding.Default.GetBytes (s);
Byte[] EncodedBytes = md5.ComputeHash (Bytes);
return BitConverter.ToString(EncodedBytes).ToLower ().Replace ("-", "");
return BitConverter.ToString (EncodedBytes).ToLower ().Replace ("-", "");
}
// Makes it possible to combine more than

View file

@ -0,0 +1,45 @@
// 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.IO;
namespace SparkleShare {
public static class SparklePaths {
public static string SparkleTmpPath = "/tmp/sparkleshare";
public static string HomePath =
Environment.GetEnvironmentVariable ("HOME");
public static string SparklePath = Path.Combine (HomePath ,"SparkleShare");
public static string SparkleConfigPath =
SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare");
public static string SparkleInstallPath =
SparkleHelpers.CombineMore ("usr", "share", "sparkleshare",
"icons", "hicolor");
public static string SparkleAvatarPath =
Path.Combine (SparkleConfigPath, "avatars");
public static string SparkleIconPath = "/usr/share/icons/hicolor";
}
}

View file

@ -43,7 +43,7 @@ namespace SparkleShare {
public SparkleRepo (string RepoPath) {
Process = new Process();
Process = new Process ();
Process.EnableRaisingEvents = false;
Process.StartInfo.RedirectStandardOutput = true;
Process.StartInfo.UseShellExecute = false;
@ -56,20 +56,20 @@ namespace SparkleShare {
UserName = "Anonymous";
Process.StartInfo.FileName = "git";
Process.StartInfo.Arguments = "config --get user.name";
Process.Start();
Process.Start ();
UserName = Process.StandardOutput.ReadToEnd ().Trim ();
// Get user.email, example: "user@github.com"
UserEmail = "not.set@git-scm.com";
Process.StartInfo.FileName = "git";
Process.StartInfo.Arguments = "config --get user.email";
Process.Start();
Process.Start ();
UserEmail = Process.StandardOutput.ReadToEnd ().Trim ();
// Get remote.origin.url, example: "ssh://git@github.com/user/repo"
Process.StartInfo.FileName = "git";
Process.StartInfo.Arguments = "config --get remote.origin.url";
Process.Start();
Process.Start ();
RemoteOriginUrl = Process.StandardOutput.ReadToEnd ().Trim ();
// Get the repository name, example: "Project"
@ -86,7 +86,7 @@ namespace SparkleShare {
// Get hash of the current commit
Process.StartInfo.FileName = "git";
Process.StartInfo.Arguments = "rev-list --max-count=1 HEAD";
Process.Start();
Process.Start ();
CurrentHash = Process.StandardOutput.ReadToEnd ().Trim ();
// Watch the repository's folder
@ -94,9 +94,9 @@ namespace SparkleShare {
Watcher.IncludeSubdirectories = true;
Watcher.EnableRaisingEvents = true;
Watcher.Filter = "*";
Watcher.Changed += new FileSystemEventHandler(OnFileActivity);
Watcher.Created += new FileSystemEventHandler(OnFileActivity);
Watcher.Deleted += new FileSystemEventHandler(OnFileActivity);
Watcher.Changed += new FileSystemEventHandler (OnFileActivity);
Watcher.Created += new FileSystemEventHandler (OnFileActivity);
Watcher.Deleted += new FileSystemEventHandler (OnFileActivity);
// Fetch remote changes every 20 seconds
FetchTimer = new Timer ();
@ -105,7 +105,7 @@ namespace SparkleShare {
Fetch ();
};
FetchTimer.Start();
FetchTimer.Start ();
BufferTimer = new Timer ();
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
@ -132,7 +132,7 @@ namespace SparkleShare {
public void OnFileActivity (object o, FileSystemEventArgs args) {
WatcherChangeTypes wct = args.ChangeType;
if (!ShouldIgnore (args.Name)) {
Console.WriteLine ("[Event][" + Name + "] " + wct.ToString() +
Console.WriteLine ("[Event][" + Name + "] " + wct.ToString () +
" '" + args.Name + "'");
StartBufferTimer ();
}
@ -155,7 +155,7 @@ namespace SparkleShare {
Console.WriteLine ("[Buffer][" + Name + "] " +
"Waiting for more changes...");
BufferTimer.Start();
BufferTimer.Start ();
} else {
@ -166,7 +166,7 @@ namespace SparkleShare {
FetchTimer.Start ();
BufferTimer.Start();
BufferTimer.Start ();
Console.WriteLine ("[Buffer][" + Name + "] " +
"Waiting for more changes...");
}
@ -176,13 +176,13 @@ namespace SparkleShare {
// Clones a remote repo
public void Clone () {
Process.StartInfo.Arguments = "clone " + RemoteOriginUrl;
Process.Start();
Process.Start ();
// Add a gitignore file
TextWriter Writer = new StreamWriter(LocalPath + ".gitignore");
Writer.WriteLine("*~"); // Ignore gedit swap files
Writer.WriteLine(".*.sw?"); // Ignore vi swap files
Writer.Close();
TextWriter Writer = new StreamWriter (LocalPath + ".gitignore");
Writer.WriteLine ("*~"); // Ignore gedit swap files
Writer.WriteLine (".*.sw?"); // Ignore vi swap files
Writer.Close ();
}
// Stages the made changes
@ -190,7 +190,7 @@ namespace SparkleShare {
BufferTimer.Stop ();
Console.WriteLine ("[Git][" + Name + "] Staging changes...");
Process.StartInfo.Arguments = "add --all";
Process.Start();
Process.Start ();
Process.WaitForExit ();
Console.WriteLine ("[Git][" + Name + "] Changes staged.");
// SparkleUI.NotificationIcon.SetSyncingState ();
@ -202,7 +202,7 @@ namespace SparkleShare {
Console.WriteLine ("[Commit][" + Name + "] " + Message);
Console.WriteLine ("[Git][" + Name + "] Commiting changes...");
Process.StartInfo.Arguments = "commit -m \"" + Message + "\"";
Process.Start();
Process.Start ();
Process.WaitForExit ();
Console.WriteLine ("[Git][" + Name + "] Changes commited.");
}
@ -213,7 +213,7 @@ namespace SparkleShare {
// SparkleUI.NotificationIcon.SetSyncingState ();
Console.WriteLine ("[Git][" + Name + "] Fetching changes... ");
Process.StartInfo.Arguments = "fetch -v";
Process.Start();
Process.Start ();
string Output = Process.StandardOutput.ReadToEnd ().Trim (); // TODO: This doesn't work :(
Process.WaitForExit ();
Console.WriteLine ("[Git][" + Name + "] Changes fetched.");
@ -231,7 +231,7 @@ namespace SparkleShare {
Console.WriteLine ("[Git][" + Name + "] Rebasing fetched changes... ");
Process.StartInfo.Arguments = "rebase origin";
Process.WaitForExit ();
Process.Start();
Process.Start ();
Console.WriteLine ("[Git][" + Name + "] Changes rebased.");
string Output = Process.StandardOutput.ReadToEnd ().Trim ();
@ -244,7 +244,7 @@ namespace SparkleShare {
Process.StartInfo.Arguments = "status";
Process.WaitForExit ();
Process.Start();
Process.Start ();
Output = Process.StandardOutput.ReadToEnd ().Trim ();
foreach (string Line in Regex.Split (Output, "\n")) {
@ -257,11 +257,11 @@ namespace SparkleShare {
Process.StartInfo.Arguments
= "checkout --ours " + ProblemFileName;
Process.WaitForExit ();
Process.Start();
Process.Start ();
DateTime DateTime = new DateTime ();
string TimeStamp =
String.Format("{0:H:mm, d MMM yyyy}", DateTime);
String.Format ("{0:H:mm, d MMM yyyy}", DateTime);
File.Move (ProblemFileName,
ProblemFileName + " (" + UserName + " - " +
@ -270,7 +270,7 @@ namespace SparkleShare {
Process.StartInfo.Arguments
= "checkout --theirs " + ProblemFileName;
Process.WaitForExit ();
Process.Start();
Process.Start ();
ShowEventBubble ("A mid-air collision happened!\n" +
"SparkleShare made a copy of your file.",
@ -285,7 +285,7 @@ namespace SparkleShare {
Process.StartInfo.Arguments = "rebase --continue";
Process.WaitForExit ();
Process.Start();
Process.Start ();
Console.WriteLine ("[Git][" + Name + "] Conflict resolved.");
Push ();
@ -295,19 +295,19 @@ namespace SparkleShare {
// Get the last committer e-mail
Process.StartInfo.Arguments = "log --format=\"%ae\" -1";
Process.Start();
Process.Start ();
string LastCommitEmail =
Process.StandardOutput.ReadToEnd ().Trim ();
// Get the last commit message
Process.StartInfo.Arguments = "log --format=\"%s\" -1";
Process.Start();
Process.Start ();
string LastCommitMessage =
Process.StandardOutput.ReadToEnd ().Trim ();
// Get the last commiter
Process.StartInfo.Arguments = "log --format=\"%an\" -1";
Process.Start();
Process.Start ();
string LastCommitUserName =
Process.StandardOutput.ReadToEnd ().Trim ();
@ -333,7 +333,7 @@ namespace SparkleShare {
public void Push () {
Console.WriteLine ("[Git][" + Name + "] Pushing changes...");
Process.StartInfo.Arguments = "push";
Process.Start();
Process.Start ();
Process.WaitForExit ();
Console.WriteLine ("[Git][" + Name + "] Changes pushed.");
// SparkleUI.NotificationIcon.SetIdleState ();
@ -366,7 +366,7 @@ namespace SparkleShare {
int FilesDeleted = 0;
Process.StartInfo.Arguments = "status";
Process.Start();
Process.Start ();
string Output = Process.StandardOutput.ReadToEnd ();
foreach (string Line in Regex.Split (Output, "\n")) {
@ -465,7 +465,7 @@ namespace SparkleShare {
break;
}
Process.StartInfo.Arguments = LocalPath;
Process.Start();
Process.Start ();
Process.StartInfo.FileName = "git";
} );

View file

@ -0,0 +1,105 @@
// 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 Gtk;
using Mono.Unix;
using System;
using System.Diagnostics;
namespace SparkleShare {
// This is SparkleShare!
public class SparkleShare {
// Short alias for the translations
public static string _ (string s) {
return Catalog.GetString (s);
}
public static SparkleRepo [] Repositories;
public static SparkleUI SparkleUI;
public static void Main (string [] args) {
// Use translations
Catalog.Init ("i18n", "locale");
// Check if git is installed
Process Process = new Process ();
Process.StartInfo.FileName = "git";
Process.StartInfo.RedirectStandardOutput = true;
Process.StartInfo.UseShellExecute = false;
Process.Start ();
if (Process.StandardOutput.ReadToEnd ().IndexOf ("version") == -1) {
Console.WriteLine (_("Git wasn't found."));
Console.WriteLine (_("You can get Git from http://git-scm.com/."));
Environment.Exit (0);
}
// Don't allow running as root
Process.StartInfo.FileName = "whoami";
Process.Start ();
if (Process.StandardOutput.ReadToEnd ().Trim ().Equals ("root")) {
Console.WriteLine (_("Sorry, you can't run SparkleShare with these permissions."));
Console.WriteLine (_("Things will go utterly wrong."));
Environment.Exit (0);
}
// Parse the command line arguments
bool HideUI = false;
if (args.Length > 0) {
foreach (string Argument in args) {
if (Argument.Equals ("--disable-gui") || Argument.Equals ("-d"))
HideUI = true;
if (Argument.Equals ("--help") || Argument.Equals ("-h")) {
ShowHelp ();
}
}
}
Gtk.Application.Init ();
SparkleUI = new SparkleUI (HideUI);
// The main loop
Gtk.Application.Run ();
}
// Prints the help output
public static void ShowHelp () {
Console.WriteLine (_("SparkleShare Copyright (C) 2010 Hylke Bons"));
Console.WriteLine (" ");
Console.WriteLine (_("This program comes with ABSOLUTELY NO WARRANTY."));
Console.WriteLine (_("This is free software, and you are welcome to redistribute it "));
Console.WriteLine (_("under certain conditions. Please read the GNU GPLv3 for details."));
Console.WriteLine (" ");
Console.WriteLine (_("SparkleShare syncs the ~/SparkleShare folder with remote repositories."));
Console.WriteLine (" ");
Console.WriteLine (_("Usage: sparkleshare [start|stop|restart] [OPTION]..."));
Console.WriteLine (_("Sync SparkleShare folder with remote repositories."));
Console.WriteLine (" ");
Console.WriteLine (_("Arguments:"));
Console.WriteLine (_("\t -d, --disable-gui\tDon't show the notification icon."));
Console.WriteLine (_("\t -h, --help\t\tDisplay this help text."));
Console.WriteLine (" ");
Environment.Exit (0);
}
}
}

View file

@ -46,14 +46,14 @@ namespace SparkleShare {
Activate += delegate {
Menu Menu = new Menu();
Menu Menu = new Menu ();
MenuItem StatusItem = new MenuItem (_("Everything is up to date"));
StatusItem.Sensitive = false;
Menu.Add (StatusItem);
Menu.Add (new SeparatorMenuItem ());
Action FolderAction = new Action("", "SparkleShare Folder");
Action FolderAction = new Action ("", "SparkleShare Folder");
FolderAction.IconName = "folder-sparkleshare";
FolderAction.IsImportant = true;
FolderAction.Activated += delegate {
@ -67,7 +67,7 @@ namespace SparkleShare {
break;
}
Process.StartInfo.Arguments = SparklePaths.SparklePath;
Process.Start();
Process.Start ();
};
Menu.Add (FolderAction.CreateMenuItem ());
@ -76,7 +76,7 @@ namespace SparkleShare {
int i = 0;
foreach (SparkleRepo SparkleRepo in SparkleShare.Repositories) {
FolderItems [i] = new Action("", SparkleRepo.Name);
FolderItems [i] = new Action ("", SparkleRepo.Name);
FolderItems [i].IconName = "folder";
FolderItems [i].IsImportant = true;
FolderItems [i].Activated += CreateWindowDelegate (SparkleRepo);

View file

@ -28,7 +28,7 @@ namespace SparkleShare {
public SparkleUI (bool HideUI) {
Process Process = new Process();
Process Process = new Process ();
Process.EnableRaisingEvents = false;
Process.StartInfo.RedirectStandardOutput = true;
Process.StartInfo.UseShellExecute = false;
@ -53,7 +53,7 @@ namespace SparkleShare {
"folder-sparkleshare.png";
break;
}
Process.Start();
Process.Start ();
// Add the SparkleShare folder to the bookmarks
switch (SparklePlatform.Name) {
@ -64,7 +64,7 @@ namespace SparkleShare {
if (File.Exists (BookmarksFileName)) {
TextWriter TextWriter = File.AppendText (BookmarksFileName);
TextWriter.WriteLine ("file://" + SparklePath + " SparkleShare");
TextWriter.Close();
TextWriter.Close ();
}
break;
@ -100,7 +100,7 @@ namespace SparkleShare {
"[synced]";
break;
}
Process.Start();
Process.Start ();
}
@ -127,7 +127,7 @@ namespace SparkleShare {
SparkleDialog.ShowAll ();
/* Process.StartInfo.FileName = "xdg-open";
Process.StartInfo.Arguments = SparklePaths.SparklePath;
Process.Start();
Process.Start ();
*/
} );
@ -145,7 +145,7 @@ namespace SparkleShare {
Watcher.EnableRaisingEvents = true;
Watcher.Created += delegate (object o, FileSystemEventArgs args) {
WatcherChangeTypes wct = args.ChangeType;
Console.WriteLine ("[Event][SparkleShare] " + wct.ToString() +
Console.WriteLine ("[Event][SparkleShare] " + wct.ToString () +
" '" + args.Name + "'");
SparkleDialog SparkleDialog = new SparkleDialog ();
SparkleDialog.ShowAll ();

View file

@ -100,7 +100,7 @@ namespace SparkleShare {
typeof (string),
typeof (string));
Process Process = new Process();
Process Process = new Process ();
Process.EnableRaisingEvents = false;
Process.StartInfo.RedirectStandardOutput = true;
Process.StartInfo.UseShellExecute = false;
@ -112,9 +112,9 @@ namespace SparkleShare {
// We're using the snowman here to separate messages :)
Process.StartInfo.Arguments =
"log --format=\"%at☃%s☃%an☃%cr☃%ae\" -25";
Process.Start();
Process.Start ();
Output += "\n" + Process.StandardOutput.ReadToEnd().Trim ();
Output += "\n" + Process.StandardOutput.ReadToEnd ().Trim ();
Output = Output.TrimStart ("\n".ToCharArray ());
string [] Lines = Regex.Split (Output, "\n");
@ -189,7 +189,7 @@ namespace SparkleShare {
Columns [2].Expand = true;
Columns [1].MinWidth = 350;
LogView.CursorChanged += delegate(object o, EventArgs args) {
LogView.CursorChanged += delegate (object o, EventArgs args) {
TreeModel Model;
if (LogView.Selection.GetSelected (out Model, out Iter)) {
SelectedEmail = (string) Model.GetValue (Iter, 4);
@ -216,9 +216,9 @@ namespace SparkleShare {
Process.StartInfo.FileName = "git";
Process.StartInfo.Arguments = "log --format=\"%an☃%ae\" -50";
Process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath;
Process.Start();
Process.Start ();
string Output = Process.StandardOutput.ReadToEnd().Trim ();
string Output = Process.StandardOutput.ReadToEnd ().Trim ();
string [] People = new string [50];
string [] Lines = Regex.Split (Output, "\n");