From ac2faeaa9e51e437185e539b39a8ab152283923b Mon Sep 17 00:00:00 2001 From: ericwa Date: Sat, 6 Apr 2013 19:30:30 +0000 Subject: [PATCH] Revert "Allow themes to override only a "base" image like" git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36481 72102866-910b-0410-8b05-ffd578937521 --- Source/GSTheme.m | 29 +++--------------------- Source/NSImage.m | 59 ++---------------------------------------------- 2 files changed, 5 insertions(+), 83 deletions(-) diff --git a/Source/GSTheme.m b/Source/GSTheme.m index 71c261799..58d8d621c 100644 --- a/Source/GSTheme.m +++ b/Source/GSTheme.m @@ -208,7 +208,6 @@ GSStringFromBorderType(NSBorderType borderType) @interface NSImage (Private) + (void) _setImagePath: (NSString*)path name: (NSString*)name; -+ (NSDictionary *) _nameToPathDictionaryWithMappings: (NSDictionary*)pathForName; @end @interface GSTheme (Private) @@ -453,10 +452,7 @@ typedef struct { NSDictionary *infoDict; NSWindow *window; GSThemeControlState state; - NSMutableDictionary *themeImagePathForName; - NSDictionary *themeImagePathForNameWithMappings; - NSString *imageName; - + NSDebugMLLog(@"GSTheme", @"%@ %p", [self name], self); /* Get rid of any cached colors list so that we regenerate it when needed */ @@ -477,7 +473,6 @@ typedef struct { imagePaths = [_bundle pathsForResourcesOfType: nil inDirectory: @"ThemeImages"]; enumerator = [imagePaths objectEnumerator]; - themeImagePathForName = [[NSMutableDictionary alloc] init]; while ((imagePath = [enumerator nextObject]) != nil) { NSString *ext = [imagePath pathExtension]; @@ -488,29 +483,11 @@ typedef struct { imageName = [imagePath lastPathComponent]; imageName = [imageName stringByDeletingPathExtension]; - [themeImagePathForName setObject: imagePath forKey: imageName]; + [_imageNames addObject: imageName]; + [NSImage _setImagePath: imagePath name: imageName]; } } - /* - * "Expand" the themeImagePathForName dictionary by applying the - * mappings in nsmappings.strings. - * - * e.g. if the theme defines - * common_3DArrowRight but not NSMenuArrow, this will add an entry - * for NSMenuArrow pointing at the common_3DArrowRight path. - */ - themeImagePathForNameWithMappings = [NSImage _nameToPathDictionaryWithMappings: themeImagePathForName]; - DESTROY(themeImagePathForName); - - enumerator = [themeImagePathForNameWithMappings keyEnumerator]; - while ((imageName = [enumerator nextObject]) != nil) - { - imagePath = [themeImagePathForNameWithMappings objectForKey: imageName]; - [NSImage _setImagePath: imagePath name: imageName]; - [_imageNames addObject: imageName]; - } - /* * Use the GSThemeDomain key in the info dictionary of the theme to * set a defaults domain which will establish user defaults values diff --git a/Source/NSImage.m b/Source/NSImage.m index 1148dca85..a12d805c3 100644 --- a/Source/NSImage.m +++ b/Source/NSImage.m @@ -120,7 +120,6 @@ BOOL NSImageForceCaching = NO; /* use on missmatch */ static NSRecursiveLock *imageLock = nil; static NSMutableDictionary *nameDict = nil; static NSDictionary *nsmapping = nil; -static NSMutableDictionary *nsmapping_inverse = nil; static NSColor *clearColor = nil; static Class cachedClass = 0; static Class bitmapClass = 0; @@ -155,7 +154,6 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep) @interface NSImage (Private) + (void) _clearFileTypeCaches: (NSNotification*)notif; -+ (NSDictionary *) _nameToPathDictionaryWithMappings: (NSDictionary*)pathForName; + (void) _setImagePath: (NSString*)path name: (NSString*)name; + (NSString *) _pathForImageNamed: (NSString *)aName; - (BOOL) _useFromFile: (NSString *)fileName; @@ -186,31 +184,8 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep) ofType: @"strings" inDirectory: @"Images"]; if (path) - { - NSEnumerator *e; - NSString *nsName; - - // read NS image name to GS image name mapping - nsmapping = RETAIN([[NSString stringWithContentsOfFile: path] + nsmapping = RETAIN([[NSString stringWithContentsOfFile: path] propertyListFromStringsFileFormat]); - - // create a GS image name to array of NS image names dict - nsmapping_inverse = [[NSMutableDictionary alloc] init]; - - e = [nsmapping keyEnumerator]; - while ((nsName = [e nextObject]) != nil) - { - NSString *gsName = [nsmapping objectForKey: nsName]; - - NSMutableArray *nsNames = [nsmapping_inverse objectForKey: gsName]; - if (nsNames == nil) - { - nsNames = [NSMutableArray array]; - [nsmapping_inverse setObject: nsNames forKey: gsName]; - } - [nsNames addObject: nsName]; - } - } clearColor = RETAIN([NSColor clearColor]); cachedClass = [NSCachedImageRep class]; bitmapClass = [NSBitmapImageRep class]; @@ -1933,7 +1908,7 @@ iterate_reps_for_types(NSArray* imageReps, SEL method) } [image setName: name]; } - else if (image != nil) + else { if (nil == path) { @@ -1950,36 +1925,6 @@ iterate_reps_for_types(NSArray* imageReps, SEL method) [imageLock unlock]; } -/** - * Expands a name->path dictionary by applying all of the nsmappings.strings - * mappings. - */ -+ (NSDictionary *) _nameToPathDictionaryWithMappings: (NSDictionary*)pathForName -{ - NSMutableDictionary *finalDict = [NSMutableDictionary dictionaryWithDictionary: pathForName]; - NSEnumerator *e; - NSString *name; - - e = [pathForName keyEnumerator]; - while ((name = [e nextObject]) != nil) - { - NSString *path = [pathForName objectForKey: name]; - NSEnumerator *namesMappedToNameEnumerator; - NSString *mappedName; - - namesMappedToNameEnumerator = [[nsmapping_inverse objectForKey: name] objectEnumerator]; - while ((mappedName = [namesMappedToNameEnumerator nextObject]) != nil) - { - if ([pathForName objectForKey: mappedName] == nil) - { - [finalDict setObject: path forKey: mappedName]; - } - } - } - - return finalDict; -} - + (NSString *) _pathForImageNamed: (NSString *)aName { NSString *realName = [nsmapping objectForKey: aName];