mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:50:48 +00:00
Unified application icons support in NSWorkspace
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20257 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
85b167cff2
commit
db4b14985e
2 changed files with 73 additions and 51 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2004-10-25 Quentin Mathe <qmathe@club-internet.fr>
|
||||||
|
|
||||||
|
* Source/NSWorkspace.m: Moved the code which looks for the application
|
||||||
|
icons in the method -iconForFile: to the method -appIconForApp:. As
|
||||||
|
a side effect, it fix the bug introduced by my last commit which caused
|
||||||
|
a nil exception when the application info.plist contains no NSIcon
|
||||||
|
entry.
|
||||||
|
|
||||||
2004-10-24 Quentin Mathe <qmathe@club-internet.fr>
|
2004-10-24 Quentin Mathe <qmathe@club-internet.fr>
|
||||||
|
|
||||||
* Source/NSWorkspace.m (-appIconForApp:): Fixed code to be more
|
* Source/NSWorkspace.m (-appIconForApp:): Fixed code to be more
|
||||||
|
|
|
@ -813,56 +813,22 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
||||||
|| [pathExtension isEqualToString: @"debug"]
|
|| [pathExtension isEqualToString: @"debug"]
|
||||||
|| [pathExtension isEqualToString: @"profile"])
|
|| [pathExtension isEqualToString: @"profile"])
|
||||||
{
|
{
|
||||||
NSBundle *bundle;
|
isApplication = YES;
|
||||||
|
|
||||||
isApplication = YES;
|
image = [self appIconForApp: fullPath];
|
||||||
bundle = [NSBundle bundleWithPath: fullPath];
|
|
||||||
iconPath = [[bundle infoDictionary] objectForKey: @"NSIcon"];
|
if (image == nil)
|
||||||
if (iconPath && [iconPath isAbsolutePath] == NO)
|
|
||||||
{
|
{
|
||||||
NSString *file = iconPath;
|
|
||||||
|
|
||||||
iconPath = [bundle pathForImageResource: file];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is no icon in the Resources of the app, try
|
* Just use the appropriate icon for the path extension
|
||||||
* looking directly in the app wrapper.
|
*/
|
||||||
*/
|
return [self _iconForExtension: pathExtension];
|
||||||
if (iconPath == nil)
|
|
||||||
{
|
|
||||||
iconPath = [fullPath stringByAppendingPathComponent: file];
|
|
||||||
if ([mgr isReadableFileAtPath: iconPath] == NO)
|
|
||||||
{
|
|
||||||
iconPath = nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* If there is no icon specified in the Info.plist for app
|
|
||||||
* try 'wrapper/app.tiff'
|
|
||||||
*/
|
|
||||||
if (iconPath == nil)
|
|
||||||
{
|
|
||||||
NSString *str;
|
|
||||||
|
|
||||||
str = [fullPath lastPathComponent];
|
|
||||||
str = [str stringByDeletingPathExtension];
|
|
||||||
iconPath = [fullPath stringByAppendingPathComponent: str];
|
|
||||||
iconPath = [iconPath stringByAppendingPathExtension: @"tiff"];
|
|
||||||
if ([mgr isReadableFileAtPath: iconPath] == NO)
|
|
||||||
{
|
|
||||||
iconPath = nil;
|
|
||||||
/*
|
|
||||||
* Just use the appropriate icon for the path extension
|
|
||||||
*/
|
|
||||||
image = [self _iconForExtension: pathExtension];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have no iconPath, try 'dir/.dir.tiff' as a
|
* If we have no iconPath, try 'dir/.dir.tiff' as a
|
||||||
* possible locations for the directory icon.
|
* possible locations for the directory icon.
|
||||||
*/
|
*/
|
||||||
if (iconPath == nil)
|
if (iconPath == nil)
|
||||||
{
|
{
|
||||||
|
@ -1481,18 +1447,66 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
||||||
*/
|
*/
|
||||||
- (NSImage*) appIconForApp: (NSString*)appName
|
- (NSImage*) appIconForApp: (NSString*)appName
|
||||||
{
|
{
|
||||||
NSBundle *bundle = [self bundleForApp: appName];
|
NSBundle *bundle;
|
||||||
NSString *iconPath;
|
NSImage *image = nil;
|
||||||
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||||
|
NSString *iconPath = nil;
|
||||||
|
NSString *fullPath;
|
||||||
|
|
||||||
|
fullPath = [self fullPathForApplication: appName];
|
||||||
|
bundle = [self bundleForApp: fullPath];
|
||||||
if (bundle == nil)
|
if (bundle == nil)
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
iconPath = [[bundle infoDictionary] objectForKey: @"NSIcon"];
|
|
||||||
iconPath = [bundle pathForImageResource: iconPath];
|
|
||||||
|
|
||||||
return [self _saveImageFor: iconPath];
|
iconPath = [[bundle infoDictionary] objectForKey: @"NSIcon"];
|
||||||
|
|
||||||
|
if (iconPath && [iconPath isAbsolutePath] == NO)
|
||||||
|
{
|
||||||
|
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 = [fullPath stringByAppendingPathComponent: file];
|
||||||
|
if ([mgr isReadableFileAtPath: iconPath] == NO)
|
||||||
|
{
|
||||||
|
iconPath = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there is no icon specified in the Info.plist for app
|
||||||
|
* try 'wrapper/app.tiff'
|
||||||
|
*/
|
||||||
|
if (iconPath == nil)
|
||||||
|
{
|
||||||
|
NSString *str;
|
||||||
|
|
||||||
|
str = [fullPath lastPathComponent];
|
||||||
|
str = [str stringByDeletingPathExtension];
|
||||||
|
iconPath = [fullPath stringByAppendingPathComponent: str];
|
||||||
|
iconPath = [iconPath stringByAppendingPathExtension: @"tiff"];
|
||||||
|
|
||||||
|
if ([mgr isReadableFileAtPath: iconPath] == NO)
|
||||||
|
{
|
||||||
|
iconPath = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iconPath != nil)
|
||||||
|
{
|
||||||
|
image = [self _saveImageFor: iconPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue