Ticket #54673: tkMacOSXDialog.c.diff

File tkMacOSXDialog.c.diff, 3.0 KB (added by mojca (Mojca Miklavec), 7 years ago)

patch for tkMacOSXDialog.c to make it work on older systems

  • macosx/tkMacOSXDialog.c

    diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
    index 1383225..8c483ec 100644
    a b typedef struct { 
    3434    NSMutableArray *fileTypeExtensions; // array of allowed extensions per name, e.g. "txt", "doc"
    3535    NSMutableArray *fileTypeLabels; // displayed string, e.g. "Text document (.txt, .doc)"
    3636    NSMutableArray *allAllowedExtensions; // set of all allowed extensions
    37     NSInteger fileTypeIndex; // index of currently selected filter
     37    NSUInteger fileTypeIndex; // index of currently selected filter
    3838} filepanelFilterInfo;
    3939
    4040filepanelFilterInfo filterInfo;
    static NSURL *getFileURL(NSString *directory, NSString *filename) { 
    270270- (void)selectFormat:(id)sender  {
    271271    NSPopUpButton *button                 = (NSPopUpButton *)sender;
    272272    filterInfo.fileTypeIndex      = [button indexOfSelectedItem];
    273     NSMutableArray *allowedtypes = filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex];
     273    NSMutableArray *allowedtypes = [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex];
    274274    [openpanel setAllowedFileTypes:allowedtypes];
    275275    filterInfo.userHasSelectedFilter = true;
    276276
    static NSURL *getFileURL(NSString *directory, NSString *filename) { 
    279279- (void)saveFormat:(id)sender  {
    280280    NSPopUpButton *button                 = (NSPopUpButton *)sender;
    281281    filterInfo.fileTypeIndex      = [button indexOfSelectedItem];
    282     NSMutableArray *allowedtypes = filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex];
     282    NSMutableArray *allowedtypes = [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex];
    283283    [savepanel setAllowedFileTypes:allowedtypes];
    284284}
    285285
    Tk_GetOpenFileObjCmd( 
    717717        #if 0
    718718        NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
    719719        #endif
    720         NSString * selectedFilter = filterInfo.fileTypeNames[filterInfo.fileTypeIndex];
     720        NSString * selectedFilter = [filterInfo.fileTypeNames objectAtIndex:filterInfo.fileTypeIndex];
    721721        Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
    722722                Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
    723723    }
    Tk_GetSaveFileObjCmd( 
    884884
    885885        [savepanel setAccessoryView:accessoryView];
    886886
    887         [savepanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
     887        [savepanel setAllowedFileTypes:[filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]];
    888888        [savepanel setAllowsOtherFileTypes:NO];
    889889    } else if (defaultType) {
    890890        /* If no filetypes are given, defaultextension is an alternative way
    Tk_GetSaveFileObjCmd( 
    971971        #if 0
    972972        NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
    973973        #endif
    974         NSString * selectedFilter = filterInfo.fileTypeNames[filterInfo.fileTypeIndex];
     974        NSString * selectedFilter = [filterInfo.fileTypeNames objectAtIndex:filterInfo.fileTypeIndex];
    975975        Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
    976976                Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
    977977    }