Adding ability to import sounds and images from palettes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19731 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-07-14 03:10:44 +00:00
parent 958fdfcabb
commit cf60ff0dda
7 changed files with 146 additions and 39 deletions

View file

@ -1,3 +1,22 @@
2004-07-12 23:08 Gregory John Casamento <greg_casamento@yahoo.com>
* GormImageEditor.m: [GormImageEditor initWithObject:inDocument:]
added call to [GormPalettesManager importedImages] to return
the images imported by any custom palettes.
* GormSoundEditor.m: [GormSoundEditor initWithObject:inDocument:]
added call to [GormPalettesManager importedSounds] to return
the sounds imported by any custom palettes.
* GormPalettesManager.m: Changed the return of
[GormPalettesManager importClasses:withDictionary:], added
[GormPalettesManager importImages:withBundle:],
[GormPalettesManager importSounds:withBundle:],
[GormPalettesManager importedImages], and
[GormPalettesManager importedImages]. These methods are
used to get the images and sounds from a palette so that
they can be used from Gorm by the user.
* GormPalettesManager.h: Added banner.
2004-07-11 23:40 Gregory John Casamento <greg_casamento@yahoo.com>
* GormDocument.m: saveGormDocument.m: Changes to prevent a
@ -12,7 +31,8 @@
on the button.
Added code to the toolbar delegate to add the "File" button to the
document toolbar.
Added code to loadDocument to load the data.info file if it's present, if not
Added code to loadDocument to load the data.info file if it's
present, if not
we simply use the defaults.
* GormDocument.h: Added new ivars for isOlderArchive, filePrefsView,
and filePrefsManager.
@ -43,8 +63,8 @@
non-ui objects in a Gorm file. It will be useful for adding DB objects
or other things which a .gorm file might need.
* GormPalettesManager.[hm]: Added [GormPalettesManager importedClasses]
and [GormPalettesManager importClasses:withDictionary:] adds the classes
from the list in the palette.table.
and [GormPalettesManager importClasses:withDictionary:] adds the
classes from the list in the palette.table.
* GormLib/IBPalette.h: Changed name of ivar. This ivar wasn't properly
named. It should have been originalWindow. This issue was causing the
.gorm load to not make a needed connection.
@ -52,16 +72,17 @@
instead of strings file format. This was needed to facilitate the
reading of all of the classes, sounds and images a palette might
import. Also modified to correctly load the nib file.
* Palettes/0Menus/main.m: Corrected window to originalWindow as detailed
above. It was referred to in a few places by the old name.
* Palettes/0Menus/main.m: Corrected window to originalWindow as
detailed above. It was referred to in a few places by the old name.
* Palettes/1Windows/main.m: same.
* Palettes/2Controls/main.m: same.
* Palettes/3Containers/main.m: same.
* Palettes/4Data/main.m: same.
* Palettes/2Controls/inspectors.m: Change to clarify the autoenable switch
on pulldown buttons.
* Palettes/2Controls/GormNSPopUpButtonInspector.gorm: Corresponding .gorm file
change for the above. Added new outlet and made new connection.
* Palettes/2Controls/inspectors.m: Change to clarify the autoenable
switch on pulldown buttons.
* Palettes/2Controls/GormNSPopUpButtonInspector.gorm: Corresponding
.gorm file change for the above. Added new outlet and made new
connection.
2004-07-09 16:24 Gregory John Casamento <greg_casamento@yahoo.com>

View file

