Launcher: Use default settings from NIB for new VM.

This commit is contained in:
asvitkine 2009-08-18 03:42:11 +00:00
parent bc7b9a6c4a
commit c465e7239e
5 changed files with 25 additions and 12 deletions

View File

@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="145"/>
<integer value="143"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -172,7 +172,7 @@
<object class="NSTextFieldCell" key="NSCell" id="564442807">
<int key="NSCellFlags">-1804468671</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">/</string>
<string key="NSContents"/>
<reference key="NSSupport" ref="112300701"/>
<reference key="NSControlView" ref="1052479163"/>
<bool key="NSDrawsBackground">YES</bool>

View File

@ -31,6 +31,7 @@ Don't show Preferences menu in spawned SheepShaver instances - or make them
use the same nib file as this app!
When choosing things like rom file and keycode files - have a checkbox to copy
selected file into the bundle.
Copy path!
*/
@ -86,6 +87,12 @@ selected file into the bundle.
[vmList registerForDraggedTypes:[NSArray arrayWithObjects:VM_DRAG_TYPE, nil]];
}
- (void) reloadDataAndSave
{
[vmList reloadData];
[[NSUserDefaults standardUserDefaults] setObject:vmArray forKey:@"vm_list"];
}
- (void) keyDown: (NSEvent *) event
{
if ([event type] == NSKeyDown && [[event characters] length] > 0) {
@ -148,8 +155,7 @@ selected file into the bundle.
}
[vmArray removeObjectAtIndex: index];
}
[[NSUserDefaults standardUserDefaults] setObject:vmArray forKey:@"vm_list"];
[vmList reloadData];
[self reloadDataAndSave];
[vmList selectRow:row byExtendingSelection:NO];
return YES;
}
@ -205,15 +211,13 @@ selected file into the bundle.
[manager createFileAtPath:[[save filename] stringByAppendingPathComponent:@"prefs"] contents:nil attributes:nil];
[vmArray addObject:[save filename]];
[vmList reloadData];
[[NSUserDefaults standardUserDefaults] setObject:vmArray forKey:@"vm_list"];
[vmList selectRow:([vmArray count] - 1) byExtendingSelection:NO];
[self editVirtualMachineSettings:self];
[[VMSettingsController sharedInstance] editSettingsForNewVM:[save filename] sender:self];
if ([[VMSettingsController sharedInstance] cancelWasClicked]) {
[manager removeFileAtPath:[save filename] handler:nil];
[vmArray removeObjectAtIndex:([vmArray count] - 1)];
[vmList reloadData];
}
// TODO advanced: show sub-panel in save dialog that says "Create Disk:"
[self reloadDataAndSave];
}
}
@ -239,8 +243,7 @@ selected file into the bundle.
{
if (returnCode == NSOKButton) {
[vmArray addObject:[open filename]];
[vmList reloadData];
[[NSUserDefaults standardUserDefaults] setObject:vmArray forKey:@"vm_list"];
[self reloadDataAndSave];
}
}
@ -322,8 +325,7 @@ selected file into the bundle.
if (returnCode == NSAlertFirstButtonReturn) {
[vmArray removeObjectAtIndex:[vmList selectedRow]];
[vmList deselectAll:self];
[vmList reloadData];
[[NSUserDefaults standardUserDefaults] setObject:vmArray forKey:@"vm_list"];
[self reloadDataAndSave];
}
}

View File

@ -67,6 +67,7 @@
- (id) init;
- (void) setupGUI;
- (void) editSettingsFor: (NSString *) vmdir sender: (id) sender;
- (void) editSettingsForNewVM: (NSString *) vmdir sender: (id) sender;
- (IBAction) addDisk: (id) sender;
- (IBAction) removeDisk: (id) sender;
- (IBAction) createDisk: (id) sender;

View File

@ -171,6 +171,16 @@ static NSString *getStringFromPrefs(const char *key)
[NSApp runModalForWindow:window];
}
- (void) editSettingsForNewVM: (NSString *) vmdir sender: (id) sender
{
chdir([vmdir fileSystemRepresentation]);
AddPrefsDefaults();
AddPlatformPrefsDefaults();
LoadPrefs([vmdir fileSystemRepresentation]);
NSWindow *window = [self window];
[NSApp runModalForWindow:window];
}
static NSString *makeRelativeIfNecessary(NSString *path)
{
char cwd[1024], filename[1024];