Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

Commit

Permalink
don't clobber the icon state from the timer, required since boot2dock…
Browse files Browse the repository at this point in the history
…er doesn't have intermediate states
  • Loading branch information
nickgartmann committed Mar 15, 2015
1 parent 73c99a1 commit 25275c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Expand Up @@ -10,13 +10,13 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Boot2Docker Status/AppDelegate.m"
timestampString = "448072377.648191"
timestampString = "448128589.476755"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "101"
endingLineNumber = "101"
landmarkName = "-shouldDisplayWindowOnBoot"
landmarkType = "5">
startingLineNumber = "15"
endingLineNumber = "15"
landmarkName = "haveRequestedShutdown"
landmarkType = "19">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
Expand Down
17 changes: 13 additions & 4 deletions Boot2Docker Status/AppDelegate.m
Expand Up @@ -12,6 +12,7 @@
@interface AppDelegate ()
@property (weak) NSUserDefaults *standardUserDefaults;
@property (weak) IBOutlet NSWindow *window;
@property BOOL haveRequestedStateChange;
@end


Expand All @@ -22,6 +23,8 @@ @implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application

_haveRequestedStateChange = NO;


_statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];

Expand Down Expand Up @@ -117,10 +120,12 @@ - (void)toggleBoot2Docker:(id)sender {
}

- (void)renderIcon:(id)sender {
if([self isBoot2DockerRunning]) {
_statusItem.image = [NSImage imageNamed:@"docker"];
} else {
_statusItem.image = [NSImage imageNamed:@"docker-alt"];
if(!_haveRequestedStateChange) {
if([self isBoot2DockerRunning]) {
_statusItem.image = [NSImage imageNamed:@"docker"];
} else {
_statusItem.image = [NSImage imageNamed:@"docker-alt"];
}
}
}

Expand All @@ -146,23 +151,27 @@ - (BOOL)isBoot2DockerRunning {
}

- (void)startBoot2Docker {
_haveRequestedStateChange = YES;
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/bash"];
[task setArguments:@[@"-c", @"/usr/local/bin/boot2docker up"]];

[task setTerminationHandler:^(NSTask *t) {
_haveRequestedStateChange = NO;
_statusItem.image = [NSImage imageNamed:@"docker"];
}];

[task launch];
}

- (void)stopBoot2Docker {
_haveRequestedStateChange = YES;
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/bash"];
[task setArguments:@[@"-c", @"/usr/local/bin/boot2docker down"]];

[task setTerminationHandler:^(NSTask *t) {
_haveRequestedStateChange = NO;
_statusItem.image = [NSImage imageNamed:@"docker-alt"];
}];

Expand Down

0 comments on commit 25275c4

Please sign in to comment.