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.1 by asvitkine, 2009-08-02T18:34:57Z vs.
Revision 1.8 by asvitkine, 2010-07-27T02:57:10Z

# Line 18 | Line 18
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   */
20  
21 #import "VMSettingsController.h"
22
21   #import "sysdeps.h"
22   #import "prefs.h"
23  
24 + // The _UINT64 define is needed to guard against a typedef mismatch with Snow Leopard headers.
25 + #define _UINT64
26 +
27 + #import "VMSettingsController.h"
28 +
29   const int CDROMRefNum = -62;                    // RefNum of driver
30  
31 + #ifdef STANDALONE_PREFS
32   void prefs_init()
33   {
34   }
# Line 32 | Line 36 | void prefs_init()
36   void prefs_exit()
37   {
38   }
39 + #endif
40  
41   @implementation VMSettingsController
42  
43   + (id) sharedInstance
44   {
45 <        static VMSettingsController *_sharedInstance = nil;
46 <        if (!_sharedInstance) {
47 <                _sharedInstance = [[VMSettingsController allocWithZone:[self zone]] init];
48 <        }
49 <        return _sharedInstance;
45 >  static VMSettingsController *_sharedInstance = nil;
46 >  if (!_sharedInstance) {
47 >    _sharedInstance = [[VMSettingsController allocWithZone:[self zone]] init];
48 >  }
49 >  return _sharedInstance;
50   }
51  
52   - (id) init
53   {
54 <  return [super initWithWindowNibName:@"VMSettingsWindow"];
54 >  self = [super initWithWindowNibName:@"VMSettingsWindow"];
55 >
56 >  cancelWasClicked = NO;
57 >
58 >  return self;
59   }
60  
61   - (int) numberOfRowsInTableView: (NSTableView *) table
# Line 131 | Line 140 | static NSString *getStringFromPrefs(cons
140    [useRawKeyCodes setIntValue: PrefsFindBool("keycodes") ];
141    [rawKeyCodes setStringValue: getStringFromPrefs("keycodefile") ];
142    [rawKeyCodes setEnabled:[useRawKeyCodes intValue]];
143 +  [browseRawKeyCodesButton setEnabled:[useRawKeyCodes intValue]];
144  
145    int wheelmode = PrefsFindInt32("mousewheelmode"), wheel = 0;
146    switch (wheelmode) {
# Line 155 | Line 165 | static NSString *getStringFromPrefs(cons
165  
166   - (void) editSettingsFor: (NSString *) vmdir sender: (id) sender
167   {
168 <        chdir([vmdir fileSystemRepresentation]);
168 >  chdir([vmdir fileSystemRepresentation]);
169 >  AddPrefsDefaults();
170 >  AddPlatformPrefsDefaults();
171 >  LoadPrefs([vmdir fileSystemRepresentation]);
172 >  NSWindow *window = [self window];
173 >  [self setupGUI];
174 >  [NSApp runModalForWindow:window];
175 > }
176 >
177 > - (void) editSettingsForNewVM: (NSString *) vmdir sender: (id) sender
178 > {
179 >  chdir([vmdir fileSystemRepresentation]);
180    AddPrefsDefaults();
181    AddPlatformPrefsDefaults();
182    LoadPrefs([vmdir fileSystemRepresentation]);
183 <        NSWindow *window = [self window];
184 <        [self setupGUI];
185 <        [NSApp runModalForWindow:window];
183 >  PrefsReplaceString("screen", "win/800/600");
184 >  PrefsReplaceString("extfs", "");
185 >  PrefsReplaceString("ether", "slirp");
186 >  PrefsReplaceInt32("ramsize", 64 << 20);
187 >  PrefsReplaceInt32("frameskip", 2);
188 >  PrefsReplaceBool("jit", true);
189 >  NSWindow *window = [self window];
190 >  [self setupGUI];
191 >  [NSApp runModalForWindow:window];
192   }
193  
194   static NSString *makeRelativeIfNecessary(NSString *path)
195   {
196 <        char cwd[1024], filename[1024];
197 <        int cwdlen;
198 <        strlcpy(filename, [path fileSystemRepresentation], sizeof(filename));
199 <        getcwd(cwd, sizeof(cwd));
200 <        cwdlen = strlen(cwd);
201 <        if (!strncmp(cwd, filename, cwdlen)) {
202 <                if (cwdlen >= 0 && cwd[cwdlen-1] != '/')
203 <                        cwdlen++;
204 <                return [NSString stringWithCString: filename + cwdlen];
205 <        }
206 <        return path;
196 >  char cwd[1024], filename[1024];
197 >  int cwdlen;
198 >  strlcpy(filename, [path fileSystemRepresentation], sizeof(filename));
199 >  getcwd(cwd, sizeof(cwd));
200 >  cwdlen = strlen(cwd);
201 >  if (!strncmp(cwd, filename, cwdlen)) {
202 >    if (cwdlen >= 0 && cwd[cwdlen-1] != '/')
203 >      cwdlen++;
204 >    return [NSString stringWithCString: filename + cwdlen];
205 >  }
206 >  return path;
207   }
208  
209   - (IBAction) addDisk: (id) sender
# Line 184 | Line 211 | static NSString *makeRelativeIfNecessary
211    NSOpenPanel *open = [NSOpenPanel openPanel];
212    [open setCanChooseDirectories:NO];
213    [open setAllowsMultipleSelection:NO];
214 <  [open beginSheetForDirectory: @""
214 >  [open setTreatsFilePackagesAsDirectories:YES];
215 >  [open beginSheetForDirectory: [[NSFileManager defaultManager] currentDirectoryPath]
216                            file: @"Unknown"
217                  modalForWindow: [self window]
218                   modalDelegate: self
# Line 195 | Line 223 | static NSString *makeRelativeIfNecessary
223   - (void) _addDiskEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
224   {
225    if (theReturnCode == NSOKButton) {
226 <                [diskArray addObject: makeRelativeIfNecessary([open filename])];
226 >    [diskArray addObject: makeRelativeIfNecessary([open filename])];
227      [disks reloadData];
228    }
229   }
# Line 213 | Line 241 | static NSString *makeRelativeIfNecessary
241   {
242    NSSavePanel *save = [NSSavePanel savePanel];
243    [save setAccessoryView: diskSaveSize];
244 <  [save beginSheetForDirectory: @""
244 >  [save setTreatsFilePackagesAsDirectories:YES];
245 >  [save beginSheetForDirectory: [[NSFileManager defaultManager] currentDirectoryPath]
246                            file: @"New.dsk"
247                  modalForWindow: [self window]
248                   modalDelegate: self
# Line 230 | Line 259 | static NSString *makeRelativeIfNecessary
259        snprintf(cmd, sizeof(cmd), "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", [[save filename] UTF8String], [diskSaveSizeField intValue]);
260        int ret = system(cmd);
261        if (ret == 0) {
262 <                                [diskArray addObject: makeRelativeIfNecessary([save filename])];
262 >        [diskArray addObject: makeRelativeIfNecessary([save filename])];
263          [disks reloadData];
264        }
265      }
# Line 241 | Line 270 | static NSString *makeRelativeIfNecessary
270   - (IBAction) useRawKeyCodesClicked: (id) sender
271   {
272    [rawKeyCodes setEnabled:[useRawKeyCodes intValue]];
273 +  [browseRawKeyCodesButton setEnabled:[useRawKeyCodes intValue]];
274   }
275  
276   - (IBAction) browseForROMFileClicked: (id) sender
# Line 248 | Line 278 | static NSString *makeRelativeIfNecessary
278    NSOpenPanel *open = [NSOpenPanel openPanel];
279    [open setCanChooseDirectories:NO];
280    [open setAllowsMultipleSelection:NO];
281 +  [open setTreatsFilePackagesAsDirectories:YES];
282    [open beginSheetForDirectory: @""
283                            file: [romFile stringValue]
284                  modalForWindow: [self window]
# Line 259 | Line 290 | static NSString *makeRelativeIfNecessary
290   - (void) _browseForROMFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
291   {
292    if (theReturnCode == NSOKButton) {
293 <                [romFile setStringValue: makeRelativeIfNecessary([open filename])];
294 <        }
293 >    [romFile setStringValue: makeRelativeIfNecessary([open filename])];
294 >  }
295   }
296  
297   - (IBAction) browseForUnixRootClicked: (id) sender
# Line 280 | Line 311 | static NSString *makeRelativeIfNecessary
311   - (void) _browseForUnixRootEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
312   {
313    if (theReturnCode == NSOKButton) {
314 <                [unixRoot setStringValue: makeRelativeIfNecessary([open filename])];
314 >    [unixRoot setStringValue: makeRelativeIfNecessary([open filename])];
315 >  }
316 > }
317 >
318 > - (IBAction) browseForKeyCodesFileClicked: (id) sender
319 > {
320 >  NSOpenPanel *open = [NSOpenPanel openPanel];
321 >  [open setCanChooseDirectories:NO];
322 >  [open setAllowsMultipleSelection:NO];
323 >  [open setTreatsFilePackagesAsDirectories:YES];
324 >  [open beginSheetForDirectory: @""
325 >                          file: [unixRoot stringValue]
326 >                modalForWindow: [self window]
327 >                 modalDelegate: self
328 >                didEndSelector: @selector(_browseForKeyCodesFileEnd: returnCode: contextInfo:)
329 >                   contextInfo: nil];
330 > }
331 >
332 > - (void) _browseForKeyCodesFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
333 > {
334 >  if (theReturnCode == NSOKButton) {
335 >    [rawKeyCodes setStringValue: makeRelativeIfNecessary([open filename])];
336    }
337   }
338  
339   - (void) cancelEdit: (id) sender
340   {
341 + #ifdef STANDALONE_PREFS
342    PrefsExit();
343 <        [[self window] close];
344 <        [NSApp stopModal];
343 > #endif
344 >  [[self window] close];
345 >  [NSApp stopModal];
346 >  cancelWasClicked = YES;
347   }
348  
349   - (void) saveChanges: (id) sender
# Line 342 | Line 397 | static NSString *makeRelativeIfNecessary
397    PrefsReplaceString("serialb", [[printerPort stringValue] UTF8String]);
398    PrefsReplaceString("ether", [[ethernetInterface stringValue] UTF8String]);
399    SavePrefs();
400 + #ifdef STANDALONE_PREFS
401    PrefsExit();
402 + #endif
403 +
404 +  [[self window] close];
405 +  [NSApp stopModal];
406 +  cancelWasClicked = NO;
407 + }
408  
409 <        [[self window] close];
410 <        [NSApp stopModal];
409 > - (BOOL) cancelWasClicked
410 > {
411 >  return cancelWasClicked;
412   }
413  
414   - (void) dealloc

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines