Skip to content

Commit

Permalink
r2078@wrk-149: tiennou | 2008-11-25 13:21:48 +0100
Browse files Browse the repository at this point in the history
 Removed unused way of getting actions via the object handler.


git-svn-id: https://blacktree-alchemy.googlecode.com/svn/branches/B5X@285 d44230c2-7321-0410-b0f2-3d6f2d243adf
  • Loading branch information
tiennou7 committed Nov 25, 2008
1 parent f7d3fe1 commit b3a5042
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 60 deletions.
27 changes: 9 additions & 18 deletions Quicksilver/Code-QuickStepCore/QSExecutor.m
Expand Up @@ -36,9 +36,9 @@

QSExecutor *QSExec;

@interface QSObject (QSActionsHandlerProtocol)
/*@interface QSObject (QSActionsHandlerProtocol)
- (NSArray *)actionsForDirectObject:(QSObject *)dObject indirectObject:(QSObject *)iObject;
@end
@end*/

@interface QSAction (QSPrivate)
- (void)_setRank:(int)newRank;
Expand Down Expand Up @@ -291,36 +291,29 @@ - (NSArray *)rankedActionsForDirectObject:(QSObject *)dObject indirectObject:(QS
}

- (NSArray *)rankedActionsForDirectObject:(QSObject *)dObject indirectObject:(QSObject *)iObject shouldBypass:(BOOL)bypass {
NSMutableArray *actions = nil;
if ([[dObject handler] respondsToSelector:@selector(actionsForDirectObject:indirectObject:)])
actions = (NSMutableArray *)[[dObject handler] actionsForDirectObject:dObject indirectObject:iObject];

if ([dObject isKindOfClass:[QSRankedObject class]]) {
dObject = [(QSRankedObject*)dObject object];
}
BOOL bypassValidation=
NSArray *actions = nil;

BOOL bypassValidation =
(bypass && [dObject isKindOfClass:[QSProxyObject class]] && [(QSProxyObject *)dObject bypassValidation]);

if (bypassValidation) {
//NSLog(@"bypass? %@ %@", dObject, NSStringFromClass([dObject class]) );
actions = [[[actionIdentifiers allValues] mutableCopy] autorelease];
}
if (!actions)
actions = (NSMutableArray *)[self validActionsForDirectObject:dObject indirectObject:iObject];
actions = [self validActionsForDirectObject:dObject indirectObject:iObject];

NSString *preferredActionID = [dObject objectForMeta:kQSObjectDefaultAction];

id preferredAction = nil;
if ([preferredActionID isEqualToString:@""])
preferredAction = [NSNull null];
else if (preferredActionID)
if (preferredActionID)
preferredAction = [self actionForIdentifier:preferredActionID];

// NSLog(@"prefer \"%@\"", preferredActionID);
// NSLog(@"actions %d", [actions count]);
#if 1
NSSortDescriptor *rankDescriptor = [[NSSortDescriptor alloc] initWithKey:@"rank" ascending:YES];
[actions sortUsingDescriptors:[NSArray arrayWithObject:rankDescriptor]];
actions = [actions sortedArrayUsingDescriptors:[NSArray arrayWithObject:rankDescriptor]];
[rankDescriptor release];
#else
actions = [QSLib scoredArrayForString:[NSString stringWithFormat:@"QSActionMnemonic:%@", [dObject primaryType]] inSet:actions mnemonicsOnly:YES];
Expand Down Expand Up @@ -414,9 +407,7 @@ - (NSArray *)validActionsForDirectObject:(QSObject *)dObject indirectObject:(QSO
//if ([validSourceActions count])
// NSLog(@"Actions for %@:%@", thisAction, validSourceActions);


if (isValid) [validActions addObject:thisAction];

}


Expand All @@ -425,7 +416,7 @@ - (NSArray *)validActionsForDirectObject:(QSObject *)dObject indirectObject:(QSO
NSLog(@"unable to find actions %@\r%@", oldActionObjects, actionIdentifiers);
NSLog(@"types %@ %@", types, fileType);
}
return validActions;
return [[validActions copy] autorelease];
}

