@@ -33,34 +33,32 @@ - (void) awakeFromNib {
33
33
[[NSFileManager defaultManager ] copyItemAtPath: cgFileInResource toPath: shuttleConfigFile error: nil ];
34
34
}
35
35
}
36
-
37
- // Load the menu content
38
- // [self loadMenu];
39
-
36
+
40
37
// Define Icons
38
+ // only regular icon is needed for 10.10 and higher. OS X changes the icon for us.
41
39
regularIcon = [NSImage imageNamed: @" StatusIcon" ];
42
40
altIcon = [NSImage imageNamed: @" StatusIconAlt" ];
43
41
42
+ // Create the status bar item
43
+ statusItem = [[NSStatusBar systemStatusBar ] statusItemWithLength: NSSquareStatusItemLength ];
44
+ [statusItem setMenu: menu];
45
+ [statusItem setImage: regularIcon];
46
+
44
47
// Check for AppKit Version, add support for darkmode if > 10.9
45
48
BOOL oldAppKitVersion = (floor (NSAppKitVersionNumber ) <= 1265 );
46
49
50
+ // 10.10 or higher, dont load the alt image let OS X style it.
47
51
if (!oldAppKitVersion)
48
52
{
49
- // 10.10 or higher, add support to icon for auto detection of Regular/Dark mode
50
- [regularIcon setTemplate: YES ];
51
- [altIcon setTemplate: YES ];
53
+ regularIcon.template = YES ;
54
+ }
55
+ // Load the alt image for OS X < 10.10
56
+ else {
57
+ [statusItem setHighlightMode: YES ];
58
+ [statusItem setAlternateImage: altIcon];
52
59
}
53
60
54
- // Create the status bar item
55
- statusItem = [[NSStatusBar systemStatusBar ] statusItemWithLength: 25.0 ];
56
-
57
- [statusItem setMenu: menu];
58
- [statusItem setHighlightMode: YES ];
59
- [statusItem setImage: regularIcon];
60
- [statusItem setAlternateImage: altIcon];
61
-
62
61
launchAtLoginController = [[LaunchAtLoginController alloc ] init ];
63
-
64
62
// Needed to trigger the menuWillOpen event
65
63
[menu setDelegate: self ];
66
64
}
@@ -357,9 +355,11 @@ - (void) buildMenu:(NSArray*)data addToMenu:(NSMenu *)m {
357
355
NSString *termTitle = cfg[@" title" ];
358
356
// Get the value of setting inTerminal
359
357
NSString *termWindow = cfg[@" inTerminal" ];
358
+ // Get the menu name will will use this as the title if title is null.
359
+ NSString *menuName = cfg[@" name" ];
360
360
361
361
// Place the terminal command, theme, and title into an comma delimited string
362
- NSString *menuRepObj = [NSString stringWithFormat: @" %@ ,%@ ,%@ ,%@ " , menuCmd, termTheme, termTitle, termWindow];
362
+ NSString *menuRepObj = [NSString stringWithFormat: @" %@ ,%@ ,%@ ,%@ , %@ " , menuCmd, termTheme, termTitle, termWindow, menuName ];
363
363
364
364
[menuItem setTitle: cfg[@" name" ]];
365
365
[menuItem setRepresentedObject: menuRepObj];
@@ -384,6 +384,7 @@ - (void) openHost:(NSMenuItem *) sender {
384
384
// Are commands run in a new tab (default) a new terminal window (new), or in the current tab of the last used window (current).
385
385
NSString *terminalWindow;
386
386
387
+
387
388
// if for some reason we get a representedObject with only one item...
388
389
if (objectsFromJSON.count <=1 ) {
389
390
escapedObject = [[sender representedObject ] stringByReplacingOccurrencesOfString: @" \" " withString: @" \\\" " ];
@@ -402,7 +403,7 @@ - (void) openHost:(NSMenuItem *) sender {
402
403
}
403
404
// Check if terminalTitle is null
404
405
if ( [[objectsFromJSON objectAtIndex: 2 ] isEqualToString: @" (null)" ]){
405
- terminalTitle = @" " ;
406
+ terminalTitle = [objectsFromJSON objectAtIndex: 4 ] ;
406
407
}else {
407
408
terminalTitle = [objectsFromJSON objectAtIndex: 2 ];
408
409
}
@@ -422,7 +423,7 @@ - (void) openHost:(NSMenuItem *) sender {
422
423
// Set Paths to iTerm Nightly AppleScripts
423
424
NSString *iTerm2NightlyNewWindow = [[NSBundle mainBundle ] pathForResource: @" iTerm2-nightly-new-window" ofType: @" scpt" ];
424
425
NSString *iTerm2NightlyCurrentWindow = [[NSBundle mainBundle ] pathForResource: @" iTerm2-nightly-current-window" ofType: @" scpt" ];
425
- NSString *iTerm2StableNewTabDefault = [[NSBundle mainBundle ] pathForResource: @" iTerm2-nightly-new-tab-default" ofType: @" scpt" ];
426
+ NSString *iTerm2NightlyNewTabDefault = [[NSBundle mainBundle ] pathForResource: @" iTerm2-nightly-new-tab-default" ofType: @" scpt" ];
426
427
427
428
// Set Paths to terminalScripts
428
429
NSString *terminalNewWindow = [[NSBundle mainBundle ] pathForResource: @" terminal-new-window" ofType: @" scpt" ];
@@ -473,7 +474,7 @@ - (void) openHost:(NSMenuItem *) sender {
473
474
[self runScript: iTerm2NightlyCurrentWindow handler: handlerName parameters: passParameters];
474
475
}else {
475
476
// we are using the default action of shuttle, use the active window in a new Tab
476
- [self runScript: iTerm2StableNewTabDefault handler: handlerName parameters: passParameters];
477
+ [self runScript: iTerm2NightlyNewTabDefault handler: handlerName parameters: passParameters];
477
478
}
478
479
}
479
480
}
@@ -601,11 +602,12 @@ - (IBAction)configure:(id)sender {
601
602
}
602
603
603
604
- (IBAction )showAbout : (id )sender {
604
-
605
- // Call the windows controller
605
+
606
+ // Call the windows controller
606
607
AboutWindowController *aboutWindow = [[AboutWindowController alloc ] initWithWindowNibName: @" AboutWindowController" ];
607
608
608
609
// Set the window to stay on top
610
+ [aboutWindow.window makeKeyAndOrderFront: nil ];
609
611
[aboutWindow.window setLevel: NSFloatingWindowLevel ];
610
612
611
613
// Show the window
0 commit comments