mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add a "New..." option to the Main Menu to create a local
repository
This commit is contained in:
committed by
Pieter de Bie
parent
c70eff74e8
commit
8a6d55dbfe
@@ -8,7 +8,7 @@
|
||||
<string key="IBDocument.HIToolboxVersion">353.00</string>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="57"/>
|
||||
<integer value="81"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@@ -213,7 +213,7 @@
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSMenuItem" id="968526216">
|
||||
<reference key="NSMenu" ref="310195297"/>
|
||||
<string key="NSTitle">New</string>
|
||||
<string type="base64-UTF8" key="NSTitle">TmV34oCmA</string>
|
||||
<string key="NSKeyEquiv">n</string>
|
||||
<int key="NSKeyEquivModMask">1048576</int>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
@@ -222,7 +222,7 @@
|
||||
</object>
|
||||
<object class="NSMenuItem" id="432647792">
|
||||
<reference key="NSMenu" ref="310195297"/>
|
||||
<string key="NSTitle">Open...</string>
|
||||
<string type="base64-UTF8" key="NSTitle">T3BlbuKApg</string>
|
||||
<string key="NSKeyEquiv">o</string>
|
||||
<int key="NSKeyEquivModMask">1048576</int>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
@@ -1212,6 +1212,14 @@
|
||||
</object>
|
||||
<int key="connectionID">933</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">newDocument:</string>
|
||||
<reference key="source" ref="954860085"/>
|
||||
<reference key="destination" ref="968526216"/>
|
||||
</object>
|
||||
<int key="connectionID">934</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@@ -2256,7 +2264,7 @@
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">933</int>
|
||||
<int key="maxID">934</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
||||
@@ -46,4 +46,36 @@
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)newDocument:(id)sender
|
||||
{
|
||||
NSOpenPanel *op = [NSOpenPanel openPanel];
|
||||
|
||||
[op setCanChooseFiles:NO];
|
||||
[op setCanChooseDirectories:YES];
|
||||
[op setAllowsMultipleSelection:NO];
|
||||
[op setMessage:@"Initialize a repository here:"];
|
||||
[op setTitle:@"New Repository"];
|
||||
if ([op runModal] == NSFileHandlingPanelOKButton)
|
||||
{
|
||||
NSString *path = [op filename];
|
||||
NSInteger terminationStatus;
|
||||
NSString *result = [PBEasyPipe outputForCommand:[PBGitBinary path] withArgs:[NSArray arrayWithObjects:@"init", @"-q", nil] inDir:path inputString:nil retValue:&terminationStatus];
|
||||
|
||||
if (terminationStatus == 0)
|
||||
[self openDocumentWithContentsOfURL:[op URL] display:YES error:NULL];
|
||||
else
|
||||
NSRunAlertPanel(@"Failed to create new Git repository", @"Git returned the following error when trying to create the repository: %@", nil, nil, nil, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item
|
||||
{
|
||||
if ([item action] == @selector(newDocument:))
|
||||
return ([PBGitBinary path] != nil);
|
||||
return [super validateMenuItem:item];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user