mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 06:01:00 +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
|
@ -164,19 +164,11 @@ static NSMutableDictionary *systemDict = nil;
|
||||||
static
|
static
|
||||||
void initSystemColors()
|
void initSystemColors()
|
||||||
{
|
{
|
||||||
systemColors = [NSColorList colorListNamed: @"System"];
|
|
||||||
if (systemColors == nil)
|
|
||||||
{
|
|
||||||
NSString *white;
|
NSString *white;
|
||||||
NSString *lightGray;
|
NSString *lightGray;
|
||||||
NSString *gray;
|
NSString *gray;
|
||||||
NSString *darkGray;
|
NSString *darkGray;
|
||||||
NSString *black;
|
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
|
// Set up a dictionary containing the names of all the system colors
|
||||||
// as keys and with colors in string format as values.
|
// as keys and with colors in string format as values.
|
||||||
|
@ -225,6 +217,15 @@ void initSystemColors()
|
||||||
//black, @"windowFrameTextColor",
|
//black, @"windowFrameTextColor",
|
||||||
nil];
|
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];
|
e = [colorStrings keyEnumerator];
|
||||||
|
|
||||||
while ((r = (NSString *)[e nextObject]))
|
while ((r = (NSString *)[e nextObject]))
|
||||||
|
@ -1251,10 +1252,9 @@ systemColorWithName(NSString *name)
|
||||||
/*
|
/*
|
||||||
* Go through all the names of system colors - for each color where
|
* Go through all the names of system colors - for each color where
|
||||||
* there is a value in the defaults database, see if the current
|
* 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
|
* Where there is a difference, update the color strings dictionary
|
||||||
* and, where a color object exists, update the system colors list
|
* and update the system colors list to contain the new color.
|
||||||
* to contain the new color.
|
|
||||||
* Finally, issue a notification if appropriate.
|
* Finally, issue a notification if appropriate.
|
||||||
*/
|
*/
|
||||||
+ (void) defaultsDidChange: (NSNotification*)notification
|
+ (void) defaultsDidChange: (NSNotification*)notification
|
||||||
|
@ -1273,33 +1273,24 @@ systemColorWithName(NSString *name)
|
||||||
|
|
||||||
if (def != nil)
|
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)
|
if (color == nil)
|
||||||
{
|
{
|
||||||
NSLog(@"System color '%@' has bad string rep - '%@'\n",
|
NSLog(@"System color '%@' has bad string rep - '%@'\n",
|
||||||
key, def);
|
key, def);
|
||||||
}
|
}
|
||||||
else
|
else if ([color isEqual: old] == NO)
|
||||||
{
|
{
|
||||||
|
didChange = YES;
|
||||||
|
[colorStrings setObject: def forKey: key];
|
||||||
[systemColors setColor: color 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];
|
[[systemDict objectForKey: key] recache];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (didChange)
|
if (didChange)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue