mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 18:11:56 +00:00
Fix writeToFile: to use the specified file name.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23594 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
08a89d3709
commit
d932c3c346
3 changed files with 77 additions and 35 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2006-09-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSColorList.h: Add documentation.
|
||||||
|
* Source/NSColorList.m: Fix ([-writeToFile:]) to work as specified
|
||||||
|
by Apple's documentation.
|
||||||
|
|
||||||
2006-09-22 Richard Frith-Macdonald <rfm@gnu.org>
|
2006-09-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/Additions/GNUstepGUI/GSDrawFunctions.h:
|
* Headers/Additions/GNUstepGUI/GSDrawFunctions.h:
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
/**
|
/**
|
||||||
* Initializes a new, empty color list registered under given name.
|
* Initializes a new, empty color list registered under given name.
|
||||||
*/
|
*/
|
||||||
- (id)initWithName:(NSString *)name;
|
- (id) initWithName: (NSString *)name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Initializes a new color list registered under given name, taking
|
* <p>Initializes a new color list registered under given name, taking
|
||||||
|
@ -86,48 +86,78 @@
|
||||||
* for now the only supported method is "0", which is an RGBA format with
|
* for now the only supported method is "0", which is an RGBA format with
|
||||||
* the arguments in order R,G,B, A.</p>
|
* the arguments in order R,G,B, A.</p>
|
||||||
*/
|
*/
|
||||||
- (id)initWithName:(NSString *)name
|
- (id) initWithName: (NSString *)name
|
||||||
fromFile:(NSString *)path;
|
fromFile: (NSString *)path;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Getting All Color Lists
|
// Getting All Color Lists
|
||||||
//
|
//
|
||||||
+ (NSArray *)availableColorLists;
|
+ (NSArray *) availableColorLists;
|
||||||
|
|
||||||
//
|
/** Returns the first color list (from the array of available lists)
|
||||||
// Getting a Color List by Name
|
* matching name.
|
||||||
//
|
*/
|
||||||
+ (NSColorList *)colorListNamed:(NSString *)name;
|
+ (NSColorList *) colorListNamed: (NSString *)name;
|
||||||
- (NSString *)name;
|
|
||||||
|
|
||||||
//
|
/** Returns an array containing all the keyus in the color list
|
||||||
// Managing Colors by Key
|
*/
|
||||||
//
|
- (NSArray *) allKeys;
|
||||||
- (NSArray *)allKeys;
|
|
||||||
- (NSColor *)colorWithKey:(NSString *)key;
|
|
||||||
- (void)insertColor:(NSColor *)color
|
|
||||||
key:(NSString *)key
|
|
||||||
atIndex:(unsigned)location;
|
|
||||||
- (void)removeColorWithKey:(NSString *)key;
|
|
||||||
- (void)setColor:(NSColor *)aColor
|
|
||||||
forKey:(NSString *)key;
|
|
||||||
|
|
||||||
//
|
/** Returns the color for the specified key (if any).
|
||||||
// Editing
|
*/
|
||||||
//
|
- (NSColor *) colorWithKey: (NSString *)key;
|
||||||
- (BOOL)isEditable;
|
|
||||||
|
|
||||||
//
|
/**
|
||||||
// Writing and Removing Files
|
* Returns a flag indicating whether the receiver is editable.
|
||||||
//
|
*/
|
||||||
- (BOOL)writeToFile:(NSString *)path;
|
- (BOOL) isEditable;
|
||||||
- (void)removeFile;
|
|
||||||
|
/** Inserts a color into the color list at the specified index.
|
||||||
|
* Removes any other color with the same name.
|
||||||
|
*/
|
||||||
|
- (void) insertColor: (NSColor *)color
|
||||||
|
key: (NSString *)key
|
||||||
|
atIndex: (unsigned)location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the receiver.
|
||||||
|
*/
|
||||||
|
- (NSString *) name;
|
||||||
|
|
||||||
|
/** Removes the color for the specified key from the list.
|
||||||
|
*/
|
||||||
|
- (void) removeColorWithKey: (NSString *)key;
|
||||||
|
|
||||||
|
/** Removes the on-disk representation of the list.
|
||||||
|
*/
|
||||||
|
- (void) removeFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the color for this key and appends it to the color list.
|
||||||
|
*/
|
||||||
|
- (void) setColor: (NSColor *)aColor
|
||||||
|
forKey: (NSString *)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the receiver to the specified path.<br />
|
||||||
|
* If path is nil, writes to a file located in the current user's personal
|
||||||
|
* Colors directory whose name is that of the list with the extension
|
||||||
|
* 'clr' appended.<br />
|
||||||
|
* If path is a directory, writes to a file in that directory whose name
|
||||||
|
* is that of the list with the extension 'clr' appended.<br />
|
||||||
|
* Otherwise (path is neither nil nor a directory), writes to the path
|
||||||
|
* without appending the l.ist name.<br />
|
||||||
|
* Returns YES on success, NO on failure.<br />
|
||||||
|
* Writing with a path of nil will cause the receiver to be added to the
|
||||||
|
* +availableColorLists if it is not already there.
|
||||||
|
*/
|
||||||
|
- (BOOL) writeToFile: (NSString *)path;
|
||||||
|
|
||||||
//
|
//
|
||||||
// NSCoding protocol
|
// NSCoding protocol
|
||||||
//
|
//
|
||||||
- (void)encodeWithCoder: (NSCoder *)aCoder;
|
- (void) encodeWithCoder: (NSCoder *)aCoder;
|
||||||
- initWithCoder: (NSCoder *)aDecoder;
|
- (id) initWithCoder: (NSCoder *)aDecoder;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ static NSColorList *themeColorList = nil;
|
||||||
*/
|
*/
|
||||||
[NSColorList _loadAvailableColorLists: nil];
|
[NSColorList _loadAvailableColorLists: nil];
|
||||||
|
|
||||||
if (path == nil || ([fm fileExistsAtPath: path isDirectory: &isDir] == NO))
|
if (path == nil)
|
||||||
{
|
{
|
||||||
NSArray *paths;
|
NSArray *paths;
|
||||||
|
|
||||||
|
@ -437,6 +437,10 @@ static NSColorList *themeColorList = nil;
|
||||||
stringByAppendingPathComponent: @"Colors"];
|
stringByAppendingPathComponent: @"Colors"];
|
||||||
isDir = YES;
|
isDir = YES;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[fm fileExistsAtPath: path isDirectory: &isDir];
|
||||||
|
}
|
||||||
|
|
||||||
if (isDir)
|
if (isDir)
|
||||||
{
|
{
|
||||||
|
@ -445,7 +449,6 @@ static NSColorList *themeColorList = nil;
|
||||||
}
|
}
|
||||||
else // it is a file
|
else // it is a file
|
||||||
{
|
{
|
||||||
_fullFileName = path;
|
|
||||||
if ([[path pathExtension] isEqual: @"clr"] == YES)
|
if ([[path pathExtension] isEqual: @"clr"] == YES)
|
||||||
{
|
{
|
||||||
ASSIGN (_fullFileName, path);
|
ASSIGN (_fullFileName, path);
|
||||||
|
@ -455,11 +458,14 @@ static NSColorList *themeColorList = nil;
|
||||||
ASSIGN (_fullFileName, [[path stringByDeletingPathExtension]
|
ASSIGN (_fullFileName, [[path stringByDeletingPathExtension]
|
||||||
stringByAppendingPathExtension: @"clr"]);
|
stringByAppendingPathExtension: @"clr"]);
|
||||||
}
|
}
|
||||||
|
path = [path stringByDeletingLastPathComponent];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the path is a standard path
|
// Check if the path is a standard path
|
||||||
if ([[path lastPathComponent] isEqualToString: @"Colors"] == NO)
|
if ([[path lastPathComponent] isEqualToString: @"Colors"] == NO)
|
||||||
path_is_standard = NO;
|
{
|
||||||
|
path_is_standard = NO;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmpPath = [path stringByDeletingLastPathComponent];
|
tmpPath = [path stringByDeletingLastPathComponent];
|
||||||
|
@ -500,7 +506,7 @@ static NSColorList *themeColorList = nil;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeFile
|
- (void) removeFile
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue