forked from pieter/gitx
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PBCloneRepsitoryToSheet.m
80 lines (57 loc) · 2.03 KB
/
PBCloneRepsitoryToSheet.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// PBCloneRepsitoryToSheet.m
// GitX
//
// Created by Nathan Kinsinger on 2/7/10.
// Copyright 2010 Nathan Kinsinger. All rights reserved.
//
#import "PBCloneRepsitoryToSheet.h"
#import "PBGitRepository.h"
@interface PBCloneRepsitoryToSheet ()
- (void) beginCloneRepsitoryToSheetForRepository:(PBGitRepository *)repo;
@end
@implementation PBCloneRepsitoryToSheet
@synthesize repository;
@synthesize isBare;
@synthesize message;
@synthesize cloneToAccessoryView;
#pragma mark -
#pragma mark PBCloneRepsitoryToSheet
+ (void) beginCloneRepsitoryToSheetForRepository:(PBGitRepository *)repo
{
PBCloneRepsitoryToSheet *sheet = [[self alloc] initWithWindowNibName:@"PBCloneRepsitoryToSheet"];
[sheet beginCloneRepsitoryToSheetForRepository:repo];
}
- (void) beginCloneRepsitoryToSheetForRepository:(PBGitRepository *)repo
{
self.repository = repo;
[self window];
}
- (void) awakeFromNib
{
NSOpenPanel *cloneToSheet = [NSOpenPanel openPanel];
[cloneToSheet setTitle:@"Clone Repository To"];
[cloneToSheet setPrompt:@"Clone"];
[self.message setStringValue:[NSString stringWithFormat:@"Select a folder to clone %@ into", [self.repository projectName]]];
[cloneToSheet setCanSelectHiddenExtension:NO];
[cloneToSheet setCanChooseFiles:NO];
[cloneToSheet setCanChooseDirectories:YES];
[cloneToSheet setAllowsMultipleSelection:NO];
[cloneToSheet setCanCreateDirectories:YES];
[cloneToSheet setAccessoryView:cloneToAccessoryView];
[cloneToSheet beginSheetForDirectory:nil file:nil types:nil
modalForWindow:[self.repository.windowController window]
modalDelegate:self
didEndSelector:@selector(cloneToSheetDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
}
- (void) cloneToSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)code contextInfo:(void *)info
{
[sheet orderOut:self];
if (code == NSOKButton) {
NSString *clonePath = [(NSOpenPanel *)sheet filename];
NSLog(@"clone path = %@", clonePath);
[self.repository cloneRepositoryToPath:clonePath bare:self.isBare];
}
}
@end