- (NSArray *)validIndirectObjectsForAction:(NSString *)action directObject:(QSObject *)dObject {
Expand Down
2 changes: 1 addition & 1 deletion Quicksilver/Code-QuickStepCore/QSObject.h
Expand Up @@ -27,7 +27,7 @@ extern NSSize QSMaxIconSize;
- (NSDragOperation)operationForDrag:(id <NSDraggingInfo>)sender ontoObject:(QSObject *)dObject withObject:(QSBasicObject *)iObject;
- (NSString *)actionForDragMask:(NSDragOperation)operation ontoObject:(QSObject *)dObject withObject:(QSBasicObject *)iObject;

- (NSArray *)actionsForDirectObject:(QSObject *)dObject indirectObject:(QSObject *)iObject;
//- (NSArray *)actionsForDirectObject:(QSObject *)dObject indirectObject:(QSObject *)iObject;
@end


Expand Down
7 changes: 4 additions & 3 deletions Quicksilver/Code-QuickStepCore/QSObject.m
Expand Up @@ -320,8 +320,10 @@ - (NSString *)descriptionWithLocale:(NSDictionary *)locale indent:(unsigned)leve

- (id)handlerForType:(NSString *)type selector:(SEL)selector {
id handler = [[QSReg objectHandlers] objectForKey:type];
if (!selector || [handler respondsToSelector:selector]) return handler;
return nil;
if(DEBUG && handler == nil)
NSLog(@"No handler for type %@", type);

return (selector == NULL ? handler : ( [handler respondsToSelector:selector] ? handler : nil ) );
}

- (id)handlerForSelector:(SEL)selector {
Expand All @@ -332,7 +334,6 @@ - (id)handler {
return [self handlerForType:[self primaryType] selector:nil];
}


- (BOOL)drawIconInRect:(NSRect)rect flipped:(BOOL)flipped {
id handler = nil;
if (handler = [self handlerForSelector:@selector(drawIconForObject:inRect:flipped:)]) {
Expand Down
25 changes: 0 additions & 25 deletions Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m
Expand Up @@ -480,29 +480,6 @@ - (BOOL)loadChildrenForObject:(QSObject *)object {

return YES;
}

- (NSArray *)actionsForDirectObject:(QSObject *)dObject indirectObject:(QSObject *)iObject {
NSString *path = [dObject objectForType:QSFilePathType];
if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:nil]) {
LSItemInfoRecord infoRec;
LSCopyItemInfoForURL((CFURLRef) [NSURL fileURLWithPath:path] , kLSRequestBasicFlagsOnly, &infoRec);
if (infoRec.flags & kLSItemInfoIsApplication) {
NSMutableArray *actions = (NSMutableArray *)[QSExec validActionsForDirectObject:dObject indirectObject:iObject];
NSString *bundleIdentifier = [[NSBundle bundleWithPath:path] bundleIdentifier];

//NSLog(@"actions %d", [actions count]);
NSDictionary *appActions = [[QSReg tableNamed:@"QSApplicationActions"] objectForKey:bundleIdentifier];
foreachkey(actionID, actionDict, appActions) {
[actions addObject:[QSAction actionWithDictionary:actionDict identifier:actionID]];
}
// NSLog(@"actions %d", [actions count]);

return actions;

}
}
return nil;
}
@end

@implementation QSBasicObject (FileHandling)
Expand Down Expand Up @@ -540,8 +517,6 @@ - (int) fileCount {

@end

#define clippingTypes [NSSet setWithObjects:@"textClipping", @"pictClipping", @"'clpp'", @"textClipping", @"'clpt'", @"webloc", @"inetloc", @"'ilht'", @"'ilaf'", nil]

@implementation QSObject (FileHandling)

+ (QSObject *)fileObjectWithPath:(NSString *)path {
Expand Down
14 changes: 1 addition & 13 deletions Quicksilver/PlugIns-Main/Finder/QSFinderProxy.m
Expand Up @@ -4,8 +4,6 @@
#import <QSFoundation/NSObject+ReaperExtensions.h>
#import <QSFoundation/NSAppleScript_BLTRExtensions.h>



@implementation QSFinderProxy
+ (id)sharedInstance {
static id _sharedInstance;
Expand Down Expand Up @@ -76,6 +74,7 @@ - (NSArray *)getInfoForFiles:(NSArray *)files {
- (BOOL)openFile:(NSString *)file {
return [[NSWorkspace sharedWorkspace] openFile:file];
}

- (NSArray *)deleteFiles:(NSArray *)files {
return nil;
}
Expand Down Expand Up @@ -174,21 +173,10 @@ - (void)setFinderScript:(NSAppleScript *)aFinderScript {


- (id)resolveProxyObject:(id)proxy {
// NSLog(@"provide");
//com.apple.finder
return [QSObject fileObjectWithArray:[self selection]];
}

- (NSArray *)typesForProxyObject:(id)proxy {
return [NSArray arrayWithObject:QSFilePathType];
}

- (NSArray *)actionsForDirectObject:(QSObject *)dObject indirectObject:(QSObject *)iObject {
// Trash Object
return [NSMutableArray arrayWithObjects:
[QSAction actionWithIdentifier:kFinderOpenTrashAction],
[QSAction actionWithIdentifier:kFinderEmptyTrashAction],
nil];
}

@end

0 comments on commit b3a5042

Please sign in to comment.