Annotation of previous/src/gui-osx/CreateFloppyController.m, revision 1.1.1.2

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

unix.superglobalmegacorp.com

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