Annotation of hatari/src/gui-osx/CreateFloppyController.m, revision 1.1.1.5

1.1       root        1: /*
                      2:   Hatari - CreateFloppyController.m
                      3: 
1.1.1.4   root        4:   This file is distributed under the GNU General Public License, version 2
                      5:   or at your option any later version. Read the file gpl.txt for details.
1.1       root        6: 
                      7:   Create floppy image window controller implementation file
                      8: 
                      9:   Feb-Mar 2006, Sébastien Molines - Created
                     10: */
                     11: 
                     12: #import "CreateFloppyController.h"
                     13: #import "Shared.h"
                     14: 
                     15: #include "main.h"
                     16: #include "configuration.h"
                     17: #include "createBlankImage.h"
1.1.1.2   root       18: #include "floppy.h"
1.1       root       19: 
                     20: @implementation CreateFloppyController
                     21: 
1.1.1.5 ! root       22: char szPath[FILENAME_MAX] ;
        !            23: 
1.1       root       24: - (IBAction)createFloppyImage:(id)sender
                     25: {
1.1.1.5 ! root       26:        BOOL            cRet;
        !            27:        int                     ret, cTracks, cSectors, cSides ;
        !            28:        NSString        *defaultDir ;
        !            29:        NSString        *newCnf ;
1.1       root       30: 
                     31:        // Get the default images directory
1.1.1.5 ! root       32:        defaultDir = [NSString stringWithCString:ConfigureParams.DiskImage.szDiskImageDirectory encoding:NSASCIIStringEncoding];
1.1       root       33: 
                     34:        // Run the SavePanel, then check if the user clicked OK
1.1.1.5 ! root       35:        newCnf = [NSApp hsavefile:YES defoDir:defaultDir defoFile:nil types:[NSArray arrayWithObjects: allF, nil] ] ;
        !            36:        if ([newCnf length] != 0)
1.1       root       37:        {
1.1.1.5 ! root       38:                [newCnf getCString:szPath maxLength:FILENAME_MAX-1 encoding:NSASCIIStringEncoding] ;
1.1       root       39:                // Get the tracks, sectors and sides values
1.1.1.5 ! root       40:                cTracks = [[tracks selectedCell] tag];
        !            41:                cSectors = [[sectors selectedCell] tag];
        !            42:                cSides = [[sides selectedCell] tag];
        !            43: 
1.1       root       44:                // Create the image
1.1.1.2   root       45:                cRet=CreateBlankImage_CreateFile(szPath, cTracks, cSectors, cSides);
                     46:                if(cRet==TRUE)
1.1.1.5 ! root       47:                 {
        !            48:                        ret = NSRunAlertPanel(@"Hatari", localize(@"Insert newly created disk in"), localize(@"Ignore"), @"  A:  ", @"  B:  ");
        !            49:                        if (ret == NSAlertDefaultReturn)
        !            50:                                                return ;
        !            51: 
        !            52:                        printf("%d\n",ret);
        !            53:                        ret = ret == NSAlertAlternateReturn ? 0 : 1 ;
        !            54:                        Floppy_SetDiskFileName(ret, szPath, NULL);
        !            55:                        Floppy_InsertDiskIntoDrive(ret);
        !            56:                 } ;
        !            57:         } ;
1.1       root       58: }
                     59: 
                     60: - (void)awakeFromNib
                     61: {
                     62:        // Fill the "Tracks" dropdown
1.1.1.5 ! root       63:        [tracks removeAllItems];
1.1       root       64:        int i;
                     65:        for (i = 40; i <= 85; i++)
                     66:        {
                     67:                [tracks addItemWithTitle:[NSString stringWithFormat:@"%d", i]]; 
                     68:                [[tracks lastItem] setTag:i];
                     69:        }
                     70:        
                     71:        // Select the default value of 80 tracks
                     72:        [tracks selectItemAtIndex:[tracks indexOfItemWithTag:80]]; // Equivalent to Tiger-only [tracks selectItemWithTag:80];
                     73: 
                     74: 
                     75: }
                     76: 
                     77: - (IBAction)runModal:(id)sender
                     78: {
1.1.1.3   root       79:        ModalWrapper *mw=[[ModalWrapper alloc] init];
                     80:        [mw runModal:window];
                     81:        [mw release];
1.1       root       82: }
                     83: 
                     84: 
                     85: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.