Some updates for the OS X GUI, mostly code cosmetics.

Thanks to Jerome Vernet for the patch.
This commit is contained in:
Thomas Huth 2014-06-26 10:17:18 +02:00
parent 1d245c826b
commit 1ed1b447fe
10 changed files with 194 additions and 169 deletions

View File

@ -41,6 +41,11 @@ website/screens
*.1.gz
doc/doxygen/html
# These are for XCode on Mac OS X:
build/*
Hatari.build/*
Release/*
# switch to regexp syntax.
syntax: regexp

View File

@ -21,9 +21,25 @@
*/
int HookedAlertNotice(const char* szMessage)
{
// NSLog(@"Notice: %@", [NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding] ) ;
return (NSAlertDefaultReturn == NSRunInformationalAlertPanel(@"Hatari", localize([NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding]),
localize(@"Ok"), nil, nil));
NSString *message ;
NSRange cantTOS, firstPv, lastPv ;
NSAlert *lalerte ;
message = [NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding] ;
//NSLog(@"Notice: %@", message ) ;
cantTOS = [message rangeOfString:@"Can not load TOS file:"] ;
firstPv = [message rangeOfString:@"'"] ;
lastPv = [message rangeOfString:@"'" options:NSBackwardsSearch] ;
if ((cantTOS.location == NSNotFound) || (firstPv.location==lastPv.location))
return (NSAlertDefaultReturn == NSRunInformationalAlertPanel(@"Hatari", localize(message), localize(@"Ok"), nil, nil));
firstPv.location++ ; firstPv.length = lastPv.location-firstPv.location ;
lalerte = [NSAlert alertWithMessageText:@"Hatari" defaultButton:localize(@"Ok") alternateButton:nil otherButton:nil
informativeTextWithFormat:localize(@"Can not load TOS file:"), [NSApp pathUser:[message substringWithRange:firstPv]]] ;
[lalerte runModal] ;
return YES ;
}
/*-----------------------------------------------------------------------*/

View File

