Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
amitailanciano committed Feb 4, 2019
2 parents 38812e4 + 535dad3 commit 1eecf38
Show file tree
Hide file tree
Showing 25 changed files with 956 additions and 113 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Download Vagrant Manager from the [GitHub Releases Page](https://github.com/lana
* Currently, vagrant machines must already be initialized in order for Vagrant Manager to detect them. Make sure you have run vagrant init on any machine you want to appear in Vagrant Manager. Once Vagrant Manager has detected a machine, you can bookmark it so that it will not disappear when you destroy the machine. You can also manually add a bookmark and specify the path to your Vagrantfile.
* Vagrant Manager requires OS X 10.8 Mountain Lion or higher

## Building DMG
* Use [appdmg](https://github.com/LinusU/node-appdmg) to build the distribution DMG.
* Put the `Vagrant Manager.app` file in the `dmg` foler
* Run `appdmg dmg/appdmg.json <outputfile>`

## Contributing to Vagrant Manager

We love code contributions! If you would like to contribute, here are some notes and guidlines:
Expand Down
36 changes: 36 additions & 0 deletions Vagrant Manager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
B150013319249FFD000A76E7 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B150013119249FFD000A76E7 /* [email protected] */; };
B150013419249FFD000A76E7 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B150013219249FFD000A76E7 /* [email protected] */; };
B15001361924A02C000A76E7 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B15001351924A02C000A76E7 /* [email protected] */; };
B15C0D3D22077EA900755337 /* ManageCustomProvidersWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = B15C0D3A22077EA800755337 /* ManageCustomProvidersWindow.m */; };
B15C0D3E22077EA900755337 /* ManageCustomProvidersWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = B15C0D3C22077EA900755337 /* ManageCustomProvidersWindow.xib */; };
B15C0D4422077FA600755337 /* CustomProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = B15C0D4022077FA600755337 /* CustomProvider.m */; };
B15C0D4522077FA600755337 /* CustomProviderManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B15C0D4322077FA600755337 /* CustomProviderManager.m */; };
B15C0D512207B1C600755337 /* VagrantInstanceCache.m in Sources */ = {isa = PBXBuildFile; fileRef = B15C0D502207B1C600755337 /* VagrantInstanceCache.m */; };
B1761B3D1A00C0140056582F /* NativeMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = B1761B3C1A00C0140056582F /* NativeMenuItem.m */; };
B17AA18B1887A75300B4C274 /* Util.m in Sources */ = {isa = PBXBuildFile; fileRef = B17AA18A1887A75300B4C274 /* Util.m */; };
B17AA18F1887CA4600B4C274 /* PreferencesWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = B17AA18D1887CA4600B4C274 /* PreferencesWindow.m */; };
Expand Down Expand Up @@ -277,6 +282,15 @@
B150013119249FFD000A76E7 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
B150013219249FFD000A76E7 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
B15001351924A02C000A76E7 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
B15C0D3A22077EA800755337 /* ManageCustomProvidersWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ManageCustomProvidersWindow.m; sourceTree = "<group>"; };
B15C0D3B22077EA800755337 /* ManageCustomProvidersWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManageCustomProvidersWindow.h; sourceTree = "<group>"; };
B15C0D3C22077EA900755337 /* ManageCustomProvidersWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ManageCustomProvidersWindow.xib; sourceTree = "<group>"; };
B15C0D4022077FA600755337 /* CustomProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomProvider.m; sourceTree = "<group>"; };
B15C0D4122077FA600755337 /* CustomProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomProvider.h; sourceTree = "<group>"; };
B15C0D4222077FA600755337 /* CustomProviderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomProviderManager.h; sourceTree = "<group>"; };
B15C0D4322077FA600755337 /* CustomProviderManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomProviderManager.m; sourceTree = "<group>"; };
B15C0D4F2207B1C600755337 /* VagrantInstanceCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VagrantInstanceCache.h; sourceTree = "<group>"; };
B15C0D502207B1C600755337 /* VagrantInstanceCache.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VagrantInstanceCache.m; sourceTree = "<group>"; };
B1761B3B1A00C0140056582F /* NativeMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeMenuItem.h; sourceTree = "<group>"; };
B1761B3C1A00C0140056582F /* NativeMenuItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeMenuItem.m; sourceTree = "<group>"; };
B17AA1891887A75300B4C274 /* Util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Util.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -376,6 +390,9 @@
837A30861A5D0D5500E12A40 /* ManageCustomCommandsWindow.h */,
837A30871A5D0D5500E12A40 /* ManageCustomCommandsWindow.m */,
837A30881A5D0D5500E12A40 /* ManageCustomCommandsWindow.xib */,
B15C0D3B22077EA800755337 /* ManageCustomProvidersWindow.h */,
B15C0D3A22077EA800755337 /* ManageCustomProvidersWindow.m */,
B15C0D3C22077EA900755337 /* ManageCustomProvidersWindow.xib */,
832B4C3A1A5FA24B0027A3BA /* BaseWindowController.h */,
832B4C3B1A5FA24B0027A3BA /* BaseWindowController.m */,
);
Expand Down Expand Up @@ -442,6 +459,7 @@
children = (
2609ECF31BC89CEA00E4B44E /* NFSScanner.h */,
2609ECF41BC89CEA00E4B44E /* NFSScanner.m */,
B15C0D3F22077EF700755337 /* Custom Providers */,
837A308B1A5D170D00E12A40 /* Custom Commands */,
83F5BBB41983B8FB00ACE853 /* Vagrant Manager */,
83F5BBB51983B90800ACE853 /* Providers */,
Expand All @@ -464,6 +482,8 @@
83E7CAB31928C2E9001C86F6 /* VirtualMachineInfo.m */,
830BAC331A0F278D00AE5F9C /* VagrantGlobalStatusScanner.h */,
830BAC341A0F278D00AE5F9C /* VagrantGlobalStatusScanner.m */,
B15C0D4F2207B1C600755337 /* VagrantInstanceCache.h */,
B15C0D502207B1C600755337 /* VagrantInstanceCache.m */,
);
name = "Vagrant Manager";
sourceTree = "<group>";
Expand Down Expand Up @@ -623,6 +643,17 @@
name = "Supporting Files";
sourceTree = "<group>";
};
B15C0D3F22077EF700755337 /* Custom Providers */ = {
isa = PBXGroup;
children = (
B15C0D4122077FA600755337 /* CustomProvider.h */,
B15C0D4022077FA600755337 /* CustomProvider.m */,
B15C0D4222077FA600755337 /* CustomProviderManager.h */,
B15C0D4322077FA600755337 /* CustomProviderManager.m */,
);
name = "Custom Providers";
sourceTree = "<group>";
};
B1761B3A1A00BE580056582F /* Native */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -733,6 +764,7 @@
B150013419249FFD000A76E7 /* [email protected] in Resources */,
8339DCA2187E756B0036E162 /* TaskOutputWindow.xib in Resources */,
83C4CDE41A060B3600611DCC /* reload.png in Resources */,
B15C0D3E22077EA900755337 /* ManageCustomProvidersWindow.xib in Resources */,
2609ECF91BC8A05100E4B44E /* rdp.png in Resources */,
B17AA1901887CA4600B4C274 /* PreferencesWindow.xib in Resources */,
B150012E19249CA2000A76E7 /* [email protected] in Resources */,
Expand Down Expand Up @@ -857,15 +889,19 @@
buildActionMask = 2147483647;
files = (
83DB673719288DD90008CB57 /* VagrantInstance.m in Sources */,
B15C0D4522077FA600755337 /* CustomProviderManager.m in Sources */,
83103A571982180C00B340BB /* ParallelsServiceProvider.m in Sources */,
B15C0D4422077FA600755337 /* CustomProvider.m in Sources */,
83E7CAB41928C2E9001C86F6 /* VirtualMachineInfo.m in Sources */,
83FD354819827545002EEA2D /* BookmarkManager.m in Sources */,
83DB673A1928AC0C0008CB57 /* VagrantMachine.m in Sources */,
B15C0D3D22077EA900755337 /* ManageCustomProvidersWindow.m in Sources */,
837A30911A5D177A00E12A40 /* CustomCommandManager.m in Sources */,
B1357A84187CEB3B00811CBC /* AppDelegate.m in Sources */,
83103A5A19821A9E00B340BB /* ParallelsMachineInfo.m in Sources */,
8360A05A18C2B39B002EA89B /* Environment.m in Sources */,
8308E14018869FAC001E0B45 /* Bookmark.m in Sources */,
B15C0D512207B1C600755337 /* VagrantInstanceCache.m in Sources */,
83DB673D1928B3510008CB57 /* VagrantManager.m in Sources */,
8308E132188662BD001E0B45 /* AboutWindow.m in Sources */,
B1761B3D1A00C0140056582F /* NativeMenuItem.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
89 changes: 53 additions & 36 deletions Vagrant Manager/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "VagrantInstance.h"
#import "BookmarkManager.h"
#import "CustomCommandManager.h"
#import "CustomProviderManager.h"

@implementation AppDelegate {
BOOL isRefreshingVagrantMachines;
Expand Down Expand Up @@ -58,6 +59,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

[[BookmarkManager sharedManager] loadBookmarks];
[[CustomCommandManager sharedManager] loadCustomCommands];
[[CustomProviderManager sharedManager] loadCustomProviders];

//initialize updates
[[SUUpdater sharedUpdater] setDelegate:self];
Expand Down Expand Up @@ -423,9 +425,9 @@ - (void)checkForVagrantUpdates:(BOOL)showAlert {

- (void)editHostsFile {
NSString *terminalEditorName = [[NSUserDefaults standardUserDefaults] valueForKey:@"terminalEditorPreference"];

NSString *terminalEditor;
if([@[@"vim", @"emacs", @"nano"] containsObject:terminalEditorName]) {

if([@[@"vim", @"emacs", @"nano", @"micro"] containsObject:terminalEditorName]) {
terminalEditor = terminalEditorName;
} else {
terminalEditor = @"nano";
Expand Down Expand Up @@ -612,42 +614,44 @@ - (void)runTerminalCommand:(NSString*)command {
NSString *s;
if ([terminalName isEqualToString:@"iTerm"]) {
s = [NSString stringWithFormat:
@"set v2_script to \"\n"
"tell application \\\"iTerm\\\"\n"
"tell current terminal\n"
"launch session \\\"Default Session\\\"\n"
"delay 0.15\n"
"activate\n"
"tell the last session\n"
"write text \\\"%@\\\"\n"
"end tell\n"
"end tell\n"
"end tell\"\n"
"set v3_script to \"\n"
"tell application \\\"iTerm\\\"\n"
"activate\n"
"tell current window\n"
"create tab with default profile\n"
"tell current session\n"
"write text \\\"%@\\\"\n"
"end tell\n"
"end tell\n"
"end tell\"\n"

"if application \"iTerm\"'s version >= \"2.9\" then\n"
"run script v3_script\n"
"else\n"
"run script v2_script\n"
"end\n", command, command];
@"if application \"iTerm\" is running then\n"
"tell application \"iTerm\"\n"
"tell current window\n"
"create tab with default profile\n"
"end tell\n"
"end tell\n"
"end if\n"
"tell application \"iTerm\"\n"
"activate\n"
"tell current session of current window\n"
"write text \"%@\"\n"
"end tell\n"
"end tell", command];
} else if ([terminalName isEqualToString:@"Hyper"]) {
s = [NSString stringWithFormat:
@"tell application \"Hyper\"\n"
"activate\n"
"delay 2\n"
"tell application \"System Events\"\n"
"keystroke \"%@\"\n"
"key code 36\n"
"end tell\n"
"end tell\n", command];
} else {
s = [NSString stringWithFormat:@"tell application \"Terminal\"\n"
"activate\n"
"do script \"%@\"\n"
s = [NSString stringWithFormat:
@"tell application \"Terminal\"\n"
"activate\n"
"do script \"%@\"\n"
"end tell\n", command];
}

NSAppleScript *as = [[NSAppleScript alloc] initWithSource: s];
[as executeAndReturnError:nil];
NSDictionary *errors = nil;
[as executeAndReturnError:&errors];

if (errors) {
[[NSAlert alertWithMessageText:@"There was an error performing the command" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@", errors[NSAppleScriptErrorMessage]] runModal];
}
}

#pragma mark - Window management
Expand All @@ -662,18 +666,27 @@ - (void)addOpenWindow:(id)window {
- (void)removeOpenWindow:(id)window {
@synchronized(openWindows) {
[openWindows removeObject:window];
[self updateProcessType];
[self updateProcessType:NO];
}
}

- (void)updateProcessType {
if([[NSUserDefaults standardUserDefaults] boolForKey:@"haltOnExit"] || [openWindows count] > 0) {
[self updateProcessType:YES];
}

- (void)updateProcessType:(BOOL)bringToFront {
if([[NSUserDefaults standardUserDefaults] boolForKey:@"haltOnExit"] || [openWindows count]) {
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
[[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyRegular];

if (bringToFront) {
SetFrontProcess(&psn);
}
} else {
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToBackgroundApplication);
[[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyAccessory];
}
}

Expand Down Expand Up @@ -785,6 +798,10 @@ - (void)updaterDidNotFindUpdate:(SUUpdater *)update {
[[NSNotificationCenter defaultCenter] postNotificationName:@"vagrant-manager.update-available" object:nil userInfo:@{@"is_update_available": [NSNumber numberWithBool:NO]}];
}

- (void)updaterWillShowModalAlert:(SUUpdater *)updater {
[NSApp activateIgnoringOtherApps:YES];
}

- (id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater {
return [[VersionComparison alloc] init];
}
Expand Down
Loading

0 comments on commit 1eecf38

Please sign in to comment.