diff --git a/SparkleShare/Mac/SparkleBubble.cs b/SparkleShare/Mac/SparkleBubble.cs deleted file mode 100644 index 05523f1f..00000000 --- a/SparkleShare/Mac/SparkleBubble.cs +++ /dev/null @@ -1,58 +0,0 @@ -// SparkleShare, a collaboration and sharing tool. -// 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 MonoMac.AppKit; -using MonoMac.Foundation; -using MonoMac.Growl; - -namespace SparkleShare { - - public class SparkleBubble : NSObject { - - public string ImagePath; - - private string title; - private string subtext; - - - public SparkleBubble (string title, string subtext) - { - this.title = title; - this.subtext = subtext; - } - - - public void Show () - { - InvokeOnMainThread (delegate { - if (ImagePath != null && File.Exists (ImagePath)) { - NSData image_data = NSData.FromFile (ImagePath); - - GrowlApplicationBridge.Notify (this.title, this.subtext, - "Start", image_data, 0, false, null); - - } else { - GrowlApplicationBridge.Notify (this.title, this.subtext, - "Start", null, 0, false, null); - } - }); - } - } -} diff --git a/SparkleShare/Mac/SparkleBubbleController.cs b/SparkleShare/Mac/SparkleBubbleController.cs new file mode 100644 index 00000000..811b8154 --- /dev/null +++ b/SparkleShare/Mac/SparkleBubbleController.cs @@ -0,0 +1,44 @@ +// SparkleShare, a collaboration and sharing tool. +// 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; + +namespace SparkleShare { + + public class SparkleBubblesController { + + public event ShowBubbleEventHandler ShowBubbleEvent; + public delegate void ShowBubbleEventHandler (string title, string subtext, string image_path); + + + public SparkleBubblesController () + { + SparkleShare.Controller.ConflictNotificationRaised += delegate { + if (ShowBubbleEvent != null) + ShowBubbleEvent ("Ouch! Mid-air collision!", + "Don't worry, SparkleShare made a copy of each conflicting file.", null); + }; + + SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email, + string message, string folder_path) { + if (ShowBubbleEvent != null) + ShowBubbleEvent (user_name, message, + SparkleShare.Controller.GetAvatar (user_email, 36)); + }; + } + } +} diff --git a/SparkleShare/Mac/SparkleBubbles.cs b/SparkleShare/Mac/SparkleBubbles.cs new file mode 100644 index 00000000..7581b537 --- /dev/null +++ b/SparkleShare/Mac/SparkleBubbles.cs @@ -0,0 +1,56 @@ +// SparkleShare, a collaboration and sharing tool. +// 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 MonoMac.AppKit; +using MonoMac.Foundation; +using MonoMac.Growl; + +namespace SparkleShare { + + public class SparkleBubbles : NSObject { + + private SparkleBubblesController controller = new SparkleBubblesController (); + + + public SparkleBubbles () + { + this.controller.ShowBubbleEvent += delegate(string title, string subtext, string image_path) { + InvokeOnMainThread (delegate { + if (!GrowlApplicationBridge.IsGrowlRunning ()) { + NSApplication.SharedApplication.RequestUserAttention ( + NSRequestUserAttentionType.InformationalRequest); + + return; + } + + if (image_path != null && File.Exists (image_path)) { + NSData image_data = NSData.FromFile (image_path); + GrowlApplicationBridge.Notify (title, subtext, + "Start", image_data, 0, false, null); + + } else { + GrowlApplicationBridge.Notify (title, subtext, + "Start", null, 0, false, null); + } + }); + }; + } + } +} diff --git a/SparkleShare/Mac/SparkleEventLog.cs b/SparkleShare/Mac/SparkleEventLog.cs index 6a2dc440..88df1f37 100644 --- a/SparkleShare/Mac/SparkleEventLog.cs +++ b/SparkleShare/Mac/SparkleEventLog.cs @@ -47,6 +47,7 @@ namespace SparkleShare { public SparkleEventLog (IntPtr handle) : base (handle) { } + // TODO: Window needs to be made resizable public SparkleEventLog () : base () { Title = "Recent Events"; @@ -67,8 +68,8 @@ namespace SparkleShare { ContentView.AddSubview (Separator); - this.progress_indicator = new NSthis.progress_indicator () { - Style = NSthis.progress_indicatorStyle.Spinning, + this.progress_indicator = new NSProgressIndicator () { + Style = NSProgressIndicatorStyle.Spinning, Frame = new RectangleF (this.web_view.Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10, 20, 20) }; @@ -167,10 +168,9 @@ namespace SparkleShare { if (this.progress_indicator.Superview == ContentView) this.progress_indicator.RemoveFromSuperview (); + // TODO: still causes some flashes this.web_view.MainFrame.LoadHtmlString (html, new NSUrl ("")); ContentView.AddSubview (this.web_view); - - Update (); }); })); diff --git a/SparkleShare/Mac/SparkleShare.csproj b/SparkleShare/Mac/SparkleShare.csproj index 4da38ecf..f8d67e36 100644 --- a/SparkleShare/Mac/SparkleShare.csproj +++ b/SparkleShare/Mac/SparkleShare.csproj @@ -87,11 +87,12 @@ - + + diff --git a/SparkleShare/Mac/SparkleUI.cs b/SparkleShare/Mac/SparkleUI.cs index efd46f7f..e96a246f 100644 --- a/SparkleShare/Mac/SparkleUI.cs +++ b/SparkleShare/Mac/SparkleUI.cs @@ -104,28 +104,12 @@ namespace SparkleShare { NSApplication.SharedApplication.DockTile.BadgeLabel = (int.Parse (NSApplication.SharedApplication.DockTile.BadgeLabel) + 1).ToString (); - if (GrowlApplicationBridge.IsGrowlRunning ()) { - SparkleBubble bubble = new SparkleBubble (user_name, message) { - ImagePath = SparkleShare.Controller.GetAvatar (user_email, 36) - }; - - bubble.Show (); - - } else { - NSApplication.SharedApplication.RequestUserAttention ( - NSRequestUserAttentionType.InformationalRequest); - } - } + } }); }; - SparkleShare.Controller.ConflictNotificationRaised += delegate { - string title = "Ouch! Mid-air collision!"; - string subtext = "Don't worry, SparkleShare made a copy of each conflicting file."; - new SparkleBubble (title, subtext).Show (); - };