@ -32,7 +32,7 @@ char szPath[FILENAME_MAX] ;
defaultDir = [NSString stringWithCString:ConfigureParams.DiskImage.szDiskImageDirectory encoding:NSASCIIStringEncoding];
// Run the SavePanel, then check if the user clicked OK
newCnf = [NSApp sauver:YES defoDir:defaultDir defoFile:nil types:[NSArray arrayWithObjects: allF, nil] ] ;
newCnf = [NSApp hsavefile:YES defoDir:defaultDir defoFile:nil types:[NSArray arrayWithObjects: allF, nil] ] ;
if ([newCnf length] != 0)
{
[newCnf getCString:szPath maxLength:FILENAME_MAX-1 encoding:NSASCIIStringEncoding] ;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="12F45" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1050" identifier="macosx"/>
<deployment version="1050" defaultVersion="1080" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
</dependencies>
<objects>
@ -61,22 +61,26 @@
<menuItem title="File" id="306">
<menu key="submenu" title="File" id="312">
<items>
<menuItem title="Insert Disk A..." keyEquivalent="A" id="309">
<menuItem title="Insert Disk A..." id="wRm-ih-tK4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="insertDiskA:" target="194" id="4611"/>
<action selector="insertDiskA:" target="194" id="hVf-bm-N4E"/>
</connections>
</menuItem>
<menuItem title="Insert Disk B..." keyEquivalent="B" id="311">
<menuItem title="Insert Disk B..." id="311">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="insertDiskB:" target="194" id="323"/>
</connections>
</menuItem>
<menuItem title="Create Blank Floppy..." keyEquivalent="V" id="595">
<menuItem title="Create Blank Floppy..." id="595">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="runModal:" target="687" id="843"/>
</connections>
</menuItem>
<menuItem title="Load Config..." keyEquivalent="o" id="4622">
<menuItem title="Load Config..." id="4622">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openConfig:" target="194" id="4623"/>
</connections>
@ -87,28 +91,32 @@
<menuItem title="Capture" id="607">
<menu key="submenu" title="Capture" id="608">
<items>
<menuItem title="Screen" keyEquivalent="p" id="609">
<modifierMask key="keyEquivalentModifierMask" control="YES" option="YES" command="YES"/>
<menuItem title="Screen" id="609">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="captureScreen:" target="194" id="828"/>
</connections>
</menuItem>
<menuItem title="Begin Animation Capture" id="610" userLabel="startCapture">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="captureAnimation:" target="194" id="829"/>
</connections>
</menuItem>
<menuItem title="End Animation Capture" id="834">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="endCaptureAnimation:" target="194" id="4615"/>
</connections>
</menuItem>
<menuItem title="Begin Sound Capture (.ym/.wav)..." id="611">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="captureSound:" target="194" id="830"/>
</connections>
</menuItem>
<menuItem title="End Sound Capture" id="835">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="endCaptureSound:" target="194" id="841"/>
</connections>
@ -123,11 +131,13 @@
<menu key="submenu" title="Memory Snapshot" id="604">
<items>
<menuItem title="Save..." id="605">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="saveMemorySnap:" target="194" id="848"/>
</connections>
</menuItem>
<menuItem title="Restore..." id="606">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="restoreMemorySnap:" target="194" id="849"/>
</connections>
@ -169,11 +179,6 @@
<menuItem title="Window" id="284">
<menu key="submenu" title="Window" systemMenu="window" id="285">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="283">
<connections>
<action selector="performMiniaturize:" target="-1" id="288"/>
</connections>
</menuItem>
<menuItem title="Full Screen" offStateImage="NSEnterFullScreenTemplate" keyEquivalent="f" id="1241">
<connections>
<action selector="doFullScreen:" target="194" id="1246"/>
@ -663,7 +668,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" id="513">
<rect key="frame" x="17" y="342" width="158" height="17"/>
<rect key="frame" x="72" y="342" width="108" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" id="4493">
<font key="font" metaFont="system"/>
@ -1952,7 +1957,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button id="2923">
<rect key="frame" x="81" y="324" width="134" height="18"/>
<rect key="frame" x="81" y="324" width="134" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Confirm Quit" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" imageScaling="proportionallyDown" inset="2" id="4497">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>

View File

@ -166,8 +166,7 @@
<object class="NSMenuItem" id="503465775">
<reference key="NSMenu" ref="26114148"/>
<string key="NSTitle">Inserer Disque A...</string>
<string key="NSKeyEquiv">A</string>
<int key="NSKeyEquivModMask">1048576</int>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -175,8 +174,7 @@
<object class="NSMenuItem" id="477162751">
<reference key="NSMenu" ref="26114148"/>
<string key="NSTitle">Inserer Disque B...</string>
<string key="NSKeyEquiv">B</string>
<int key="NSKeyEquivModMask">1048576</int>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -184,8 +182,7 @@
<object class="NSMenuItem" id="510526516">
<reference key="NSMenu" ref="26114148"/>
<string key="NSTitle">Créer Disquette Vierge...</string>
<string key="NSKeyEquiv">V</string>
<int key="NSKeyEquivModMask">1048576</int>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -193,8 +190,7 @@
<object class="NSMenuItem" id="657617717">
<reference key="NSMenu" ref="26114148"/>
<string key="NSTitle">Charge Config...</string>
<string key="NSKeyEquiv">o</string>
<int key="NSKeyEquivModMask">1048576</int>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -225,8 +221,7 @@
<object class="NSMenuItem" id="314193243">
<reference key="NSMenu" ref="63374293"/>
<string key="NSTitle">Ecran</string>
<string key="NSKeyEquiv">p</string>
<int key="NSKeyEquivModMask">1835008</int>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -235,7 +230,6 @@
<reference key="NSMenu" ref="63374293"/>
<string key="NSTitle">Début Capture Animation</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -244,7 +238,6 @@
<reference key="NSMenu" ref="63374293"/>
<string key="NSTitle">Arreter Capture Animation</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -253,7 +246,6 @@
<reference key="NSMenu" ref="63374293"/>
<string key="NSTitle">Enregistrer Son (.ym/.wav)...</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -262,7 +254,6 @@
<reference key="NSMenu" ref="63374293"/>
<string key="NSTitle">Arreter Enregistrement Son</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -297,7 +288,6 @@
<reference key="NSMenu" ref="188743164"/>
<string key="NSTitle">Sauver...</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -306,7 +296,6 @@
<reference key="NSMenu" ref="188743164"/>
<string key="NSTitle">Restorer...</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1047744906"/>
<reference key="NSMixedImage" ref="40280553"/>
@ -529,7 +518,6 @@
<string key="NSFrame">{{13, 40}, {663, 422}}</string>
<reference key="NSSuperview" ref="443493239"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="372820215"/>
<array class="NSMutableArray" key="NSTabViewItems">
<object class="NSTabViewItem" id="884471291">
<string key="NSIdentifier">1</string>

View File

@ -66,7 +66,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.7.0b</string>
<string>1.8.0b</string>
<key>CFBundleSignature</key>
<string>HATA</string>
<key>CFBundleVersion</key>

View File

@ -249,7 +249,7 @@ char szPath[FILENAME_MAX];
{ directoryToOpen = [defaultInitialDir stringByExpandingTildeInPath]; // no path: use user's directory
fileToPreselect = nil; } ;
newPath = [NSApp ouvrir:chooseDirectories defoDir:defaultInitialDir defoFile:nil types:what] ;
newPath = [NSApp hopenfile:chooseDirectories defoDir:defaultInitialDir defoFile:nil types:what] ;
if ([newPath length] != 0) // user canceled if empty
{
[mutString setString:[NSString stringWithString:newPath]] ; // save this path
@ -445,7 +445,13 @@ BOOL flag1, flag2;
[opnPanel setCanChooseFiles: YES];
[opnPanel setAccessoryView:partage] ;
btOk = [opnPanel runModalForDirectory:ru file:@"hatari"] == NSOKButton ; // Ok ? under 10.5
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1058
[opnPanel setDirectoryURL:[NSURL URLWithString:ru]] ;
[opnPanel setNameFieldStringValue:@"hatari"] ;
btOk = [opnPanel runModal] == NSOKButton ; // Ok ?
#else // */
btOk = [opnPanel runModalForDirectory:ru file:@"hatari"] == NSOKButton ; // Ok ? sous 10.5
#endif
if (!btOk) return ; // Cancel
@ -477,16 +483,18 @@ BOOL btOk ;
[savPanel setAllowedFileTypes:[NSArray arrayWithObject:@"cfg"]] ;
[savPanel setAccessoryView:hartage] ;
/* if ([NSSavePanel instancesRespondToSelector:@selector(setDirectoryURL:)])
{
[savPanel setDirectoryURL:[NSURL URLWithString:ru]] ; // A partir de 10.6
[savPanel setNameFieldStringValue:@"hatari"] ;
btOk = [savPanel runModal] == NSOKButton ; // Ok ?
}
else */
btOk = [savPanel runModalForDirectory:ru file:@"hatari"] == NSOKButton ; // Ok ?
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1058
if (!btOk) return ; // Annuler
[savPanel setDirectoryURL:[NSURL URLWithString:ru]] ; // A partir de 10.6
[savPanel setNameFieldStringValue:@"hatari"] ;
btOk = [savPanel runModal] == NSOKButton ; // Ok ?
#else // */
btOk = [savPanel runModalForDirectory:ru file:@"hatari"] == NSOKButton ; // Ok ?
#endif
if (!btOk)
return ; // Cancel
[configNm setString:[[savPanel URL] path]];
@ -501,10 +509,11 @@ BOOL btOk ;
NSString *defaultDirectory ;
defaultDirectory = [NSString stringWithCString:(Paths_GetHatariHome()) encoding:NSASCIIStringEncoding] ;
/* if ([NSOpenPanel instancesRespondToSelector:@selector(setDirectoryURL:)])
[opnPanel setDirectoryURL:[NSURL URLWithString:defaultDirectory]] ;
else // */
[opnPanel setDirectory:defaultDirectory] ;
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1058
[opnPanel setDirectoryURL:[NSURL URLWithString:defaultDirectory]] ;
#else // */
[opnPanel setDirectory:defaultDirectory] ;
#endif
}
- (IBAction)halle:(id)sender
@ -512,10 +521,11 @@ NSString *defaultDirectory ;
NSString *defaultDirectory ;
defaultDirectory = [NSString stringWithCString:(Paths_GetHatariHome()) encoding:NSASCIIStringEncoding] ;
/* if ([NSSavePanel instancesRespondToSelector:@selector(setDirectoryURL:)])
[savPanel setDirectoryURL:[NSURL URLWithString:defaultDirectory]] ;
else */
[savPanel setDirectory:defaultDirectory] ;
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1058
[savPanel setDirectoryURL:[NSURL URLWithString:defaultDirectory]] ;
#else // */
[savPanel setDirectory:defaultDirectory] ;
#endif
}
@ -525,20 +535,13 @@ NSString *defaultDirectory ;
*/
- (IBAction)commitAndClose:(id)sender
{
applyChanges = true; // applyChanges moved in interface
// The user clicked OK
[self saveAllControls];
// If a reset is required, ask the user first
if (Change_DoNeedReset(&CurrentParams, &ConfigureParams))
applyChanges = NSRunAlertPanel (localize(@"Reset the emulator"), localize(@"Must be reset"),
localize(@"Don't reset"), localize(@"Reset"), nil) == NSAlertAlternateReturn ;
// Close the window
[window close] ;
//GuiOsx_Resume();
}
// Populate Joystick key dropdown
@ -604,6 +607,7 @@ NSString *defaultDirectory ;
// Backup of configuration settings to CurrentParams (which we will only
// commit back to the configuration settings if choosing OK)
CurrentParams = ConfigureParams;
applyChanges=false;
[self setAllControls];
@ -614,14 +618,28 @@ NSString *defaultDirectory ;
[mw release]; // */
if (applyChanges) // solve bug screen-reset
Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, true) ;
else
ConfigureParams = CurrentParams;
//GuiOsx_Pause();
//[[NSApplication sharedApplication] runModalForWindow:window];
// solve bug screen-reset: close and kill preference windows before
// M. Saro, 2013
//if(Ok button in preferences Windows)
{
// Check if change need reset
if (Change_DoNeedReset(&CurrentParams, &ConfigureParams))
{
applyChanges = NSRunAlertPanel(localize(@"Reset the emulator"), localize(@"Must be reset"),
localize(@"Don't reset"), localize(@"Reset"), nil) == NSAlertAlternateReturn ;
if (applyChanges) Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, true) ;
else
ConfigureParams = CurrentParams; //Restore backup params
}
else
Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, false); //Apply config without reset
}
// else // not OK button
// {
// ConfigureParams = CurrentParams; //Restore backup params
// }
}
/*-----------------------------------------------------------------------*/

