From fcbc83c98bda754879cfa0ab6260e8f96bd4f09c Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sat, 17 Oct 2015 23:31:36 -0700 Subject: [PATCH] bug fixes - Fixed the icon it was not turning white. - Fixed iTerm2 variable - About window on top changes - Setting the name of the menu command as the title, if title is null --- Shuttle.xcodeproj/project.pbxproj | 5 +++- Shuttle/AboutWindowController.xib | 13 ++++++--- Shuttle/AppDelegate.m | 46 ++++++++++++++++--------------- Shuttle/Shuttle-Info.plist | 6 ++-- Shuttle/shuttle.default.json | 6 ++-- 5 files changed, 43 insertions(+), 33 deletions(-) diff --git a/Shuttle.xcodeproj/project.pbxproj b/Shuttle.xcodeproj/project.pbxproj index 77d7556..8489867 100644 --- a/Shuttle.xcodeproj/project.pbxproj +++ b/Shuttle.xcodeproj/project.pbxproj @@ -204,7 +204,7 @@ C149EBF015D5214600B1F558 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = fitztrev; }; buildConfigurationList = C149EBF315D5214600B1F558 /* Build configuration list for PBXProject "Shuttle" */; @@ -303,6 +303,7 @@ CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -352,6 +353,7 @@ GCC_PREFIX_HEADER = "Shuttle/Shuttle-Prefix.pch"; INFOPLIST_FILE = "Shuttle/Shuttle-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "shuttle.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -367,6 +369,7 @@ GCC_PREFIX_HEADER = "Shuttle/Shuttle-Prefix.pch"; INFOPLIST_FILE = "Shuttle/Shuttle-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "shuttle.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; diff --git a/Shuttle/AboutWindowController.xib b/Shuttle/AboutWindowController.xib index 1348a07..19a5411 100644 --- a/Shuttle/AboutWindowController.xib +++ b/Shuttle/AboutWindowController.xib @@ -1,14 +1,13 @@ - + - + - @@ -20,7 +19,7 @@ - + @@ -29,10 +28,12 @@ + + @@ -41,6 +42,7 @@ + @@ -49,6 +51,7 @@ + @@ -57,6 +60,7 @@ + diff --git a/Shuttle/AppDelegate.m b/Shuttle/AppDelegate.m index 6b5f2cc..c1e2eb9 100644 --- a/Shuttle/AppDelegate.m +++ b/Shuttle/AppDelegate.m @@ -33,34 +33,32 @@ - (void) awakeFromNib { [[NSFileManager defaultManager] copyItemAtPath:cgFileInResource toPath:shuttleConfigFile error:nil]; } } - - // Load the menu content - // [self loadMenu]; - + // Define Icons + //only regular icon is needed for 10.10 and higher. OS X changes the icon for us. regularIcon = [NSImage imageNamed:@"StatusIcon"]; altIcon = [NSImage imageNamed:@"StatusIconAlt"]; + // Create the status bar item + statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; + [statusItem setMenu:menu]; + [statusItem setImage: regularIcon]; + // Check for AppKit Version, add support for darkmode if > 10.9 BOOL oldAppKitVersion = (floor(NSAppKitVersionNumber) <= 1265); + // 10.10 or higher, dont load the alt image let OS X style it. if (!oldAppKitVersion) { - // 10.10 or higher, add support to icon for auto detection of Regular/Dark mode - [regularIcon setTemplate:YES]; - [altIcon setTemplate:YES]; + regularIcon.template = YES; + } + // Load the alt image for OS X < 10.10 + else{ + [statusItem setHighlightMode:YES]; + [statusItem setAlternateImage: altIcon]; } - // Create the status bar item - statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:25.0]; - - [statusItem setMenu:menu]; - [statusItem setHighlightMode:YES]; - [statusItem setImage: regularIcon]; - [statusItem setAlternateImage: altIcon]; - launchAtLoginController = [[LaunchAtLoginController alloc] init]; - // Needed to trigger the menuWillOpen event [menu setDelegate:self]; } @@ -357,9 +355,11 @@ - (void) buildMenu:(NSArray*)data addToMenu:(NSMenu *)m { NSString *termTitle = cfg[@"title"]; //Get the value of setting inTerminal NSString *termWindow = cfg[@"inTerminal"]; + //Get the menu name will will use this as the title if title is null. + NSString *menuName = cfg[@"name"]; //Place the terminal command, theme, and title into an comma delimited string - NSString *menuRepObj = [NSString stringWithFormat:@"%@,%@,%@,%@", menuCmd, termTheme, termTitle, termWindow]; + NSString *menuRepObj = [NSString stringWithFormat:@"%@,%@,%@,%@,%@", menuCmd, termTheme, termTitle, termWindow, menuName]; [menuItem setTitle:cfg[@"name"]]; [menuItem setRepresentedObject:menuRepObj]; @@ -384,6 +384,7 @@ - (void) openHost:(NSMenuItem *) sender { //Are commands run in a new tab (default) a new terminal window (new), or in the current tab of the last used window (current). NSString *terminalWindow; + //if for some reason we get a representedObject with only one item... if (objectsFromJSON.count <=1) { escapedObject = [[sender representedObject] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; @@ -402,7 +403,7 @@ - (void) openHost:(NSMenuItem *) sender { } //Check if terminalTitle is null if( [[objectsFromJSON objectAtIndex:2] isEqualToString:@"(null)"]){ - terminalTitle = @""; + terminalTitle = [objectsFromJSON objectAtIndex:4]; }else{ terminalTitle = [objectsFromJSON objectAtIndex:2]; } @@ -422,7 +423,7 @@ - (void) openHost:(NSMenuItem *) sender { //Set Paths to iTerm Nightly AppleScripts NSString *iTerm2NightlyNewWindow = [[NSBundle mainBundle] pathForResource:@"iTerm2-nightly-new-window" ofType:@"scpt"]; NSString *iTerm2NightlyCurrentWindow = [[NSBundle mainBundle] pathForResource:@"iTerm2-nightly-current-window" ofType:@"scpt"]; - NSString *iTerm2StableNewTabDefault = [[NSBundle mainBundle] pathForResource:@"iTerm2-nightly-new-tab-default" ofType:@"scpt"]; + NSString *iTerm2NightlyNewTabDefault = [[NSBundle mainBundle] pathForResource:@"iTerm2-nightly-new-tab-default" ofType:@"scpt"]; //Set Paths to terminalScripts NSString *terminalNewWindow = [[NSBundle mainBundle] pathForResource:@"terminal-new-window" ofType:@"scpt"]; @@ -473,7 +474,7 @@ - (void) openHost:(NSMenuItem *) sender { [self runScript:iTerm2NightlyCurrentWindow handler:handlerName parameters:passParameters]; }else { //we are using the default action of shuttle, use the active window in a new Tab - [self runScript:iTerm2StableNewTabDefault handler:handlerName parameters:passParameters]; + [self runScript:iTerm2NightlyNewTabDefault handler:handlerName parameters:passParameters]; } } } @@ -601,11 +602,12 @@ - (IBAction)configure:(id)sender { } - (IBAction)showAbout:(id)sender { - - //Call the windows controller + + //Call the windows controller AboutWindowController *aboutWindow = [[AboutWindowController alloc] initWithWindowNibName:@"AboutWindowController"]; //Set the window to stay on top + [aboutWindow.window makeKeyAndOrderFront:nil]; [aboutWindow.window setLevel:NSFloatingWindowLevel]; //Show the window diff --git a/Shuttle/Shuttle-Info.plist b/Shuttle/Shuttle-Info.plist index 75d3eb7..2080b6b 100644 --- a/Shuttle/Shuttle-Info.plist +++ b/Shuttle/Shuttle-Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile shuttle CFBundleIdentifier - shuttle.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.2.3 + 1.2.4 CFBundleSignature ???? CFBundleVersion - 1.2.3 + 1.2.4 LSApplicationCategoryType public.app-category.developer-tools LSMinimumSystemVersion diff --git a/Shuttle/shuttle.default.json b/Shuttle/shuttle.default.json index 7e85b3d..a3fa14d 100644 --- a/Shuttle/shuttle.default.json +++ b/Shuttle/shuttle.default.json @@ -16,9 +16,9 @@ { "cmd": "ps aux | grep foo", "inTerminal": "new", - "name": "My Dev Server", - "theme": "Homebrew", - "title": "Dev Server - SSH" + "name": "look for process foo", + "theme": "Default", + "title": "grep foo" }, { "Spouses Servers": [