-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Self Control app source, with ability to open empty VM for buil…
…ding.
- Loading branch information
1 parent
f778131
commit 1fafc9e
Showing
16 changed files
with
5,028 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.14 KB
(110%)
...oj/project.xcworkspace/xcuserdata/russellallen.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
// | |||
// RunningSelfVMManagerModel.h | |||
// Self | |||
// | |||
// Created by Russell Allen on 13/01/12. | |||
// Copyright 2012 AUTHORS. All rights reserved. | |||
// | |||
|
|||
#import <Cocoa/Cocoa.h> | |||
|
|||
@class SelfWorld; | |||
|
|||
@interface RunningSelfVMManagerModel : NSObject <NSTableViewDelegate, NSTableViewDataSource> { | |||
NSMutableArray *running; | |||
IBOutlet NSTableView* myTable; | |||
IBOutlet NSButton* openTerminalButton; | |||
IBOutlet NSButton* forceQuitButton; | |||
} | |||
|
|||
-(void)registerRunningVM:(SelfWorld *)vm; | |||
-(void)killAll; | |||
-(NSString*)nameOfSelectedWorld; | |||
-(BOOL)warnBeforeClose; | |||
-(void)notifyTaskEnded:(SelfWorld *)vm; | |||
-(void)forceQuit:(NSNotification *)aNotification; | |||
-(void)openTerminal:(NSNotification *)aNotification; | |||
|
|||
@property (nonatomic, retain) IBOutlet NSTableView* myTable; | |||
@property (nonatomic, retain) IBOutlet NSButton* openTerminalButton; | |||
@property (nonatomic, retain) IBOutlet NSButton* forceQuitButton; | |||
|
|||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,129 @@ | |||
// | |||
// RunningSelfVMManagerModel.m | |||
// Self | |||
// | |||
// Created by Russell Allen on 13/01/12. | |||
// Copyright 2012 AUTHORS. All rights reserved. | |||
// | |||
|
|||
#import "RunningSelfVMManagerModel.h" | |||
#import "SelfAppDelegate.h" | |||
#import "SelfWorld.h" | |||
|
|||
@implementation RunningSelfVMManagerModel | |||
|
|||
@synthesize myTable; | |||
@synthesize openTerminalButton; | |||
@synthesize forceQuitButton; | |||
|
|||
-(void)awakeFromNib | |||
{ | |||
// Register myself for use by application | |||
SelfAppDelegate *app = [NSApp delegate]; | |||
[app setModel: self]; | |||
[openTerminalButton setEnabled:NO]; | |||
[forceQuitButton setEnabled:NO]; | |||
} | |||
|
|||
- (id)init | |||
{ | |||
self = [super init]; | |||
if (self) { | |||
// Initialization code here. | |||
running = [[NSMutableArray alloc] init]; | |||
} | |||
return self; | |||
} | |||
|
|||
- (void) dealloc | |||
{ | |||
[running release]; | |||
[super dealloc]; | |||
} | |||
|
|||
-(void)registerRunningVM:(SelfWorld *)vm | |||
{ | |||
[running addObject: vm]; | |||
[vm notifyMe:self]; | |||
[myTable reloadData]; | |||
} | |||
|
|||
-(BOOL)warnBeforeClose | |||
{ | |||
return [running count] > 0; | |||
} | |||
|
|||
-(void)killAll | |||
{ | |||
NSTask *t; | |||
NSEnumerator* myIterator = [running objectEnumerator]; | |||
|
|||
while( t = [myIterator nextObject]) | |||
{ | |||
[t terminate]; | |||
} | |||
} | |||
|
|||
-(void)notifyTaskEnded:(SelfWorld *)vm | |||
{ | |||
[running removeObject:vm]; | |||
[myTable reloadData]; | |||
} | |||
|
|||
// TableViewDataSource | |||
|
|||
- (id)tableView:(NSTableView *)tableView | |||
objectValueForTableColumn:(NSTableColumn *)tableColumn | |||
row:(NSInteger)row { | |||
|
|||
return [[running objectAtIndex:row] getName]; | |||
|
|||
} | |||
|
|||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { | |||
return [running count]; | |||
} | |||
|
|||
// TableViewDelagate | |||
|
|||
- (IBAction)tableViewSelected:(NSTableView *)tableView | |||
{ | |||
if ([tableView selectedRow] == -1) { | |||
[openTerminalButton setEnabled:NO]; | |||
[forceQuitButton setEnabled:NO]; | |||
} else { | |||
[openTerminalButton setEnabled:YES]; | |||
[forceQuitButton setEnabled:YES]; | |||
} | |||
} | |||
|
|||
- (NSString*)nameOfSelectedWorld | |||
{ | |||
return [(SelfWorld*)[running objectAtIndex:[myTable selectedRow]] getNameForScreen]; | |||
} | |||
|
|||
// MANAGING | |||
|
|||
- (void)openTerminal:(NSNotification *)aNotification | |||
{ | |||
NSString *s = [NSString stringWithFormat: | |||
@"tell application \"Terminal\" to do script \"screen -t Self -D -r %@\"", [self nameOfSelectedWorld]]; | |||
NSAppleScript *as = [[NSAppleScript alloc] initWithSource: s]; | |||
[as executeAndReturnError:nil]; | |||
|
|||
s = @"tell application \"Terminal\" to activate"; | |||
as = [[NSAppleScript alloc] initWithSource: s]; | |||
[as executeAndReturnError:nil]; | |||
|
|||
|
|||
} | |||
|
|||
- (void)forceQuit:(NSNotification *)aNotification | |||
{ | |||
[(SelfWorld*)[running objectAtIndex:[myTable selectedRow]] terminate]; | |||
} | |||
|
|||
// END MANAGING | |||
|
|||
|
|||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
<?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>CFBundleDevelopmentRegion</key> | |||
<string>en</string> | |||
<key>CFBundleDocumentTypes</key> | |||
<array> | |||
<dict> | |||
<key>CFBundleTypeExtensions</key> | |||
<array> | |||
<string>snap</string> | |||
</array> | |||
<key>CFBundleTypeName</key> | |||
<string>Self Snapshot</string> | |||
<key>CFBundleTypeRole</key> | |||
<string>Editor</string> | |||
</dict> | |||
</array> | |||
<key>CFBundleExecutable</key> | |||
<string>${EXECUTABLE_NAME}</string> | |||
<key>CFBundleIconFile</key> | |||
<string>Self ControlIcon</string> | |||
<key>CFBundleIdentifier</key> | |||
<string>org.selflanguage.${PRODUCT_NAME:rfc1034identifier}</string> | |||
<key>CFBundleInfoDictionaryVersion</key> | |||
<string>6.0</string> | |||
<key>CFBundleName</key> | |||
<string>${PRODUCT_NAME}</string> | |||
<key>CFBundlePackageType</key> | |||
<string>APPL</string> | |||
<key>CFBundleShortVersionString</key> | |||
<string>4.5</string> | |||
<key>CFBundleSignature</key> | |||
<string>????</string> | |||
<key>CFBundleURLTypes</key> | |||
<array/> | |||
<key>CFBundleVersion</key> | |||
<string>1</string> | |||
<key>LSApplicationCategoryType</key> | |||
<string>public.app-category.utilities</string> | |||
<key>LSMinimumSystemVersion</key> | |||
<string>${MACOSX_DEPLOYMENT_TARGET}</string> | |||
<key>NSHumanReadableCopyright</key> | |||
<string>Copyright © 2012 AUTHORS. See LICENCE.</string> | |||
<key>NSMainNibFile</key> | |||
<string>MainMenu</string> | |||
<key>NSPrincipalClass</key> | |||
<string>NSApplication</string> | |||
<key>NSServices</key> | |||
<array/> | |||
<key>UTExportedTypeDeclarations</key> | |||
<array/> | |||
<key>UTImportedTypeDeclarations</key> | |||
<array/> | |||
</dict> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
// | |||
// Prefix header for all source files of the 'Self' target in the 'Self' project | |||
// | |||
|
|||
#ifdef __OBJC__ | |||
#import <Cocoa/Cocoa.h> | |||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
<?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/> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
// | |||
// SelfAppDelegate.h | |||
// Self | |||
// | |||
// Created by Russell Allen on 7/01/12. | |||
// Copyright 2012 AUTHORS. All rights reserved. | |||
// | |||
|
|||
#import <Cocoa/Cocoa.h> | |||
|
|||
@class RunningSelfVMManagerModel; | |||
|
|||
@interface SelfAppDelegate : NSObject <NSApplicationDelegate> { | |||
NSWindow *window; | |||
RunningSelfVMManagerModel *vmManagerModel; | |||
} | |||
|
|||
@property (assign) IBOutlet NSWindow *window; | |||
|
|||
-(void)setModel:(RunningSelfVMManagerModel *)model; | |||
-(int)installVM; | |||
|
|||
@end |
Oops, something went wrong.