4 |
|
* |
5 |
|
* $Id$ |
6 |
|
* |
7 |
< |
* Basilisk II (C) 1997-2004 Christian Bauer |
7 |
> |
* Basilisk II (C) 1997-2005 Christian Bauer |
8 |
|
* |
9 |
|
* This program is free software; you can redistribute it and/or modify |
10 |
|
* it under the terms of the GNU General Public License as published by |
105 |
|
|
106 |
|
@end |
107 |
|
|
108 |
– |
@implementation PrefsEditor |
109 |
– |
|
108 |
|
#import <AppKit/NSImage.h> // For [NSBundle pathForImageResource:] proto |
109 |
|
|
110 |
|
#include <string> |
114 |
|
#import "sysdeps.h" // Types used in Basilisk C++ code |
115 |
|
#import "video_macosx.h" // some items that we edit here |
116 |
|
#import "misc_macosx.h" // WarningSheet() prototype |
117 |
+ |
#import "main_macosx.h" // ChoiceAlert() prototype |
118 |
+ |
|
119 |
|
|
120 |
|
#import <prefs.h> |
121 |
|
|
122 |
|
#define DEBUG 0 |
123 |
|
#import <debug.h> |
124 |
|
|
125 |
+ |
@implementation PrefsEditor |
126 |
+ |
|
127 |
|
- (PrefsEditor *) init |
128 |
|
{ |
129 |
|
self = [super init]; |
198 |
|
{ |
199 |
|
[volsDS addObject: (NSObject *) locked |
200 |
|
withPath: [oP filename] ]; |
201 |
< |
PrefsAddString("disk", [[oP filename] cString]); |
201 |
> |
PrefsAddString("disk", [[oP filename] UTF8String]); |
202 |
|
[diskImages reloadData]; |
203 |
|
edited = YES; |
204 |
|
} |
219 |
|
types:nil] == NSOKButton ) |
220 |
|
{ |
221 |
|
[extFS setStringValue: [oP directory] ]; |
222 |
< |
PrefsReplaceString("extfs", [[oP directory] cString]); |
222 |
> |
PrefsReplaceString("extfs", [[oP directory] UTF8String]); |
223 |
|
edited = YES; |
224 |
|
} |
225 |
|
} |
236 |
|
types:nil] == NSOKButton ) |
237 |
|
{ |
238 |
|
[prefsFile setStringValue: [oP filename] ]; |
239 |
< |
UserPrefsPath = [[oP filename] cString]; |
239 |
> |
UserPrefsPath = [[oP filename] UTF8String]; |
240 |
|
} |
241 |
|
} |
242 |
|
|
252 |
|
types:nil] == NSOKButton ) |
253 |
|
{ |
254 |
|
[ROMfile setStringValue: [oP filename] ]; |
255 |
< |
PrefsReplaceString("rom", [[oP filename] cString]); |
255 |
> |
PrefsReplaceString("rom", [[oP filename] UTF8String]); |
256 |
|
edited = YES; |
257 |
|
} |
258 |
|
} |
261 |
|
|
262 |
|
- (IBAction) ChangeBootFrom: (NSMatrix *)sender |
263 |
|
{ |
264 |
< |
if ( [sender selectedCell] == bootFromCD ) |
264 |
> |
if ( [sender selectedCell] == (id)bootFromCD ) |
265 |
|
PrefsReplaceInt32("bootdriver", CDROMRefNum); |
266 |
|
else |
267 |
|
PrefsReplaceInt32("bootdriver", 0); |
436 |
|
if ( [sP runModalForDirectory:NSHomeDirectory() file:@"basilisk-II.vol"] == NSOKButton ) |
437 |
|
{ |
438 |
|
char cmd[1024]; |
439 |
< |
const char *filename = [[sP filename] cString]; |
439 |
> |
const char *filename = [[sP filename] UTF8String]; |
440 |
|
int retVal, |
441 |
|
size = [newVolumeSize intValue]; |
442 |
|
|
443 |
|
sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", filename, size); |
444 |
+ |
|
445 |
|
retVal = system(cmd); |
446 |
|
if (retVal != 0) |
447 |
|
{ |
474 |
|
|
475 |
|
- (IBAction) DeleteVolume: (id)sender |
476 |
|
{ |
474 |
– |
// const char *path = [self RemoveVolumeEntry]; |
475 |
– |
// if ( unlink(path) == -1 ) |
477 |
|
NSString *Path = [self RemoveVolumeEntry]; |
478 |
|
|
479 |
+ |
if ( ! Path ) |
480 |
+ |
return; |
481 |
+ |
|
482 |
|
if ( ! [[NSFileManager defaultManager] removeFileAtPath: Path |
483 |
|
handler: self] ) |
484 |
|
{ |
485 |
|
WarningSheet(@"Unable to delete volume", panel); |
486 |
< |
// NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, path, strerror(errno)); |
486 |
> |
NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, |
487 |
> |
[Path cString], strerror(errno)); |
488 |
|
} |
489 |
|
} |
490 |
|
|
519 |
|
{ |
520 |
|
NSString *path = [etherNet stringValue]; |
521 |
|
|
522 |
< |
PrefsReplaceString("ether", [path cString]); |
522 |
> |
PrefsReplaceString("ether", [path UTF8String]); |
523 |
|
edited = YES; |
524 |
|
} |
525 |
|
|
527 |
|
{ |
528 |
|
NSString *path = [extFS stringValue]; |
529 |
|
|
530 |
< |
PrefsReplaceString("extfs", [path cString]); |
530 |
> |
PrefsReplaceString("extfs", [path UTF8String]); |
531 |
|
edited = YES; |
532 |
|
} |
533 |
|
|
544 |
|
{ |
545 |
|
NSString *path = [modem stringValue]; |
546 |
|
|
547 |
< |
PrefsReplaceString("seriala", [path cString]); |
547 |
> |
PrefsReplaceString("seriala", [path UTF8String]); |
548 |
|
edited = YES; |
549 |
|
} |
550 |
|
|
563 |
|
{ |
564 |
|
NSString *path = [printer stringValue]; |
565 |
|
|
566 |
< |
PrefsReplaceString("serialb", [path cString]); |
566 |
> |
PrefsReplaceString("serialb", [path UTF8String]); |
567 |
|
edited = YES; |
568 |
|
} |
569 |
|
|
571 |
|
{ |
572 |
|
NSString *path = [ROMfile stringValue]; |
573 |
|
|
574 |
< |
PrefsReplaceString("rom", [path cString]); |
574 |
> |
PrefsReplaceString("rom", [path UTF8String]); |
575 |
|
} |
576 |
|
|
577 |
|
- (IBAction) RemoveSCSI: (id)sender |
584 |
|
NSLog (@"%s - [SCSIds deleteRow: %d] failed", __PRETTY_FUNCTION__, row); |
585 |
|
[SCSIdisks reloadData]; |
586 |
|
sprintf(pref, "scsi%d", SCSIid); |
587 |
< |
PrefsRemoveItem(pref,0); |
587 |
> |
//PrefsRemoveItem(pref,0); |
588 |
> |
PrefsRemoveItem(pref, 1); |
589 |
|
} |
590 |
|
|
585 |
– |
//- (const char *) RemoveVolumeEntry |
591 |
|
- (NSString *) RemoveVolumeEntry |
592 |
|
{ |
593 |
|
int row = [diskImages selectedRow]; |
595 |
|
if ( row != -1 ) |
596 |
|
{ |
597 |
|
NSString *Path = [volsDS pathAtRow: row]; |
598 |
< |
const char *path = [Path cString], |
598 |
> |
const char *path = [Path UTF8String], |
599 |
|
*str; |
600 |
|
int tmp = 0; |
601 |
|
|
602 |
+ |
NSString *prompt = [NSString stringWithFormat: @"%s\n%s", |
603 |
+ |
"Are you sure you want to delete the file", |
604 |
+ |
path]; |
605 |
+ |
|
606 |
+ |
if ( ! ChoiceAlert([prompt cString], "Delete", "Cancel") ) |
607 |
+ |
return NULL; |
608 |
+ |
|
609 |
|
while ( (str = PrefsFindString("disk", tmp) ) != NULL ) |
610 |
|
{ |
611 |
|
if ( strcmp(str, path) == 0 ) |
668 |
|
char *argv[2]; |
669 |
|
|
670 |
|
argv[0] = "--prefs", |
671 |
< |
argv[1] = (char *) [[prefsFile stringValue] cString]; |
671 |
> |
argv[1] = (char *) [[prefsFile stringValue] UTF8String]; |
672 |
|
|
673 |
|
[self loadPrefs: argc |
674 |
|
args: argv]; |
681 |
|
} |
682 |
|
|
683 |
|
- (void) setStringOf: (NSTextField *) field |
684 |
< |
fromPref: (const char *) prefName |
684 |
> |
fromPref: (const char *) prefName |
685 |
|
{ |
686 |
|
const char *value = PrefsFindString(prefName, 0); |
687 |
|
|
688 |
|
if ( value ) |
689 |
< |
[field setStringValue: [NSString stringWithCString: value] ]; |
689 |
> |
[field setStringValue: [NSString stringWithUTF8String: value] ]; |
690 |
|
} |
691 |
|
|
692 |
|
- (IBAction) SavePrefs: (id)sender |
723 |
|
[self setStringOf: extFS fromPref: "extfs" ]; |
724 |
|
[self setStringOf: modem fromPref: "seriala"]; |
725 |
|
[self setStringOf: printer fromPref: "serialb"]; |
726 |
< |
[self setStringOf: ROMfile fromPref: "rom" ]; |
726 |
> |
[self setStringOf: ROMfile fromPref: "rom"]; |
727 |
|
|
728 |
< |
[prefsFile setStringValue: [NSString stringWithCString: UserPrefsPath.c_str()] ]; |
728 |
> |
[prefsFile setStringValue: [NSString stringWithUTF8String: UserPrefsPath.c_str()] ]; |
729 |
|
|
730 |
|
|
731 |
|
parse_screen_prefs(PrefsFindString("screen")); |
818 |
|
{ |
819 |
|
if ( *str == '*' ) |
820 |
|
[volsDS addObject: (NSObject *) locked |
821 |
< |
withPath: [NSString stringWithCString: str+1]]; |
821 |
> |
withPath: [NSString stringWithUTF8String: str+1]]; |
822 |
|
else |
823 |
|
[volsDS addObject: (NSObject *) blank |
824 |
< |
withPath: [NSString stringWithCString: str]]; |
824 |
> |
withPath: [NSString stringWithUTF8String: str]]; |
825 |
|
} |
826 |
|
|
827 |
|
[diskImages setDataSource: volsDS]; |