Hey both,
I've just taken a look at it. Some comments about the intention first:
* Can you tell me when these preferences fire? When would you open
GitX with PWD set, but not through the CLI? That is, when is
openCurDirOnLaunch relevant? If it's only when debugging GitX or so, I
think it shouldn't be visible in the GUI (but might be a hidden
preference).
* I don't think the current labels in the preference window make it
clear what the options do
* The open panel preference is OK, but we'll probably throw it out
with 0.8 when we add in the welcome screen.
Then the code: I think this can be cleared up a little, and put
pointers on the other side, like this:
- (void)applicationDidFinishLaunching:(NSNotification*)notification
{
[self registerServices];
// Only try to open a default document if there are no documents open
already.
// For example, the application might have been launched by
double-clicking a .git repository,
// or by dragging a folder to the app icon
if ([[[PBRepositoryDocumentController sharedDocumentController]
documents] count])
return
// Don't try to open stuff if GitX is not the frontmost app (For
example,
// when opening through the CLI)
if (![[NSApplication sharedApplication] isActive])
return;
NSURL *url = nil;
if ([PBGitDefaults openCurDirOnLaunch]) {
// Try to open the current directory as a git repository
NSString *curPath = [[[NSProcessInfo processInfo] environment]
objectForKey:@"PWD"];
if (curPath)
url = [NSURL fileURLWithPath:curPath];
}
NSError *error = nil;
if (!url || [[PBRepositoryDocumentController
sharedDocumentController] openDocumentWithContentsOfURL:url
display:YES error:&error] == NO) {
// The current directory was not enabled or could not be opened
(most likely it’s not a git repository)
if ([PBGitDefaults showOpenPanelOnLaunch]) {
// show an open panel for the user to select a
repository to view
[[PBRepositoryDocumentController
sharedDocumentController]
openDocument:self];
}
}
}
but otherwise it looks fine.