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

1.1       root        1: /*
                      2:   Hatari - CreateFloppyController.m
                      3: 
                      4:   This file is distributed under the GNU Public License, version 2 or at
                      5:   your option any later version. Read the file gpl.txt for details.
                      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: 
                     22: - (IBAction)createFloppyImage:(id)sender
                     23: {
1.1.1.2   root       24:        BOOL cRet;
                     25:        
1.1       root       26:        // Create a SavePanel
                     27:        NSSavePanel *savePanel = [NSSavePanel savePanel];
                     28: 
                     29:        // Set its allowed file types
                     30:        NSArray* allowedFileTypes = [NSArray arrayWithObjects: @"st", @"msa", @"dim", @"gz", nil];
                     31:        [savePanel setAllowedFileTypes:allowedFileTypes];
                     32:        
                     33:        // Get the default images directory
1.1.1.2   root       34:        NSString* defaultDir = [NSString stringWithCString:ConfigureParams.DiskImage.szDiskImageDirectory encoding:NSASCIIStringEncoding];
1.1       root       35: 
                     36:        // Run the SavePanel, then check if the user clicked OK
                     37:     if ( NSOKButton == [savePanel runModalForDirectory:defaultDir file:nil] )
                     38:        {
                     39:                // Get the path to the chosen file
                     40:                NSString *path = [savePanel filename];
                     41:        
                     42:                // Make a non-const C string out of it
1.1.1.2   root       43:                const char* constSzPath = [path cStringUsingEncoding:NSASCIIStringEncoding];
1.1       root       44:                size_t cbPath = strlen(constSzPath) + 1;
                     45:                char szPath[cbPath];
                     46:                strncpy(szPath, constSzPath, cbPath);
                     47:                                        
                     48:                // Get the tracks, sectors and sides values
                     49:                int cTracks = [[tracks selectedCell] tag];
                     50:                int cSectors = [[sectors selectedCell] tag];
                     51:                int cSides = [[sides selectedCell] tag];
                     52:                                        
                     53:                // Create the image
1.1.1.2   root       54:                cRet=CreateBlankImage_CreateFile(szPath, cTracks, cSectors, cSides);
                     55:                if(cRet==TRUE)
                     56:                {
                     57:                        int ret = NSRunAlertPanel(@"Hatari", @"Insert newly created disk in", @"Ignore", @"A:", @"B:");
                     58:                        if (ret != NSAlertDefaultReturn)
                     59:                        {
                     60:                                printf("%d\n",ret);
                     61:                                if(ret==-1) ret=1; //0=>Drive 0, -1=>Drive 1
                     62:                                
                     63:                                Floppy_SetDiskFileName(ret, szPath, NULL);
                     64:                                Floppy_InsertDiskIntoDrive(ret);
                     65:                        }
                     66:                }
                     67:                        
1.1       root       68:        }
                     69: }
                     70: 
                     71: - (void)awakeFromNib
                     72: {
                     73:        // Fill the "Tracks" dropdown
                     74:     [tracks removeAllItems];
                     75:        int i;
                     76:        for (i = 40; i <= 85; i++)
                     77:        {
                     78:                [tracks addItemWithTitle:[NSString stringWithFormat:@"%d", i]]; 
                     79:                [[tracks lastItem] setTag:i];
                     80:        }
                     81:        
                     82:        // Select the default value of 80 tracks
                     83:        [tracks selectItemAtIndex:[tracks indexOfItemWithTag:80]]; // Equivalent to Tiger-only [tracks selectItemWithTag:80];
                     84: 
                     85: 
                     86: }
                     87: 
                     88: - (IBAction)runModal:(id)sender
                     89: {
1.1.1.3 ! root       90:        ModalWrapper *mw=[[ModalWrapper alloc] init];
        !            91:        [mw runModal:window];
        !            92:        [mw release];
1.1       root       93: }
                     94: 
                     95: 
                     96: @end

unix.superglobalmegacorp.com

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