diff --git a/ApplicationController.m b/ApplicationController.m
index 6752c9a..3bc6724 100644
--- a/ApplicationController.m
+++ b/ApplicationController.m
@@ -68,18 +68,30 @@
// 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] == 0 && [[NSApplication sharedApplication] isActive]) {
- // Try to open the current directory as a git repository
- NSURL *url = nil;
- if([[[NSProcessInfo processInfo] environment] objectForKey:@"PWD"])
- url = [NSURL fileURLWithPath:[[[NSProcessInfo processInfo] environment] objectForKey:@"PWD"]];
- NSError *error = nil;
- if (!url || [[PBRepositoryDocumentController sharedDocumentController] openDocumentWithContentsOfURL:url display:YES error:&error] == NO) {
- // The current directory could not be opened (most likely it’s not a git repository)
- // so show an open panel for the user to select a repository to view
- [[PBRepositoryDocumentController sharedDocumentController] openDocument:self];
- }
+ if ([[[PBRepositoryDocumentController sharedDocumentController] documents] count])
+ return;
+
+ if (![[NSApplication sharedApplication] isActive])
+ return;
+
+ NSURL *url = nil;
+
+ // Try to find the current directory, to open that as a repository
+ if ([PBGitDefaults openCurDirOnLaunch]) {
+ NSString *curPath = [[[NSProcessInfo processInfo] environment] objectForKey:@"PWD"];
+ if (curPath)
+ url = [NSURL fileURLWithPath:curPath];
}
+
+ // Try to open the found URL
+ NSError *error = nil;
+ if (url && [[PBRepositoryDocumentController sharedDocumentController] openDocumentWithContentsOfURL:url display:YES error:&error])
+ return;
+
+ // The current directory was not enabled or could not be opened (most likely it’s not a git repository).
+ // show an open panel for the user to select a repository to view
+ if ([PBGitDefaults showOpenPanelOnLaunch])
+ [[PBRepositoryDocumentController sharedDocumentController] openDocument:self];
}
- (void) windowWillClose: sender
diff --git a/English.lproj/Preferences.xib b/English.lproj/Preferences.xib
index 2a1a298..465f1e1 100644
--- a/English.lproj/Preferences.xib
+++ b/English.lproj/Preferences.xib
@@ -46,7 +46,7 @@
- {{121, 70}, {179, 22}}
+ {{121, 50}, {179, 22}}
YES
@@ -112,7 +112,7 @@
268
- {{118, 20}, {192, 42}}
+ {{118, 0}, {192, 42}}
YES
@@ -128,7 +128,7 @@
268
- {{306, 74}, {54, 14}}
+ {{306, 54}, {54, 14}}
YES
@@ -177,6 +177,28 @@
25
+
+
+ 268
+ {{18, 78}, {207, 18}}
+
+ YES
+
+ -2080244224
+ 0
+ U2hvdyAiT3BlbiIgcGFuZWwgb24gbGF1bmNoA
+
+
+ 1211912703
+ 2
+
+
+
+
+ 200
+ 25
+
+
{400, 139}
@@ -428,7 +450,7 @@
YES
- PBShowWhitespaceDifferences
+ PBShowOpenPanelOnLaunch
YES
@@ -865,6 +887,22 @@
117
+
+
+ value: values.PBShowOpenPanelOnLaunch
+
+
+
+
+
+ value: values.PBShowOpenPanelOnLaunch
+ value
+ values.PBShowOpenPanelOnLaunch
+ 2
+
+
+ 121
+
@@ -900,11 +938,12 @@
YES
+
-
+
General
@@ -1226,6 +1265,20 @@
+
+ 118
+
+
+ YES
+
+
+
+
+
+ 119
+
+
+
@@ -1246,6 +1299,8 @@
11.IBPluginDependency
114.IBPluginDependency
115.IBPluginDependency
+ 118.IBPluginDependency
+ 119.IBPluginDependency
12.IBPluginDependency
13.IBPluginDependency
14.IBPluginDependency
@@ -1314,6 +1369,8 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
{{514, 459}, {106, 71}}
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -1327,7 +1384,7 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- {{297, 436}, {400, 139}}
+ {{324, 683}, {400, 139}}
com.apple.InterfaceBuilder.CocoaPlugin
YES
@@ -1381,7 +1438,7 @@
- 117
+ 121
diff --git a/PBGitDefaults.h b/PBGitDefaults.h
index 6610681..fec2430 100644
--- a/PBGitDefaults.h
+++ b/PBGitDefaults.h
@@ -17,5 +17,7 @@
+ (BOOL) confirmPublicGists;
+ (BOOL) isGistPublic;
+ (BOOL)showWhitespaceDifferences;
++ (BOOL)openCurDirOnLaunch;
++ (BOOL)showOpenPanelOnLaunch;
@end
diff --git a/PBGitDefaults.m b/PBGitDefaults.m
index c605617..dc9cfd1 100644
--- a/PBGitDefaults.m
+++ b/PBGitDefaults.m
@@ -15,6 +15,8 @@
#define kConfirmPublicGists @"PBConfirmPublicGists"
#define kPublicGist @"PBGistPublic"
#define kShowWhitespaceDifferences @"PBShowWhitespaceDifferences"
+#define kOpenCurDirOnLaunch @"PBOpenCurDirOnLaunch"
+#define kShowOpenPanelOnLaunch @"PBShowOpenPanelOnLaunch"
@implementation PBGitDefaults
@@ -33,6 +35,10 @@
forKey:kPublicGist];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kShowWhitespaceDifferences];
+ [defaultValues setObject:[NSNumber numberWithBool:YES]
+ forKey:kOpenCurDirOnLaunch];
+ [defaultValues setObject:[NSNumber numberWithBool:YES]
+ forKey:kShowOpenPanelOnLaunch];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
}
@@ -61,9 +67,19 @@
return [[NSUserDefaults standardUserDefaults] boolForKey:kPublicGist];
}
-
+ (BOOL)showWhitespaceDifferences
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kShowWhitespaceDifferences];
}
+
++ (BOOL)openCurDirOnLaunch
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:kOpenCurDirOnLaunch];
+}
+
++ (BOOL)showOpenPanelOnLaunch
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:kShowOpenPanelOnLaunch];
+}
+
@end