mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 19:51:00 +00:00
Improved resource handling.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20517 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b9e8478246
commit
452e9e9d0f
8 changed files with 124 additions and 9 deletions
|
@ -1,3 +1,11 @@
|
|||
2005-01-03 23:56 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormDocument.m: Improved resource handling in saveGormDocument:
|
||||
* GormImageEditor.m: Implemented deleteSelection
|
||||
* GormImage.[hm]: Added new init methods.
|
||||
* GormSoundEditor.m: Implemented deleteSelection
|
||||
* GormSound.[hm]: Added new init methods.
|
||||
|
||||
2005-01-02 15:11 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormImageEditor.m
|
||||
|
|
|
@ -1955,7 +1955,7 @@ static NSImage *fileImage = nil;
|
|||
|
||||
NSDebugLog(@"Add the sound %@", file);
|
||||
soundPath = [documentPath stringByAppendingPathComponent: file];
|
||||
[soundsView addObject: [[GormSound alloc] initWithPath: soundPath]];
|
||||
[soundsView addObject: [GormSound soundForPath: soundPath inWrapper: YES]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1977,7 +1977,7 @@ static NSImage *fileImage = nil;
|
|||
|
||||
NSDebugLog(@"Add the image %@", file);
|
||||
imagePath = [documentPath stringByAppendingPathComponent: file];
|
||||
[imagesView addObject: [GormImage imageForPath: imagePath]];
|
||||
[imagesView addObject: [GormImage imageForPath: imagePath inWrapper: YES]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2791,7 +2791,13 @@ static NSImage *fileImage = nil;
|
|||
archiveResult = [filePrefsManager saveToFile: infoPath];
|
||||
}
|
||||
|
||||
// copy sounds into the new folder...
|
||||
//
|
||||
// Copy resources into the new folder...
|
||||
// Gorm doesn't copy these into the folder right away since the folder may
|
||||
// not yet exist. This allows the user to add/delete resources as they see fit
|
||||
// but only those which they end up with will actually be put into the wrapper
|
||||
// when the model/document is saved.
|
||||
//
|
||||
if (archiveResult)
|
||||
{
|
||||
NSArray *sounds = [soundsView objects];
|
||||
|
@ -2813,11 +2819,17 @@ static NSImage *fileImage = nil;
|
|||
copied = [mgr copyPath: path
|
||||
toPath: soundPath
|
||||
handler: nil];
|
||||
if(copied)
|
||||
{
|
||||
[object setInWrapper: YES];
|
||||
[object setSoundPath: soundPath];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// mark as copied if paths are equal...
|
||||
copied = YES;
|
||||
[object setInWrapper: YES];
|
||||
}
|
||||
|
||||
if (!copied)
|
||||
|
@ -2844,11 +2856,17 @@ static NSImage *fileImage = nil;
|
|||
copied = [mgr copyPath: path
|
||||
toPath: imagePath
|
||||
handler: nil];
|
||||
if(copied)
|
||||
{
|
||||
[object setInWrapper: YES];
|
||||
[object setImagePath: imagePath];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// mark it as copied if paths are equal.
|
||||
copied = YES;
|
||||
[object setInWrapper: YES];
|
||||
}
|
||||
|
||||
if (!copied)
|
||||
|
|
|
@ -43,9 +43,15 @@
|
|||
}
|
||||
|
||||
+ (GormImage *) imageForPath: (NSString *)path;
|
||||
+ (GormImage *) imageForPath: (NSString *)path inWrapper: (BOOL)flag;
|
||||
- (id) initWithPath: (NSString *)aPath;
|
||||
- (id) initWithPath: (NSString *)aPath
|
||||
inWrapper: (BOOL)flag;
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath;
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath
|
||||
inWrapper: (BOOL)flag;
|
||||
- (void) setImageName: (NSString *)aName;
|
||||
- (NSString *) imageName;
|
||||
- (void) setImagePath: (NSString *)aPath;
|
||||
|
|
24
GormImage.m
24
GormImage.m
|
@ -50,21 +50,39 @@
|
|||
@implementation GormImage
|
||||
+ (GormImage*)imageForPath: (NSString *)aPath
|
||||
{
|
||||
return AUTORELEASE([[GormImage alloc] initWithPath: aPath]);
|
||||
return [GormImage imageForPath: aPath inWrapper: NO];
|
||||
}
|
||||
|
||||
+ (GormImage*)imageForPath: (NSString *)aPath inWrapper: (BOOL)flag
|
||||
{
|
||||
return AUTORELEASE([[GormImage alloc] initWithPath: aPath inWrapper: flag]);
|
||||
}
|
||||
|
||||
- (id) initWithPath: (NSString *)aPath
|
||||
{
|
||||
return [self initWithPath: aPath inWrapper: NO];
|
||||
}
|
||||
|
||||
- (id) initWithPath: (NSString *)aPath inWrapper: (BOOL)flag
|
||||
{
|
||||
NSString *aName = [[aPath lastPathComponent] stringByDeletingPathExtension];
|
||||
if((self = [self initWithName: aName path: aPath]) == nil)
|
||||
if((self = [self initWithName: aName path: aPath inWrapper: flag]) == nil)
|
||||
{
|
||||
RELEASE(self);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath
|
||||
{
|
||||
return [self initWithName: aName path: aPath inWrapper: NO];
|
||||
}
|
||||
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath
|
||||
inWrapper: (BOOL)flag
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
|
@ -103,7 +121,7 @@
|
|||
}
|
||||
|
||||
isSystemImage = NO;
|
||||
isInWrapper = NO;
|
||||
isInWrapper = flag;
|
||||
[image setArchiveByName: NO];
|
||||
[smallImage setArchiveByName: NO];
|
||||
}
|
||||
|
|
|
@ -411,6 +411,26 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
|
|||
{
|
||||
}
|
||||
|
||||
- (void) deleteSelection
|
||||
{
|
||||
if(![selected isSystemImage])
|
||||
{
|
||||
if([selected isInWrapper])
|
||||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSString *path = [selected imagePath];
|
||||
BOOL removed = [mgr removeFileAtPath: path
|
||||
handler: nil];
|
||||
if(!removed)
|
||||
{
|
||||
NSString *msg = [NSString stringWithFormat: @"Could not delete file %@", path];
|
||||
NSLog(msg);
|
||||
}
|
||||
}
|
||||
[super deleteSelection];
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL)flag
|
||||
{
|
||||
return NSDragOperationCopy;
|
||||
|
|
|
@ -39,10 +39,17 @@
|
|||
BOOL isSystemSound;
|
||||
BOOL isInWrapper;
|
||||
}
|
||||
|
||||
+ (GormSound*) soundForPath: (NSString *)path;
|
||||
+ (GormSound*) soundForPath: (NSString *)path inWrapper: (BOOL)flag;
|
||||
- (id) initWithPath: (NSString *)aPath;
|
||||
- (id) initWithPath: (NSString *)aPath
|
||||
inWrapper: (BOOL)flag;
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath;
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath
|
||||
inWrapper: (BOOL)flag;
|
||||
- (void) setSoundName: (NSString *)aName;
|
||||
- (NSString *) soundName;
|
||||
- (void) setSoundPath: (NSString *)aPath;
|
||||
|
|
24
GormSound.m
24
GormSound.m
|
@ -30,13 +30,23 @@
|
|||
@implementation GormSound
|
||||
+ (GormSound*) soundForPath: (NSString *)aPath
|
||||
{
|
||||
return AUTORELEASE([[GormSound alloc] initWithPath: aPath]);
|
||||
return [GormSound soundForPath: aPath inWrapper: NO];
|
||||
}
|
||||
|
||||
+ (GormSound*) soundForPath: (NSString *)aPath inWrapper: (BOOL)flag
|
||||
{
|
||||
return AUTORELEASE([[GormSound alloc] initWithPath: aPath inWrapper: flag]);
|
||||
}
|
||||
|
||||
- (id) initWithPath: (NSString *)aPath
|
||||
{
|
||||
return [self initWithPath: aPath inWrapper: NO];
|
||||
}
|
||||
|
||||
- (id) initWithPath: (NSString *)aPath inWrapper: (BOOL)flag
|
||||
{
|
||||
NSString *aName = [[aPath lastPathComponent] stringByDeletingPathExtension];
|
||||
if((self = [self initWithName: aName path: aPath]) == nil)
|
||||
if((self = [self initWithName: aName path: aPath inWrapper: flag]) == nil)
|
||||
{
|
||||
RELEASE(self);
|
||||
}
|
||||
|
@ -45,6 +55,14 @@
|
|||
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath
|
||||
{
|
||||
return [self initWithName: aName path: aPath inWrapper: NO];
|
||||
}
|
||||
|
||||
|
||||
- (id) initWithName: (NSString *)aName
|
||||
path: (NSString *)aPath
|
||||
inWrapper: (BOOL)flag
|
||||
{
|
||||
NSSound *sound = [[NSSound alloc] initWithContentsOfFile: aPath
|
||||
byReference: YES];
|
||||
|
@ -55,7 +73,7 @@
|
|||
//#warning "we want to store the sound somewhere"
|
||||
[(NSSound *)sound setName: aName];
|
||||
isSystemSound = NO;
|
||||
isInWrapper = NO;
|
||||
isInWrapper = flag;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -402,6 +402,26 @@ static NSMapTable *docMap = 0;
|
|||
{
|
||||
}
|
||||
|
||||
- (void) deleteSelection
|
||||
{
|
||||
if(![selected isSystemSound])
|
||||
{
|
||||
if([selected isInWrapper])
|
||||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSString *path = [selected soundPath];
|
||||
BOOL removed = [mgr removeFileAtPath: path
|
||||
handler: nil];
|
||||
if(!removed)
|
||||
{
|
||||
NSString *msg = [NSString stringWithFormat: @"Could not delete file %@", path];
|
||||
NSLog(msg);
|
||||
}
|
||||
}
|
||||
[super deleteSelection];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
if (dragType == IBObjectPboardType)
|
||||
|
|
Loading…
Reference in a new issue