Skip to content

Commit

Permalink
Added Self Control app source, with ability to open empty VM for buil…
Browse files Browse the repository at this point in the history
…ding.
  • Loading branch information
russellallen committed Mar 30, 2012
1 parent f778131 commit 1fafc9e
Show file tree
Hide file tree
Showing 16 changed files with 5,028 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*~ *~
*.snap *.snap
*.old *.old
Self
bin/linux/AddTrailingNewline bin/linux/AddTrailingNewline
bin/linux/UpdateFiles bin/linux/UpdateFiles
bin/linux/cmprev bin/linux/cmprev
Expand Down
Binary file not shown.
Binary file added controller/osx/Self.app/Contents/MacOS/Self
Binary file not shown.
32 changes: 32 additions & 0 deletions controller/osx/Self/RunningSelfVMManagerModel.h
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
129 changes: 129 additions & 0 deletions controller/osx/Self/RunningSelfVMManagerModel.m
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
57 changes: 57 additions & 0 deletions controller/osx/Self/Self Control-Info.plist
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>
7 changes: 7 additions & 0 deletions controller/osx/Self/Self Control-Prefix.pch
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
5 changes: 5 additions & 0 deletions controller/osx/Self/Self.entitlements
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>
23 changes: 23 additions & 0 deletions controller/osx/Self/SelfAppDelegate.h
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
Loading

0 comments on commit 1fafc9e

Please sign in to comment.