@ -24,6 +24,8 @@
#include "GormPrivate.h"
#include "GormFunctions.h"
#include "GormPalettesManager.h"
#include <AppKit/NSImage.h>
/*
* Method to return the image that should be used to display objects within
@ -195,9 +197,10 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
if (self != nil)
{
NSButtonCell *proto;
NSArray *list;
NSMutableArray *list = [NSMutableArray array];
NSEnumerator *en;
id obj;
GormPalettesManager *palettesManager = [(Gorm *)NSApp palettesManager];
[self registerForDraggedTypes: [NSArray arrayWithObjects:
NSFilenamesPboardType, nil]];
@ -232,7 +235,8 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
}
// add all of the system objects...
list = systemImagesList();
[list addObjectsFromArray: systemImagesList()];
[list addObjectsFromArray: [palettesManager importedImages]];
en = [list objectEnumerator];
while((obj = [en nextObject]) != nil)
{

View file

@ -1,6 +1,36 @@
/* GormPalettesManager.h
*
* Copyright (C) 1999, 2003 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk>
* Date: 1999, 2003
*
* This file is part of GNUstep.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef INCLUDED_GormPalettesManager_h
#define INCLUDED_GormPalettesManager_h
#include <Foundation/NSObject.h>
@class NSMutableArray, NSMutableDictionary, NSDictionary, NSArray, NSBundle;
@class NSPanel, NSMatrix, NSView;
@interface GormPalettesManager : NSObject
{
NSPanel *panel;
@ -11,13 +41,23 @@
int current;
BOOL hiddenDuringTest;
NSMutableDictionary *importedClasses;
NSMutableArray *importedImages;
NSMutableArray *importedSounds;
}
// methods for loading and display the palette panels
- (void) loadPalette: (NSString*)path;
- (id) openPalette: (id) sender;
- (NSPanel*) panel;
- (void) setCurrentPalette: (id)anObject;
- (NSDictionary *) importClasses: (NSArray *)classes withDictionary: (NSDictionary *)dict;
// methods for importing stuff from palettes
- (void) importClasses: (NSArray *)classes withDictionary: (NSDictionary *)dict;
- (NSDictionary *) importedClasses;
- (void) importImages: (NSArray *)images withBundle: (NSBundle *) bundle;
- (NSArray *) importedImages;
- (void) importSounds: (NSArray *)sounds withBundle: (NSBundle *) bundle;
- (NSArray *) importedSounds;
@end
#endif

View file

@ -24,6 +24,8 @@
#include "GormPrivate.h"
#include <Foundation/NSArray.h>
#include <AppKit/NSImage.h>
#include <AppKit/NSSound.h>
#define BUILTIN_PALETTES @"BuiltinPalettes"
#define USER_PALETTES @"UserPalettes"
@ -278,6 +280,8 @@ static NSImage *dragImage = nil;
bundles = [NSMutableArray new];
palettes = [NSMutableArray new];
importedClasses = [NSMutableDictionary new];
importedImages = [NSMutableArray new];
importedSounds = [NSMutableArray new];
scrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
[scrollView setHasHorizontalScroller: YES];
@ -320,19 +324,19 @@ static NSImage *dragImage = nil;
{
[self loadPalette: [array objectAtIndex: index]];
}
// if we have any user palettes load them as well.
if(userPalettes != nil)
{
NSEnumerator *en = [userPalettes objectEnumerator];
id paletteName = nil;
while((paletteName = [en nextObject]) != nil)
{
[self loadPalette: paletteName];
}
}
}
// if we have any user palettes load them as well.
if(userPalettes != nil)
{
NSEnumerator *en = [userPalettes objectEnumerator];
id paletteName = nil;
while((paletteName = [en nextObject]) != nil)
{
[self loadPalette: paletteName];
}
}
/*
* Select initial palette - this should be the standard controls palette.
*/
@ -395,7 +399,7 @@ static NSImage *dragImage = nil;
paletteInfo = [[NSString stringWithContentsOfFile: path] propertyList];
if (paletteInfo == nil)
{
NSRunAlertPanel(NULL, _(@"Failed to load 'palette.table'"),
NSRunAlertPanel(NULL, _(@"Failed to load 'palette.table', you may need to update GNUstep-make."),
_(@"OK"), NULL, NULL);
return;
}
@ -428,22 +432,19 @@ static NSImage *dragImage = nil;
exportClasses = [paletteInfo objectForKey: @"ExportClasses"];
if(exportClasses != nil)
{
NSDictionary *classes = [self importClasses: exportClasses withDictionary: nil];
[importedClasses addEntriesFromDictionary: classes];
[self importClasses: exportClasses withDictionary: nil];
}
exportImages = [paletteInfo objectForKey: @"ExportImages"];
if(exportImages != nil)
{
// id classManager = [(Gorm *)NSApp classManager];
// [classManager importClasses: exportClasses fromPalette: palette];
[self importImages: exportImages withBundle: bundle];
}
exportSounds = [paletteInfo objectForKey: @"ExportSounds"];
if(exportSounds != nil)
{
// id classManager = [(Gorm *)NSApp classManager];
// [classManager importClasses: exportClasses fromPalette: palette];
[self importSounds: exportSounds withBundle: bundle];
}
[palette finishInstantiate];
@ -556,7 +557,7 @@ static NSImage *dragImage = nil;
[dragView setNeedsDisplay: YES];
}
- (NSDictionary *) importClasses: (NSArray *)classes withDictionary: (NSDictionary *)dict
- (void) importClasses: (NSArray *)classes withDictionary: (NSDictionary *)dict
{
NSEnumerator *en = [classes objectEnumerator];
id className = nil;
@ -580,11 +581,52 @@ static NSImage *dragImage = nil;
[masterDict addEntriesFromDictionary: dict];
}
return masterDict;
// add the classes to the dictionary...
[importedClasses addEntriesFromDictionary: masterDict];
}
- (NSDictionary *)importedClasses
- (NSDictionary *) importedClasses
{
return importedClasses;
}
- (void) importImages: (NSArray *)images withBundle: (NSBundle *) bundle
{
NSEnumerator *en = [images objectEnumerator];
id name = nil;
NSMutableArray *paths = [NSMutableArray array];
while((name = [en nextObject]) != nil)
{
NSString *path = [bundle pathForImageResource: name];
[paths addObject: path];
}
[importedImages addObjectsFromArray: paths];
}
- (NSArray *) importedImages
{
return importedImages;
}
- (void) importSounds: (NSArray *)sounds withBundle: (NSBundle *) bundle
{
NSEnumerator *en = [sounds objectEnumerator];
id name = nil;
NSMutableArray *paths = [NSMutableArray array];
while((name = [en nextObject]) != nil)
{
NSString *path = [bundle pathForSoundResource: name];
[paths addObject: path];
}
[importedSounds addObjectsFromArray: paths];
}
- (NSArray *) importedSounds
{
return importedSounds;
}
@end

View file

@ -27,7 +27,7 @@ objectValueForTableColumn: (NSTableColumn *)tc
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *list = [defaults objectForKey: @"UserPalettes"];
id value = nil; // NSFontAttributeName
id value = nil;
if([list count] > 0)
{
value = [[list objectAtIndex: rowIndex] lastPathComponent];
@ -68,7 +68,6 @@ objectValueForTableColumn: (NSTableColumn *)tc
- (void) addAction: (id)sender
{
NSLog(@"Here...");
[[(Gorm *)NSApp palettesManager] openPalette: self];
[table reloadData];
}

View file

@ -231,7 +231,6 @@ extern NSString *GormResizeCellNotification;
@interface GormSoundEditor : GormGenericEditor
{
}
// don't redeclare methods already declared in protocols.
+ (GormSoundEditor*) editorForDocument: (id<IBDocuments>)aDocument;
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f;
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL)flag;
@ -240,7 +239,6 @@ extern NSString *GormResizeCellNotification;
@interface GormImageEditor : GormGenericEditor
{
}
// don't redeclare methods already declared in protocols.
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f;
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL)flag;
- (void) refreshCells;

View file

@ -24,6 +24,7 @@
#include "GormPrivate.h"
#include "GormFunctions.h"
#include "GormPalettesManager.h"
#include <AppKit/NSSound.h>
/*
@ -198,9 +199,10 @@ static NSMapTable *docMap = 0;
if (self != nil)
{
NSButtonCell *proto;
NSArray *list;
NSMutableArray *list = [NSMutableArray array];
NSEnumerator *en;
id obj;
GormPalettesManager *palettesManager = [(Gorm *)NSApp palettesManager];
[self registerForDraggedTypes: [NSArray arrayWithObjects:
IBObjectPboardType, GormLinkPboardType, nil]];
@ -235,7 +237,8 @@ static NSMapTable *docMap = 0;
}
// add all of the system objects...
list = systemSoundsList();
[list addObjectsFromArray: systemSoundsList()];
[list addObjectsFromArray: [palettesManager importedSounds]];
en = [list objectEnumerator];
while((obj = [en nextObject]) != nil)
{