From aa3523c1aac6b5f5f0dba17b2990ad2d1de5f274 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 1 Jun 2010 20:58:08 +0200 Subject: [PATCH] fix notifications in Add dialog and other places --- SparkleShare/SparkleBubble.cs | 4 -- SparkleShare/SparkleDialog.cs | 118 ++++++++++++++++++++-------------- SparkleShare/SparkleRepo.cs | 2 + SparkleShare/SparkleUI.cs | 2 + 4 files changed, 72 insertions(+), 54 deletions(-) diff --git a/SparkleShare/SparkleBubble.cs b/SparkleShare/SparkleBubble.cs index 0cd88304..b7189ad2 100644 --- a/SparkleShare/SparkleBubble.cs +++ b/SparkleShare/SparkleBubble.cs @@ -23,13 +23,9 @@ namespace SparkleShare { public class SparkleBubble : Notification { public SparkleBubble (string Title, string Subtext) : base (Title, Subtext) { - Timeout = 4500; Urgency = Urgency.Low; - Show (); IconName = "folder-sparkleshare"; - - // TODO: Doesn't work for some reason AttachToStatusIcon (SparkleUI.NotificationIcon); } diff --git a/SparkleShare/SparkleDialog.cs b/SparkleShare/SparkleDialog.cs index cea05c69..651ad64b 100644 --- a/SparkleShare/SparkleDialog.cs +++ b/SparkleShare/SparkleDialog.cs @@ -119,9 +119,18 @@ namespace SparkleShare { else RepoName = RepoRemoteUrl.Substring (ColumnPos + 1); - SparkleBubble SparkleBubble = + SparkleBubble SyncingBubble = new SparkleBubble (_("Syncing folder ‘") + RepoName + "’", - _("SparkleShare will notify you when this is done.")); + _("SparkleShare will notify you ") + + _("when this is done.")); + + SyncingBubble.AddAction ("", _("Dismiss"), + delegate { + SyncingBubble.Close (); + } + ); + + SyncingBubble.Show (); Process Process = new Process (); Process.EnableRaisingEvents = true; @@ -138,62 +147,71 @@ namespace SparkleShare { Process.Start (); string Output = Process.StandardOutput.ReadToEnd (); - if (Output.Contains ("fatal")) { - - SparkleBubble = - new SparkleBubble ("Something went wrong while syncing " + - " ‘" + RepoName + "’", - "Please double check the address and\n" + - "network connection."); - - SparkleBubble.AddAction ("", _("Try Again…"), - delegate { - Process.StartInfo.FileName = "xdg-open"; - Process.StartInfo.Arguments = - SparkleHelpers.CombineMore - (SparklePaths.SparklePath, RepoName); - Process.Start (); - } - ); - - SparkleDialog SparkleDialog = new SparkleDialog (RepoRemoteUrl); - SparkleDialog.ShowAll (); - - Destroy (); - - } + Console.WriteLine ("[Git][" + RepoName + "] Cloning repository..."); // Move the folder to the SparkleShare folder when done cloning Process.Exited += delegate { - Directory.Move ( - SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, - RepoName), - SparkleHelpers.CombineMore (SparklePaths.SparklePath, - RepoName) - ); + if (Output.Contains ("fatal:")) { - // Show a confirmation notification - SparkleBubble = - new SparkleBubble (_("Successfully synced the folder ") + - "‘" + RepoName + "’", - _("Now make great stuff happen!")); + SparkleBubble ErrorBubble = + new SparkleBubble ("Something went wrong while syncing " + + " ‘" + RepoName + "’", + "Please double check the address and\n" + + "network connection."); - SparkleBubble.AddAction ("", _("Open Folder"), - delegate { - Process.StartInfo.FileName = "xdg-open"; - Process.StartInfo.Arguments = - SparkleHelpers.CombineMore ( - SparklePaths.SparklePath, RepoName); - Process.Start (); - } - ); + ErrorBubble.AddAction ("", _("Try Again…"), + delegate { + Process.StartInfo.FileName = "xdg-open"; + Process.StartInfo.Arguments = + SparkleHelpers.CombineMore + (SparklePaths.SparklePath, RepoName); + Process.Start (); + } + ); - // Destroy the Add dialog - Destroy (); + ErrorBubble.Show (); - // Refresh the UI - SparkleShare.SparkleUI = new SparkleUI (true); + SparkleDialog SparkleDialog = new SparkleDialog (RepoRemoteUrl); + SparkleDialog.ShowAll (); + + Destroy (); + + } else { + + Directory.Move ( + SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, + RepoName), + SparkleHelpers.CombineMore (SparklePaths.SparklePath, + RepoName) + ); + + Console.WriteLine ("[Git][" + RepoName + "] Repository cloned"); + + // Show a confirmation notification + SparkleBubble FinishedBubble = + new SparkleBubble (_("Successfully synced folder ") + + "‘" + RepoName + "’", + _("Now make great stuff happen!")); + + FinishedBubble.AddAction ("", _("Open Folder"), + delegate { + Process.StartInfo.FileName = "xdg-open"; + Process.StartInfo.Arguments = + SparkleHelpers.CombineMore ( + SparklePaths.SparklePath, RepoName); + Process.Start (); + } + ); + FinishedBubble.Show (); + + // Destroy the Add dialog + Destroy (); + + // Refresh the UI + SparkleShare.SparkleUI = new SparkleUI (true); + + } }; diff --git a/SparkleShare/SparkleRepo.cs b/SparkleShare/SparkleRepo.cs index 03cb98eb..eff05f4c 100644 --- a/SparkleShare/SparkleRepo.cs +++ b/SparkleShare/SparkleRepo.cs @@ -469,6 +469,8 @@ namespace SparkleShare { Process.StartInfo.FileName = "git"; } ); + StuffChangedBubble.Show (); + } } diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 3d95de2f..d3b732da 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -131,6 +131,8 @@ namespace SparkleShare { Process.Start (); */ } ); + + NoFoldersBubble.Show (); }