Fixes for file icons

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4796 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-09-02 11:28:47 +00:00
parent 8061040ee1
commit f82fbaa30b
3 changed files with 56 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Thu Sep 2 12:50:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* NSWorkspace.m: Fixes for locating icons in application resources.
* NSBundleAdditions.m: implemented ([-pathForImageresource:])
Thu Sep 2 9:50:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* NSWorkspace.m: Attempted fix for locateApplicationBinary and tidied.

View file

@ -38,6 +38,7 @@
#include <Foundation/NSInvocation.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSString.h>
#include <AppKit/NSImage.h>
#include <AppKit/NSView.h>
#include <AppKit/NSNibLoading.h>
@ -45,7 +46,27 @@
- (NSString *)pathForImageResource:(NSString *)name
{
return nil;
NSString *ext = [name pathExtension];
NSString *path = nil;
if (ext != nil)
{
name = [name stringByDeletingPathExtension];
path = [self pathForResource: name ofType: ext];
}
else
{
NSArray *types = [NSImage imageUnfilteredFileTypes];
unsigned c = [types count];
unsigned i;
for (i = 0; path == nil && i < c; i++)
{
ext = [types objectAtIndex: i];
path = [self pathForResource: name ofType: ext];
}
}
return path;
}
+ (BOOL) loadNibFile: (NSString *)fileName

View file

@ -182,9 +182,21 @@ extIconForApp(NSWorkspace *ws, NSString *appName, NSDictionary *typeInfo)
if ([file isAbsolutePath] == NO)
{
NSString *path;
NSString *iconPath;
NSBundle *bundle;
path = [ws fullPathForApplication: appName];
file = [path stringByAppendingPathComponent: file];
bundle = [NSBundle bundleWithPath: path];
iconPath = [bundle pathForImageResource: file];
/*
* If the icon is not in the Resources of the app, try looking
* directly in the app wrapper.
*/
if (iconPath == nil)
{
iconPath = [path stringByAppendingPathComponent: file];
}
path = iconPath;
}
if ([[NSFileManager defaultManager] isReadableFileAtPath: file] == YES)
{
@ -662,7 +674,22 @@ inFileViewerRootedAtPath: (NSString *)rootFullpath
iconPath = [[bundle infoDictionary] objectForKey: @"NSIcon"];
if (iconPath && [iconPath isAbsolutePath] == NO)
{
iconPath = [aPath stringByAppendingPathComponent: iconPath];
NSString *file = iconPath;
iconPath = [bundle pathForImageResource: file];
/*
* If there is no icon in the Resources of the app, try
* looking directly in the app wrapper.
*/
if (iconPath == nil)
{
iconPath = [aPath stringByAppendingPathComponent: file];
if ([mgr isReadableFileAtPath: iconPath] == NO)
{
iconPath = nil;
}
}
}
/*
* If there is no icon specified in the Info.plist for app