Skip to content

Commit

Permalink
Support NSValueBinding.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeabdullah committed Nov 16, 2011
1 parent 7a6810a commit 885d772
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions UKDockProgressIndicator.h
Expand Up @@ -32,6 +32,9 @@
on top of the app's icon in the dock. Use it just like an NSProgressIndicator.
You can even have it call through to another progress indicator if desired. */

/* Supports NSValueBinding
*/

@interface UKDockProgressIndicator : NSObject
{
double max;
Expand Down
35 changes: 35 additions & 0 deletions UKDockProgressIndicator.m
Expand Up @@ -43,6 +43,13 @@ - (id) init
return self;
}

- (void)dealloc;
{
[self unbind:NSValueBinding];

[super dealloc];
}

- (void) release
{
[NSApp setApplicationIconImage: savedDockIcon];
Expand Down Expand Up @@ -158,4 +165,32 @@ -(void) updateDockTile
[NSApp setApplicationIconImage: dockIcon];
}

#pragma mark Bindings

+ (void)initialize; { [self exposeBinding:NSValueBinding]; }

- (id)valueForUndefinedKey:(NSString *)key;
{
if ([key isEqualToString:NSValueBinding])
{
return [self valueForKey:@"doubleValue"];
}
else
{
return [super valueForUndefinedKey:key];
}
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key;
{
if ([key isEqualToString:NSValueBinding])
{
return [self setValue:value forKey:@"doubleValue"];
}
else
{
return [super setValue:value forUndefinedKey:key];
}
}

@end

0 comments on commit 885d772

Please sign in to comment.