ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm
(Generate patch)

Comparing SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm (file contents):
Revision 1.2 by asvitkine, 2009-08-02T20:24:38Z vs.
Revision 1.7 by asvitkine, 2009-08-30T17:56:30Z

# Line 25 | Line 25
25  
26   const int CDROMRefNum = -62;                    // RefNum of driver
27  
28 + #ifdef STANDALONE_PREFS
29   void prefs_init()
30   {
31   }
# Line 32 | Line 33 | void prefs_init()
33   void prefs_exit()
34   {
35   }
36 + #endif
37  
38   @implementation VMSettingsController
39  
40   + (id) sharedInstance
41   {
42 <        static VMSettingsController *_sharedInstance = nil;
43 <        if (!_sharedInstance) {
44 <                _sharedInstance = [[VMSettingsController allocWithZone:[self zone]] init];
45 <        }
46 <        return _sharedInstance;
42 >  static VMSettingsController *_sharedInstance = nil;
43 >  if (!_sharedInstance) {
44 >    _sharedInstance = [[VMSettingsController allocWithZone:[self zone]] init];
45 >  }
46 >  return _sharedInstance;
47   }
48  
49   - (id) init
50   {
51    self = [super initWithWindowNibName:@"VMSettingsWindow"];
52  
53 <        cancelWasClicked = NO;
53 >  cancelWasClicked = NO;
54  
55 <        return self;
55 >  return self;
56   }
57  
58   - (int) numberOfRowsInTableView: (NSTableView *) table
# Line 135 | Line 137 | static NSString *getStringFromPrefs(cons
137    [useRawKeyCodes setIntValue: PrefsFindBool("keycodes") ];
138    [rawKeyCodes setStringValue: getStringFromPrefs("keycodefile") ];
139    [rawKeyCodes setEnabled:[useRawKeyCodes intValue]];
140 +  [browseRawKeyCodesButton setEnabled:[useRawKeyCodes intValue]];
141  
142    int wheelmode = PrefsFindInt32("mousewheelmode"), wheel = 0;
143    switch (wheelmode) {
# Line 159 | Line 162 | static NSString *getStringFromPrefs(cons
162  
163   - (void) editSettingsFor: (NSString *) vmdir sender: (id) sender
164   {
165 <        chdir([vmdir fileSystemRepresentation]);
165 >  chdir([vmdir fileSystemRepresentation]);
166 >  AddPrefsDefaults();
167 >  AddPlatformPrefsDefaults();
168 >  LoadPrefs([vmdir fileSystemRepresentation]);
169 >  NSWindow *window = [self window];
170 >  [self setupGUI];
171 >  [NSApp runModalForWindow:window];
172 > }
173 >
174 > - (void) editSettingsForNewVM: (NSString *) vmdir sender: (id) sender
175 > {
176 >  chdir([vmdir fileSystemRepresentation]);
177    AddPrefsDefaults();
178    AddPlatformPrefsDefaults();
179    LoadPrefs([vmdir fileSystemRepresentation]);
180 <        NSWindow *window = [self window];
181 <        [self setupGUI];
182 <        [NSApp runModalForWindow:window];
180 >  PrefsReplaceString("screen", "win/800/600");
181 >  PrefsReplaceString("extfs", "");
182 >  PrefsReplaceString("ether", "slirp");
183 >  PrefsReplaceInt32("ramsize", 64 << 20);
184 >  PrefsReplaceInt32("frameskip", 2);
185 >  PrefsReplaceBool("jit", true);
186 >  NSWindow *window = [self window];
187 >  [self setupGUI];
188 >  [NSApp runModalForWindow:window];
189   }
190  
191   static NSString *makeRelativeIfNecessary(NSString *path)
192   {
193 <        char cwd[1024], filename[1024];
194 <        int cwdlen;
195 <        strlcpy(filename, [path fileSystemRepresentation], sizeof(filename));
196 <        getcwd(cwd, sizeof(cwd));
197 <        cwdlen = strlen(cwd);
198 <        if (!strncmp(cwd, filename, cwdlen)) {
199 <                if (cwdlen >= 0 && cwd[cwdlen-1] != '/')
200 <                        cwdlen++;
201 <                return [NSString stringWithCString: filename + cwdlen];
202 <        }
203 <        return path;
193 >  char cwd[1024], filename[1024];
194 >  int cwdlen;
195 >  strlcpy(filename, [path fileSystemRepresentation], sizeof(filename));
196 >  getcwd(cwd, sizeof(cwd));
197 >  cwdlen = strlen(cwd);
198 >  if (!strncmp(cwd, filename, cwdlen)) {
199 >    if (cwdlen >= 0 && cwd[cwdlen-1] != '/')
200 >      cwdlen++;
201 >    return [NSString stringWithCString: filename + cwdlen];
202 >  }
203 >  return path;
204   }
205  
206   - (IBAction) addDisk: (id) sender
# Line 188 | Line 208 | static NSString *makeRelativeIfNecessary
208    NSOpenPanel *open = [NSOpenPanel openPanel];
209    [open setCanChooseDirectories:NO];
210    [open setAllowsMultipleSelection:NO];
211 <  [open beginSheetForDirectory: @""
211 >  [open setTreatsFilePackagesAsDirectories:YES];
212 >  [open beginSheetForDirectory: [[NSFileManager defaultManager] currentDirectoryPath]
213                            file: @"Unknown"
214                  modalForWindow: [self window]
215                   modalDelegate: self
# Line 199 | Line 220 | static NSString *makeRelativeIfNecessary
220   - (void) _addDiskEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
221   {
222    if (theReturnCode == NSOKButton) {
223 <                [diskArray addObject: makeRelativeIfNecessary([open filename])];
223 >    [diskArray addObject: makeRelativeIfNecessary([open filename])];
224      [disks reloadData];
225    }
226   }
# Line 217 | Line 238 | static NSString *makeRelativeIfNecessary
238   {
239    NSSavePanel *save = [NSSavePanel savePanel];
240    [save setAccessoryView: diskSaveSize];
241 <  [save beginSheetForDirectory: @""
241 >  [save setTreatsFilePackagesAsDirectories:YES];
242 >  [save beginSheetForDirectory: [[NSFileManager defaultManager] currentDirectoryPath]
243                            file: @"New.dsk"
244                  modalForWindow: [self window]
245                   modalDelegate: self
# Line 234 | Line 256 | static NSString *makeRelativeIfNecessary
256        snprintf(cmd, sizeof(cmd), "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", [[save filename] UTF8String], [diskSaveSizeField intValue]);
257        int ret = system(cmd);
258        if (ret == 0) {
259 <                                [diskArray addObject: makeRelativeIfNecessary([save filename])];
259 >        [diskArray addObject: makeRelativeIfNecessary([save filename])];
260          [disks reloadData];
261        }
262      }
# Line 245 | Line 267 | static NSString *makeRelativeIfNecessary
267   - (IBAction) useRawKeyCodesClicked: (id) sender
268   {
269    [rawKeyCodes setEnabled:[useRawKeyCodes intValue]];
270 +  [browseRawKeyCodesButton setEnabled:[useRawKeyCodes intValue]];
271   }
272  
273   - (IBAction) browseForROMFileClicked: (id) sender
# Line 252 | Line 275 | static NSString *makeRelativeIfNecessary
275    NSOpenPanel *open = [NSOpenPanel openPanel];
276    [open setCanChooseDirectories:NO];
277    [open setAllowsMultipleSelection:NO];
278 +  [open setTreatsFilePackagesAsDirectories:YES];
279    [open beginSheetForDirectory: @""
280                            file: [romFile stringValue]
281                  modalForWindow: [self window]
# Line 263 | Line 287 | static NSString *makeRelativeIfNecessary
287   - (void) _browseForROMFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
288   {
289    if (theReturnCode == NSOKButton) {
290 <                [romFile setStringValue: makeRelativeIfNecessary([open filename])];
291 <        }
290 >    [romFile setStringValue: makeRelativeIfNecessary([open filename])];
291 >  }
292   }
293  
294   - (IBAction) browseForUnixRootClicked: (id) sender
# Line 284 | Line 308 | static NSString *makeRelativeIfNecessary
308   - (void) _browseForUnixRootEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
309   {
310    if (theReturnCode == NSOKButton) {
311 <                [unixRoot setStringValue: makeRelativeIfNecessary([open filename])];
311 >    [unixRoot setStringValue: makeRelativeIfNecessary([open filename])];
312 >  }
313 > }
314 >
315 > - (IBAction) browseForKeyCodesFileClicked: (id) sender
316 > {
317 >  NSOpenPanel *open = [NSOpenPanel openPanel];
318 >  [open setCanChooseDirectories:NO];
319 >  [open setAllowsMultipleSelection:NO];
320 >  [open setTreatsFilePackagesAsDirectories:YES];
321 >  [open beginSheetForDirectory: @""
322 >                          file: [unixRoot stringValue]
323 >                modalForWindow: [self window]
324 >                 modalDelegate: self
325 >                didEndSelector: @selector(_browseForKeyCodesFileEnd: returnCode: contextInfo:)
326 >                   contextInfo: nil];
327 > }
328 >
329 > - (void) _browseForKeyCodesFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
330 > {
331 >  if (theReturnCode == NSOKButton) {
332 >    [rawKeyCodes setStringValue: makeRelativeIfNecessary([open filename])];
333    }
334   }
335  
336   - (void) cancelEdit: (id) sender
337   {
338 + #ifdef STANDALONE_PREFS
339    PrefsExit();
340 <        [[self window] close];
341 <        [NSApp stopModal];
342 <        cancelWasClicked = YES;
340 > #endif
341 >  [[self window] close];
342 >  [NSApp stopModal];
343 >  cancelWasClicked = YES;
344   }
345  
346   - (void) saveChanges: (id) sender
# Line 347 | Line 394 | static NSString *makeRelativeIfNecessary
394    PrefsReplaceString("serialb", [[printerPort stringValue] UTF8String]);
395    PrefsReplaceString("ether", [[ethernetInterface stringValue] UTF8String]);
396    SavePrefs();
397 + #ifdef STANDALONE_PREFS
398    PrefsExit();
399 + #endif
400  
401 <        [[self window] close];
402 <        [NSApp stopModal];
403 <        cancelWasClicked = NO;
401 >  [[self window] close];
402 >  [NSApp stopModal];
403 >  cancelWasClicked = NO;
404   }
405  
406   - (BOOL) cancelWasClicked

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines