Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1248 from skurfer/validIndirects

resolve direct object before using it to determine indirects
  • Loading branch information...
commit 0fb18dcf2bbcd8e0432fa8c13d8706cd02519f8b 2 parents 21ab077 + 0e24f29
@pjrobertson pjrobertson authored
View
2  Quicksilver/Code-App/QSController.m
@@ -545,7 +545,7 @@ - (id)resolveProxyObject:(id)proxy {
} else {
QSObject *object = [[[self interfaceController] dSelector] objectValue];
if ([object isEqual:proxy]) return [[[self interfaceController] dSelector] previousObjectValue];
- if ([object isKindOfClass:[QSProxyObject class]]) return nil;
+ if ([object isProxyObject]) return nil;
return object;
}
return nil;
View
4 Quicksilver/Code-QuickStepCore/QSAction.m
@@ -310,9 +310,7 @@ - (QSObject *)performOnDirectObject:(QSObject *)dObject indirectObject:(QSObject
if (!provider) {
provider = [QSReg getClassInstance:class];
}
- if ([[dObject primaryType] isEqualToString:QSProxyType]) {
- dObject = (QSObject *)[dObject resolvedObject];
- }
+ dObject = [dObject resolvedObject];
if ([[dict objectForKey:kActionSplitPluralArguments] boolValue] && [dObject count] > 1) {
NSArray *objects = [dObject splitObjects];
id object;
View
1  Quicksilver/Code-QuickStepCore/QSBasicObject.h
@@ -55,7 +55,6 @@
- (NSString *)toolTip;
- (BOOL)drawIconInRect:(NSRect)rect flipped:(BOOL)flipped;
- (NSString *)kind;
-- (QSBasicObject *)resolvedObject;
- (void)becameSelected;
@end
View
2  Quicksilver/Code-QuickStepCore/QSBasicObject.m
@@ -91,8 +91,6 @@ - (NSString *)toolTip {return nil;}
- (BOOL)drawIconInRect:(NSRect)rect flipped:(BOOL)flipped {return NO;}
- (NSString *)description {return [NSString stringWithFormat:@"%@ <%p>, %@", NSStringFromClass([self class]), self, [self identifier]];}
-
-- (QSBasicObject *)resolvedObject {return self;}
@end
@implementation QSBasicObject (QSPasteboard)
View
5 Quicksilver/Code-QuickStepCore/QSCommand.m
@@ -470,12 +470,13 @@ - (void)executeFromMenuWithIndirect:(id)sender {
}
- (void)executeWithIndirect:(id)indirectObject {
- [self setIndirectObject:(QSObject *)[indirectObject resolvedObject]];
+ [self setIndirectObject:[indirectObject resolvedObject]];
[self executeFromMenu:nil];
}
- (NSArray *)validIndirects {
- NSArray *indirects = [[[self aObject] provider] validIndirectObjectsForAction:[[self aObject] identifier] directObject:[self dObject]];
+ QSObject *directObject = [[self dObject] resolvedObject];
+ NSArray *indirects = [[[self aObject] provider] validIndirectObjectsForAction:[[self aObject] identifier] directObject:directObject];
if ([indirects count] >1 && [[indirects objectAtIndex:1] isKindOfClass:[NSArray class]]) indirects = [indirects objectAtIndex:1];
if ([indirects count] == 1 && [[indirects objectAtIndex:0] containsType:QSTextProxyType]) {
indirects = nil;
View
5 Quicksilver/Code-QuickStepCore/QSExecutor.m
@@ -289,7 +289,7 @@ - (NSArray *)rankedActionsForDirectObject:(QSObject *)dObject indirectObject:(QS
actions = (NSMutableArray *)[[dObject handler] actionsForDirectObject:dObject indirectObject:iObject];
BOOL bypassValidation =
- (bypass && [dObject isKindOfClass:[QSProxyObject class]] && [(QSProxyObject *)dObject bypassValidation]);
+ (bypass && [dObject isProxyObject] && [(QSProxyObject *)dObject bypassValidation]);
if (bypassValidation) {
//NSLog(@"bypass? %@ %@", dObject, NSStringFromClass([dObject class]) );
@@ -395,7 +395,8 @@ - (NSArray *)validActionsForDirectObject:(QSObject *)dObject indirectObject:(QSO
- (NSArray *)validIndirectObjectsForAction:(NSString *)action directObject:(QSObject *)dObject {
QSActionProvider *actionObject = [[actionIdentifiers objectForKey:action] objectForKey:kActionClass];
// NSLog(@"actionobject %@", actionObject);
- return [actionObject validIndirectObjectsForAction:action directObject:dObject];
+ QSObject *directObject = [dObject resolvedObject];
+ return [actionObject validIndirectObjectsForAction:action directObject:directObject];
}
- (BOOL)actionIsEnabled:(QSAction*)action {
View
2  Quicksilver/Code-QuickStepCore/QSObject.h
@@ -137,6 +137,8 @@ extern NSSize QSMaxIconSize;
- (NSMutableDictionary *)cache;
- (void)setCache:(NSMutableDictionary *)aCache;
+- (BOOL)isProxyObject;
+- (QSObject *)resolvedObject;
@end
View
40 Quicksilver/Code-QuickStepCore/QSObject.m
@@ -223,15 +223,15 @@ + (id)objectByMergingObjects:(NSArray *)objects withObject:(QSObject *)object {
}
- (NSArray *)splitObjects {
-
- if ([self count] == 1) {
- return [NSArray arrayWithObject:self];
+ QSObject *object = [self resolvedObject];
+ if ([object count] == 1) {
+ return [NSArray arrayWithObject:object];
}
- NSArray *splitObjects = [self objectForCache:kQSObjectComponents];
+ NSArray *splitObjects = [object objectForCache:kQSObjectComponents];
if (!splitObjects) {
- splitObjects = [self children];
+ splitObjects = [object children];
}
return splitObjects;
}
@@ -433,10 +433,7 @@ - (id)primaryObject {return itemForKey([self primaryType]);}
//- (void)setObject:(id)object forKey:(id)aKey {[data setObject:object forKey:aKey];}
- (id)_safeObjectForType:(id)aKey {
- id object = [data objectForKey:aKey];
- if (!object && [[self primaryType] isEqualToString:QSProxyType])
- object = [[self resolvedObject] arrayForType:aKey];
- return object;
+ return [data objectForKey:aKey];
#if 0
if (flags.multiTyped)
return[data objectForKey:aKey];
@@ -568,6 +565,15 @@ - (NSUInteger) primaryCount {
return [self count];
}
+- (BOOL)isProxyObject
+{
+ return NO;
+}
+
+- (QSObject *)resolvedObject
+{
+ return self;
+}
@end
@implementation QSObject (Hierarchy)
@@ -909,11 +915,8 @@ - (id)findDuplicateOrRegisterID {
@implementation QSObject (Icon)
- (BOOL)loadIcon {
NSString *namedIcon = [self objectForMeta:kQSObjectIconName];
- if ([self iconLoaded]) {
- if (!namedIcon)
- return NO;
- else if (![namedIcon isEqualToString:@"ProxyIcon"])
- return NO;
+ if ([self iconLoaded] && !namedIcon) {
+ return NO;
}
[self setIconLoaded:YES];
@@ -922,14 +925,7 @@ - (BOOL)loadIcon {
[iconLoadedArray addObject:self];
if (namedIcon) {
- NSImage *image = nil;
- if ([namedIcon isEqualToString:@"ProxyIcon"]) {
- QSObject *resolved = (QSObject *)[self resolvedObject];
- [resolved loadIcon];
- image = [resolved icon];
- }
- else
- image = [QSResourceManager imageNamed:namedIcon];
+ NSImage *image = [QSResourceManager imageNamed:namedIcon];
if (image) {
[self setIcon:image];
return YES;
View
2  Quicksilver/Code-QuickStepCore/QSObject_Pasteboard.m
@@ -187,7 +187,7 @@ - (BOOL)putOnPasteboard:(NSPasteboard *)pboard declareTypes:(NSArray *)types inc
// get the different pboard types from the object's data dictionary -- they're all stored here
types = [[[[self dataDictionary] allKeys] mutableCopy] autorelease];
if ([types containsObject:QSProxyType])
- [(NSMutableArray *)types addObjectsFromArray:[[(QSObject *)[self resolvedObject] dataDictionary] allKeys]];
+ [(NSMutableArray *)types addObjectsFromArray:[[[self resolvedObject] dataDictionary] allKeys]];
}
else {
NSMutableSet *typeSet = [NSMutableSet setWithArray:types];
View
39 Quicksilver/Code-QuickStepCore/QSProxyObject.m
@@ -78,7 +78,10 @@ - (QSObject*)proxyObject {
if ([provider respondsToSelector:@selector(cacheTimeForProxy:)])
interval = [[self proxyProvider] cacheTimeForProxy:self];
- [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(releaseProxy) userInfo:nil repeats:NO];
+ dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)interval * NSEC_PER_SEC);
+ dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
+ [self releaseProxy];
+ });
return proxy;
}
@@ -112,10 +115,10 @@ - (BOOL)bypassValidation {
return [[self proxyProvider] respondsToSelector:@selector(bypassValidation)] && [[self proxyProvider] bypassValidation];
}
-- (QSBasicObject *)resolvedObject {return [self proxyObject];}
+- (QSObject *)resolvedObject {return [self proxyObject];}
- (NSString *)stringValue {
- return [(QSObject*)[self resolvedObject] stringValue];
+ return [[self resolvedObject] stringValue];
}
- (BOOL)respondsToSelector:(SEL)aSelector {
@@ -141,4 +144,34 @@ - (void)objectIconModified:(NSNotification *)notif
{
[self updateIcon:[[self proxyObject] icon]];
}
+
+- (BOOL)isProxyObject
+{
+ return YES;
+}
+
+- (id)_safeObjectForType:(id)aKey {
+ id object = [data objectForKey:aKey];
+ if (!object) {
+ object = [[self resolvedObject] _safeObjectForType:aKey];
+ }
+ return object;
+}
+
+- (BOOL)loadIcon
+{
+ NSString *namedIcon = [self objectForMeta:kQSObjectIconName];
+ if (!namedIcon || [namedIcon isEqualToString:@"ProxyIcon"]) {
+ // use the resolved object's icon instead
+ QSObject *resolved = [self resolvedObject];
+ [resolved loadIcon];
+ NSImage *image = [resolved icon];
+ if (image) {
+ [self setIconLoaded:YES];
+ [self setIcon:image];
+ return YES;
+ }
+ }
+ return [super loadIcon];
+}
@end
View
6 Quicksilver/Code-QuickStepCore/QSProxyObjectSource.m
@@ -16,7 +16,7 @@ @implementation QSProxyObjectHandler
- (NSString *)detailsOfObject:(QSObject *)object {
NSString *details = nil;
- id provider = ( [object isKindOfClass:[QSProxyObject class]] ? [(QSProxyObject*)object proxyProvider] : nil );
+ id provider = ( [object isProxyObject] ? [(QSProxyObject*)object proxyProvider] : nil );
if (provider && [provider respondsToSelector:@selector(detailsOfObject:)]) {
details = [provider detailsOfObject:object];
}
@@ -27,7 +27,7 @@ - (NSString *)detailsOfObject:(QSObject *)object {
- (NSString *)identifierForObject:(QSObject*)object {
NSString *identifier = nil;
- id provider = ( [object isKindOfClass:[QSProxyObject class]] ? [(QSProxyObject*)object proxyProvider] : nil );
+ id provider = ( [object isProxyObject] ? [(QSProxyObject*)object proxyProvider] : nil );
if (provider && [provider respondsToSelector:@selector(identifierForObject:)]) {
identifier = [provider identifierForObject:object];
}
@@ -38,7 +38,7 @@ - (NSString *)identifierForObject:(QSObject*)object {
- (BOOL)loadChildrenForObject:(QSObject *)object {
BOOL loaded = NO;
- id provider = ( [object isKindOfClass:[QSProxyObject class]] ? [(QSProxyObject*)object proxyProvider] : nil );
+ id provider = ( [object isProxyObject] ? [(QSProxyObject*)object proxyProvider] : nil );
if (provider && [provider respondsToSelector:@selector(loadChildrenForObject:)]) {
loaded = [provider loadChildrenForObject:object];
}
View
3  Quicksilver/Code-QuickStepInterface/QSInterfaceController.m
@@ -350,7 +350,8 @@ - (void)updateIndirectObjects {
id actionProvider = [aObj provider];
NSArray *indirects = nil;
if (actionProvider && [actionProvider respondsToSelector:@selector(validIndirectObjectsForAction:directObject:)]) {
- indirects = [actionProvider validIndirectObjectsForAction:[aObj identifier] directObject:[dSelector objectValue]];
+ QSObject *directObject = [[dSelector objectValue] resolvedObject];
+ indirects = [actionProvider validIndirectObjectsForAction:[aObj identifier] directObject:directObject];
}
// If the validIndirectObjectsForAction... method hasn't been implemented, attempt to get valid indirects from the action's 'indirectTypes'
if(!indirects) {
View
5 Quicksilver/Code-QuickStepInterface/QSSearchObjectView.m
@@ -1860,9 +1860,8 @@ - (BOOL)canQuicklookCurrentObject {
object = [(QSRankedObject *)object object];
}
// resolve proxy objects
- if ([object isKindOfClass:[QSProxyObject class]]) {
- object = [(QSProxyObject *)object resolvedObject];
- }
+ object = [object resolvedObject];
+
if ([object validPaths] || [[object primaryType] isEqualToString:QSURLType]) {
quicklookObject = [object retain];
savedSearchMode = searchMode;
View
6 Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSActionProvider_EmbeddedProviders.m
@@ -315,10 +315,10 @@ - (NSArray *)validIndirectObjectsForAction:(NSString *)action directObject:(QSOb
} else if ([action isEqualToString:kFileMoveToAction] || [action isEqualToString:kFileCopyToAction]) {
// We only want folders for the move to / copy to actions (can't move to anything else)
NSMutableArray *fileObjects = [[[QSLibrarian sharedInstance] arrayForType:QSFilePathType] mutableCopy];
- NSString *currentFolderPath = [[[[dObject splitObjects] lastObject] singleFilePath] stringByDeletingLastPathComponent];
+ NSString *currentFolderPath = [[[dObject validPaths] lastObject] stringByDeletingLastPathComponent];
- // if the object already exists, get that object. Otherwise create a new one
- QSObject *currentFolderObject = [QSObject fileObjectWithPath:currentFolderPath];
+ // if the parent directory was found, put it first - otherwise, leave the pane blank
+ id currentFolderObject = currentFolderPath ? [QSObject fileObjectWithPath:currentFolderPath] : [NSNull null];
NSIndexSet *folderIndexes = [fileObjects indexesOfObjectsWithOptions:NSEnumerationConcurrent passingTest:^BOOL(QSObject *thisObject, NSUInteger i, BOOL *stop) {
return ([thisObject isFolder] && (thisObject != currentFolderObject));
View
8 Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSObjectActions.m
@@ -117,20 +117,20 @@ - (NSWindow *)showMenu:(NSMenu *)menu forObject:(QSObject *)object {
}
- (QSObject *)showChildMenu:(QSObject *)dObject {
- [self showMenu:[(QSObject*)[dObject resolvedObject] childrenMenu] forObject:dObject];
+ [self showMenu:[[dObject resolvedObject] childrenMenu] forObject:dObject];
return nil;
}
- (QSObject *)showMenu:(QSObject *)dObject {
- [self showMenu:[(QSObject*)[dObject resolvedObject] fullMenu] forObject:dObject];
+ [self showMenu:[[dObject resolvedObject] fullMenu] forObject:dObject];
return nil;
}
- (QSObject *)showActionMenu:(QSObject *)dObject {
- [self showMenu:[(QSObject*)[dObject resolvedObject] actionsMenu] forObject:dObject];
+ [self showMenu:[[dObject resolvedObject] actionsMenu] forObject:dObject];
return nil;
}
- (QSObject *)saveObject:(QSObject *)dObject toDirectory:(QSObject *)iObject {
- dObject = (QSObject *)[dObject resolvedObject];
+ dObject = [dObject resolvedObject];
id handler = [dObject handler];
NSData *data = nil;
NSString *filename = nil;
Please sign in to comment.
Something went wrong with that request. Please try again.