Index: WinNSOpenPanel.m =================================================================== --- WinNSOpenPanel.m (revisiĆ³n: 37516) +++ WinNSOpenPanel.m (copia de trabajo) @@ -111,28 +111,19 @@ return L"All (*.*)\0*.*\0"; } - NSMutableSet *set = [NSMutableSet set]; NSEnumerator *en = nil; id type = nil; NSDocumentController *dc = [NSDocumentController sharedDocumentController]; NSMutableString *filterString = [NSMutableString string]; - NSMutableString *typesString = [NSMutableString string]; + + en = [types objectEnumerator]; - [set addObjectsFromArray: types]; - en = [set objectEnumerator]; - - // build the string.. + // Build the string, adding one entry for each type while((type = [en nextObject]) != nil) { - [filterString appendFormat:@"%@ (*.%@),", [dc displayNameForType: type], - type]; - [typesString appendFormat: @"*.%@;",type]; + [filterString appendFormat:@"%@ (*.%@)address@hidden", [dc displayNameForType: type], + type, type]; } - [filterString replaceCharactersInRange:NSMakeRange([filterString length]-1,1) - withString:@"+"]; - [filterString appendString:typesString]; - [filterString replaceCharactersInRange:NSMakeRange([filterString length]-1,1) - withString:@"+"]; // Add the nulls... unichar *fs = (unichar *)[filterString cStringUsingEncoding: @@ -281,8 +272,6 @@ { BOOL flag = YES; int result = NSOKButton; - NSDocumentController *dc = [NSDocumentController sharedDocumentController]; - NSArray *extensionsForDefaultType = [dc fileExtensionsFromType: [dc defaultType]]; NSMutableSet *typeset = [NSMutableSet set]; NSArray *types = nil; @@ -317,14 +306,7 @@ ofn.hwndOwner = (HWND)[window windowNumber]; ofn.lpstrFilter = (unichar *)filter_string_from_types(types); ofn.nFilterIndex = 0; - if ([extensionsForDefaultType count] > 0) - { - NSUInteger defaultIndex = [types indexOfObject: [extensionsForDefaultType objectAtIndex: 0]]; - if (defaultIndex != NSNotFound) - { - ofn.nFilterIndex = defaultIndex + 1; - } - } + ofn.lpstrTitle = (unichar *)[[self title] cStringUsingEncoding: NSUnicodeStringEncoding]; if ([name length]) { @@ -467,25 +449,19 @@ BOOL flag = YES; int result = NSOKButton; NSDocumentController *dc = [NSDocumentController sharedDocumentController]; - NSArray *extensionsForDefaultType = [dc fileExtensionsFromType: [dc defaultType]]; - NSMutableSet *typeset = [NSMutableSet set]; + id doc = [dc documentClassForType: [fileTypes objectAtIndex: 0]]; NSArray *types = nil; - [typeset addObjectsFromArray: fileTypes]; - types = [typeset allObjects]; + // Get all writable types, not only the current type. FOr the case when + // the user wants change the format of the file + types = [doc writableTypes]; ofn.hwndOwner = (HWND)[window windowNumber]; ofn.lpstrFilter = (unichar *)filter_string_from_types(types); - ofn.nFilterIndex = 0; - if ([extensionsForDefaultType count] > 0) - { - NSUInteger defaultIndex = [types indexOfObject: [extensionsForDefaultType objectAtIndex: 0]]; - if (defaultIndex != NSNotFound) - { - ofn.nFilterIndex = defaultIndex + 1; - } - } + // Select the current type + ofn.nFilterIndex = [types indexOfObject: [fileTypes objectAtIndex: 0]]; + ofn.lpstrTitle = (unichar *)[[self title] cStringUsingEncoding: NSUnicodeStringEncoding]; if ([name length]) { NSString *file = [name lastPathComponent];