mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:30:48 +00:00
Changed initSystemColors() and [defaultsDidChange:] so that
setting a system colour in the defaults file works again. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14019 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c2f4bf85a8
commit
94e24b9626
1 changed files with 66 additions and 75 deletions
|
@ -163,20 +163,12 @@ static NSMutableDictionary *systemDict = nil;
|
|||
|
||||
static
|
||||
void initSystemColors()
|
||||
{
|
||||
systemColors = [NSColorList colorListNamed: @"System"];
|
||||
if (systemColors == nil)
|
||||
{
|
||||
NSString *white;
|
||||
NSString *lightGray;
|
||||
NSString *gray;
|
||||
NSString *darkGray;
|
||||
NSString *black;
|
||||
NSEnumerator *e;
|
||||
NSString *r;
|
||||
|
||||
// Set up default system colors
|
||||
systemColors = [[NSColorList alloc] initWithName: @"System"];
|
||||
|
||||
// Set up a dictionary containing the names of all the system colors
|
||||
// as keys and with colors in string format as values.
|
||||
|
@ -225,6 +217,15 @@ void initSystemColors()
|
|||
//black, @"windowFrameTextColor",
|
||||
nil];
|
||||
|
||||
systemColors = [NSColorList colorListNamed: @"System"];
|
||||
if (systemColors == nil)
|
||||
{
|
||||
NSEnumerator *e;
|
||||
NSString *r;
|
||||
|
||||
// Set up default system colors
|
||||
systemColors = [[NSColorList alloc] initWithName: @"System"];
|
||||
|
||||
e = [colorStrings keyEnumerator];
|
||||
|
||||
while ((r = (NSString *)[e nextObject]))
|
||||
|
@ -1251,10 +1252,9 @@ systemColorWithName(NSString *name)
|
|||
/*
|
||||
* Go through all the names of system colors - for each color where
|
||||
* there is a value in the defaults database, see if the current
|
||||
* string value of the color differs from the old one.
|
||||
* value of the color differs from the old one.
|
||||
* Where there is a difference, update the color strings dictionary
|
||||
* and, where a color object exists, update the system colors list
|
||||
* to contain the new color.
|
||||
* and update the system colors list to contain the new color.
|
||||
* Finally, issue a notification if appropriate.
|
||||
*/
|
||||
+ (void) defaultsDidChange: (NSNotification*)notification
|
||||
|
@ -1273,33 +1273,24 @@ systemColorWithName(NSString *name)
|
|||
|
||||
if (def != nil)
|
||||
{
|
||||
NSString *old = [colorStrings objectForKey: key];
|
||||
NSColor *old = [systemColors colorWithKey: key];
|
||||
NSColor *color = [NSColor colorFromString: def];
|
||||
|
||||
if ([def isEqualToString: old] == NO)
|
||||
{
|
||||
NSColor *color;
|
||||
|
||||
didChange = YES;
|
||||
[colorStrings setObject: def forKey: key];
|
||||
color = [systemColors colorWithKey: key];
|
||||
if (color != nil)
|
||||
{
|
||||
color = [NSColor colorFromString: def];
|
||||
if (color == nil)
|
||||
{
|
||||
NSLog(@"System color '%@' has bad string rep - '%@'\n",
|
||||
key, def);
|
||||
}
|
||||
else
|
||||
else if ([color isEqual: old] == NO)
|
||||
{
|
||||
didChange = YES;
|
||||
[colorStrings setObject: def forKey: key];
|
||||
[systemColors setColor: color forKey: key];
|
||||
// Refresh the cach for this named colour
|
||||
// Refresh the cache for this named colour
|
||||
[[systemDict objectForKey: key] recache];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (didChange)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue