From 5ef01566b0c099e52cab170d06291e4aa8c7b932 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 13 May 2011 01:22:03 +0100 Subject: [PATCH] mac statusicon: fix more whitespace --- SparkleShare/Mac/SparkleStatusIcon.cs | 552 +++++++++++++------------- 1 file changed, 276 insertions(+), 276 deletions(-) diff --git a/SparkleShare/Mac/SparkleStatusIcon.cs b/SparkleShare/Mac/SparkleStatusIcon.cs index b5f78752..8fc367b2 100644 --- a/SparkleShare/Mac/SparkleStatusIcon.cs +++ b/SparkleShare/Mac/SparkleStatusIcon.cs @@ -27,326 +27,326 @@ using MonoMac.ObjCRuntime; namespace SparkleShare { - // The statusicon that stays in the - // user's notification area - public class SparkleStatusIcon : NSObject { + // The statusicon that stays in the + // user's notification area + public class SparkleStatusIcon : NSObject { - private Timer Animation; - private int FrameNumber; - private string StateText; + private Timer Animation; + private int FrameNumber; + private string StateText; - private NSStatusItem StatusItem; - private NSMenu Menu; - private NSMenuItem StateMenuItem; - private NSMenuItem FolderMenuItem; - private NSMenuItem [] FolderMenuItems; - private NSMenuItem SyncMenuItem; - private NSMenuItem NotificationsMenuItem; - - private delegate void Task (); - private EventHandler [] Tasks; + private NSStatusItem StatusItem; + private NSMenu Menu; + private NSMenuItem StateMenuItem; + private NSMenuItem FolderMenuItem; + private NSMenuItem [] FolderMenuItems; + private NSMenuItem SyncMenuItem; + private NSMenuItem NotificationsMenuItem; + + private delegate void Task (); + private EventHandler [] Tasks; - - // Short alias for the translations - public static string _ (string s) - { - return Catalog.GetString (s); - } + + // Short alias for the translations + public static string _ (string s) + { + return Catalog.GetString (s); + } - - public SparkleStatusIcon () : base () - { - Animation = CreateAnimation (); + + public SparkleStatusIcon () : base () + { + Animation = CreateAnimation (); - StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (28); - StatusItem.HighlightMode = true; - - SetNormalState (); - CreateMenu (); - - Menu.Delegate = new SparkleStatusIconMenuDelegate (); + StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (28); + StatusItem.HighlightMode = true; + + SetNormalState (); + CreateMenu (); + + Menu.Delegate = new SparkleStatusIconMenuDelegate (); - SparkleShare.Controller.FolderSizeChanged += delegate { - InvokeOnMainThread (delegate { - if (!Animation.Enabled) - SetNormalState (); - - UpdateMenu (); - }); - }; - - SparkleShare.Controller.FolderListChanged += delegate { - InvokeOnMainThread (delegate { - SetNormalState (); - CreateMenu (); - }); - }; + SparkleShare.Controller.FolderSizeChanged += delegate { + InvokeOnMainThread (delegate { + if (!Animation.Enabled) + SetNormalState (); + + UpdateMenu (); + }); + }; + + SparkleShare.Controller.FolderListChanged += delegate { + InvokeOnMainThread (delegate { + SetNormalState (); + CreateMenu (); + }); + }; - SparkleShare.Controller.OnIdle += delegate { - InvokeOnMainThread (delegate { - SetNormalState (); - UpdateMenu (); - }); - }; + SparkleShare.Controller.OnIdle += delegate { + InvokeOnMainThread (delegate { + SetNormalState (); + UpdateMenu (); + }); + }; - SparkleShare.Controller.OnSyncing += delegate { - InvokeOnMainThread (delegate { - SetAnimationState (); - UpdateMenu (); - }); - }; + SparkleShare.Controller.OnSyncing += delegate { + InvokeOnMainThread (delegate { + SetAnimationState (); + UpdateMenu (); + }); + }; - SparkleShare.Controller.OnError += delegate { - InvokeOnMainThread (delegate { - SetNormalState (true); - UpdateMenu (); - }); - }; - } + SparkleShare.Controller.OnError += delegate { + InvokeOnMainThread (delegate { + SetNormalState (true); + UpdateMenu (); + }); + }; + } - // Creates the Animation that handles the syncing animation - private Timer CreateAnimation () - { - FrameNumber = 0; + // Creates the Animation that handles the syncing animation + private Timer CreateAnimation () + { + FrameNumber = 0; - Timer Animation = new Timer () { - Interval = 35 - }; + Timer Animation = new Timer () { + Interval = 35 + }; - Animation.Elapsed += delegate { - if (FrameNumber < 4) - FrameNumber++; - else - FrameNumber = 0; + Animation.Elapsed += delegate { + if (FrameNumber < 4) + FrameNumber++; + else + FrameNumber = 0; - InvokeOnMainThread (delegate { - string image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, - "Pixmaps", "idle" + FrameNumber + ".png"); - + InvokeOnMainThread (delegate { + string image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, + "Pixmaps", "idle" + FrameNumber + ".png"); + string alternate_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "idle" + FrameNumber + "-active.png"); StatusItem.Image = new NSImage (image_path); StatusItem.AlternateImage = new NSImage (alternate_image_path); StatusItem.Image.Size = new SizeF (16, 16); - StatusItem.AlternateImage.Size = new SizeF (16, 16); - }); - }; + StatusItem.AlternateImage.Size = new SizeF (16, 16); + }); + }; - return Animation; - } + return Animation; + } - // Creates the menu that is popped up when the - // user clicks the status icon - public void CreateMenu () - { - Menu = new NSMenu (); - - StateMenuItem = new NSMenuItem () { - Title = StateText - }; - - Menu.AddItem (StateMenuItem); - Menu.AddItem (NSMenuItem.SeparatorItem); + // Creates the menu that is popped up when the + // user clicks the status icon + public void CreateMenu () + { + Menu = new NSMenu (); + + StateMenuItem = new NSMenuItem () { + Title = StateText + }; + + Menu.AddItem (StateMenuItem); + Menu.AddItem (NSMenuItem.SeparatorItem); - FolderMenuItem = new NSMenuItem () { - Title = "SparkleShare" - }; + FolderMenuItem = new NSMenuItem () { + Title = "SparkleShare" + }; - FolderMenuItem.Activated += delegate { - SparkleShare.Controller.OpenSparkleShareFolder (); - }; + FolderMenuItem.Activated += delegate { + SparkleShare.Controller.OpenSparkleShareFolder (); + }; - string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath, - "sparkleshare-mac.icns"); - - FolderMenuItem.Image = new NSImage (folder_icon_path); - FolderMenuItem.Image.Size = new SizeF (16, 16); - - Menu.AddItem (FolderMenuItem); + string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath, + "sparkleshare-mac.icns"); + + FolderMenuItem.Image = new NSImage (folder_icon_path); + FolderMenuItem.Image.Size = new SizeF (16, 16); + + Menu.AddItem (FolderMenuItem); - if (SparkleShare.Controller.Folders.Count > 0) { - FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count]; - Tasks = new EventHandler [SparkleShare.Controller.Folders.Count]; - - int i = 0; - foreach (string path in SparkleShare.Controller.Folders) { + if (SparkleShare.Controller.Folders.Count > 0) { + FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count]; + Tasks = new EventHandler [SparkleShare.Controller.Folders.Count]; + + int i = 0; + foreach (string path in SparkleShare.Controller.Folders) { - /* TODO - if (repo.HasUnsyncedChanges) - folder_action.IconName = "dialog-error"; */ - - NSMenuItem item = new NSMenuItem (); - - item.Title = System.IO.Path.GetFileName (path); - item.Image = NSImage.ImageNamed ("NSFolder"); - item.Image.Size = new SizeF (16, 16); + /* TODO + if (repo.HasUnsyncedChanges) + folder_action.IconName = "dialog-error"; */ + + NSMenuItem item = new NSMenuItem (); + + item.Title = System.IO.Path.GetFileName (path); + item.Image = NSImage.ImageNamed ("NSFolder"); + item.Image.Size = new SizeF (16, 16); - Tasks [i] = OpenEventLogDelegate (path); - - FolderMenuItems [i] = item; - FolderMenuItems [i].Activated += Tasks [i]; - Menu.AddItem (FolderMenuItems [i]); - - i++; - }; - } else { - FolderMenuItems = new NSMenuItem [1]; + Tasks [i] = OpenEventLogDelegate (path); + + FolderMenuItems [i] = item; + FolderMenuItems [i].Activated += Tasks [i]; + Menu.AddItem (FolderMenuItems [i]); + + i++; + }; + } else { + FolderMenuItems = new NSMenuItem [1]; - FolderMenuItems [0] = new NSMenuItem () { - Title = "No Remote Folders Yet" - }; - - Menu.AddItem (FolderMenuItems [0]); - } - - Menu.AddItem (NSMenuItem.SeparatorItem); + FolderMenuItems [0] = new NSMenuItem () { + Title = "No Remote Folders Yet" + }; + + Menu.AddItem (FolderMenuItems [0]); + } + + Menu.AddItem (NSMenuItem.SeparatorItem); - SyncMenuItem = new NSMenuItem () { - Title = "Add Remote Folder…" - }; - - if (!SparkleShare.Controller.FirstRun) { - SyncMenuItem.Activated += delegate { - InvokeOnMainThread (delegate { - NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); - - if (SparkleUI.Intro == null) { - SparkleUI.Intro = new SparkleIntro (); - SparkleUI.Intro.ShowServerForm (true); - } - - if (!SparkleUI.Intro.IsVisible) - SparkleUI.Intro.ShowServerForm (true); - - SparkleUI.Intro.OrderFrontRegardless (); - SparkleUI.Intro.MakeKeyAndOrderFront (this); - }); - }; - } + SyncMenuItem = new NSMenuItem () { + Title = "Add Remote Folder…" + }; + + if (!SparkleShare.Controller.FirstRun) { + SyncMenuItem.Activated += delegate { + InvokeOnMainThread (delegate { + NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); + + if (SparkleUI.Intro == null) { + SparkleUI.Intro = new SparkleIntro (); + SparkleUI.Intro.ShowServerForm (true); + } + + if (!SparkleUI.Intro.IsVisible) + SparkleUI.Intro.ShowServerForm (true); + + SparkleUI.Intro.OrderFrontRegardless (); + SparkleUI.Intro.MakeKeyAndOrderFront (this); + }); + }; + } - Menu.AddItem (SyncMenuItem); - Menu.AddItem (NSMenuItem.SeparatorItem); + Menu.AddItem (SyncMenuItem); + Menu.AddItem (NSMenuItem.SeparatorItem); - NotificationsMenuItem = new NSMenuItem (); - - if (SparkleShare.Controller.NotificationsEnabled) - NotificationsMenuItem.Title = "Turn Notifications Off"; - else - NotificationsMenuItem.Title = "Turn Notifications On"; - - NotificationsMenuItem.Activated += delegate { - SparkleShare.Controller.ToggleNotifications (); - - InvokeOnMainThread (delegate { - if (SparkleShare.Controller.NotificationsEnabled) - NotificationsMenuItem.Title = "Turn Notifications Off"; - else - NotificationsMenuItem.Title = "Turn Notifications On"; - }); - }; + NotificationsMenuItem = new NSMenuItem (); + + if (SparkleShare.Controller.NotificationsEnabled) + NotificationsMenuItem.Title = "Turn Notifications Off"; + else + NotificationsMenuItem.Title = "Turn Notifications On"; + + NotificationsMenuItem.Activated += delegate { + SparkleShare.Controller.ToggleNotifications (); + + InvokeOnMainThread (delegate { + if (SparkleShare.Controller.NotificationsEnabled) + NotificationsMenuItem.Title = "Turn Notifications Off"; + else + NotificationsMenuItem.Title = "Turn Notifications On"; + }); + }; - Menu.AddItem (NotificationsMenuItem); - - StatusItem.Menu = Menu; - StatusItem.Menu.Update (); - } + Menu.AddItem (NotificationsMenuItem); + + StatusItem.Menu = Menu; + StatusItem.Menu.Update (); + } - - // A method reference that makes sure that opening the - // event log for each repository works correctly - private EventHandler OpenEventLogDelegate (string path) - { - return delegate { - InvokeOnMainThread (delegate { - NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); - - SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) { - return l.LocalPath.Equals (path); - }); - - // Check whether the log is already open, create a new one if - // that's not the case or present it to the user if it is - if (log == null) { - SparkleUI.OpenLogs.Add (new SparkleLog (path)); - SparkleUI.OpenLogs [SparkleUI.OpenLogs.Count - 1].MakeKeyAndOrderFront (this); - } else { - log.OrderFrontRegardless (); - log.MakeKeyAndOrderFront (this); - } - }); - }; - } + + // A method reference that makes sure that opening the + // event log for each repository works correctly + private EventHandler OpenEventLogDelegate (string path) + { + return delegate { + InvokeOnMainThread (delegate { + NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); + + SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) { + return l.LocalPath.Equals (path); + }); + + // Check whether the log is already open, create a new one if + // that's not the case or present it to the user if it is + if (log == null) { + SparkleUI.OpenLogs.Add (new SparkleLog (path)); + SparkleUI.OpenLogs [SparkleUI.OpenLogs.Count - 1].MakeKeyAndOrderFront (this); + } else { + log.OrderFrontRegardless (); + log.MakeKeyAndOrderFront (this); + } + }); + }; + } - public void UpdateMenu () - { - StateMenuItem.Title = StateText; - } + public void UpdateMenu () + { + StateMenuItem.Title = StateText; + } - // The state when there's nothing going on - private void SetNormalState () - { - SetNormalState (false); - } + // The state when there's nothing going on + private void SetNormalState () + { + SetNormalState (false); + } - // The state when there's nothing going on - private void SetNormalState (bool error) - { - Animation.Stop (); - - if (SparkleShare.Controller.Folders.Count == 0) { - StateText = _("Welcome to SparkleShare!"); - InvokeOnMainThread (delegate { - StatusItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0.png"); - StatusItem.Image.Size = new SizeF (16, 16); - - StatusItem.AlternateImage = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0-active.png"); - StatusItem.AlternateImage.Size = new SizeF (16, 16); - }); - } else { - if (error) { - StateText = _("Not everything is synced"); - InvokeOnMainThread (delegate { - // TODO: Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24); - }); - } else { - StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")"; - InvokeOnMainThread (delegate { - StatusItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0.png"); + // The state when there's nothing going on + private void SetNormalState (bool error) + { + Animation.Stop (); + + if (SparkleShare.Controller.Folders.Count == 0) { + StateText = _("Welcome to SparkleShare!"); + InvokeOnMainThread (delegate { + StatusItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0.png"); + StatusItem.Image.Size = new SizeF (16, 16); + + StatusItem.AlternateImage = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0-active.png"); + StatusItem.AlternateImage.Size = new SizeF (16, 16); + }); + } else { + if (error) { + StateText = _("Not everything is synced"); + InvokeOnMainThread (delegate { + // TODO: Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24); + }); + } else { + StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")"; + InvokeOnMainThread (delegate { + StatusItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0.png"); StatusItem.AlternateImage = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0-active.png"); StatusItem.Image.Size = new SizeF (16, 16); - StatusItem.AlternateImage.Size = new SizeF (16, 16); - }); - } - } - } + StatusItem.AlternateImage.Size = new SizeF (16, 16); + }); + } + } + } - // The state when animating - private void SetAnimationState () - { - StateText = _("Syncing…"); + // The state when animating + private void SetAnimationState () + { + StateText = _("Syncing…"); - if (!Animation.Enabled) - Animation.Start (); - } - } - - - public class SparkleStatusIconMenuDelegate : NSMenuDelegate { - - public override void MenuWillHighlightItem (NSMenu menu, NSMenuItem item) { } - - public override void MenuWillOpen (NSMenu menu) - { - InvokeOnMainThread (delegate { - NSApplication.SharedApplication.DockTile.BadgeLabel = null; - }); - } - } + if (!Animation.Enabled) + Animation.Start (); + } + } + + + public class SparkleStatusIconMenuDelegate : NSMenuDelegate { + + public override void MenuWillHighlightItem (NSMenu menu, NSMenuItem item) { } + + public override void MenuWillOpen (NSMenu menu) + { + InvokeOnMainThread (delegate { + NSApplication.SharedApplication.DockTile.BadgeLabel = null; + }); + } + } }