From 2ef24a975596e84e6e8a38b78b0ef29b09bf6c27 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Sat, 16 Apr 2016 09:59:43 +0100 Subject: [PATCH 1/6] Update the home screen --- .../Base.lproj/CPHomeWindowController.xib | 137 +++++++++--------- .../CPCLIToolInstallationController.h | 6 + .../CPCLIToolInstallationController.m | 11 ++ app/CocoaPods/CPAppDelegate.m | 6 +- app/CocoaPods/CPHomeWindowController.m | 9 +- .../HomeButtonBG.imageset/Contents.json | 21 +++ .../HomeButtonBG.imageset/HomeButtonBG.png | Bin 0 -> 2819 bytes .../Supporting Files/Localizable.strings | 4 +- 8 files changed, 116 insertions(+), 78 deletions(-) create mode 100644 app/CocoaPods/Home Screen.xcassets/HomeButtonBG.imageset/Contents.json create mode 100644 app/CocoaPods/Home Screen.xcassets/HomeButtonBG.imageset/HomeButtonBG.png diff --git a/app/CocoaPods/Base.lproj/CPHomeWindowController.xib b/app/CocoaPods/Base.lproj/CPHomeWindowController.xib index c8cfdfe8..f00f56c4 100644 --- a/app/CocoaPods/Base.lproj/CPHomeWindowController.xib +++ b/app/CocoaPods/Base.lproj/CPHomeWindowController.xib @@ -9,6 +9,7 @@ + @@ -21,15 +22,14 @@ - - - + + - + - + @@ -84,7 +84,7 @@ - + @@ -169,9 +169,26 @@ + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + - - - - - - - - - - + - - - - - + + + + + @@ -266,7 +258,7 @@ - + @@ -280,10 +272,10 @@ - + - + By installing the CocoaPods Command Line Tools you can run the pod command from your favourite terminal. @@ -294,7 +286,7 @@ This means you get access to the whole command-line API, not just what the Cocoa - + @@ -302,7 +294,7 @@ This means you get access to the whole command-line API, not just what the Cocoa - + Do you want to Install the @@ -312,7 +304,7 @@ Command-Line Tools? - - - + + + + @@ -295,7 +296,7 @@ This means you get access to the whole command-line API, not just what the Cocoa - + Do you want to Install the diff --git a/app/CocoaPods/CLI Integrations/CPCLIToolInstallationController.m b/app/CocoaPods/CLI Integrations/CPCLIToolInstallationController.m index 505eda10..ff80f727 100644 --- a/app/CocoaPods/CLI Integrations/CPCLIToolInstallationController.m +++ b/app/CocoaPods/CLI Integrations/CPCLIToolInstallationController.m @@ -45,7 +45,7 @@ - (BOOL)shouldInstallBinstubIfNecessary; return NO; } - return [self binstubAlreadyExists]; + return ![self binstubAlreadyExists]; } @@ -180,11 +180,16 @@ - (BOOL)promptIfOverwriting return YES; } + BOOL isRubyGemsVersion = [self currentBinStubComesFromRubygems]; + NSAlert *alert = [NSAlert new]; alert.alertStyle = NSCriticalAlertStyle; NSString *formatString = NSLocalizedString(@"INSTALL_CLI_WARNING_MESSAGE_TEXT", nil); alert.messageText = [NSString stringWithFormat:formatString, self.destinationURL.path]; - alert.informativeText = NSLocalizedString(@"INSTALL_CLI_WARNING_INFORMATIVE_TEXT", nil); + + NSString *information = isRubyGemsVersion ? @"INSTALL_CLI_FROM_GEM_INFORMATIVE_TEXT" : @"INSTALL_CLI_WARNING_INFORMATIVE_TEXT"; + alert.informativeText = NSLocalizedString(information, nil); + [alert addButtonWithTitle:NSLocalizedString(@"INSTALL_CLI_WARNING_OVERWRITE", nil)]; [alert addButtonWithTitle:NSLocalizedString(@"CANCEL", nil)]; @@ -199,6 +204,19 @@ - (NSURL *)binstubSourceURL; return [NSURL fileURLWithPathComponents:@[ bundlePath, @"Contents", @"Helpers", @"pod" ]]; } +- (BOOL)currentBinStubComesFromRubygems +{ + NSError *error = nil; + NSString *contents = [NSString stringWithContentsOfURL:self.destinationURL encoding:NSUTF16StringEncoding error:&error]; + if (error) { + NSLog(@"Error looking at BinStub: %@", error); + return NO; + } + + NSString *message = @"generated by RubyGems."; + return [contents containsString:message]; +} + - (BOOL)binstubAlreadyExists; { return access([self.destinationURL.path UTF8String], F_OK) == 0; @@ -256,7 +274,11 @@ - (BOOL)installBinstubToAccessibleDestination; NSError *error = nil; NSURL *sourceURL = self.binstubSourceURL; NSFileManager *fileManager = [NSFileManager defaultManager]; - [fileManager removeItemAtURL:self.destinationURL error:&error]; + + if ([fileManager fileExistsAtPath:self.destinationURL.path]) { + [fileManager removeItemAtURL:self.destinationURL error:&error]; + } + BOOL succeeded = [fileManager copyItemAtURL:sourceURL toURL:self.destinationURL error:&error]; if (error) { NSLog(@"Failed to copy source `%@` (%@)", sourceURL.path, error); diff --git a/app/CocoaPods/Supporting Files/Localizable.strings b/app/CocoaPods/Supporting Files/Localizable.strings index ff913318..14a0a8da 100644 --- a/app/CocoaPods/Supporting Files/Localizable.strings +++ b/app/CocoaPods/Supporting Files/Localizable.strings @@ -1,13 +1,12 @@ -"INSTALL_CLI_MESSAGE_TEXT" = "Do you wish to install the CocoaPods Command-Line Tool?"; -"UPDATE_CLI_MESSAGE_TEXT" = "Do you wish to update the CocoaPods Command-Line Tool?"; - -"INSTALL_CLI_INFORMATIVE_TEXT" = "If you wish to use CocoaPods from the Terminal, a “%@” tool can be installed which will allow you easy access to the CocoaPods installation contained inside this application.\n\nThis is not needed for the application to function normally and can always be installed at a later time by using the menu item found under the application menu."; +"INSTALL_CLI_MESSAGE_TEXT" = "Do you want to install the CocoaPods Command-Line Tool?"; +"UPDATE_CLI_MESSAGE_TEXT" = "Do you want to update the CocoaPods Command-Line Tool?"; "INSTALL_CLI_ALTERNATE_DESTINATION" = "Install to Alternate Destination…"; "INSTALL_CLI" = "Install to “%@”"; -"INSTALL_CLI_WARNING_MESSAGE_TEXT" = "You already have a “%@” tool installed. Are you sure you want to overwrite it?"; -"INSTALL_CLI_WARNING_INFORMATIVE_TEXT" = "The tool was likely installed from the Terminal by running the “gem install cocoapods” command. If you wish to keep that installation intact, be sure to choose an alternate filename or directory (preferably in your Terminal PATH) for this tool.\n\nNote that you can always revert by running the aforementioned Terminal command again."; +"INSTALL_CLI_WARNING_MESSAGE_TEXT" = "You already have `pod` at “%@”. Are you sure you want to overwrite it?"; +"INSTALL_CLI_FROM_GEM_INFORMATIVE_TEXT" = "Your `pod` command was installed via `gem install cocoapods`.\n\nClicking install will replace that version with the `pod` command hosted inside this app.\n\nNote that you can always revert back by running the Terminal commands again."; +"INSTALL_CLI_WARNING_INFORMATIVE_TEXT" = "The tool was likely installed from the Terminal by running the “gem install cocoapods” command. \n\nIf you wish to keep that installation intact, be sure to choose an alternate filename or directory (preferably in your Terminal PATH) for this tool.\n\nNote that you can always revert by running the aforementioned Terminal command again."; "INSTALL_CLI_WARNING_OVERWRITE" = "Overwrite"; "WORKSPACE_GENERATED_NOTIFICATION_TITLE" = "Pod Workspace Ready"; @@ -30,7 +29,7 @@ "PODFILE_WINDOW_NEWER_LOCKFILE_ERROR_BUTTON_TITTLE" = "Check For Updates"; "MAIN_WINDOW_TITLE" = "Welcome to CocoaPods"; -"MAIN_WINDOW_OPEN_GUIDES_BUTTON_TITLE" = "Get started..."; +"MAIN_WINDOW_OPEN_GUIDES_BUTTON_TITLE" = "Get started with CocoaPods"; "MAIN_WINDOW_OPEN_SEARCH_BUTTON_TITLE" = "Search for Pods"; "MAIN_WINDOW_CHANGELOG_BUTTON_TITLE" = "What's New?"; "MAIN_WINDOW_OPEN_DOCUMENT_BUTTON_TITLE" = "Open an existing Podfile"; \ No newline at end of file From 9e11660819f0fd8c8b6cdb0c6bb1ad260ad382bc Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Sat, 16 Apr 2016 13:00:53 +0100 Subject: [PATCH 5/6] Make it possible to disable Sparkle updates - fixes #170 --- app/CocoaPods.xcodeproj/project.pbxproj | 4 +++ app/CocoaPods/Base.lproj/MainMenu.xib | 34 +++++++++++++++++++--- app/CocoaPods/CPSparkleDelegate.swift | 38 +++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 app/CocoaPods/CPSparkleDelegate.swift diff --git a/app/CocoaPods.xcodeproj/project.pbxproj b/app/CocoaPods.xcodeproj/project.pbxproj index 45252b8b..f15fa59a 100644 --- a/app/CocoaPods.xcodeproj/project.pbxproj +++ b/app/CocoaPods.xcodeproj/project.pbxproj @@ -73,6 +73,7 @@ 60814A881C2BCFEA00D6663E /* CPWhiteCheckedButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 60814A871C2BCFEA00D6663E /* CPWhiteCheckedButton.m */; }; 60814A8A1C2C420600D6663E /* CPInterfaceBuilderOnlyLabels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60814A891C2C420600D6663E /* CPInterfaceBuilderOnlyLabels.swift */; }; 60C2CBF21CC238CF009B30CA /* CPHomeMenuTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 60C2CBF11CC238CF009B30CA /* CPHomeMenuTableCellView.m */; }; + 60C2CBF41CC25D5A009B30CA /* CPSparkleDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C2CBF31CC25D5A009B30CA /* CPSparkleDelegate.swift */; }; 60E693A71C49B0870058DF5F /* NSArray+Helpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 601ACAA51C392BDD0058FA86 /* NSArray+Helpers.m */; }; 60E693A91C49B5980058DF5F /* CPSpotlightDocumentSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60E693A81C49B5980058DF5F /* CPSpotlightDocumentSource.swift */; }; 60E693AC1C49BFDF0058DF5F /* CPHomeWindowDocumentEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = 60E693AB1C49BFDF0058DF5F /* CPHomeWindowDocumentEntry.m */; }; @@ -258,6 +259,7 @@ 60814A891C2C420600D6663E /* CPInterfaceBuilderOnlyLabels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CPInterfaceBuilderOnlyLabels.swift; sourceTree = ""; }; 60C2CBF01CC238CF009B30CA /* CPHomeMenuTableCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPHomeMenuTableCellView.h; sourceTree = ""; }; 60C2CBF11CC238CF009B30CA /* CPHomeMenuTableCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CPHomeMenuTableCellView.m; sourceTree = ""; }; + 60C2CBF31CC25D5A009B30CA /* CPSparkleDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CPSparkleDelegate.swift; sourceTree = ""; }; 60E693A81C49B5980058DF5F /* CPSpotlightDocumentSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CPSpotlightDocumentSource.swift; sourceTree = ""; }; 60E693AA1C49BFDF0058DF5F /* CPHomeWindowDocumentEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPHomeWindowDocumentEntry.h; sourceTree = ""; }; 60E693AB1C49BFDF0058DF5F /* CPHomeWindowDocumentEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CPHomeWindowDocumentEntry.m; sourceTree = ""; }; @@ -598,6 +600,7 @@ 60E693B41C4A71E50058DF5F /* CPSidebarDocumentsController.swift */, 934FF1881C4F1E2A000B4302 /* CPDocumentController.swift */, 657841C81C6BE0EC00B6671E /* CPPodfileInitController.swift */, + 60C2CBF31CC25D5A009B30CA /* CPSparkleDelegate.swift */, ); name = "Home Window"; sourceTree = ""; @@ -1013,6 +1016,7 @@ 605119231C08F02D0037B95E /* CPBrownVisualEffectsView.swift in Sources */, 60FE01701B9B7F1E0027EEE3 /* SUUpdater+DebugMode.m in Sources */, 60E693BB1C4A8F1D0058DF5F /* ColouredViews.swift in Sources */, + 60C2CBF41CC25D5A009B30CA /* CPSparkleDelegate.swift in Sources */, 60814A881C2BCFEA00D6663E /* CPWhiteCheckedButton.m in Sources */, 331188571BEBCB0F00272793 /* CPCLIToolInstallationController.m in Sources */, 60E693B51C4A71E50058DF5F /* CPSidebarDocumentsController.swift in Sources */, diff --git a/app/CocoaPods/Base.lproj/MainMenu.xib b/app/CocoaPods/Base.lproj/MainMenu.xib index b662a5b8..d2b15ee7 100644 --- a/app/CocoaPods/Base.lproj/MainMenu.xib +++ b/app/CocoaPods/Base.lproj/MainMenu.xib @@ -1,7 +1,7 @@ - + - + @@ -11,13 +11,22 @@ - + - + + + + + + + + + + @@ -48,6 +57,22 @@ + + + + + + + NSNegateBoolean + + + + + + + + + @@ -507,5 +532,6 @@ + diff --git a/app/CocoaPods/CPSparkleDelegate.swift b/app/CocoaPods/CPSparkleDelegate.swift new file mode 100644 index 00000000..84409c2e --- /dev/null +++ b/app/CocoaPods/CPSparkleDelegate.swift @@ -0,0 +1,38 @@ +import Cocoa +import Sparkle + +class CPSparkleDelegate: NSObject, SUUpdaterDelegate { + @IBOutlet var toggleSparkleMenuItem: NSMenuItem! + + let disableKey = "CPDisableSparkleUpdates" + + override func awakeFromNib() { + super.awakeFromNib() + updateMenuItem() + } + + @IBAction func toggleSparkleUpdates(button: AnyObject) { + let defaults = NSUserDefaults.standardUserDefaults() + let disabled = defaults.boolForKey(disableKey) + defaults.setBool(!disabled, forKey: disableKey) + defaults.synchronize() + + updateMenuItem() + } + + func updateMenuItem() { + let defaults = NSUserDefaults.standardUserDefaults() + if defaults.boolForKey(disableKey) { + toggleSparkleMenuItem.title = "Re-enable Sparkle Updates" + } else { + toggleSparkleMenuItem.title = "Disable Sparkle Updates" + } + } + + func updaterMayCheckForUpdates(updater: SUUpdater!) -> Bool { + let defaults = NSUserDefaults.standardUserDefaults() + let disabled = defaults.boolForKey(disableKey) + return !disabled + } + +} From ec606a23cfa80431b69e681c4ffca77a3952fcf2 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Sat, 16 Apr 2016 13:21:17 +0100 Subject: [PATCH 6/6] Use menu enabled instead of visbility to stop confusing hiding of root menu items fixes - #261 --- app/CocoaPods/Base.lproj/CPHomeWindowController.xib | 6 +++--- app/CocoaPods/CPMenuVisiblityDirector.swift | 2 +- app/CocoaPods/Podfile.storyboard | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/CocoaPods/Base.lproj/CPHomeWindowController.xib b/app/CocoaPods/Base.lproj/CPHomeWindowController.xib index ee8cc871..96cf2644 100644 --- a/app/CocoaPods/Base.lproj/CPHomeWindowController.xib +++ b/app/CocoaPods/Base.lproj/CPHomeWindowController.xib @@ -23,7 +23,7 @@ - + @@ -201,7 +201,7 @@ - + @@ -425,7 +425,7 @@ Command-Line Tools? - + diff --git a/app/CocoaPods/CPMenuVisiblityDirector.swift b/app/CocoaPods/CPMenuVisiblityDirector.swift index a8315b69..c05a001e 100644 --- a/app/CocoaPods/CPMenuVisiblityDirector.swift +++ b/app/CocoaPods/CPMenuVisiblityDirector.swift @@ -28,7 +28,7 @@ class CPMenuVisiblityDirector: NSObject { let windowHasDocument = docs.documentForWindow(window) != nil for menu in podfileEditorMenuItems { - menu.hidden = !windowHasDocument + menu.enabled = !windowHasDocument } } } diff --git a/app/CocoaPods/Podfile.storyboard b/app/CocoaPods/Podfile.storyboard index 08c15bf6..f29ee331 100644 --- a/app/CocoaPods/Podfile.storyboard +++ b/app/CocoaPods/Podfile.storyboard @@ -373,7 +373,7 @@