-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmongoPref.m
More file actions
72 lines (60 loc) · 1.73 KB
/
Copy pathmongoPref.m
File metadata and controls
72 lines (60 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// mongoPref.m
// mongodb.prefpane
//
// Created by Iv‡n ValdŽs Castillo on 4/12/10.
// Copyright (c) 2010 Iv‡n ValdŽs Castillo, released under the MIT license
//
#import "mongoPref.h"
#import "MBSliderButton.h"
#import "DaemonController.h"
@implementation mongoPref
@synthesize theSlider;
@synthesize theArguments;
- (void) mainViewDidLoad;
{
dC = [[DaemonController alloc] initWithDelegate:self andArguments:[theArguments stringValue]];
[theSlider setState:[dC isRunning] ? NSOnState : NSOffState];
preferences = [[NSUserDefaults standardUserDefaults] retain];
preferencesDict = [NSDictionary dictionaryWithObjectsAndKeys:@"", @"arguments", nil];
[preferences registerDefaults:preferencesDict];
[theArguments setStringValue:[preferences objectForKey:@"arguments"]];
}
- (void) daemonStopped;
{
[theSlider setState:NSOffState animate:YES];
}
- (void) daemonStarted;
{
[theSlider setState:NSOnState animate:YES];
}
- (void) dealloc;
{
[dC release];
[preferences release];
[preferencesDict release];
[super dealloc];
}
- (IBAction) startStopDaemon:(id)sender;
{
if (![dC locateBinary]) {
[NSAlert alertWithMessageText:@"Cannot locate mongod :("
defaultButton:@"Ok"
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"Please make sure you have the mongod binary either in /usr/local/bin, /usr/bin, /bin, or /opt/bin"];
[theSlider setState:NSOffState];
return;
}
if (theSlider.state == NSOffState) {
[dC stop];
} else {
[dC setArguments:[theArguments stringValue]];
[dC start];
}
}
- (IBAction) changeArguments:(id)sender;
{
[preferences setObject:[theArguments stringValue] forKey:@"arguments"];
}
@end