From 6357c95bcb0a06f93b77fe2419bc0d4cf86fd703 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 8 Aug 2010 20:16:48 +0100 Subject: [PATCH 01/24] [repo] Handle cloning empty repos well --- SparkleLib/SparkleRepo.cs | 48 ++++++++++++++++++++++++------- SparkleShare/SparkleStatusIcon.cs | 3 ++ 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index afd19580..8619ccc6 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -85,6 +85,8 @@ namespace SparkleLib { CurrentHash = GetCurrentHash (); Domain = GetDomain (RemoteOriginUrl); + if (CurrentHash == null) + CreateInitialCommit (); HasChanged = false; @@ -128,6 +130,9 @@ namespace SparkleLib { // since SparkleShare was stopped AddCommitAndPush (); + if (CurrentHash == null) + CurrentHash = GetCurrentHash (); + SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Idling..."); } @@ -409,7 +414,7 @@ namespace SparkleLib { SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing changes..."); - Process.StartInfo.Arguments = "push"; + Process.StartInfo.Arguments = "push origin master"; Process.Start (); Process.WaitForExit (); @@ -466,6 +471,9 @@ namespace SparkleLib { public string GetDomain (string url) { + if (RemoteOriginUrl.Equals ("")) + return ""; + string domain = url.Substring (RemoteOriginUrl.IndexOf ("@") + 1); if (domain.IndexOf (":") > -1) @@ -482,19 +490,25 @@ namespace SparkleLib { public string GetCurrentHash () { - string current_hash; + Process process = new Process () { + EnableRaisingEvents = true + }; - Process process = new Process (); process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.UseShellExecute = false; - process.StartInfo.FileName = "git"; - process.StartInfo.WorkingDirectory = LocalPath; - process.StartInfo.Arguments = "rev-list --max-count=1 HEAD"; - process.Start (); + process.StartInfo.UseShellExecute = false; + process.StartInfo.FileName = "git"; + process.StartInfo.WorkingDirectory = LocalPath; + process.StartInfo.Arguments = "rev-list --max-count=1 HEAD"; - current_hash = process.StandardOutput.ReadToEnd ().Trim (); - - return current_hash; + process.Start (); + process.WaitForExit (); + + string current_hash = process.StandardOutput.ReadToEnd ().Trim (); + + if (process.ExitCode != 0) + return null; + else + return current_hash; } @@ -551,6 +565,18 @@ namespace SparkleLib { } + // Create a first commit in case the user has cloned + // an empty repository + private void CreateInitialCommit () + { + + TextWriter writer = new StreamWriter (Path.Combine (LocalPath, "SparkleShare.txt")); + writer.WriteLine (":)"); + writer.Close (); + + } + + // Gets the url of the remote repo, example: "ssh://git@git.gnome.org/project" public string GetRemoteOriginUrl () { diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 26bc4791..32ef40a1 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -295,6 +295,9 @@ namespace SparkleShare { public void ShowState () { + if (SyncingReposCount < 0) + SyncingReposCount = 0; + if (SyncingReposCount > 0) SetSyncingState (); else From 6b518fdbaa2e47efc0d41693426bee67e57e174c Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 8 Aug 2010 22:07:50 +0100 Subject: [PATCH 02/24] [ui] only specifically remove/add to the repo list, instead of throwing everything out --- SparkleShare/SparkleUI.cs | 119 +++++++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 48 deletions(-) diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 920a219a..59a22df7 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -75,18 +75,17 @@ namespace SparkleShare { Filter = "*" }; - watcher.Deleted += delegate { + watcher.Deleted += delegate (object o, FileSystemEventArgs args) { - foreach (SparkleRepo repo in Repositories) - repo.Stop (); - - Application.Invoke (delegate { UpdateRepositories (); } ); + RemoveRepository (args.FullPath); + Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); }; - watcher.Created += delegate { + watcher.Created += delegate (object o, FileSystemEventArgs args) { - Application.Invoke (delegate {UpdateRepositories (); } ); + AddRepository (args.FullPath); + Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); }; @@ -323,6 +322,65 @@ namespace SparkleShare { } + public void AddRepository (string folder_path) { + + // Check if the folder is a git repo + if (!Directory.Exists (SparkleHelpers.CombineMore (folder_path, ".git"))) + return; + + SparkleRepo repo = new SparkleRepo (folder_path); + + repo.NewCommit += delegate (object o, NewCommitArgs args) { + Application.Invoke (delegate { ShowNewCommitBubble (args.Author, args.Email, args.Message); }); + }; + + repo.Commited += delegate (object o, SparkleEventArgs args) { + Application.Invoke (delegate { CheckForUnicorns (args.Message); }); + }; + + repo.FetchingStarted += delegate { + Application.Invoke (UpdateStatusIconToSyncing); + }; + + repo.FetchingFinished += delegate { + Application.Invoke (UpdateStatusIconToIdle); + }; + + repo.PushingStarted += delegate { + Application.Invoke (UpdateStatusIconToSyncing); + }; + + repo.PushingFinished += delegate { + Application.Invoke (UpdateStatusIconToIdle); + }; + + repo.ConflictDetected += delegate { + Application.Invoke (ShowConflictBubble); + }; + + Repositories.Add (repo); + + } + + + public void RemoveRepository (string folder_path) { + + string repo_name = Path.GetFileName (folder_path); + + foreach (SparkleRepo repo in Repositories) { + + if (repo.Name.Equals (repo_name)) { + + repo.Stop (); + Repositories.Remove (repo); + break; + + } + + } + + } + // Updates the list of repositories with all the // folders in the SparkleShare folder public void UpdateRepositories () @@ -330,51 +388,16 @@ namespace SparkleShare { Repositories = new List (); - foreach (string folder in Directory.GetDirectories (SparklePaths.SparklePath)) { + foreach (string folder_path in Directory.GetDirectories (SparklePaths.SparklePath)) { - // Check if the folder is a git repo - if (Directory.Exists (SparkleHelpers.CombineMore (folder, ".git"))) { - - SparkleRepo repo = new SparkleRepo (folder); - - repo.NewCommit += delegate (object o, NewCommitArgs args) { - Application.Invoke (delegate { ShowNewCommitBubble (args.Author, args.Email, args.Message); }); - }; - - repo.Commited += delegate (object o, SparkleEventArgs args) { - Application.Invoke (delegate { CheckForUnicorns (args.Message); }); - }; - - repo.FetchingStarted += delegate { - Application.Invoke (UpdateStatusIconToSyncing); - }; - - repo.FetchingFinished += delegate { - Application.Invoke (UpdateStatusIconToIdle); - }; - - repo.PushingStarted += delegate { - Application.Invoke (UpdateStatusIconToSyncing); - }; - - repo.PushingFinished += delegate { - Application.Invoke (UpdateStatusIconToIdle); - }; - - repo.ConflictDetected += delegate { - Application.Invoke (ShowConflictBubble); - }; - - Repositories.Add (repo); - - } - - // Update the list in the statusicon - if (NotificationIcon != null) - NotificationIcon.CreateMenu (); + AddRepository (folder_path); } + // Update the list in the statusicon + if (NotificationIcon != null) + NotificationIcon.CreateMenu (); + } From 7dbab85b6afc99e166db2372a1fbddbe95d4097c Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 8 Aug 2010 22:22:39 +0100 Subject: [PATCH 03/24] [intro] Use new mechanism of updating the repo list --- SparkleShare/SparkleIntro.cs | 12 +++++------- SparkleShare/SparkleUI.cs | 6 ++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SparkleShare/SparkleIntro.cs b/SparkleShare/SparkleIntro.cs index 9f04b2aa..bdbbac02 100644 --- a/SparkleShare/SparkleIntro.cs +++ b/SparkleShare/SparkleIntro.cs @@ -402,8 +402,11 @@ namespace SparkleShare { if (i > 1) target_folder_name += " (" + i + ")"; - Directory.Move (tmp_folder, - SparkleHelpers.CombineMore (SparklePaths.SparklePath, target_folder_name)); + string target_folder_path; + target_folder_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + target_folder_name); + + Directory.Move (tmp_folder, target_folder_path); } catch (Exception e) { @@ -577,12 +580,7 @@ namespace SparkleShare { Button finish_button = new Button (_("Finish")); finish_button.Clicked += delegate (object o, EventArgs args) { - - if(SparkleShare.SparkleUI != null) - SparkleShare.SparkleUI.UpdateRepositories (); - Destroy (); - }; controls.Add (finish_button); diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 59a22df7..5595d341 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -78,14 +78,12 @@ namespace SparkleShare { watcher.Deleted += delegate (object o, FileSystemEventArgs args) { RemoveRepository (args.FullPath); - Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); }; watcher.Created += delegate (object o, FileSystemEventArgs args) { AddRepository (args.FullPath); - Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); }; @@ -360,6 +358,8 @@ namespace SparkleShare { Repositories.Add (repo); + Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); + } @@ -379,6 +379,8 @@ namespace SparkleShare { } + Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); + } // Updates the list of repositories with all the From 9c31c7f8e7d0dd0902e21da807d7b590191b130f Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 8 Aug 2010 22:28:56 +0100 Subject: [PATCH 04/24] [ui] be more efficient populating and fix threading issue --- SparkleShare/SparkleUI.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 5595d341..34b64827 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -89,7 +89,7 @@ namespace SparkleShare { CreateConfigurationFolders (); - UpdateRepositories (); + PopulateRepositories (); // Don't create the window and status // icon when --disable-gui was given @@ -358,7 +358,8 @@ namespace SparkleShare { Repositories.Add (repo); - Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); + if (NotificationIcon != null) + Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); } @@ -379,27 +380,22 @@ namespace SparkleShare { } - Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); + if (NotificationIcon != null) + Application.Invoke (delegate { NotificationIcon.CreateMenu (); }); } + // Updates the list of repositories with all the // folders in the SparkleShare folder - public void UpdateRepositories () + public void PopulateRepositories () { Repositories = new List (); - foreach (string folder_path in Directory.GetDirectories (SparklePaths.SparklePath)) { - + foreach (string folder_path in Directory.GetDirectories (SparklePaths.SparklePath)) AddRepository (folder_path); - } - - // Update the list in the statusicon - if (NotificationIcon != null) - NotificationIcon.CreateMenu (); - } From 76a26b84b3ff1a90636960d1509774c53d920220 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Mon, 9 Aug 2010 09:53:38 +0100 Subject: [PATCH 05/24] [statusicon] don't allow there to be more repos syncing than there are repos --- SparkleShare/SparkleStatusIcon.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 32ef40a1..f4b078a2 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -298,6 +298,9 @@ namespace SparkleShare { if (SyncingReposCount < 0) SyncingReposCount = 0; + if (SyncingReposCount > SparkleUI.Repositories.Count) + SyncingReposCount = SparkleUI.Repositories.Count; + if (SyncingReposCount > 0) SetSyncingState (); else From bf31b9c5b59685203ccd994c669eb106c258eb3c Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Mon, 9 Aug 2010 10:51:00 +0100 Subject: [PATCH 06/24] [statusicon] Update folder size after each state change --- SparkleShare/SparkleStatusIcon.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index f4b078a2..91a84d8c 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -29,12 +29,14 @@ namespace SparkleShare { public int SyncingReposCount; - private Timer Timer; private Menu Menu; private MenuItem StatusMenuItem; private string StateText; + + private Timer Timer; private Gdk.Pixbuf [] AnimationFrames; private int FrameNumber; + private Gtk.Action FolderAction; private double FolderSize; @@ -134,7 +136,15 @@ namespace SparkleShare { } - private string GetSizeFormat (double byte_count) + private void UpdateFolderSize () + { + + FolderSize = GetFolderSize (new DirectoryInfo (SparklePaths.SparklePath)); + + } + + + private string FormatFileSize (double byte_count) { string size = ""; @@ -295,6 +305,8 @@ namespace SparkleShare { public void ShowState () { + UpdateFolderSize (); + if (SyncingReposCount < 0) SyncingReposCount = 0; @@ -308,7 +320,7 @@ namespace SparkleShare { UpdateStatusMenuItem (); - Console.WriteLine ("Number of repos syncing: " + SyncingReposCount); + SparkleHelpers.DebugInfo ("Status", "Number of repos syncing: " + SyncingReposCount); } @@ -319,8 +331,8 @@ namespace SparkleShare { Timer.Stop (); - Pixbuf = SparkleHelpers.GetIcon ("folder-sparkleshare", 24); - StateText = _("Up to date") + " (" + GetSizeFormat (FolderSize) + ")"; + Pixbuf = SparkleHelpers.GetIcon ("folder-sparkleshare", 24); + StateText = _("Up to date") + " (" + FormatFileSize (FolderSize) + ")"; } From 54022c265febeabf4823095086b881dd1aa5f6ea Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Mon, 9 Aug 2010 23:54:43 +0100 Subject: [PATCH 07/24] [cli] add a --version argument --- SparkleLib/SparkleFetcher.cs | 1 + SparkleShare/SparkleShare.cs | 37 ++++++++++++++++++++++++++++--- SparkleShare/SparkleStatusIcon.cs | 4 ++-- SparkleShare/SparkleUI.cs | 26 ++++++++++++++++++++++ 4 files changed, 63 insertions(+), 5 deletions(-) diff --git a/SparkleLib/SparkleFetcher.cs b/SparkleLib/SparkleFetcher.cs index 86501627..378fac49 100644 --- a/SparkleLib/SparkleFetcher.cs +++ b/SparkleLib/SparkleFetcher.cs @@ -98,6 +98,7 @@ namespace SparkleLib { private void InstallUserInfo () { + // TODO: Use TargetFolder and move SparklePaths out of SparkleLib string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config"); if (File.Exists (global_config_file_path)) { diff --git a/SparkleShare/SparkleShare.cs b/SparkleShare/SparkleShare.cs index 68cd5620..e4a00663 100644 --- a/SparkleShare/SparkleShare.cs +++ b/SparkleShare/SparkleShare.cs @@ -25,13 +25,15 @@ namespace SparkleShare { // This is SparkleShare! public class SparkleShare { + public static SparkleUI SparkleUI; + + // Short alias for the translations public static string _ (string s) { return Catalog.GetString (s); } - public static SparkleUI SparkleUI; public static void Main (string [] args) { @@ -60,26 +62,44 @@ namespace SparkleShare { Environment.Exit (0); } - // Parse the command line arguments bool HideUI = false; + + // Parse the command line arguments if (args.Length > 0) { + foreach (string Argument in args) { + if (Argument.Equals ("--disable-gui") || Argument.Equals ("-d")) HideUI = true; + + if (Argument.Equals ("--version") || Argument.Equals ("-v")) { + + PrintVersion (); + Environment.Exit (0); + + } + if (Argument.Equals ("--help") || Argument.Equals ("-h")) { + ShowHelp (); Environment.Exit (0); + } + } + } SparkleUI = new SparkleUI (HideUI); SparkleUI.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.")); @@ -93,8 +113,19 @@ namespace SparkleShare { 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 (_("\t -h, --help\t\tShow this help text.")); + Console.WriteLine (_("\t -v, --version\t\tPrint version information.")); Console.WriteLine (" "); + + } + + + // Prints the version information + public static void PrintVersion () + { + + Console.WriteLine (_("SparkleShare " + Defines.VERSION)); + } } diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 91a84d8c..12e6d659 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -256,7 +256,7 @@ namespace SparkleShare { Menu.Add (new SeparatorMenuItem ()); - MenuItem about_item = new MenuItem (_("About")); + MenuItem about_item = new MenuItem (_("Visit Website")); about_item.Activated += delegate { @@ -331,7 +331,7 @@ namespace SparkleShare { Timer.Stop (); - Pixbuf = SparkleHelpers.GetIcon ("folder-sparkleshare", 24); + Pixbuf = AnimationFrames [0]; StateText = _("Up to date") + " (" + FormatFileSize (FolderSize) + ")"; } diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 34b64827..86dc8953 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -23,6 +23,8 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Runtime.InteropServices; +using System.Text; namespace SparkleShare { @@ -47,6 +49,8 @@ namespace SparkleShare { BusG.Init (); Gtk.Application.Init (); + SetProcessName ("sparkleshare"); + Repositories = new List (); Process = new Process () { @@ -106,6 +110,7 @@ namespace SparkleShare { NotificationIcon = new SparkleStatusIcon (); } + } @@ -418,6 +423,27 @@ namespace SparkleShare { } + + [DllImport ("libc")] + private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5); + + + private void SetProcessName (string name) + { + + try { + + if (prctl (15, Encoding.ASCII.GetBytes (name + "\0"), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0) { + + throw new ApplicationException ("Error setting process name: " + + Mono.Unix.Native.Stdlib.GetLastError ()); + + } + + } catch (EntryPointNotFoundException) {} + + } + } } From d2a5b6ad3d391514e05a7a89133b2e1180fe75a2 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 10 Aug 2010 00:08:37 +0100 Subject: [PATCH 08/24] [cli] update formatting somewhat --- SparkleShare/SparkleShare.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SparkleShare/SparkleShare.cs b/SparkleShare/SparkleShare.cs index e4a00663..1bb77ad1 100644 --- a/SparkleShare/SparkleShare.cs +++ b/SparkleShare/SparkleShare.cs @@ -100,13 +100,17 @@ namespace SparkleShare { public static void ShowHelp () { - Console.WriteLine (_("SparkleShare Copyright (C) 2010 Hylke Bons")); + Console.WriteLine (" "); + Console.WriteLine (_("SparkleShare, an instant update workflow to Git.")); + Console.WriteLine (_("Copyright (C) 2010 Hylke Bons")); Console.WriteLine (" "); Console.WriteLine (_("This program comes with ABSOLUTELY NO WARRANTY.")); + Console.WriteLine (" "); 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 (_("SparkleShare automatically syncs Git repositories in ")); + Console.WriteLine (_("the ~/SparkleShare folder with their remote origins.")); Console.WriteLine (" "); Console.WriteLine (_("Usage: sparkleshare [start|stop|restart] [OPTION]...")); Console.WriteLine (_("Sync SparkleShare folder with remote repositories.")); From 9f59d5aeb26d6149337d939399ce7e4b36e1896b Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 10 Aug 2010 10:34:47 +0100 Subject: [PATCH 09/24] [statusicon] Check if file exists before asking for its size --- SparkleShare/SparkleStatusIcon.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 12e6d659..28b12ab5 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -125,9 +125,15 @@ namespace SparkleShare { FileInfo [] files = parent.GetFiles(); - foreach (FileInfo file in files) + foreach (FileInfo file in files) { + + if (!file.Exists) + return 0; + size += file.Length; + } + foreach (DirectoryInfo directory in parent.GetDirectories()) size += GetFolderSize (directory); From f5289c01603bdd0fc06ac2e9570cebc7ff532dc7 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 10 Aug 2010 10:43:17 +0100 Subject: [PATCH 10/24] [statusicon] make filesize localisable --- SparkleShare/SparkleStatusIcon.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 28b12ab5..7e9be87e 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -150,19 +150,21 @@ namespace SparkleShare { } + // Format a file size nicely. + // Example: 1048576 becomes "1 ᴍʙ" private string FormatFileSize (double byte_count) { string size = ""; if (byte_count >= 1099511627776) - size = String.Format ("{0:##.##}", Math.Round (byte_count / 1099511627776, 1)) + " ᴛʙ"; + size = String.Format (_("{0:##.##} ᴛʙ"), Math.Round (byte_count / 1099511627776, 1)); else if (byte_count >= 1073741824) - size = String.Format ("{0:##.##}", Math.Round (byte_count / 1073741824, 1)) + " ɢʙ"; + size = String.Format (_("{0:##.##} ɢʙ"), Math.Round (byte_count / 1073741824, 1)); else if (byte_count >= 1048576) - size = String.Format ("{0:##.##}", Math.Round (byte_count / 1048576, 1)) + " ᴍʙ"; + size = String.Format (_("{0:##.##} ᴍʙ"), Math.Round (byte_count / 1048576, 1)); else if (byte_count >= 1024) - size = String.Format ("{0:##.##}", Math.Round (byte_count / 1024, 1)) + " ᴋʙ"; + size = String.Format (_("{0:##.##} ᴋʙ"), Math.Round (byte_count / 1024, 1)); else size = byte_count.ToString () + " bytes"; From 93bcc84065e8f8e9b999a235b8b39617406d074e Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 10 Aug 2010 15:17:29 +0100 Subject: [PATCH 11/24] [intro] Add cancel button to add dialog when needed --- SparkleShare/SparkleIntro.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/SparkleShare/SparkleIntro.cs b/SparkleShare/SparkleIntro.cs index bdbbac02..fff03ca0 100644 --- a/SparkleShare/SparkleIntro.cs +++ b/SparkleShare/SparkleIntro.cs @@ -443,16 +443,31 @@ namespace SparkleShare { }; + + if (StepTwoOnly) { + + Button cancel_button = new Button (_("Cancel")); + + cancel_button.Clicked += delegate { + Destroy (); + }; + + controls.Add (cancel_button); + + + } else { + Button skip_button = new Button (_("Skip")); skip_button.Clicked += delegate { ShowStepThree (); }; - - if (!StepTwoOnly) controls.Add (skip_button); + } + + controls.Add (AddButton); layout_vertical.PackStart (header, false, false, 0); From adb0312965fd03a4de473da5d385073ed7b43a77 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 10 Aug 2010 16:05:47 +0100 Subject: [PATCH 12/24] [statusicon] fix annoying skewed star bug due to updating ui from a different thread --- SparkleShare/SparkleStatusIcon.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 7e9be87e..e1ef043c 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -339,7 +339,7 @@ namespace SparkleShare { Timer.Stop (); - Pixbuf = AnimationFrames [0]; + Application.Invoke (delegate { SetPixbuf (AnimationFrames [0]); }); StateText = _("Up to date") + " (" + FormatFileSize (FolderSize) + ")"; } From fcbcf50aeb426015bd7983e56c64da7e42c29893 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 10 Aug 2010 16:19:48 +0100 Subject: [PATCH 13/24] [statusicon] show the menu on right click too --- SparkleShare/SparkleStatusIcon.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index e1ef043c..69aed34f 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -62,6 +62,7 @@ namespace SparkleShare { CreateMenu (); Activate += ShowMenu; + PopupMenu += ShowMenu; SetIdleState (); ShowState (); From bcafa7c94f8b935d53aac8edb6cf21ea1f8fb1de Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 10 Aug 2010 22:22:51 +0100 Subject: [PATCH 14/24] [statusicon] code cleanup --- SparkleShare/SparkleStatusIcon.cs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 69aed34f..067a2601 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -52,8 +52,9 @@ namespace SparkleShare { FolderSize = GetFolderSize (new DirectoryInfo (SparklePaths.SparklePath)); - CreateAnimationFrames (); - CreateTimer (); + FrameNumber = 0; + AnimationFrames = CreateAnimationFrames (); + Timer = CreateTimer (); SyncingReposCount = 0; @@ -61,7 +62,11 @@ namespace SparkleShare { StatusMenuItem = new MenuItem (); CreateMenu (); + + // Primary mouse button Activate += ShowMenu; + + // Secondary mouse button PopupMenu += ShowMenu; SetIdleState (); @@ -70,29 +75,29 @@ namespace SparkleShare { } - private void CreateAnimationFrames () + private Gdk.Pixbuf [] CreateAnimationFrames () { - FrameNumber = 0; - - AnimationFrames = new Gdk.Pixbuf [5]; + Gdk.Pixbuf [] animation_frames = new Gdk.Pixbuf [5]; Gdk.Pixbuf frames_pixbuf = SparkleHelpers.GetIcon ("process-syncing-sparkleshare", 24); - for (int i = 0; i < AnimationFrames.Length; i++) - AnimationFrames [i] = new Gdk.Pixbuf (frames_pixbuf, (i * 24), 0, 24, 24); + for (int i = 0; i < animation_frames.Length; i++) + animation_frames [i] = new Gdk.Pixbuf (frames_pixbuf, (i * 24), 0, 24, 24); + + return animation_frames; } // Creates the timer that handles the syncing animation - private void CreateTimer () + private Timer CreateTimer () { - Timer = new Timer () { + Timer timer = new Timer () { Interval = 35 }; - Timer.Elapsed += delegate { + timer.Elapsed += delegate { if (FrameNumber < AnimationFrames.Length - 1) FrameNumber++; @@ -103,6 +108,8 @@ namespace SparkleShare { }; + return timer; + } From eea38eb0f0eb95bedffa2b374f4880e5409bc6ea Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 11 Aug 2010 23:53:32 +0100 Subject: [PATCH 15/24] [statusicon] Fix bug where the size of a temporary directory is checked that may not exist anymore --- SparkleLib/SparkleRepo.cs | 2 ++ SparkleShare/SparkleStatusIcon.cs | 5 +++-- data/sparkleshare.invitation | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 data/sparkleshare.invitation diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 8619ccc6..1a31d818 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -311,6 +311,8 @@ namespace SparkleLib { public void Rebase () { + Add (); // TODO: Experiment for the "You have unstaged changes" bug + Watcher.EnableRaisingEvents = false; SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Rebasing changes..."); diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 067a2601..c32b338e 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -131,9 +131,10 @@ namespace SparkleShare { double size = 0; - FileInfo [] files = parent.GetFiles(); + if (!parent.Name.Equals ("rebase-apply")) + return 0; - foreach (FileInfo file in files) { + foreach (FileInfo file in parent.GetFiles()) { if (!file.Exists) return 0; diff --git a/data/sparkleshare.invitation b/data/sparkleshare.invitation new file mode 100644 index 00000000..33b48b43 --- /dev/null +++ b/data/sparkleshare.invitation @@ -0,0 +1,6 @@ + + + git.gnome.org + gnome-design + a22bc6f4b9ffe8e5acd4be0838d41aa10a1187dd + From 125440071ca9122f7546e3c47f7df804daf03921 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 12 Aug 2010 00:07:14 +0100 Subject: [PATCH 16/24] fix the previous fix. am tired --- SparkleShare/SparkleStatusIcon.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index c32b338e..8b40ea72 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -131,7 +131,7 @@ namespace SparkleShare { double size = 0; - if (!parent.Name.Equals ("rebase-apply")) + if (parent.Name.Equals ("rebase-apply")) return 0; foreach (FileInfo file in parent.GetFiles()) { From e52d65e4d89b188059926db8fb066fd90a2279ab Mon Sep 17 00:00:00 2001 From: Michael Monreal Date: Thu, 12 Aug 2010 09:42:22 +0100 Subject: [PATCH 17/24] [cli] remove pid file when sparkleshare isn't running --- AUTHORS | 1 + SparkleShare/sparkleshare.in | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 9507963b..8f845076 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,6 +13,7 @@ Contributors: Jakub Steiner Lapo Calamandrei Łukasz Jernaś + Michael Monreal Oleg Khlystov Philipp Gildein Ruben Vermeersch diff --git a/SparkleShare/sparkleshare.in b/SparkleShare/sparkleshare.in index 6a5e559d..ea373c17 100644 --- a/SparkleShare/sparkleshare.in +++ b/SparkleShare/sparkleshare.in @@ -27,11 +27,17 @@ case $1 in ;; stop) - if [ -e "/tmp/sparkleshare/sparkleshare.pid" ]; then - echo -n "Stopping SparkleShare..." - kill `cat /tmp/sparkleshare/sparkleshare.pid` - rm -f /tmp/sparkleshare/sparkleshare.pid - echo " Done." + if [ -e "${pidfile}" ]; then + sparklepid=`cat ${pidfile}` + if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then + echo -n "Stopping SparkleShare..." + kill ${sparklepid} + rm -f ${pidfile} + echo " Done." + else + echo "SparkleShare isn't running, removing stale pid file" + rm -f ${pidfile} + fi else echo "SparkleShare isn't running." fi @@ -67,4 +73,5 @@ case $1 in *) echo "Usage: sparkleshare {start|stop|restart|help}" ;; + esac From 9d409d6762f99406e64b45a438e7fe8478c99dbf Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 12 Aug 2010 09:43:24 +0100 Subject: [PATCH 18/24] [repo] explicitly fetch from origin master --- SparkleLib/SparkleRepo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 1a31d818..d73e1bf9 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -283,7 +283,7 @@ namespace SparkleLib { SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes..."); - process.StartInfo.Arguments = "fetch"; + process.StartInfo.Arguments = "fetch origin master"; process.Start (); From 80e03c86e1b1d90c9007d7b556d27106ee83aec9 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 12 Aug 2010 23:08:33 +0100 Subject: [PATCH 19/24] [intro] adjust some folder name logic --- SparkleShare/SparkleIntro.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/SparkleShare/SparkleIntro.cs b/SparkleShare/SparkleIntro.cs index fff03ca0..4898dc5c 100644 --- a/SparkleShare/SparkleIntro.cs +++ b/SparkleShare/SparkleIntro.cs @@ -336,27 +336,34 @@ namespace SparkleShare { string server = ""; + if (name.EndsWith ("/")) + name = name.TrimEnd ("/".ToCharArray ()); + if (radio_button.Active) { server = SparkleToGitUrl (ServerEntry.Text); // Remove the trailing slash if there is one if (server.EndsWith ("/")) - server = server.Trim ("/".ToCharArray ()); + server = server.TrimEnd ("/".ToCharArray ()); } - if (radio_button_gitorious.Active) + + if (radio_button_gitorious.Active) { + server = "ssh://git@gitorious.org"; + if (!name.EndsWith (".git")) + name += ".git"; + + } + if (radio_button_github.Active) server = "ssh://git@github.com"; if (radio_button_gnome.Active) - server = "ssh://git@gnome.org"; - - if (!name.EndsWith (".git")) - name += ".git"; + server = "ssh://git@gnome.org/git/"; string canonical_name = System.IO.Path.GetFileNameWithoutExtension (name); FolderEntry.Text = canonical_name; From 6e51d4524de3ec684e8b8e82f86e911ee20bd7e3 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 13 Aug 2010 00:27:28 +0100 Subject: [PATCH 20/24] new class [invitation] --- SparkleLib/SparkleRepo.cs | 3 +- SparkleShare/Makefile.am | 1 + SparkleShare/SparkleInvitation.cs | 43 +++++++++++++++++++++++ SparkleShare/SparkleUI.cs | 2 ++ data/gnome-design.sparkleshare-invitation | 7 ++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 SparkleShare/SparkleInvitation.cs create mode 100644 data/gnome-design.sparkleshare-invitation diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index d73e1bf9..7f738cba 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -23,8 +23,7 @@ using System.Timers; namespace SparkleLib { - public class SparkleRepo - { + public class SparkleRepo { private Process Process; private Timer FetchTimer; diff --git a/SparkleShare/Makefile.am b/SparkleShare/Makefile.am index f3183d46..a5d76615 100644 --- a/SparkleShare/Makefile.am +++ b/SparkleShare/Makefile.am @@ -11,6 +11,7 @@ SOURCES = \ SparkleBubble.cs \ SparkleEntry.cs \ SparkleIntro.cs \ + SparkleInvitation.cs \ SparkleShare.cs \ SparkleSpinner.cs \ SparkleStatusIcon.cs \ diff --git a/SparkleShare/SparkleInvitation.cs b/SparkleShare/SparkleInvitation.cs new file mode 100644 index 00000000..5b135107 --- /dev/null +++ b/SparkleShare/SparkleInvitation.cs @@ -0,0 +1,43 @@ +// SparkleShare, an instant update workflow to Git. +// Copyright (C) 2010 Hylke Bons +// +// 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 . + +using System; +using System.IO; +using System.Xml; + +namespace SparkleShare { + + class SparkleInvitation { + + public SparkleInvitation (string file_path) + { + + XmlDocument xml_doc = new XmlDocument (); + xml_doc.Load (file_path); + + XmlNodeList server_xml = xml_doc.GetElementsByTagName ("server"); + XmlNodeList repository_xml = xml_doc.GetElementsByTagName ("repository"); + XmlNodeList key_xml = xml_doc.GetElementsByTagName ("key"); + + string server = server_xml [0].InnerText; + string repository = repository_xml [0].InnerText; + string key = key_xml [0].InnerText; + + } + + } + +} diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 86dc8953..9bcc6fe6 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -49,6 +49,8 @@ namespace SparkleShare { BusG.Init (); Gtk.Application.Init (); + SparkleInvitation i = new SparkleInvitation ("/home/hbons/SparkleShare/sparkleshare.invitation"); + SetProcessName ("sparkleshare"); Repositories = new List (); diff --git a/data/gnome-design.sparkleshare-invitation b/data/gnome-design.sparkleshare-invitation new file mode 100644 index 00000000..0f237b93 --- /dev/null +++ b/data/gnome-design.sparkleshare-invitation @@ -0,0 +1,7 @@ + + + + + + + From 1cd1ac42241943a73787fcc5bdb868d67ef65428 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 14 Aug 2010 11:22:49 +0100 Subject: [PATCH 21/24] rename [window] to [log] --- SparkleLib/SparkleRepo.cs | 4 +- SparkleShare/Makefile.am | 1 + SparkleShare/SparkleLog.cs | 291 ++++++++++++++++++++++++++++++ SparkleShare/SparkleStatusIcon.cs | 4 +- SparkleShare/SparkleWindow.cs | 32 ---- 5 files changed, 296 insertions(+), 36 deletions(-) create mode 100644 SparkleShare/SparkleLog.cs diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 7f738cba..15302761 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -282,7 +282,7 @@ namespace SparkleLib { SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes..."); - process.StartInfo.Arguments = "fetch origin master"; + process.StartInfo.Arguments = "fetch -v origin master"; process.Start (); @@ -316,7 +316,7 @@ namespace SparkleLib { SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Rebasing changes..."); - Process.StartInfo.Arguments = "rebase -v origin/master"; + Process.StartInfo.Arguments = "rebase -v FETCH_HEAD"; Process.WaitForExit (); Process.Start (); diff --git a/SparkleShare/Makefile.am b/SparkleShare/Makefile.am index a5d76615..12abb8a9 100644 --- a/SparkleShare/Makefile.am +++ b/SparkleShare/Makefile.am @@ -12,6 +12,7 @@ SOURCES = \ SparkleEntry.cs \ SparkleIntro.cs \ SparkleInvitation.cs \ + SparkleLog.cs \ SparkleShare.cs \ SparkleSpinner.cs \ SparkleStatusIcon.cs \ diff --git a/SparkleShare/SparkleLog.cs b/SparkleShare/SparkleLog.cs new file mode 100644 index 00000000..f75e893e --- /dev/null +++ b/SparkleShare/SparkleLog.cs @@ -0,0 +1,291 @@ +// SparkleShare, an instant update workflow to Git. +// Copyright (C) 2010 Hylke Bons +// +// 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 . + +using Gtk; +using Mono.Unix; +using SparkleLib; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text.RegularExpressions; +using System.Timers; + +namespace SparkleShare { + + public class SparkleLog : Window { + + // Short alias for the translations + public static string _ (string s) + { + return Catalog.GetString (s); + } + + private SparkleRepo SparkleRepo; + private VBox LayoutVertical; + private ScrolledWindow ScrolledWindow; + + public SparkleLog (SparkleRepo sparkle_repo) : base ("") + { + + SparkleRepo = sparkle_repo; + SetSizeRequest (540, 640); + SetPosition (WindowPosition.Center); + BorderWidth = 12; + + // TRANSLATORS: {0} is a folder name, and {1} is a server address + Title = String.Format(_("Recent Events in ‘{0}’"), SparkleRepo.Name); + IconName = "folder"; + + LayoutVertical = new VBox (false, 12); + + LayoutVertical.PackStart (CreateEventLog (), true, true, 0); + + HButtonBox dialog_buttons = new HButtonBox { + Layout = ButtonBoxStyle.Edge, + BorderWidth = 0 + }; + + Button open_folder_button = new Button (_("Open Folder")); + open_folder_button.Clicked += delegate (object o, EventArgs args) { + Process process = new Process (); + process.StartInfo.FileName = "xdg-open"; + string path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + SparkleRepo.Name); + process.StartInfo.Arguments = path.Replace(" ", "\\ "); + process.Start (); + Destroy (); + }; + + Button close_button = new Button (Stock.Close); + close_button.Clicked += delegate (object o, EventArgs args) { + Destroy (); + }; + + dialog_buttons.Add (open_folder_button); + dialog_buttons.Add (close_button); + + LayoutVertical.PackStart (dialog_buttons, false, false, 0); + + Add (LayoutVertical); + + } + + + public void UpdateEventLog () + { + + LayoutVertical.Remove (ScrolledWindow); + ScrolledWindow = CreateEventLog (); + LayoutVertical.PackStart (ScrolledWindow, true, true, 0); + LayoutVertical.ReorderChild (ScrolledWindow, 0); + ShowAll (); + + } + + + private ScrolledWindow CreateEventLog () + { + + int number_of_events = 50; + + Process process = new Process (); + process.EnableRaisingEvents = true; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.UseShellExecute = false; + process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath; + process.StartInfo.FileName = "git"; + process.StartInfo.Arguments = "log --format=\"%at☃%an☃%ae☃%s\" -" + number_of_events; + + process.Start (); + + string output = process.StandardOutput.ReadToEnd ().Trim (); + + output = output.TrimStart ("\n".ToCharArray ()); + string [] lines = Regex.Split (output, "\n"); + int linesLength = lines.Length; + if (output == "") + linesLength = 0; + + // Sort by time and get the last 25 + Array.Sort (lines); + Array.Reverse (lines); + + List activity_days = new List (); + + for (int i = 0; i < number_of_events && i < linesLength; i++) { + + string line = lines [i]; + + // Look for the snowman! + string [] parts = Regex.Split (line, "☃"); + + int unix_timestamp = int.Parse (parts [0]); + string user_name = parts [1]; + string user_email = parts [2]; + string message = parts [3]; + + DateTime date_time = UnixTimestampToDateTime (unix_timestamp); + + message = message.Replace ("/", " ‣ "); + message = message.Replace ("\n", " "); + + ChangeSet change_set = new ChangeSet (user_name, user_email, message, date_time); + + bool change_set_inserted = false; + foreach (ActivityDay stored_activity_day in activity_days) { + + if (stored_activity_day.DateTime.Year == change_set.DateTime.Year && + stored_activity_day.DateTime.Month == change_set.DateTime.Month && + stored_activity_day.DateTime.Day == change_set.DateTime.Day) { + + stored_activity_day.Add (change_set); + change_set_inserted = true; + break; + + } + + } + + if (!change_set_inserted) { + + ActivityDay activity_day = new ActivityDay (change_set.DateTime); + activity_day.Add (change_set); + activity_days.Add (activity_day); + + } + + } + + + VBox layout_vertical = new VBox (false, 0); + + foreach (ActivityDay activity_day in activity_days) { + + TreeIter iter = new TreeIter (); + ListStore list_store = new ListStore (typeof (Gdk.Pixbuf), + typeof (string), + typeof (string)); + + foreach (ChangeSet change_set in activity_day) { + + iter = list_store.Append (); + list_store.SetValue (iter, 0, SparkleHelpers.GetAvatar (change_set.UserEmail , 32)); + list_store.SetValue (iter, 1, "" + change_set.UserName + "\n" + + "" + change_set.Message + ""); + list_store.SetValue (iter, 2, change_set.UserEmail); + + } + + Label date_label = new Label ("") { + UseMarkup = true, + Xalign = 0, + Xpad = 9, + Ypad = 9 + }; + + DateTime today = DateTime.Now; + DateTime yesterday = DateTime.Now.AddDays (-1); + + if (today.Day == activity_day.DateTime.Day && + today.Month == activity_day.DateTime.Month && + today.Year == activity_day.DateTime.Year) { + + date_label.Markup = "Today"; + + } else if (yesterday.Day == activity_day.DateTime.Day && + yesterday.Month == activity_day.DateTime.Month && + yesterday.Year == activity_day.DateTime.Year) { + + date_label.Markup = "Yesterday"; + + } else { + + date_label.Markup = "" + activity_day.DateTime.ToString ("ddd MMM d, yyyy") + ""; + + } + + layout_vertical.PackStart (date_label, false, false, 0); + + IconView icon_view = new IconView (list_store) { + ItemWidth = 470, + MarkupColumn = 1, + Orientation = Orientation.Horizontal, + PixbufColumn = 0, + Spacing = 9 + }; + + icon_view.SelectionChanged += delegate { + icon_view.UnselectAll (); + }; + + layout_vertical.PackStart (icon_view, false, false, 0); + + } + + ScrolledWindow = new ScrolledWindow (); + ScrolledWindow.ShadowType = ShadowType.None; + ScrolledWindow.AddWithViewport (layout_vertical); + + return ScrolledWindow; + + } + + + // Converts a UNIX timestamp to a more usable time object + public DateTime UnixTimestampToDateTime (int timestamp) + { + DateTime unix_epoch = new DateTime (1970, 1, 1, 0, 0, 0, 0); + return unix_epoch.AddSeconds (timestamp); + } + + + } + + + public class ActivityDay : List + { + + public DateTime DateTime; + + public ActivityDay (DateTime date_time) + { + DateTime = date_time; + DateTime = new DateTime (DateTime.Year, DateTime.Month, DateTime.Day); + } + + } + + + public class ChangeSet + { + + public string UserName; + public string UserEmail; + public string Message; + public DateTime DateTime; + + public ChangeSet (string user_name, string user_email, string message, DateTime date_time) + { + UserName = user_name; + UserEmail = user_email; + Message = message; + DateTime = date_time; + } + + } + +} diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 8b40ea72..657d40b2 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -118,8 +118,8 @@ namespace SparkleShare { return delegate { - SparkleWindow SparkleWindow = new SparkleWindow (repo); - SparkleWindow.ShowAll (); + SparkleLog log = new SparkleLog (repo); + log.ShowAll (); }; diff --git a/SparkleShare/SparkleWindow.cs b/SparkleShare/SparkleWindow.cs index f3de3478..404cdcd1 100644 --- a/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -255,37 +255,5 @@ namespace SparkleShare { } - - public class ActivityDay : List - { - - public DateTime DateTime; - - public ActivityDay (DateTime date_time) - { - DateTime = date_time; - DateTime = new DateTime (DateTime.Year, DateTime.Month, DateTime.Day); - } - - } - - - public class ChangeSet - { - - public string UserName; - public string UserEmail; - public string Message; - public DateTime DateTime; - - public ChangeSet (string user_name, string user_email, string message, DateTime date_time) - { - UserName = user_name; - UserEmail = user_email; - Message = message; - DateTime = date_time; - } - - } } From 38eb444e88cdb5f600e18f656b08f94a40e92a15 Mon Sep 17 00:00:00 2001 From: Michael Monreal Date: Sat, 14 Aug 2010 11:28:34 +0100 Subject: [PATCH 22/24] [cli] improved wrapper script --- SparkleShare/sparkleshare.in | 123 +++++++++++++++-------------------- 1 file changed, 53 insertions(+), 70 deletions(-) diff --git a/SparkleShare/sparkleshare.in b/SparkleShare/sparkleshare.in index ea373c17..251b65ee 100644 --- a/SparkleShare/sparkleshare.in +++ b/SparkleShare/sparkleshare.in @@ -2,76 +2,59 @@ pidfile=/tmp/sparkleshare/sparkleshare.pid -# Create a directory to save the pid to +start() { + if [ -e "${pidfile}" ]; then + sparklepid=`cat ${pidfile}` + if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then + echo "SparkleShare is already running." + exit 0 + else + echo "SparkleShare stale pid file found, starting a new instance." + rm -f $pidfile + fi + fi + + echo -n "Starting SparkleShare... " + mkdir -p /tmp/sparkleshare/ + # Start SparkleShare in the background and save the pid + mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 & + echo $! > ${pidfile} + echo "Done." +} + +stop() { + if [ -e "${pidfile}" ]; then + sparklepid=`cat ${pidfile}` + if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then + echo -n "Stopping SparkleShare... " + kill ${sparklepid} + rm -f ${pidfile} + echo "Done." + else + echo "SparkleShare is not running, removing stale pid file." + rm -f ${pidfile} + fi + else + echo "SparkleShare is not running." + fi +} + case $1 in - start) - if [ -e "${pidfile}" ]; then - sparklepid=`cat ${pidfile}` - if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ] - then - echo "SparkleShare is already running" - exit 0 - else - echo "SparkleShare stale pid file found, starting a new instance" - rm -f $pidfile - fi - fi - - echo -n "Starting SparkleShare..." - mkdir -p /tmp/sparkleshare/ - # Start SparkleShare in the background and save the pid - mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 & - PID=$! - echo $PID > /tmp/sparkleshare/sparkleshare.pid - echo " Done." - ;; - - stop) - if [ -e "${pidfile}" ]; then - sparklepid=`cat ${pidfile}` - if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then - echo -n "Stopping SparkleShare..." - kill ${sparklepid} - rm -f ${pidfile} - echo " Done." - else - echo "SparkleShare isn't running, removing stale pid file" - rm -f ${pidfile} - fi - else - echo "SparkleShare isn't running." - fi - ;; - - restart) - if [ -e "/tmp/sparkleshare/sparkleshare.pid" ]; then - echo -n "Stopping SparkleShare..." - kill `cat /tmp/sparkleshare/sparkleshare.pid` - rm -f /tmp/sparkleshare/sparkleshare.pid - echo " Done." - else - echo "SparkleShare isn't running." - fi - - if [ -e "/tmp/sparkleshare/sparkleshare.pid" ]; then - echo "SparkleShare is already running." - else - echo -n "Starting SparkleShare..." - - # Start SparkleShare in the background and save the pid - mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 & - PID=$! - echo $PID > /tmp/sparkleshare/sparkleshare.pid - echo " Done." - fi - ;; - - --help | help) - mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" --help - ;; - + start|--start) + start + ;; + stop|--stop) + stop + ;; + restart|--restart) + stop + start + ;; + help|--help) + mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" --help + ;; *) - echo "Usage: sparkleshare {start|stop|restart|help}" - ;; - + echo "Usage: sparkleshare {start|stop|restart|help}" + ;; esac + From 06d41a13a71df48435dd7b3f3a01c559c2893839 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 14 Aug 2010 15:08:04 +0100 Subject: [PATCH 23/24] [intro] code cleanup --- SparkleShare/SparkleIntro.cs | 905 +++++++++++++----------------- SparkleShare/SparkleStatusIcon.cs | 2 +- SparkleShare/SparkleUI.cs | 2 +- SparkleShare/SparkleWindow.cs | 245 ++------ 4 files changed, 438 insertions(+), 716 deletions(-) diff --git a/SparkleShare/SparkleIntro.cs b/SparkleShare/SparkleIntro.cs index 4898dc5c..a2cba78c 100644 --- a/SparkleShare/SparkleIntro.cs +++ b/SparkleShare/SparkleIntro.cs @@ -24,17 +24,18 @@ using System.Text.RegularExpressions; namespace SparkleShare { - public class SparkleIntro : Window { + public class SparkleIntro : SparkleWindow { private Entry NameEntry; private Entry EmailEntry; private SparkleEntry ServerEntry; private SparkleEntry FolderEntry; private Button NextButton; - private Button AddButton; - private bool StepTwoOnly; + private Button SyncButton; + private bool ServerFormOnly; private string SecondaryTextColor; + // Short alias for the translations public static string _ (string s) { @@ -42,542 +43,460 @@ namespace SparkleShare { } - public SparkleIntro () : base ("") + public SparkleIntro () : base () { - BorderWidth = 0; - IconName = "folder-sparkleshare"; - Resizable = true; - WindowPosition = WindowPosition.Center; + ServerFormOnly = false; + SecondaryTextColor = GdkColorToHex (Style.Foreground (StateType.Insensitive)); - StepTwoOnly = false; - - SetDefaultSize (640, 480); - - Window window = new Window (""); - SecondaryTextColor = GdkColorToHex (window.Style.Foreground (StateType.Insensitive)); - - ShowStepOne (); + ShowAccountForm (); } - private void ShowStepOne () + private void ShowAccountForm () { - HBox layout_horizontal = new HBox (false, 6); + Reset (); - Image side_splash = new Image (SparkleHelpers.CombineMore (Defines.PREFIX, "share", "pixmaps", - "side-splash.png")); + VBox layout_vertical = new VBox (false, 0); - VBox wrapper = new VBox (false, 0); + Label header = new Label ("" + + _("Welcome to SparkleShare!") + + "") { + UseMarkup = true, + Xalign = 0 + }; - VBox layout_vertical = new VBox (false, 0) { - BorderWidth = 30 + Label information = new Label (_("Before we can create a SparkleShare folder on this " + + "computer, we need a few bits of information from you.")) { + Xalign = 0, + Wrap = true + }; + + Table table = new Table (4, 2, true) { + RowSpacing = 6 + }; + + UnixUserInfo unix_user_info = new UnixUserInfo (UnixEnvironment.UserName); + + Label name_label = new Label ("" + _("Full Name:") + "") { + UseMarkup = true, + Xalign = 0 }; - Label header = new Label ("" + - _("Welcome to SparkleShare!") + - "") { - UseMarkup = true, - Xalign = 0 - }; - - Label information = new Label (_("Before we can create a SparkleShare folder on this " + - "computer, we need a few bits of information from you.")) { - Xalign = 0, - Wrap = true - }; - - Table table = new Table (4, 2, true) { - RowSpacing = 6 - }; - - UnixUserInfo unix_user_info = new UnixUserInfo (UnixEnvironment.UserName); - - Label name_label = new Label ("" + _("Full Name:") + "") { - UseMarkup = true, - Xalign = 0 - }; - - NameEntry = new Entry (unix_user_info.RealName); - NameEntry.Changed += delegate { - CheckStepOneFields (); - }; + NameEntry = new Entry (unix_user_info.RealName); + NameEntry.Changed += delegate { + CheckAccountForm (); + }; - EmailEntry = new Entry (GetUserEmail ()); - EmailEntry.Changed += delegate { - CheckStepOneFields (); - }; + EmailEntry = new Entry (GetUserEmail ()); + EmailEntry.Changed += delegate { + CheckAccountForm (); + }; - Label email_label = new Label ("" + _("Email:") + "") { - UseMarkup = true, - Xalign = 0 - }; + Label email_label = new Label ("" + _("Email:") + "") { + UseMarkup = true, + Xalign = 0 + }; - table.Attach (name_label, 0, 1, 0, 1); - table.Attach (NameEntry, 1, 2, 0, 1); - table.Attach (email_label, 0, 1, 1, 2); - table.Attach (EmailEntry, 1, 2, 1, 2); - - HButtonBox controls = new HButtonBox () { - BorderWidth = 12, - Layout = ButtonBoxStyle.End - }; + table.Attach (name_label, 0, 1, 0, 1); + table.Attach (NameEntry, 1, 2, 0, 1); + table.Attach (email_label, 0, 1, 1, 2); + table.Attach (EmailEntry, 1, 2, 1, 2); + + NextButton = new Button (_("Next")) { + Sensitive = false + }; + + NextButton.Clicked += delegate (object o, EventArgs args) { - NextButton = new Button (_("Next")) { - Sensitive = false - }; - - NextButton.Clicked += delegate (object o, EventArgs args) { + NextButton.Remove (NextButton.Child); + NextButton.Add (new Label (_("Configuring…"))); - NextButton.Remove (NextButton.Child); - NextButton.Add (new Label (_("Configuring…"))); + NextButton.Sensitive = false; + table.Sensitive = false; - NextButton.Sensitive = false; - table.Sensitive = false; + NextButton.ShowAll (); - NextButton.ShowAll (); + Configure (); + ShowServerForm (); - Configure (); - ShowStepTwo (); + }; + + AddButton (NextButton); - }; - - controls.Add (NextButton); + layout_vertical.PackStart (header, false, false, 0); + layout_vertical.PackStart (information, false, false, 21); + layout_vertical.PackStart (new Label (""), false, false, 0); + layout_vertical.PackStart (table, false, false, 0); - layout_vertical.PackStart (header, false, false, 0); - layout_vertical.PackStart (information, false, false, 21); - layout_vertical.PackStart (new Label (""), false, false, 0); - layout_vertical.PackStart (table, false, false, 0); -// layout_vertical.PackStart (check_button, false, false, 0); + Add (layout_vertical); - - wrapper.PackStart (layout_vertical, true, true, 0); - wrapper.PackStart (controls, false, true, 0); - - layout_horizontal.PackStart (side_splash, false, false, 0); - layout_horizontal.PackStart (wrapper, true, true, 0); - - Add (layout_horizontal); - - CheckStepOneFields (); + CheckAccountForm (); ShowAll (); } - public void ShowStepTwo (bool step_two_only) + public void ShowServerForm (bool server_form_only) { - StepTwoOnly = step_two_only; - ShowStepTwo (); + ServerFormOnly = server_form_only; + ShowServerForm (); } - public void ShowStepTwo () + public void ShowServerForm () { - Remove (Child); - - HBox layout_horizontal = new HBox (false, 6); - - Image side_splash = new Image (SparkleHelpers.CombineMore (Defines.PREFIX, "share", "pixmaps", - "side-splash.png")); - - VBox wrapper = new VBox (false, 0); + Reset (); - VBox layout_vertical = new VBox (false, 0) { - BorderWidth = 30 + VBox layout_vertical = new VBox (false, 0); + + Label header = new Label ("" + + _("Where is your remote folder?") + + "") { + UseMarkup = true, + Xalign = 0 + }; + + Table table = new Table (7, 2, false) { + RowSpacing = 12 + }; + + HBox layout_server = new HBox (true, 0); + + ServerEntry = new SparkleEntry () { + ExampleText = _("ssh://address-to-my-server/") + }; + + ServerEntry.Changed += CheckServerForm; + + RadioButton radio_button = new RadioButton ("" + _("On my own server:") + ""); + + layout_server.Add (radio_button); + layout_server.Add (ServerEntry); + + string github_text = "" + "Github" + "\n" + + "" + + _("Free hosting for Free and Open Source Software projects.") + "\n" + + _("Also has paid accounts for extra private space and bandwidth.") + + ""; + + RadioButton radio_button_github = new RadioButton (radio_button, github_text); + + (radio_button_github.Child as Label).UseMarkup = true; + (radio_button_github.Child as Label).Wrap = true; + + string gnome_text = "" + _("The GNOME Project") + "\n" + + "" + + _("GNOME is an easy to understand interface to your computer.") + "\n" + + _("Select this option if you’re a developer or designer working on GNOME.") + + ""; + + RadioButton radio_button_gnome = new RadioButton (radio_button, gnome_text); + + (radio_button_gnome.Child as Label).UseMarkup = true; + (radio_button_gnome.Child as Label).Wrap = true; + + string gitorious_text = "" + _("Gitorious") + "\n" + + "" + + _("Completely Free as in Freedom infrastructure.") + "\n" + + _("Free accounts for Free and Open Source projects.") + + ""; + RadioButton radio_button_gitorious = new RadioButton (radio_button, gitorious_text) { + Xalign = 0 }; - - Label header = new Label ("" + - _("Where is your remote folder?") + - "") { - UseMarkup = true, - Xalign = 0 - }; - Table table = new Table (7, 2, false) { - RowSpacing = 12 - }; + (radio_button_gitorious.Child as Label).UseMarkup = true; + (radio_button_gitorious.Child as Label).Wrap = true; - HBox layout_server = new HBox (true, 0); + radio_button_github.Toggled += delegate { - ServerEntry = new SparkleEntry () { - ExampleText = _("ssh://address-to-my-server/") - }; - - ServerEntry.Changed += CheckStepTwoFields; + if (radio_button_github.Active) + FolderEntry.ExampleText = "Username/Folder"; - RadioButton radio_button = new RadioButton ("" + _("On my own server:") + ""); + }; - layout_server.Add (radio_button); - layout_server.Add (ServerEntry); - - string github_text = "" + "Github" + "\n" + - "" + - _("Free hosting for Free and Open Source Software projects.") + "\n" + - _("Also has paid accounts for extra private space and bandwidth.") + - ""; + radio_button_gitorious.Toggled += delegate { - RadioButton radio_button_github = new RadioButton (radio_button, github_text); + if (radio_button_gitorious.Active) + FolderEntry.ExampleText = "Project/Folder"; - (radio_button_github.Child as Label).UseMarkup = true; - (radio_button_github.Child as Label).Wrap = true; + }; - string gnome_text = "" + _("The GNOME Project") + "\n" + - "" + - _("GNOME is an easy to understand interface to your computer.") + "\n" + - _("Select this option if you’re a developer or designer working on GNOME.") + - ""; + radio_button_gnome.Toggled += delegate { - RadioButton radio_button_gnome = new RadioButton (radio_button, gnome_text); + if (radio_button_gnome.Active) + FolderEntry.ExampleText = "Project"; - (radio_button_gnome.Child as Label).UseMarkup = true; - (radio_button_gnome.Child as Label).Wrap = true; + }; - string gitorious_text = "" + _("Gitorious") + "\n" + - "" + - _("Completely Free as in Freedom infrastructure.") + "\n" + - _("Free accounts for Free and Open Source projects.") + - ""; - RadioButton radio_button_gitorious = new RadioButton (radio_button, gitorious_text) { - Xalign = 0 - }; - - (radio_button_gitorious.Child as Label).UseMarkup = true; - (radio_button_gitorious.Child as Label).Wrap = true; - radio_button_github.Toggled += delegate { + radio_button.Toggled += delegate { - if (radio_button_github.Active) - FolderEntry.ExampleText = "Username/Folder"; - - }; - - radio_button_gitorious.Toggled += delegate { - - if (radio_button_gitorious.Active) - FolderEntry.ExampleText = "Project/Folder"; - - }; - - radio_button_gnome.Toggled += delegate { - - if (radio_button_gnome.Active) - FolderEntry.ExampleText = "Project"; - - }; - - - radio_button.Toggled += delegate { - - if (radio_button.Active) { - - FolderEntry.ExampleText = "Folder"; - ServerEntry.Sensitive = true; - CheckStepTwoFields (); - - } else { - - ServerEntry.Sensitive = false; - CheckStepTwoFields (); - - } - - ShowAll (); - - }; - - table.Attach (layout_server, 0, 2, 1, 2); - table.Attach (radio_button_github, 0, 2, 2, 3); - table.Attach (radio_button_gitorious, 0, 2, 3, 4); - table.Attach (radio_button_gnome, 0, 2, 4, 5); - - HBox layout_folder = new HBox (true, 0); - - FolderEntry = new SparkleEntry () { - ExampleText = "Folder" - }; - - FolderEntry.Changed += CheckStepTwoFields; - - Label folder_label = new Label ("" + _("Folder Name:") + "") { - UseMarkup = true, - Xalign = 1 - }; - - (radio_button.Child as Label).UseMarkup = true; - - layout_folder.PackStart (folder_label, true, true, 12); - layout_folder.PackStart (FolderEntry, true, true, 0); - - - HButtonBox controls = new HButtonBox () { - BorderWidth = 12, - Layout = ButtonBoxStyle.End, - Spacing = 6 - }; - - AddButton = new Button (_("Sync")); - - AddButton.Clicked += delegate { - - string name = FolderEntry.Text; - - // Remove the starting slash if there is one - if (name.StartsWith ("/")) - name = name.Substring (1); - - string server = ""; - - if (name.EndsWith ("/")) - name = name.TrimEnd ("/".ToCharArray ()); - - if (radio_button.Active) { - - server = SparkleToGitUrl (ServerEntry.Text); - - // Remove the trailing slash if there is one - if (server.EndsWith ("/")) - server = server.TrimEnd ("/".ToCharArray ()); - - } - - - if (radio_button_gitorious.Active) { - - server = "ssh://git@gitorious.org"; - - if (!name.EndsWith (".git")) - name += ".git"; - - } - - if (radio_button_github.Active) - server = "ssh://git@github.com"; - - if (radio_button_gnome.Active) - server = "ssh://git@gnome.org/git/"; - - string canonical_name = System.IO.Path.GetFileNameWithoutExtension (name); - FolderEntry.Text = canonical_name; - - string url = server + "/" + name; - string tmp_folder = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, - canonical_name); - - SparkleFetcher fetcher = new SparkleFetcher (url, tmp_folder); - - Console.WriteLine (url); - - fetcher.CloningStarted += delegate { - - SparkleHelpers.DebugInfo ("Git", "[" + canonical_name + "] Cloning Repository"); - - }; - - - fetcher.CloningFinished += delegate { - - SparkleHelpers.DebugInfo ("Git", "[" + canonical_name + "] Repository cloned"); - - ClearAttributes (tmp_folder); - - try { - - bool folder_exists = Directory.Exists ( - SparkleHelpers.CombineMore (SparklePaths.SparklePath, canonical_name)); - - int i = 1; - while (folder_exists) { - - i++; - folder_exists = Directory.Exists ( - SparkleHelpers.CombineMore (SparklePaths.SparklePath, - canonical_name + " (" + i + ")")); - - } - - string target_folder_name = canonical_name; - - if (i > 1) - target_folder_name += " (" + i + ")"; - - string target_folder_path; - target_folder_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - target_folder_name); - - Directory.Move (tmp_folder, target_folder_path); - - } catch (Exception e) { - - SparkleHelpers.DebugInfo ("Git", - "[" + name + "] Error moving folder: " + e.Message); - - } - - Application.Invoke (delegate { ShowFinishedStep (); }); - - }; - - - fetcher.CloningFailed += delegate { - - SparkleHelpers.DebugInfo ("Git", "[" + canonical_name + "] Cloning failed"); - - if (Directory.Exists (tmp_folder)) { - - ClearAttributes (tmp_folder); - Directory.Delete (tmp_folder, true); - - SparkleHelpers.DebugInfo ("Config", - "[" + name + "] Deleted temporary directory"); - - } - - Application.Invoke (delegate { ShowErrorStep (); }); - - }; - - ShowStepTwoAndAHalf (); - fetcher.Clone (); - - }; - - - if (StepTwoOnly) { - - Button cancel_button = new Button (_("Cancel")); - - cancel_button.Clicked += delegate { - Destroy (); - }; - - controls.Add (cancel_button); + if (radio_button.Active) { + FolderEntry.ExampleText = "Folder"; + ServerEntry.Sensitive = true; + CheckServerForm (); } else { - Button skip_button = new Button (_("Skip")); + ServerEntry.Sensitive = false; + CheckServerForm (); - skip_button.Clicked += delegate { - ShowStepThree (); - }; + } - controls.Add (skip_button); + ShowAll (); + + }; + + table.Attach (layout_server, 0, 2, 1, 2); + table.Attach (radio_button_github, 0, 2, 2, 3); + table.Attach (radio_button_gitorious, 0, 2, 3, 4); + table.Attach (radio_button_gnome, 0, 2, 4, 5); + + HBox layout_folder = new HBox (true, 0); + + FolderEntry = new SparkleEntry () { + ExampleText = "Folder" + }; + + FolderEntry.Changed += CheckServerForm; + + Label folder_label = new Label ("" + _("Folder Name:") + "") { + UseMarkup = true, + Xalign = 1 + }; + + (radio_button.Child as Label).UseMarkup = true; + + layout_folder.PackStart (folder_label, true, true, 12); + layout_folder.PackStart (FolderEntry, true, true, 0); + + SyncButton = new Button (_("Sync")); + + SyncButton.Clicked += delegate { + + string name = FolderEntry.Text; + + // Remove the starting slash if there is one + if (name.StartsWith ("/")) + name = name.Substring (1); + + string server = ""; + + if (name.EndsWith ("/")) + name = name.TrimEnd ("/".ToCharArray ()); + + if (radio_button.Active) { + + server = SparkleToGitUrl (ServerEntry.Text); + + // Remove the trailing slash if there is one + if (server.EndsWith ("/")) + server = server.TrimEnd ("/".ToCharArray ()); } - controls.Add (AddButton); + if (radio_button_gitorious.Active) { - layout_vertical.PackStart (header, false, false, 0); - layout_vertical.PackStart (new Label (""), false, false, 3); - layout_vertical.PackStart (table, false, false, 0); - layout_vertical.PackStart (layout_folder, false, false, 6); + server = "ssh://git@gitorious.org"; - wrapper.PackStart (layout_vertical, true, true, 0); - wrapper.PackStart (controls, false, true, 0); + if (!name.EndsWith (".git")) + name += ".git"; - layout_horizontal.PackStart (side_splash, false, false, 0); - layout_horizontal.PackStart (wrapper, true, true, 0); + } - Add (layout_horizontal); + if (radio_button_github.Active) + server = "ssh://git@github.com"; - CheckStepTwoFields (); + if (radio_button_gnome.Active) + server = "ssh://git@gnome.org/git/"; + + string canonical_name = System.IO.Path.GetFileNameWithoutExtension (name); + FolderEntry.Text = canonical_name; + + string url = server + "/" + name; + string tmp_folder = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, + canonical_name); + + SparkleFetcher fetcher = new SparkleFetcher (url, tmp_folder); + + SparkleHelpers.DebugInfo ("Git", "[" + name + "] Formed URL: " + url); + + fetcher.CloningStarted += delegate { + + SparkleHelpers.DebugInfo ("Git", "[" + canonical_name + "] Cloning Repository"); + + }; + + + fetcher.CloningFinished += delegate { + + SparkleHelpers.DebugInfo ("Git", "[" + canonical_name + "] Repository cloned"); + + ClearAttributes (tmp_folder); + + try { + + bool folder_exists = Directory.Exists ( + SparkleHelpers.CombineMore (SparklePaths.SparklePath, canonical_name)); + + int i = 1; + while (folder_exists) { + + i++; + folder_exists = Directory.Exists ( + SparkleHelpers.CombineMore (SparklePaths.SparklePath, + canonical_name + " (" + i + ")")); + + } + + string target_folder_name = canonical_name; + + if (i > 1) + target_folder_name += " (" + i + ")"; + + string target_folder_path; + target_folder_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + target_folder_name); + + Directory.Move (tmp_folder, target_folder_path); + + } catch (Exception e) { + + SparkleHelpers.DebugInfo ("Git", + "[" + name + "] Error moving folder: " + e.Message); + + } + + Application.Invoke (delegate { ShowSuccessPage (); }); + + }; + + + fetcher.CloningFailed += delegate { + + SparkleHelpers.DebugInfo ("Git", "[" + canonical_name + "] Cloning failed"); + + if (Directory.Exists (tmp_folder)) { + + ClearAttributes (tmp_folder); + Directory.Delete (tmp_folder, true); + + SparkleHelpers.DebugInfo ("Config", + "[" + name + "] Deleted temporary directory"); + + } + + Application.Invoke (delegate { ShowErrorPage (); }); + + }; + + ShowSyncingPage (); + fetcher.Clone (); + + }; + + + if (ServerFormOnly) { + + Button cancel_button = new Button (_("Cancel")); + + cancel_button.Clicked += delegate { + Destroy (); + }; + + AddButton (cancel_button); + + + } else { + + Button skip_button = new Button (_("Skip")); + + skip_button.Clicked += delegate { + ShowCompletedPage (); + }; + + AddButton (skip_button); + + } + + AddButton (SyncButton); + + layout_vertical.PackStart (header, false, false, 0); + layout_vertical.PackStart (new Label (""), false, false, 3); + layout_vertical.PackStart (table, false, false, 0); + layout_vertical.PackStart (layout_folder, false, false, 6); + + Add (layout_vertical); + + CheckServerForm (); ShowAll (); } - private void ShowErrorStep () + private void ShowErrorPage () { - Remove (Child); - - HBox layout_horizontal = new HBox (false, 6); - - Image side_splash = new Image (SparkleHelpers.CombineMore (Defines.PREFIX, "share", "pixmaps", - "side-splash.png")); - - VBox wrapper = new VBox (false, 0); + Reset (); - VBox layout_vertical = new VBox (false, 0) { - BorderWidth = 30 + VBox layout_vertical = new VBox (false, 0); + + Label header = new Label ("" + + _("Something went wrong…") + + "\n") { + UseMarkup = true, + Xalign = 0 + }; + + Label information = new Label ("" + + _("Hey, it's an Alpha!") + + "") { + Xalign = 0, + Wrap = true, + UseMarkup = true + }; + + Button try_again_button = new Button (_("Try again…")) { + Sensitive = true }; - - Label header = new Label ("" + - _("Something went wrong…") + - "\n") { - UseMarkup = true, - Xalign = 0 - }; - - Label information = new Label ("" + - _("Hey, it's an Alpha!") + - "") { - Xalign = 0, - Wrap = true, - UseMarkup = true - }; + + try_again_button.Clicked += delegate (object o, EventArgs args) { - - HButtonBox controls = new HButtonBox () { - BorderWidth = 12, - Layout = ButtonBoxStyle.End - }; + ShowServerForm (); - Button try_again_button = new Button (_("Try again…")) { - Sensitive = true - }; - - try_again_button.Clicked += delegate (object o, EventArgs args) { + }; + + AddButton (try_again_button); - ShowStepTwo (); + layout_vertical.PackStart (header, false, false, 0); + layout_vertical.PackStart (information, false, false, 0); - }; - - controls.Add (try_again_button); - - layout_vertical.PackStart (header, false, false, 0); - layout_vertical.PackStart (information, false, false, 0); - - wrapper.PackStart (layout_vertical, true, true, 0); - wrapper.PackStart (controls, false, true, 0); - - layout_horizontal.PackStart (side_splash, false, false, 0); - layout_horizontal.PackStart (wrapper, true, true, 0); - - Add (layout_horizontal); + Add (layout_vertical); ShowAll (); - + } - private void ShowFinishedStep () + private void ShowSuccessPage () { - Remove (Child); + Reset (); - HBox layout_horizontal = new HBox (false, 6); + VBox layout_vertical = new VBox (false, 0); - Image side_splash = new Image (SparkleHelpers.CombineMore (Defines.PREFIX, "share", "pixmaps", - "side-splash.png")); - - VBox wrapper = new VBox (false, 0); - - VBox layout_vertical = new VBox (false, 0) { - BorderWidth = 30 - }; - Label header = new Label ("" + _("Folder synced successfully!") + "") { @@ -593,51 +512,30 @@ namespace SparkleShare { UseMarkup = true }; - - HButtonBox controls = new HButtonBox () { - BorderWidth = 12, - Layout = ButtonBoxStyle.End - }; - Button finish_button = new Button (_("Finish")); finish_button.Clicked += delegate (object o, EventArgs args) { Destroy (); }; - controls.Add (finish_button); + AddButton (finish_button); layout_vertical.PackStart (header, false, false, 0); layout_vertical.PackStart (information, false, false, 0); - wrapper.PackStart (layout_vertical, true, true, 0); - wrapper.PackStart (controls, false, true, 0); - - layout_horizontal.PackStart (side_splash, false, false, 0); - layout_horizontal.PackStart (wrapper, true, true, 0); - - Add (layout_horizontal); + Add (layout_vertical); ShowAll (); } - private void ShowStepTwoAndAHalf () + private void ShowSyncingPage () { - Remove (Child); - - HBox layout_horizontal = new HBox (false, 6); - - Image side_splash = new Image (SparkleHelpers.CombineMore (Defines.PREFIX, "share", "pixmaps", - "side-splash.png")); - - VBox wrapper = new VBox (false, 0); + Reset (); - VBox layout_vertical = new VBox (false, 0) { - BorderWidth = 30 - }; + VBox layout_vertical = new VBox (false, 0); Label header = new Label ("" + String.Format (_("Syncing folder ‘{0}’…"), FolderEntry.Text) + @@ -655,17 +553,12 @@ namespace SparkleShare { Xalign = 0 }; - HButtonBox controls = new HButtonBox () { - BorderWidth = 12, - Layout = ButtonBoxStyle.End, - Spacing = 6 - }; Button button = new Button () { Sensitive = false }; - if (StepTwoOnly) { + if (ServerFormOnly) { button.Label = _("Finish"); button.Clicked += delegate { @@ -676,12 +569,12 @@ namespace SparkleShare { button.Label = _("Next"); button.Clicked += delegate { - ShowStepThree (); + ShowCompletedPage (); }; } - controls.Add (button); + AddButton (button); SparkleSpinner spinner = new SparkleSpinner (22); @@ -700,36 +593,19 @@ namespace SparkleShare { layout_vertical.PackStart (box, false, false, 0); - wrapper.PackStart (layout_vertical, true, true, 0); - wrapper.PackStart (controls, false, true, 0); - - layout_horizontal.PackStart (side_splash, false, false, 0); - layout_horizontal.PackStart (wrapper, true, true, 0); - - Add (layout_horizontal); - - CheckStepTwoFields (); + Add (layout_vertical); ShowAll (); } - private void ShowStepThree () + private void ShowCompletedPage () { - Remove (Child); + Reset (); - HBox layout_horizontal = new HBox (false, 6); - - Image side_splash = new Image (SparkleHelpers.CombineMore (Defines.PREFIX, "share", "pixmaps", - "side-splash.png")); - - VBox wrapper = new VBox (false, 0); - - VBox layout_vertical = new VBox (false, 0) { - BorderWidth = 30 - }; + VBox layout_vertical = new VBox (false, 0); Label header = new Label ("" + _("SparkleShare is ready to go!") + @@ -757,11 +633,6 @@ namespace SparkleShare { layout_vertical.PackStart (information, false, false, 21); layout_vertical.PackStart (link_wrapper, false, false, 0); - HButtonBox controls = new HButtonBox () { - Layout = ButtonBoxStyle.End, - BorderWidth = 12 - }; - Button finish_button = new Button (_("Finish")); finish_button.Clicked += delegate (object o, EventArgs args) { @@ -773,15 +644,9 @@ namespace SparkleShare { }; - controls.Add (finish_button); + AddButton (finish_button); - wrapper.PackStart (layout_vertical, true, true, 0); - wrapper.PackStart (controls, false, false, 0); - - layout_horizontal.PackStart (side_splash, false, false, 0); - layout_horizontal.PackStart (wrapper, true, true, 0); - - Add (layout_horizontal); + Add (layout_vertical); ShowAll (); @@ -790,7 +655,7 @@ namespace SparkleShare { // Enables or disables the 'Next' button depending on the // entries filled in by the user - private void CheckStepOneFields () + private void CheckAccountForm () { if (NameEntry.Text.Length > 0 && @@ -809,30 +674,30 @@ namespace SparkleShare { // Enables the Add button when the fields are // filled in correctly - public void CheckStepTwoFields (object o, EventArgs args) + public void CheckServerForm (object o, EventArgs args) { - CheckStepTwoFields (); + CheckServerForm (); } // Enables the Add button when the fields are // filled in correctly - public void CheckStepTwoFields () + public void CheckServerForm () { - AddButton.Sensitive = false; + SyncButton.Sensitive = false; bool IsFolder = !FolderEntry.Text.Trim ().Equals (""); if (ServerEntry.Sensitive == true) { if (IsGitUrl (ServerEntry.Text) && IsFolder) - AddButton.Sensitive = true; + SyncButton.Sensitive = true; } else if (IsFolder) { - AddButton.Sensitive = true; + SyncButton.Sensitive = true; } diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index 657d40b2..aff3ed5a 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -243,7 +243,7 @@ namespace SparkleShare { add_item.Activated += delegate { SparkleIntro intro = new SparkleIntro (); - intro.ShowStepTwo (true); + intro.ShowServerForm (true); intro.ShowAll (); }; diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 9bcc6fe6..7d10a66a 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -49,7 +49,7 @@ namespace SparkleShare { BusG.Init (); Gtk.Application.Init (); - SparkleInvitation i = new SparkleInvitation ("/home/hbons/SparkleShare/sparkleshare.invitation"); +// SparkleInvitation i = new SparkleInvitation ("/home/hbons/SparkleShare/sparkleshare.invitation"); SetProcessName ("sparkleshare"); diff --git a/SparkleShare/SparkleWindow.cs b/SparkleShare/SparkleWindow.cs index 404cdcd1..2aefd828 100644 --- a/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -28,232 +28,89 @@ namespace SparkleShare { public class SparkleWindow : Window { - // Short alias for the translations - public static string _ (string s) - { - return Catalog.GetString (s); - } + private HBox HBox; + private VBox VBox; + private VBox Wrapper; + private HButtonBox Buttons; - private SparkleRepo SparkleRepo; - private VBox LayoutVertical; - private ScrolledWindow ScrolledWindow; - public SparkleWindow (SparkleRepo sparkle_repo) : base ("") + public SparkleWindow () : base ("") { - SparkleRepo = sparkle_repo; - SetSizeRequest (540, 640); - SetPosition (WindowPosition.Center); - BorderWidth = 12; - - // TRANSLATORS: {0} is a folder name, and {1} is a server address - Title = String.Format(_("Recent Events in ‘{0}’"), SparkleRepo.Name); - IconName = "folder"; + BorderWidth = 0; + IconName = "folder-sparkleshare"; + Resizable = true; + WindowPosition = WindowPosition.Center; - LayoutVertical = new VBox (false, 12); + SetDefaultSize (640, 480); - LayoutVertical.PackStart (CreateEventLog (), true, true, 0); + Buttons = CreateButtonBox (); - HButtonBox dialog_buttons = new HButtonBox { - Layout = ButtonBoxStyle.Edge, - BorderWidth = 0 - }; + HBox = new HBox (false, 6); - Button open_folder_button = new Button (_("Open Folder")); - open_folder_button.Clicked += delegate (object o, EventArgs args) { - Process process = new Process (); - process.StartInfo.FileName = "xdg-open"; - string path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - SparkleRepo.Name); - process.StartInfo.Arguments = path.Replace(" ", "\\ "); - process.Start (); - Destroy (); + string image_path = SparkleHelpers.CombineMore (Defines.PREFIX, "share", "pixmaps", "side-splash.png"); + Image side_splash = new Image (image_path); + + VBox = new VBox (false, 0); + + Wrapper = new VBox (false, 0) { + BorderWidth = 30 }; - Button close_button = new Button (Stock.Close); - close_button.Clicked += delegate (object o, EventArgs args) { - Destroy (); - }; + VBox.PackStart (Wrapper, true, true, 0); + VBox.PackStart (Buttons, false, false, 0); - dialog_buttons.Add (open_folder_button); - dialog_buttons.Add (close_button); + HBox.PackStart (side_splash, false, false, 0); + HBox.PackStart (VBox, true, true, 0); - LayoutVertical.PackStart (dialog_buttons, false, false, 0); - - Add (LayoutVertical); + base.Add (HBox); } - public void UpdateEventLog () + private HButtonBox CreateButtonBox () { - LayoutVertical.Remove (ScrolledWindow); - ScrolledWindow = CreateEventLog (); - LayoutVertical.PackStart (ScrolledWindow, true, true, 0); - LayoutVertical.ReorderChild (ScrolledWindow, 0); + return new HButtonBox () { + BorderWidth = 12, + Layout = ButtonBoxStyle.End, + Spacing = 6 + }; + + } + + + public void AddButton (Button button) + { + + Buttons.Add (button); ShowAll (); } - private ScrolledWindow CreateEventLog () + new public void Add (Widget widget) { - int number_of_events = 50; - - Process process = new Process (); - process.EnableRaisingEvents = true; - process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.UseShellExecute = false; - process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath; - process.StartInfo.FileName = "git"; - process.StartInfo.Arguments = "log --format=\"%at☃%an☃%ae☃%s\" -" + number_of_events; - - process.Start (); - - string output = process.StandardOutput.ReadToEnd ().Trim (); - - output = output.TrimStart ("\n".ToCharArray ()); - string [] lines = Regex.Split (output, "\n"); - int linesLength = lines.Length; - if (output == "") - linesLength = 0; - - // Sort by time and get the last 25 - Array.Sort (lines); - Array.Reverse (lines); - - List activity_days = new List (); - - for (int i = 0; i < number_of_events && i < linesLength; i++) { - - string line = lines [i]; - - // Look for the snowman! - string [] parts = Regex.Split (line, "☃"); - - int unix_timestamp = int.Parse (parts [0]); - string user_name = parts [1]; - string user_email = parts [2]; - string message = parts [3]; - - DateTime date_time = UnixTimestampToDateTime (unix_timestamp); - - message = message.Replace ("/", " ‣ "); - message = message.Replace ("\n", " "); - - ChangeSet change_set = new ChangeSet (user_name, user_email, message, date_time); - - bool change_set_inserted = false; - foreach (ActivityDay stored_activity_day in activity_days) { - - if (stored_activity_day.DateTime.Year == change_set.DateTime.Year && - stored_activity_day.DateTime.Month == change_set.DateTime.Month && - stored_activity_day.DateTime.Day == change_set.DateTime.Day) { - - stored_activity_day.Add (change_set); - change_set_inserted = true; - break; - - } - - } - - if (!change_set_inserted) { - - ActivityDay activity_day = new ActivityDay (change_set.DateTime); - activity_day.Add (change_set); - activity_days.Add (activity_day); - - } - - } - - - VBox layout_vertical = new VBox (false, 0); - - foreach (ActivityDay activity_day in activity_days) { - - TreeIter iter = new TreeIter (); - ListStore list_store = new ListStore (typeof (Gdk.Pixbuf), - typeof (string), - typeof (string)); - - foreach (ChangeSet change_set in activity_day) { - - iter = list_store.Append (); - list_store.SetValue (iter, 0, SparkleHelpers.GetAvatar (change_set.UserEmail , 32)); - list_store.SetValue (iter, 1, "" + change_set.UserName + "\n" + - "" + change_set.Message + ""); - list_store.SetValue (iter, 2, change_set.UserEmail); - - } - - Label date_label = new Label ("") { - UseMarkup = true, - Xalign = 0, - Xpad = 9, - Ypad = 9 - }; - - DateTime today = DateTime.Now; - DateTime yesterday = DateTime.Now.AddDays (-1); - - if (today.Day == activity_day.DateTime.Day && - today.Month == activity_day.DateTime.Month && - today.Year == activity_day.DateTime.Year) { - - date_label.Markup = "Today"; - - } else if (yesterday.Day == activity_day.DateTime.Day && - yesterday.Month == activity_day.DateTime.Month && - yesterday.Year == activity_day.DateTime.Year) { - - date_label.Markup = "Yesterday"; - - } else { - - date_label.Markup = "" + activity_day.DateTime.ToString ("ddd MMM d, yyyy") + ""; - - } - - layout_vertical.PackStart (date_label, false, false, 0); - - IconView icon_view = new IconView (list_store) { - ItemWidth = 470, - MarkupColumn = 1, - Orientation = Orientation.Horizontal, - PixbufColumn = 0, - Spacing = 9 - }; - - icon_view.SelectionChanged += delegate { - icon_view.UnselectAll (); - }; - - layout_vertical.PackStart (icon_view, false, false, 0); - - } - - ScrolledWindow = new ScrolledWindow (); - ScrolledWindow.ShadowType = ShadowType.None; - ScrolledWindow.AddWithViewport (layout_vertical); - - return ScrolledWindow; + Wrapper.PackStart (widget, true, true, 0); + ShowAll (); } - // Converts a UNIX timestamp to a more usable time object - public DateTime UnixTimestampToDateTime (int timestamp) + public void Reset () { - DateTime unix_epoch = new DateTime (1970, 1, 1, 0, 0, 0, 0); - return unix_epoch.AddSeconds (timestamp); - } + if (Wrapper.Children.Length > 0) + Wrapper.Remove (Wrapper.Children [0]); + + foreach (Button button in Buttons) + Buttons.Remove (button); + + ShowAll (); + + } } - } From f25c0c1e8ed9d4f1e4defc015fcd2c6246932062 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 14 Aug 2010 15:59:11 +0100 Subject: [PATCH 24/24] [log] Add timestamps --- SparkleShare/SparkleLog.cs | 53 +++++++++++++++++++++++-------- SparkleShare/SparkleStatusIcon.cs | 1 - 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/SparkleShare/SparkleLog.cs b/SparkleShare/SparkleLog.cs index f75e893e..903f489b 100644 --- a/SparkleShare/SparkleLog.cs +++ b/SparkleShare/SparkleLog.cs @@ -20,23 +20,23 @@ using SparkleLib; using System; using System.Collections.Generic; using System.Diagnostics; -using System.IO; using System.Text.RegularExpressions; -using System.Timers; namespace SparkleShare { public class SparkleLog : Window { + private SparkleRepo SparkleRepo; + private VBox LayoutVertical; + private ScrolledWindow ScrolledWindow; + + // Short alias for the translations public static string _ (string s) { return Catalog.GetString (s); } - private SparkleRepo SparkleRepo; - private VBox LayoutVertical; - private ScrolledWindow ScrolledWindow; public SparkleLog (SparkleRepo sparkle_repo) : base ("") { @@ -60,17 +60,22 @@ namespace SparkleShare { }; Button open_folder_button = new Button (_("Open Folder")); + open_folder_button.Clicked += delegate (object o, EventArgs args) { + + string path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, SparkleRepo.Name); + Process process = new Process (); - process.StartInfo.FileName = "xdg-open"; - string path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - SparkleRepo.Name); - process.StartInfo.Arguments = path.Replace(" ", "\\ "); + process.StartInfo.FileName = "xdg-open"; + process.StartInfo.Arguments = path.Replace(" ", "\\ "); // Escape space-characters process.Start (); + Destroy (); + }; Button close_button = new Button (Stock.Close); + close_button.Clicked += delegate (object o, EventArgs args) { Destroy (); }; @@ -102,8 +107,10 @@ namespace SparkleShare { int number_of_events = 50; - Process process = new Process (); - process.EnableRaisingEvents = true; + Process process = new Process () { + EnableRaisingEvents = true + }; + process.StartInfo.RedirectStandardOutput = true; process.StartInfo.UseShellExecute = false; process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath; @@ -140,7 +147,6 @@ namespace SparkleShare { DateTime date_time = UnixTimestampToDateTime (unix_timestamp); - message = message.Replace ("/", " ‣ "); message = message.Replace ("\n", " "); ChangeSet change_set = new ChangeSet (user_name, user_email, message, date_time); @@ -180,12 +186,21 @@ namespace SparkleShare { typeof (string), typeof (string)); + Gdk.Color color = Style.Foreground (StateType.Insensitive); + string secondary_text_color = GdkColorToHex (color); + foreach (ChangeSet change_set in activity_day) { iter = list_store.Append (); + list_store.SetValue (iter, 0, SparkleHelpers.GetAvatar (change_set.UserEmail , 32)); + list_store.SetValue (iter, 1, "" + change_set.UserName + "\n" + - "" + change_set.Message + ""); + "" + + change_set.Message + "\n" + + "" + change_set.DateTime.ToString ("HH:mm") + "" + + ""); + list_store.SetValue (iter, 2, change_set.UserEmail); } @@ -253,6 +268,18 @@ namespace SparkleShare { } + // Converts a Gdk RGB color to a hex value. + // Example: from "rgb:0,0,0" to "#000000" + public string GdkColorToHex (Gdk.Color color) + { + + return String.Format ("#{0:X2}{1:X2}{2:X2}", + (int) Math.Truncate (color.Red / 256.00), + (int) Math.Truncate (color.Green / 256.00), + (int) Math.Truncate (color.Blue / 256.00)); + + } + } diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index aff3ed5a..032a97ee 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -244,7 +244,6 @@ namespace SparkleShare { SparkleIntro intro = new SparkleIntro (); intro.ShowServerForm (true); - intro.ShowAll (); };