View File

@ -195,12 +195,12 @@ char szPath[FILENAME_MAX] ; // for general use
- (void)insertDisk:(int)disque
{
NSString *ceDisk ;
NSString *aDisk ;
ceDisk = [NSApp ouvrir:NO defoDir:nil defoFile:@"" types:[NSArray arrayWithObjects:allF,nil]] ;
if ([ceDisk length] == 0) return ; // user canceled
aDisk = [NSApp hopenfile:NO defoDir:nil defoFile:@"" types:[NSArray arrayWithObjects:allF,nil]] ;
if ([aDisk length] == 0) return ; // user canceled
[ceDisk getCString:szPath maxLength:FILENAME_MAX-1 encoding:NSASCIIStringEncoding] ;
[aDisk getCString:szPath maxLength:FILENAME_MAX-1 encoding:NSASCIIStringEncoding] ;
Floppy_SetDiskFileName(disque, szPath, NULL) ;
Floppy_InsertDiskIntoDrive(disque) ;
}
@ -234,12 +234,12 @@ char szPath[FILENAME_MAX] ; // for general use
- (NSString*)displayFileSelection:(const char*)pathInParams preferredFileName:(NSString*)preferredFileName allowedExtensions:(NSArray*)allowedExtensions
{
BOOL test ;
NSString *directoryToOpen;
NSString *fileToPreselect;
NSString *preferredPath;
NSString *extensionText;
NSString *selectFile;
// BOOL test ;
NSString *directoryToOpen;
NSString *fileToPreselect;
NSString *preferredPath;
NSString *extensionText;
NSString *selectFile;
// Get the path from the user settings
preferredPath = [[NSString stringWithCString:pathInParams encoding:NSASCIIStringEncoding] stringByAbbreviatingWithTildeInPath];
@ -261,7 +261,7 @@ NSString *selectFile;
// SavePanel for choosing what file to write
extensionText = [NSString stringWithFormat:localize(@"Please specify a .%@ file"), [allowedExtensions componentsJoinedByString:localize(@" or a .")] ];
selectFile = [NSApp sauver:YES defoDir:directoryToOpen defoFile:fileToPreselect types:allowedExtensions titre:extensionText ] ;
selectFile = [NSApp hsavefile:YES defoDir:directoryToOpen defoFile:fileToPreselect types:allowedExtensions titre:extensionText ] ;
if ([selectFile length] != 0 )
return selectFile ;
@ -357,7 +357,7 @@ NSString *newPath ;
{ directoryToOpen = [@"~" stringByExpandingTildeInPath]; // Currently no path: we use user's directory
fileToPreselect = nil; } ;
newPath = [NSApp ouvrir:NO defoDir:directoryToOpen defoFile:fileToPreselect types:[NSArray arrayWithObject:@"sav"] ] ;
newPath = [NSApp hopenfile:NO defoDir:directoryToOpen defoFile:fileToPreselect types:[NSArray arrayWithObject:@"sav"] ] ;
if ([newPath length] != 0) // Perform the memory snapshot load
MemorySnapShot_Restore([newPath cStringUsingEncoding:NSASCIIStringEncoding], TRUE);
@ -384,13 +384,13 @@ NSString *newPath ;
- (IBAction)help:(id)sender
{
NSString *l_aide ;
NSString *the_help;
l_aide = [[NSBundle mainBundle] pathForResource:@"manual" ofType:@"html" inDirectory:@"HatariHelp"] ;
the_help = [[NSBundle mainBundle] pathForResource:@"manual" ofType:@"html" inDirectory:@"HatariHelp"];
if (![[NSWorkspace sharedWorkspace] openFile:l_aide withApplication:@"HelpViewer"])
if (![[NSWorkspace sharedWorkspace] openFile:l_aide withApplication:@"Help Viewer"])
[[NSWorkspace sharedWorkspace] openFile:l_aide] ;
if (![[NSWorkspace sharedWorkspace] openFile:the_help withApplication:@"HelpViewer"])
if (![[NSWorkspace sharedWorkspace] openFile:the_help withApplication:@"Help Viewer"])
[[NSWorkspace sharedWorkspace] openFile:the_help];
}
- (IBAction)compat:(id)sender
@ -419,7 +419,7 @@ CNF_PARAMS CurrentParams;
GuiOsx_Pause();
newCfg = [NSApp ouvrir:NO defoDir:nil defoFile:ConfigFile types:[NSArray arrayWithObject:@"cfg"] ] ;
newCfg = [NSApp hopenfile:NO defoDir:nil defoFile:ConfigFile types:[NSArray arrayWithObject:@"cfg"] ] ;
if ([newCfg length] != 0)
{
@ -433,9 +433,9 @@ CNF_PARAMS CurrentParams;
localize(@"Don't reset"), localize(@"Reset"), nil) == NSAlertAlternateReturn ;
if (applyChanges)
Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, true) ;
Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, true); // Ok with Reset
else
ConfigureParams = CurrentParams ;
ConfigureParams = CurrentParams; //Restore previous Params.
} ;
GuiOsx_Resume();

View File

@ -12,8 +12,8 @@
#define localize(laklef) [[NSBundle mainBundle] localizedStringForKey:laklef value:(laklef != nil ? laklef : @"???") table:@"Localizable"]
// disk extensions
#define allF @"st",@"msa",@"dim",@"gz",@"zip"
// disk extensions alowed in open box
#define allF @"st",@"msa",@"dim",@"gz",@"zip",@"stx",@"ipf",@"raw",@"ctr"
// cartdridge extensions
#define allC @"img",@"rom",@"bin",@"cart"
// TOS extensions
@ -46,16 +46,17 @@ void GuiOsx_Resume(void);
//
@interface NSApplication (service)
// Some usefull tools
// choose file to open
- (NSString *)ouvrir:(BOOL)chooseDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types ;
- (NSString *)ouvrir:(BOOL)chooseDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types titre:(NSString *)titre ;
- (NSString *)hopenfile:(BOOL)chooseDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types ;
- (NSString *)hopenfile:(BOOL)chooseDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types titre:(NSString *)titre ;
// choose file to save
- (NSString *)sauver:(BOOL)creatDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types ;
- (NSString *)sauver:(BOOL)creatDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types titre:(NSString *)titre ;
- (NSString *)hsavefile:(BOOL)creatDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types ;
- (NSString *)hsavefile:(BOOL)creatDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types titre:(NSString *)titre ;
// Return localized path, Full path or partial path.
- (NSString *)localpath:(NSString *)celuila ; // Full
- (NSString *)pathUser:(NSString *)celuici ; // Partiel si possible, sinon complet.
- (NSString *)localpath:(NSString *)thepath ; // Full
- (NSString *)pathUser:(NSString *)thepath ; // Partial if possible.
@end

