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.5 by asvitkine, 2009-08-18T03:26:17Z

# 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 <  return [super initWithWindowNibName:@"VMSettingsWindow"];
51 >  self = [super initWithWindowNibName:@"VMSettingsWindow"];
52 >
53 >  cancelWasClicked = NO;
54 >
55 >  return self;
56   }
57  
58   - (int) numberOfRowsInTableView: (NSTableView *) table
# Line 131 | 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 155 | 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];
169 >  NSWindow *window = [self window];
170 >  [self setupGUI];
171 >  [NSApp runModalForWindow:window];
172   }
173  
174   static NSString *makeRelativeIfNecessary(NSString *path)
175   {
176 <        char cwd[1024], filename[1024];
177 <        int cwdlen;
178 <        strlcpy(filename, [path fileSystemRepresentation], sizeof(filename));
179 <        getcwd(cwd, sizeof(cwd));
180 <        cwdlen = strlen(cwd);
181 <        if (!strncmp(cwd, filename, cwdlen)) {
182 <                if (cwdlen >= 0 && cwd[cwdlen-1] != '/')
183 <                        cwdlen++;
184 <                return [NSString stringWithCString: filename + cwdlen];
185 <        }
186 <        return path;
176 >  char cwd[1024], filename[1024];
177 >  int cwdlen;
178 >  strlcpy(filename, [path fileSystemRepresentation], sizeof(filename));
179 >  getcwd(cwd, sizeof(cwd));
180 >  cwdlen = strlen(cwd);
181 >  if (!strncmp(cwd, filename, cwdlen)) {
182 >    if (cwdlen >= 0 && cwd[cwdlen-1] != '/')
183 >      cwdlen++;
184 >    return [NSString stringWithCString: filename + cwdlen];
185 >  }
186 >  return path;
187   }
188  
189   - (IBAction) addDisk: (id) sender
# Line 184 | Line 191 | static NSString *makeRelativeIfNecessary
191    NSOpenPanel *open = [NSOpenPanel openPanel];
192    [open setCanChooseDirectories:NO];
193    [open setAllowsMultipleSelection:NO];
194 <  [open beginSheetForDirectory: @""
194 >  [open setTreatsFilePackagesAsDirectories:YES];
195 >  [open beginSheetForDirectory: [[NSFileManager defaultManager] currentDirectoryPath]
196                            file: @"Unknown"
197                  modalForWindow: [self window]
198                   modalDelegate: self
# Line 195 | Line 203 | static NSString *makeRelativeIfNecessary
203   - (void) _addDiskEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
204   {
205    if (theReturnCode == NSOKButton) {
206 <                [diskArray addObject: makeRelativeIfNecessary([open filename])];
206 >    [diskArray addObject: makeRelativeIfNecessary([open filename])];
207      [disks reloadData];
208    }
209   }
# Line 213 | Line 221 | static NSString *makeRelativeIfNecessary
221   {
222    NSSavePanel *save = [NSSavePanel savePanel];
223    [save setAccessoryView: diskSaveSize];
224 <  [save beginSheetForDirectory: @""
224 >  [save setTreatsFilePackagesAsDirectories:YES];
225 >  [save beginSheetForDirectory: [[NSFileManager defaultManager] currentDirectoryPath]
226                            file: @"New.dsk"
227                  modalForWindow: [self window]
228                   modalDelegate: self
# Line 230 | Line 239 | static NSString *makeRelativeIfNecessary
239        snprintf(cmd, sizeof(cmd), "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", [[save filename] UTF8String], [diskSaveSizeField intValue]);
240        int ret = system(cmd);
241        if (ret == 0) {
242 <                                [diskArray addObject: makeRelativeIfNecessary([save filename])];
242 >        [diskArray addObject: makeRelativeIfNecessary([save filename])];
243          [disks reloadData];
244        }
245      }
# Line 241 | Line 250 | static NSString *makeRelativeIfNecessary
250   - (IBAction) useRawKeyCodesClicked: (id) sender
251   {
252    [rawKeyCodes setEnabled:[useRawKeyCodes intValue]];
253 +  [browseRawKeyCodesButton setEnabled:[useRawKeyCodes intValue]];
254   }
255  
256   - (IBAction) browseForROMFileClicked: (id) sender
# Line 248 | Line 258 | static NSString *makeRelativeIfNecessary
258    NSOpenPanel *open = [NSOpenPanel openPanel];
259    [open setCanChooseDirectories:NO];
260    [open setAllowsMultipleSelection:NO];
261 +  [open setTreatsFilePackagesAsDirectories:YES];
262    [open beginSheetForDirectory: @""
263                            file: [romFile stringValue]
264                  modalForWindow: [self window]
# Line 259 | Line 270 | static NSString *makeRelativeIfNecessary
270   - (void) _browseForROMFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
271   {
272    if (theReturnCode == NSOKButton) {
273 <                [romFile setStringValue: makeRelativeIfNecessary([open filename])];
274 <        }
273 >    [romFile setStringValue: makeRelativeIfNecessary([open filename])];
274 >  }
275   }
276  
277   - (IBAction) browseForUnixRootClicked: (id) sender
# Line 280 | Line 291 | static NSString *makeRelativeIfNecessary
291   - (void) _browseForUnixRootEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
292   {
293    if (theReturnCode == NSOKButton) {
294 <                [unixRoot setStringValue: makeRelativeIfNecessary([open filename])];
294 >    [unixRoot setStringValue: makeRelativeIfNecessary([open filename])];
295 >  }
296 > }
297 >
298 > - (IBAction) browseForKeyCodesFileClicked: (id) sender
299 > {
300 >  NSOpenPanel *open = [NSOpenPanel openPanel];
301 >  [open setCanChooseDirectories:NO];
302 >  [open setAllowsMultipleSelection:NO];
303 >  [open setTreatsFilePackagesAsDirectories:YES];
304 >  [open beginSheetForDirectory: @""
305 >                          file: [unixRoot stringValue]
306 >                modalForWindow: [self window]
307 >                 modalDelegate: self
308 >                didEndSelector: @selector(_browseForKeyCodesFileEnd: returnCode: contextInfo:)
309 >                   contextInfo: nil];
310 > }
311 >
312 > - (void) _browseForKeyCodesFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
313 > {
314 >  if (theReturnCode == NSOKButton) {
315 >    [rawKeyCodes setStringValue: makeRelativeIfNecessary([open filename])];
316    }
317   }
318  
319   - (void) cancelEdit: (id) sender
320   {
321 + #ifdef STANDALONE_PREFS
322    PrefsExit();
323 <        [[self window] close];
324 <        [NSApp stopModal];
323 > #endif
324 >  [[self window] close];
325 >  [NSApp stopModal];
326 >  cancelWasClicked = YES;
327   }
328  
329   - (void) saveChanges: (id) sender
# Line 342 | Line 377 | static NSString *makeRelativeIfNecessary
377    PrefsReplaceString("serialb", [[printerPort stringValue] UTF8String]);
378    PrefsReplaceString("ether", [[ethernetInterface stringValue] UTF8String]);
379    SavePrefs();
380 + #ifdef STANDALONE_PREFS
381    PrefsExit();
382 + #endif
383  
384 <        [[self window] close];
385 <        [NSApp stopModal];
384 >  [[self window] close];
385 >  [NSApp stopModal];
386 >  cancelWasClicked = NO;
387 > }
388 >
389 > - (BOOL) cancelWasClicked
390 > {
391 >  return cancelWasClicked;
392   }
393  
394   - (void) dealloc

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines