Add fall-back that if a folder image is not found, the generic folde ricon is picked up. Also add Movies special folders

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39513 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rmottola 2016-03-09 23:39:52 +00:00
parent 74ae5822ea
commit d22537f16f
2 changed files with 22 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2016-03-10 Riccardo Mottola <rm@gnu.org>
* Source/NSWorkspace.m
Add fall-back that if a folder image is not found, the generic folde ricon is picked up. Also add Movies special folders.
2016-03-09 Riccardo Mottola <rm@gnu.org> 2016-03-09 Riccardo Mottola <rm@gnu.org>
* Headers/AppKit/NSImage.h * Headers/AppKit/NSImage.h

View file

@ -675,6 +675,7 @@ static NSDictionary *urlPreferences = nil;
NSArray *desktopDir; NSArray *desktopDir;
NSArray *imgDir; NSArray *imgDir;
NSArray *musicDir; NSArray *musicDir;
NSArray *videoDir;
NSString *sysDir; NSString *sysDir;
NSUInteger i; NSUInteger i;
@ -729,6 +730,8 @@ static NSDictionary *urlPreferences = nil;
NSUserDomainMask, YES); NSUserDomainMask, YES);
musicDir = NSSearchPathForDirectoriesInDomains(NSMusicDirectory, musicDir = NSSearchPathForDirectoriesInDomains(NSMusicDirectory,
NSUserDomainMask, YES); NSUserDomainMask, YES);
videoDir = NSSearchPathForDirectoriesInDomains(NSMoviesDirectory,
NSUserDomainMask, YES);
/* we try to guess a System directory and check if looks like one */ /* we try to guess a System directory and check if looks like one */
sysDir = nil; sysDir = nil;
@ -778,6 +781,11 @@ static NSDictionary *urlPreferences = nil;
[folderPathIconDict setObject: @"MusicFolder" [folderPathIconDict setObject: @"MusicFolder"
forKey: [musicDir objectAtIndex: i]]; forKey: [musicDir objectAtIndex: i]];
} }
for (i = 0; i < [videoDir count]; i++)
{
[folderPathIconDict setObject: @"VideoFolder"
forKey: [videoDir objectAtIndex: i]];
}
folderIconCache = [[NSMutableDictionary alloc] init]; folderIconCache = [[NSMutableDictionary alloc] init];
return self; return self;
@ -1457,6 +1465,12 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
if (iconImage == nil) if (iconImage == nil)
{ {
iconImage = [NSImage _standardImageWithName: iconName]; iconImage = [NSImage _standardImageWithName: iconName];
if (!iconImage)
{
/* no specific image found in theme, fall-back to folder */
NSLog(@"no image found for %@", iconName);
iconImage = [NSImage _standardImageWithName: @"Folder"];
}
/* the dictionary retains the image */ /* the dictionary retains the image */
[folderIconCache setObject: iconImage forKey: iconName]; [folderIconCache setObject: iconImage forKey: iconName];
} }