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.3 by asvitkine, 2009-08-06T06:42:43Z vs.
Revision 1.4 by asvitkine, 2009-08-06T18:12:24Z

# Line 37 | Line 37 | void prefs_exit()
37  
38   + (id) sharedInstance
39   {
40 <        static VMSettingsController *_sharedInstance = nil;
41 <        if (!_sharedInstance) {
42 <                _sharedInstance = [[VMSettingsController allocWithZone:[self zone]] init];
43 <        }
44 <        return _sharedInstance;
40 >  static VMSettingsController *_sharedInstance = nil;
41 >  if (!_sharedInstance) {
42 >    _sharedInstance = [[VMSettingsController allocWithZone:[self zone]] init];
43 >  }
44 >  return _sharedInstance;
45   }
46  
47   - (id) init
48   {
49    self = [super initWithWindowNibName:@"VMSettingsWindow"];
50  
51 <        cancelWasClicked = NO;
51 >  cancelWasClicked = NO;
52  
53 <        return self;
53 >  return self;
54   }
55  
56   - (int) numberOfRowsInTableView: (NSTableView *) table
# Line 135 | Line 135 | static NSString *getStringFromPrefs(cons
135    [useRawKeyCodes setIntValue: PrefsFindBool("keycodes") ];
136    [rawKeyCodes setStringValue: getStringFromPrefs("keycodefile") ];
137    [rawKeyCodes setEnabled:[useRawKeyCodes intValue]];
138 +  [browseRawKeyCodesButton setEnabled:[useRawKeyCodes intValue]];
139  
140    int wheelmode = PrefsFindInt32("mousewheelmode"), wheel = 0;
141    switch (wheelmode) {
# Line 159 | Line 160 | static NSString *getStringFromPrefs(cons
160  
161   - (void) editSettingsFor: (NSString *) vmdir sender: (id) sender
162   {
163 <        chdir([vmdir fileSystemRepresentation]);
163 >  chdir([vmdir fileSystemRepresentation]);
164    AddPrefsDefaults();
165    AddPlatformPrefsDefaults();
166    LoadPrefs([vmdir fileSystemRepresentation]);
167 <        NSWindow *window = [self window];
168 <        [self setupGUI];
169 <        [NSApp runModalForWindow:window];
167 >  NSWindow *window = [self window];
168 >  [self setupGUI];
169 >  [NSApp runModalForWindow:window];
170   }
171  
172   static NSString *makeRelativeIfNecessary(NSString *path)
173   {
174 <        char cwd[1024], filename[1024];
175 <        int cwdlen;
176 <        strlcpy(filename, [path fileSystemRepresentation], sizeof(filename));
177 <        getcwd(cwd, sizeof(cwd));
178 <        cwdlen = strlen(cwd);
179 <        if (!strncmp(cwd, filename, cwdlen)) {
180 <                if (cwdlen >= 0 && cwd[cwdlen-1] != '/')
181 <                        cwdlen++;
182 <                return [NSString stringWithCString: filename + cwdlen];
183 <        }
184 <        return path;
174 >  char cwd[1024], filename[1024];
175 >  int cwdlen;
176 >  strlcpy(filename, [path fileSystemRepresentation], sizeof(filename));
177 >  getcwd(cwd, sizeof(cwd));
178 >  cwdlen = strlen(cwd);
179 >  if (!strncmp(cwd, filename, cwdlen)) {
180 >    if (cwdlen >= 0 && cwd[cwdlen-1] != '/')
181 >      cwdlen++;
182 >    return [NSString stringWithCString: filename + cwdlen];
183 >  }
184 >  return path;
185   }
186  
187   - (IBAction) addDisk: (id) sender
# Line 200 | Line 201 | static NSString *makeRelativeIfNecessary
201   - (void) _addDiskEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
202   {
203    if (theReturnCode == NSOKButton) {
204 <                [diskArray addObject: makeRelativeIfNecessary([open filename])];
204 >    [diskArray addObject: makeRelativeIfNecessary([open filename])];
205      [disks reloadData];
206    }
207   }
# Line 236 | Line 237 | static NSString *makeRelativeIfNecessary
237        snprintf(cmd, sizeof(cmd), "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", [[save filename] UTF8String], [diskSaveSizeField intValue]);
238        int ret = system(cmd);
239        if (ret == 0) {
240 <                                [diskArray addObject: makeRelativeIfNecessary([save filename])];
240 >        [diskArray addObject: makeRelativeIfNecessary([save filename])];
241          [disks reloadData];
242        }
243      }
# Line 247 | Line 248 | static NSString *makeRelativeIfNecessary
248   - (IBAction) useRawKeyCodesClicked: (id) sender
249   {
250    [rawKeyCodes setEnabled:[useRawKeyCodes intValue]];
251 +  [browseRawKeyCodesButton setEnabled:[useRawKeyCodes intValue]];
252   }
253  
254   - (IBAction) browseForROMFileClicked: (id) sender
# Line 266 | Line 268 | static NSString *makeRelativeIfNecessary
268   - (void) _browseForROMFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
269   {
270    if (theReturnCode == NSOKButton) {
271 <                [romFile setStringValue: makeRelativeIfNecessary([open filename])];
272 <        }
271 >    [romFile setStringValue: makeRelativeIfNecessary([open filename])];
272 >  }
273   }
274  
275   - (IBAction) browseForUnixRootClicked: (id) sender
# Line 287 | Line 289 | static NSString *makeRelativeIfNecessary
289   - (void) _browseForUnixRootEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
290   {
291    if (theReturnCode == NSOKButton) {
292 <                [unixRoot setStringValue: makeRelativeIfNecessary([open filename])];
292 >    [unixRoot setStringValue: makeRelativeIfNecessary([open filename])];
293 >  }
294 > }
295 >
296 > - (IBAction) browseForKeyCodesFileClicked: (id) sender
297 > {
298 >  NSOpenPanel *open = [NSOpenPanel openPanel];
299 >  [open setCanChooseDirectories:NO];
300 >  [open setAllowsMultipleSelection:NO];
301 >  [open setTreatsFilePackagesAsDirectories:YES];
302 >  [open beginSheetForDirectory: @""
303 >                          file: [unixRoot stringValue]
304 >                modalForWindow: [self window]
305 >                 modalDelegate: self
306 >                didEndSelector: @selector(_browseForKeyCodesFileEnd: returnCode: contextInfo:)
307 >                   contextInfo: nil];
308 > }
309 >
310 > - (void) _browseForKeyCodesFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
311 > {
312 >  if (theReturnCode == NSOKButton) {
313 >    [rawKeyCodes setStringValue: makeRelativeIfNecessary([open filename])];
314    }
315   }
316  
317   - (void) cancelEdit: (id) sender
318   {
319    PrefsExit();
320 <        [[self window] close];
321 <        [NSApp stopModal];
322 <        cancelWasClicked = YES;
320 >  [[self window] close];
321 >  [NSApp stopModal];
322 >  cancelWasClicked = YES;
323   }
324  
325   - (void) saveChanges: (id) sender
# Line 352 | Line 375 | static NSString *makeRelativeIfNecessary
375    SavePrefs();
376    PrefsExit();
377  
378 <        [[self window] close];
379 <        [NSApp stopModal];
380 <        cancelWasClicked = NO;
378 >  [[self window] close];
379 >  [NSApp stopModal];
380 >  cancelWasClicked = NO;
381   }
382  
383   - (BOOL) cancelWasClicked

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines