Change to add all system sounds to the sound editor.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19339 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-05-15 17:03:33 +00:00
parent 17e6bc1492
commit 70ede8ec98
4 changed files with 54 additions and 1 deletions

View file

@ -1,3 +1,11 @@
2004-05-15 12:42 Gregory John Casamento <greg_casamento@yahoo.com>
* GormFunctions.[hm]: added function to get all system sounds.
NOTE: Current there aren't any, but why wait? I'm assuming
that they'll go into $GNUSTEP_SYSTEM_ROOT/Library/Sounds.
* GormSoundEditor.m: Added call to add all system sounds
to the editor.
2004-05-15 11:14 Gregory John Casamento <greg_casamento@yahoo.com>
* Gorm.m: Add call to [GormDocument closeAllEditors] to

View file

@ -58,4 +58,7 @@ NSDictionary *colorToDict(NSColor *color);
// get the list of images...
NSArray *systemImagesList();
// get the list of images...
NSArray *systemSoundsList();
#endif

View file

@ -244,3 +244,26 @@ NSArray *systemImagesList()
return result;
}
NSArray *systemSoundsList()
{
NSString *system = [NSOpenStepRootDirectory() stringByAppendingPathComponent: @"System"];
NSString *lib = [system stringByAppendingPathComponent: @"Library"];
NSString *path = [lib stringByAppendingPathComponent: @"Sounds"];
NSArray *contents = [[NSFileManager defaultManager] directoryContentsAtPath: path];
NSEnumerator *en = [contents objectEnumerator];
NSMutableArray *result = [NSMutableArray array];
id obj;
NSArray *fileTypes = [NSSound soundUnfilteredFileTypes];
while((obj = [en nextObject]) != nil)
{
if([fileTypes containsObject: [obj pathExtension]])
{
NSString *pathString = [path stringByAppendingPathComponent: obj];
[result addObject: pathString];
}
}
return result;
}

View file

@ -198,6 +198,9 @@ static NSMapTable *docMap = 0;
if (self != nil)
{
NSButtonCell *proto;
NSArray *list;
NSEnumerator *en;
id obj;
[self registerForDraggedTypes: [NSArray arrayWithObjects:
IBObjectPboardType, GormLinkPboardType, nil]];
@ -224,7 +227,23 @@ static NSMapTable *docMap = 0;
[self setPrototype: proto];
RELEASE(proto);
NSMapInsert(docMap, (void*)aDocument, (void*)self);
[self addObject: anObject];
// do not insert it if it's nil.
if(anObject != nil)
{
[self addObject: anObject];
}
// add all of the system objects...
list = systemSoundsList();
en = [list objectEnumerator];
while((obj = [en nextObject]) != nil)
{
NSString *name = [[obj lastPathComponent] stringByDeletingPathExtension];
GormSound *sound = [[GormSound alloc] initWithName: name path: obj];
[sound setSystemSound: YES];
[self addObject: sound];
}
// set up the notification...
[[NSNotificationCenter defaultCenter]