Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small bug fixes #494

Merged
merged 4 commits into from
Oct 13, 2011
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 41 additions & 23 deletions Quicksilver/Code-QuickStepCore/QSCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,31 @@ - (void)setIndirectObject:(QSObject*)newObject {

- (QSAction *)aObject {
QSAction *action = aObject;
if (!action) {
action = [QSAction actionWithIdentifier:[[self commandDict] objectForKey:@"actionID"]];
[self setActionObject:action];
}
if (!action) {
action = [QSAction actionWithDictionary:[[self commandDict] objectForKey:@"actionArchive"]];
[self setActionObject:action];
if (action) {
return action;
}

NSDictionary *cmdDict = [self commandDict];

action = [QSAction actionWithIdentifier:[cmdDict objectForKey:@"actionID"]];

if (!action) {
action = [QSAction actionWithDictionary:[cmdDict objectForKey:@"actionArchive"]];
}

if (!action) {
NSLog(@"Warning: no action object for Command %@\nCommand Dictionary: %@", self, cmdDict);
}
else {
[self setActionObject:action];
}

return action;
}

- (QSObject *)dObject {
QSObject *object = dObject;
// If we have the object, do not go through numerous 'if(!object)' before returning
// Return the object if it already exists
if (object) {
return object;
}
Expand All @@ -306,25 +317,31 @@ - (QSObject *)dObject {

if (directID) {
object = [QSObject objectWithIdentifier:directID];
// For cases where the command has a directID/directArchive, but it's corresponding object hasn't already been created (i.e. *not* in the catalog)
if (!object) {
// sniffs the string to create a new object
object = [QSObject objectWithString:directID];
object = [QSAction actionWithIdentifier:directID];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the direct object be set to a QSAction here? Seems odd, but maybe there’s a reason.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was in Alcor's original code, but I took it out when I made the first
changes in this area. (Actually it may have been Etienne that put it in,
can't remember, don't have the internet capabilities atm to check - sorry!)
I took it out as we had no idea what it did.

This time around I left it in because I thought I shouldn't necessarily
change things just because I don't understand them.

On 5 October 2011 14:01, Rob McBroom <
reply@reply.github.com>wrote:

          if (!object) {
  •                 // sniffs the string to create a new object
    
  •                 object = [QSObject objectWithString:directID];
    
  •                 object = [QSAction actionWithIdentifier:directID];
    

Should the direct object be set to a QSAction here? Seems odd, but maybe
theres a reason.

Reply to this email directly or view it on GitHub:
https://github.com/quicksilver/Quicksilver/pull/494/files#r155754

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep a copy of the B54 code (or at least it’s the oldest commit we have) for reference. There’s no mention of QSAction in that method. My guess is something got copied and pasted, but not changed to suit the new context. I say yank it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK then I'm pretty sure Etienne put it in when he made the changes there
before me. I'll yank it :)

On 6 October 2011 19:34, Rob McBroom <
reply@reply.github.com>wrote:

          if (!object) {
  •                 // sniffs the string to create a new object
    
  •                 object = [QSObject objectWithString:directID];
    
  •                 object = [QSAction actionWithIdentifier:directID];
    

I keep a copy of the B54 code (or at least its the oldest commit we have)
for reference. Theres no mention of QSAction in that method. My guess is
something got copied and pasted, but not changed to suit the new context. I
say yank it.

Reply to this email directly or view it on GitHub:
https://github.com/quicksilver/Quicksilver/pull/494/files#r158319

}
}

if (!object) {
object = [QSObject objectWithDictionary:[[self commandDict] objectForKey:@"directArchive"]];
object = [QSObject objectWithDictionary:[cmdDict objectForKey:@"directArchive"]];
}


if (!object)
if (!object) {
object = [QSObject fileObjectWithPath:[QSRez pathWithLocatorInformation:[cmdDict objectForKey:@"directResource"]]];
}

// For cases where the command has a directID/directArchive, but it's corresponding object hasn't already been created (i.e. *not* in the catalog)
if (!object && directID) {
// sniffs the string to create a new object
object = [QSObject objectWithString:directID];
}


// For cases where we really can't determine the object
if (!object) {
NSLog(@"Warning: no direct object for Command %@\nCommand Dictionary: %@", self, cmdDict);
}
if (object) {
else {
[self setDirectObject:object];
}
return object;
Expand All @@ -338,24 +355,25 @@ - (QSObject *)iObject {

NSDictionary *cmdDict = [self commandDict];
NSString *indirectID = [cmdDict objectForKey:@"indirectID"];

if (indirectID) {
object = [QSObject objectWithIdentifier:indirectID];
if (!object) {
// For cases where the object doesn't exist
if (!object) {
// create an object by sniffing the string
object = [QSObject objectWithString:indirectID];
}
}
}

if (!object) {
object = [QSObject objectWithDictionary:[[self commandDict] objectForKey:@"indirectArchive"]];
object = [QSObject objectWithDictionary:[cmdDict objectForKey:@"indirectArchive"]];
}

if (!object) {
object = [QSObject fileObjectWithPath:[QSRez pathWithLocatorInformation:[cmdDict objectForKey:@"indirectResource"]]];
}

// For cases where the object doesn't exist (not in the catalog)
if (!object && indirectID) {
// create an object by sniffing the string
object = [QSObject objectWithString:indirectID];
}

if (object) {
[self setIndirectObject:object];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,43 @@ - (NSArray *)actions {
}

- (NSArray *)validActionsForDirectObject:(QSObject *)dObject indirectObject:(QSObject *)iObject {
if ([[[dObject singleFilePath] stringByStandardizingPath] hasPrefix:@"/Volumes/"])
NSArray *paths = [dObject arrayForType:QSFilePathType];
BOOL valid = NO;
if (paths)
{
valid = YES;
for (NSString *path in paths) {
if (![[path stringByStandardizingPath] hasPrefix:@"/Volumes/"]) {
valid = NO;
break;
}
}
}
if (valid)
return [NSArray arrayWithObject:kDiskEjectAction];
else
else {
return nil;
}
}

- (QSObject *)performAction:(QSAction *)action directObject:(QSBasicObject *)dObject indirectObject:(QSBasicObject *)iObject {
NSString *firstFile = [dObject singleFilePath];
if ([[[NSWorkspace sharedWorkspace] mountedLocalVolumePaths] containsObject:[[dObject singleFilePath] stringByStandardizingPath]]) {
if (![[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath:firstFile]) {
NSDictionary *errorDict;
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@"tell application \"Finder\" to eject disk \"%@\"", [[NSFileManager defaultManager] displayNameAtPath:firstFile]]];
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
for (NSString *mountedVolume in [dObject arrayForType:QSFilePathType]) {
if ([[ws mountedLocalVolumePaths] containsObject:[mountedVolume stringByStandardizingPath]]) {
NSError *err = nil;
if (![ws unmountAndEjectDeviceAtURL:[NSURL fileURLWithPath:mountedVolume] error:&err]) {
NSLog(@"Error unmounting: %@\nTrying to use Finder (via Applescript)",err);
NSDictionary *errorDict = nil;
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@"tell application \"Finder\" to eject disk \"%@\"", [[NSFileManager defaultManager] displayNameAtPath:mountedVolume]]];
[script executeAndReturnError:&errorDict];
[script release];
if (errorDict) NSBeep();
if (errorDict) {
NSBeep();
NSLog(@"Error: %@",errorDict);
}
}
}
}
return nil;
}

Expand Down