mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Use URL to generate all of the path component cells
This commit is contained in:
parent
0e61c251bf
commit
fb280df615
4 changed files with 51 additions and 5 deletions
|
@ -55,6 +55,7 @@ typedef NSUInteger NSPathStyle;
|
|||
SEL _doubleAction;
|
||||
NSArray *_pathComponentCells;
|
||||
NSPathComponentCell *_clickedPathComponentCell;
|
||||
id _objectValue;
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(NSEvent *)event
|
||||
|
|
|
@ -2201,6 +2201,11 @@ didStartElement: (NSString*)elementName
|
|||
{
|
||||
object = [element attributeForKey: @"stringValue"];
|
||||
}
|
||||
else if ([class isSubclassOfClass: [NSPathCell class]])
|
||||
{
|
||||
GSXibElement *el = [element elementForKey: @"url"];
|
||||
object = [NSURL URLWithString: [el attributeForKey: @"string"]];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try the title attribute first as it is the more common encoding...
|
||||
|
@ -3226,6 +3231,7 @@ didStartElement: (NSString*)elementName
|
|||
{
|
||||
hasValue = [currentElement attributeForKey: @"title"] != nil;
|
||||
hasValue |= [currentElement attributeForKey: @"image"] != nil;
|
||||
hasValue |= [currentElement attributeForKey: @"string"] != nil;
|
||||
}
|
||||
else if ([@"NSControlContents" isEqualToString: key])
|
||||
{
|
||||
|
|
|
@ -176,6 +176,18 @@ static Class pathComponentCellClass;
|
|||
_doubleAction = action;
|
||||
}
|
||||
|
||||
- (id) objectValue
|
||||
{
|
||||
return _objectValue;
|
||||
}
|
||||
|
||||
- (void) setObjectValue: (id)obj
|
||||
{
|
||||
ASSIGN(_objectValue, obj);
|
||||
[self setPathComponentCells:
|
||||
[NSPathCell _generateCellsForURL: (NSURL *)_objectValue]];
|
||||
}
|
||||
|
||||
- (NSURL *) URL
|
||||
{
|
||||
return [self objectValue];
|
||||
|
@ -184,7 +196,6 @@ static Class pathComponentCellClass;
|
|||
- (void) setURL: (NSURL *)url
|
||||
{
|
||||
[self setObjectValue: url];
|
||||
[self setPathComponentCells: [NSPathCell _generateCellsForURL: url]];
|
||||
}
|
||||
|
||||
- (id<NSPathCellDelegate>) delegate
|
||||
|
@ -230,15 +241,20 @@ static Class pathComponentCellClass;
|
|||
{
|
||||
[self setPathStyle: [coder decodeIntegerForKey: @"NSPathStyle"]];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if ([coder containsValueForKey: @"NSPathComponentCells"])
|
||||
{
|
||||
[self setPathComponentCells: [coder decodeObjectForKey: @"NSPathComponentCells"]];
|
||||
}
|
||||
*/
|
||||
|
||||
// [self setURL: [self objectValue]];
|
||||
NSLog(@"OBJECTVALUE = %@", [self objectValue]);
|
||||
|
||||
/*
|
||||
if ([coder containsValueForKey: @"NSContents"])
|
||||
{
|
||||
[self setURL: [coder decodeObjectForKey: @"NSContents"]];
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -305,6 +321,10 @@ static Class pathComponentCellClass;
|
|||
{
|
||||
image = [NSImage imageNamed: @"NSFolder"];
|
||||
}
|
||||
else if (isDir == YES && at_root == YES)
|
||||
{
|
||||
image = [NSImage imageNamed: @"NSComputer"];
|
||||
}
|
||||
else
|
||||
{
|
||||
image = [[NSWorkspace sharedWorkspace] iconForFile: [[url path] lastPathComponent]];
|
||||
|
|
|
@ -33,6 +33,25 @@
|
|||
|
||||
@implementation NSPathComponentCell
|
||||
|
||||
- (instancetype) init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_image = nil;
|
||||
_url = nil;
|
||||
_lastComponent = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_image);
|
||||
RELEASE(_url);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSImage *) image
|
||||
{
|
||||
return _image;
|
||||
|
|
Loading…
Reference in a new issue