Updates for better handling of files by extension

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4155 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-04-28 11:17:11 +00:00
parent 306f784b22
commit 52b3275a9e
2 changed files with 81 additions and 66 deletions

View file

@ -51,45 +51,45 @@
//
// Opening Files
//
- (BOOL)openFile:(NSString *)fullPath;
- (BOOL)openFile:(NSString *)fullPath
fromImage:(NSImage *)anImage
at:(NSPoint)point
inView:(NSView *)aView;
- (BOOL)openFile:(NSString *)fullPath
withApplication:(NSString *)appName;
- (BOOL)openFile:(NSString *)fullPath
withApplication:(NSString *)appName
andDeactivate:(BOOL)flag;
- (BOOL)openTempFile:(NSString *)fullPath;
- (BOOL)openFile: (NSString *)fullPath;
- (BOOL)openFile: (NSString *)fullPath
fromImage: (NSImage *)anImage
at: (NSPoint)point
inView: (NSView *)aView;
- (BOOL)openFile: (NSString *)fullPath
withApplication: (NSString *)appName;
- (BOOL)openFile: (NSString *)fullPath
withApplication: (NSString *)appName
andDeactivate: (BOOL)flag;
- (BOOL)openTempFile: (NSString *)fullPath;
//
// Manipulating Files
//
- (BOOL)performFileOperation:(NSString *)operation
source:(NSString *)source
destination:(NSString *)destination
files:(NSArray *)files
tag:(int *)tag;
- (BOOL)selectFile:(NSString *)fullPath
inFileViewerRootedAtPath:(NSString *)rootFullpath;
- (BOOL)performFileOperation: (NSString *)operation
source: (NSString *)source
destination: (NSString *)destination
files: (NSArray *)files
tag: (int *)tag;
- (BOOL)selectFile: (NSString *)fullPath
inFileViewerRootedAtPath: (NSString *)rootFullpath;
//
// Requesting Information about Files
//
- (NSString *)fullPathForApplication:(NSString *)appName;
- (BOOL)getFileSystemInfoForPath:(NSString *)fullPath
isRemovable:(BOOL *)removableFlag
isWritable:(BOOL *)writableFlag
isUnmountable:(BOOL *)unmountableFlag
description:(NSString **)description
type:(NSString **)fileSystemType;
- (BOOL)getInfoForFile:(NSString *)fullPath
application:(NSString **)appName
type:(NSString **)type;
- (NSImage *)iconForFile:(NSString *)fullPath;
- (NSImage *)iconForFiles:(NSArray *)pathArray;
- (NSImage *)iconForFileType:(NSString *)fileType;
- (NSString *)fullPathForApplication: (NSString *)appName;
- (BOOL)getFileSystemInfoForPath: (NSString *)fullPath
isRemovable: (BOOL *)removableFlag
isWritable: (BOOL *)writableFlag
isUnmountable: (BOOL *)unmountableFlag
description: (NSString **)description
type: (NSString **)fileSystemType;
- (BOOL)getInfoForFile: (NSString *)fullPath
application: (NSString **)appName
type: (NSString **)type;
- (NSImage *)iconForFile: (NSString *)fullPath;
- (NSImage *)iconForFiles: (NSArray *)pathArray;
- (NSImage *)iconForFileType: (NSString *)fileType;
//
// Tracking Changes to the File System
@ -106,15 +106,15 @@
// Launching and Manipulating Applications
//
- (void)hideOtherApplications;
- (BOOL)launchApplication:(NSString *)appName;
- (BOOL)launchApplication:(NSString *)appName
showIcon:(BOOL)showIcon
autolaunch:(BOOL)autolaunch;
- (BOOL)launchApplication: (NSString *)appName;
- (BOOL)launchApplication: (NSString *)appName
showIcon: (BOOL)showIcon
autolaunch: (BOOL)autolaunch;
//
// Unmounting a Device
//
- (BOOL)unmountAndEjectDeviceAtPath:(NSString *)path;
- (BOOL)unmountAndEjectDeviceAtPath: (NSString *)path;
//
// Tracking Status Changes for Devices
@ -137,17 +137,29 @@
//
// Animating an Image
//
- (void)slideImage:(NSImage *)image
from:(NSPoint)fromPoint
to:(NSPoint)toPoint;
- (void)slideImage: (NSImage *)image
from: (NSPoint)fromPoint
to: (NSPoint)toPoint;
//
// Requesting Additional Time before Power Off or Logout
//
- (int)extendPowerOffBy:(int)requested;
- (int)extendPowerOffBy: (int)requested;
@end
#ifndef NO_GNUSTEP
@interface NSWorkspace (GNUstep)
- (NSString*) getBestAppInRole: (NSString*)role
forExtension: (NSString*)ext;
- (NSString*) getBestIconForExtension: (NSString*)ext;
- (NSDictionary*) infoForExtension: (NSString*)ext;
- (void) setBestApp: (NSString*)appName
inRole: (NSString*)role
forExtension: (NSString*)ext;
- (void) setBestIcon: (NSString*)iconPath forExtension: (NSString*)ext;
@end
#endif
/* Notifications */
extern NSString *NSWorkspaceDidLaunchApplicationNotification;

View file

@ -284,6 +284,10 @@ main(int argc, char** argv)
/*
* Load information about the types of files that an application supports.
* For each extension found, produce a dictionary, keyed by app name, that
* contains dictionaries giving type info for that extension.
* NB. in order to make extensions case-insensiteve - we always convert
* to lowercase.
*/
static void addExtensionsForApplication(NSDictionary *info, NSString *app)
{
@ -316,11 +320,6 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
return;
}
t = (NSDictionary*)o1;
s = [t objectForKey: @"NSRole"];
if (s == nil || [s isEqual: @"None"] == YES)
{
continue; /* Not an extension we open. */
}
o1 = [t objectForKey: @"NSUnixExtensions"];
if (o1 == nil)
{
@ -335,19 +334,19 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
j = [a1 count];
while (j-- > 0)
{
NSString *e;
NSMutableArray *a;
NSString *e;
NSMutableDictionary *d;
e = [[a1 objectAtIndex: j] uppercaseString];
a = [extensionsMap objectForKey: e];
if (a == nil)
e = [[a1 objectAtIndex: j] lowercaseString];
d = [extensionsMap objectForKey: e];
if (d == nil)
{
a = [NSMutableArray arrayWithCapacity: 1];
[extensionsMap setObject: a forKey: e];
d = [NSMutableDictionary dictionaryWithCapacity: 1];
[extensionsMap setObject: d forKey: e];
}
if ([a containsObject: app] == NO)
if ([d objectForKey: app] == NO)
{
[a addObject: app];
[d setObject: o0 forKey: app];
}
}
}
@ -358,7 +357,7 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
* If we have an old format list of extensions
* handled by this application - ensure that
* the name of the application is listed in
* the array of applications handling each of
* the dictionary of applications handling each of
* the extensions.
*/
o0 = [info objectForKey: @"NSExtensions"];
@ -375,19 +374,23 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
i = [a0 count];
while (i-- > 0)
{
NSString *e;
NSMutableArray *a;
NSString *e;
NSMutableDictionary *d;
e = [[a0 objectAtIndex: i] uppercaseString];
a = [extensionsMap objectForKey: e];
if (a == nil)
e = [[a0 objectAtIndex: i] lowercaseString];
d = [extensionsMap objectForKey: e];
if (d == nil)
{
a = [NSMutableArray arrayWithCapacity: 1];
[extensionsMap setObject: a forKey: e];
d = [NSMutableDictionary dictionaryWithCapacity: 1];
[extensionsMap setObject: d forKey: e];
}
if ([a containsObject: app] == NO)
if ([d objectForKey: app] == nil)
{
[a addObject: app];
NSDictionary *info;
info = [NSDictionary dictionaryWithObjectsAndKeys:
nil];
[d setObject: info forKey: app];
}
}
}
@ -408,9 +411,9 @@ scanDirectory(NSMutableDictionary *services, NSString *path)
NSString *newPath;
BOOL isDir;
if (ext != nil &&
([ext isEqualToString: @"app"] || [ext isEqualToString: @"debug"]))
([ext isEqualToString: @"app"] || [ext isEqualToString: @"debug"]
|| [ext isEqualToString: @"profile"]))
{
newPath = [path stringByAppendingPathComponent: name];
if ([mgr fileExistsAtPath: newPath isDirectory: &isDir] && isDir)