View File

@ -89,27 +89,19 @@ void GuiOsx_Resume(void)
@implementation NSApplication (service)
// ouvrir un fichier ou dossier
// Open file or directory
//
- (NSString *)ouvrir:(BOOL)chooseDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types
- (NSString *)hopenfile:(BOOL)chooseDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types
{
return [self ouvrir:chooseDir defoDir:defoDir defoFile:defoFile types:types titre:nil] ;
return [self hopenfile:chooseDir defoDir:defoDir defoFile:defoFile types:types titre:nil] ;
}
/* informations
NSFileManager *gestion = [NSFileManager defaultManager] ;
if ([gestion instancesRespondToSelector:@selector(machin)])
{ // utilisation de machin }
else
{ // utilisation de truc de 10.5 } ;
*/
- (NSString *)ouvrir:(BOOL)chooseDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types titre:(NSString *)titre
- (NSString *)hopenfile:(BOOL)chooseDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types titre:(NSString *)titre
{
NSOpenPanel *openPanel ;
NSArray *lesURLs = nil ;
BOOL btOk ;
NSArray *lesURLs = nil ;
BOOL btOk ;
openPanel = [NSOpenPanel openPanel];
[openPanel setCanChooseDirectories: chooseDir];
@ -120,14 +112,14 @@ BOOL btOk ;
[openPanel setAllowsOtherFileTypes:YES] ; } ;
if (titre != nil) [openPanel setTitle:titre] ;
/* if ([NSOpenPanel instancesRespondToSelector:@selector(setNameFieldStringValue:)])
{
if (defoDir!=nil) [openPanel setDirectoryURL:[NSURL URLWithString:defoDir]] ; // A partir de 10.6
if (defoFile!=nil) [openPanel setNameFieldStringValue:defoFile] ;
btOk = [openPanel runModal] == NSOKButton ; // Ok ?
}
else // */
btOk = [openPanel runModalForDirectory:defoDir file:defoFile] == NSOKButton ; // Ok ? deprecated en 10.6
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1058
if (defoDir!=nil) [openPanel setDirectoryURL:[NSURL URLWithString:defoDir]] ; // 10.6 & newer
if (defoFile!=nil) [openPanel setNameFieldStringValue:defoFile] ;
btOk = [openPanel runModal] == NSOKButton ; // Ok ?
#else // */
btOk = [openPanel runModalForDirectory:defoDir file:defoFile] == NSOKButton ; // 10.5
#endif
if (btOk)
{ lesURLs = [openPanel URLs] ;
@ -137,82 +129,82 @@ BOOL btOk ;
return @"" ;
}
// sauver un fichier
// Save file
//
- (NSString *)sauver:(BOOL)creatDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types
- (NSString *)hsavefile:(BOOL)creatDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types
{
return [self sauver:creatDir defoDir:defoDir defoFile:defoFile types:types titre:nil] ;
return [self hsavefile:creatDir defoDir:defoDir defoFile:defoFile types:types titre:nil] ;
}
- (NSString *)sauver:(BOOL)creatDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types titre:(NSString *)titre
- (NSString *)hsavefile:(BOOL)creatDir defoDir:(NSString *)defoDir defoFile:(NSString *)defoFile types:(NSArray *)types titre:(NSString *)titre
{
NSSavePanel *sauvPanel ;
NSURL *lURL ;
BOOL btOk ;
NSSavePanel *savPanel ;
NSURL *lURL ;
BOOL btOk ;
sauvPanel = [NSSavePanel savePanel];
[sauvPanel setCanCreateDirectories:creatDir];
savPanel = [NSSavePanel savePanel];
[savPanel setCanCreateDirectories:creatDir];
if (types != nil)
{ [sauvPanel setAllowedFileTypes:types] ;
[sauvPanel setAllowsOtherFileTypes:YES] ; } ;
if (titre != nil) [sauvPanel setTitle:titre] ;
{ [savPanel setAllowedFileTypes:types] ;
[savPanel setAllowsOtherFileTypes:YES] ; } ;
if (titre != nil) [savPanel setTitle:titre] ;
/* if ([NSSavePanel instancesRespondToSelector:@selector(setNameFieldStringValue:)])
{
if (defoDir!=nil) [sauvPanel setDirectoryURL:[NSURL URLWithString:defoDir]] ; // A partir de 10.6
if (defoFile!=nil) [sauvPanel setNameFieldStringValue:defoFile] ;
btOk = [sauvPanel runModal] == NSOKButton ; // Ok?
}
else // */
btOk = [sauvPanel runModalForDirectory:defoDir file:defoFile] == NSOKButton ; // Ok ? deprecated en 10.6
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1058
if (defoDir!=nil) [savPanel setDirectoryURL:[NSURL URLWithString:defoDir]] ; // A partir de 10.6
if (defoFile!=nil) [savPanel setNameFieldStringValue:defoFile] ;
btOk = [savPanel runModal] == NSOKButton ; // Ok?
#else // */
btOk = [savPanel runModalForDirectory:defoDir file:defoFile] == NSOKButton ; // Ok ? deprecated en 10.6
#endif
if (btOk)
{ lURL = [sauvPanel URL] ;
{ lURL = [savPanel URL] ;
if (lURL != nil)
return [lURL path] ;
} ;
return @"" ;
}
// retourne le chemin localisé
// Returne localized path
//
- (NSString *)localpath:(NSString *)cuila :(NSFileManager *)gerer // réentrante
- (NSString *)localpath:(NSString *)thepath :(NSFileManager *)afilemanager
{
NSString *lafin ;
NSArray *Les_composantes ;
NSString *thend ;
NSArray *thelist ;
if (cuila == nil) return @"" ;
if ([cuila length] == 0) return @"" ;
if (![gerer fileExistsAtPath:cuila])
{ lafin = [cuila lastPathComponent] ;
return [[self localpath:[cuila stringByDeletingLastPathComponent] :gerer] stringByAppendingPathComponent:lafin] ;
if (thepath == nil) return @"" ;
if ([thepath length] == 0) return @"" ;
if (![afilemanager fileExistsAtPath:thepath])
{ thend = [thepath lastPathComponent] ;
return [[self localpath:[thepath stringByDeletingLastPathComponent] :afilemanager] stringByAppendingPathComponent:thend] ;
} ;
Les_composantes = [gerer componentsToDisplayForPath:cuila] ; // convert in matrix
if ( [Les_composantes count] != 0)
return [NSString pathWithComponents:Les_composantes] ; // return localized path
thelist = [afilemanager componentsToDisplayForPath:thepath] ; // convert in matrix
if ( [thelist count] != 0)
return [NSString pathWithComponents:thelist] ; // return localized path
else
return cuila ;
return thepath ;
}
- (NSString *)localpath:(NSString *)celuila // retourne un chemin localisé complet
- (NSString *)localpath:(NSString *)thepath // return a full localized path
{
NSFileManager *gestion = [NSFileManager defaultManager] ; // call "default manager"
return [self localpath:celuila :gestion] ;
NSFileManager *afilemanager = [NSFileManager defaultManager] ; // call "default manager"
return [self localpath:thepath :afilemanager] ;
}
// retourne un chemin localisé relatif au compte utilisateur (si possible) ~/Bureau/
// return a localized path related to user home directoryr ~/
//
- (NSString *)pathUser:(NSString *)celuici
- (NSString *)pathUser:(NSString *)thepath
{
NSString *ici ;
NSString *chemin ;
NSString *here ;
NSString *apath ;
chemin = [self localpath:celuici] ;
if ([chemin length] == 0) return @"" ;
ici = [self localpath:[@"~/" stringByExpandingTildeInPath]] ;
if (([chemin rangeOfString:ici].location) != NSNotFound)
return [NSString stringWithFormat:@"~%@", [chemin substringFromIndex:[ici length]]] ;
return chemin ;
apath = [self localpath:thepath] ;
if ([apath length] == 0) return @"" ;
here = [self localpath:[@"~/" stringByExpandingTildeInPath]] ;
if (([apath rangeOfString:here].location) != NSNotFound)
return [NSString stringWithFormat:@"~%@", [apath substringFromIndex:[here length]]] ;
return apath;
}
@end