forked from dgrijalva/gitx
-
Notifications
You must be signed in to change notification settings - Fork 76
/
PBCloneRepsitoryToSheet.m
82 lines (62 loc) · 2.11 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
81
82
//
// PBCloneRepsitoryToSheet.m
// GitX
//
// Created by Nathan Kinsinger on 2/7/10.
// Copyright 2010 Nathan Kinsinger. All rights reserved.
//
#import "PBCloneRepsitoryToSheet.h"
#import "PBGitRepository.h"
#import "PBGitWindowController.h"
@interface PBCloneRepsitoryToSheet ()
- (void) beginCloneRepsitoryToSheetForRepository:(PBGitRepository *)repo;
@end
@implementation PBCloneRepsitoryToSheet
@synthesize repository;
@synthesize isBare;
@synthesize message;
@synthesize cloneToAccessoryView;
static PBCloneRepsitoryToSheet *sheet;
#pragma mark -
#pragma mark PBCloneRepsitoryToSheet
+ (void) beginCloneRepsitoryToSheetForRepository:(PBGitRepository *)repo
{
if (!sheet) {
sheet = [[self alloc] initWithWindowNibName:@"PBCloneRepsitoryToSheet"];
}
[sheet beginCloneRepsitoryToSheetForRepository:repo];
}
- (void) beginCloneRepsitoryToSheetForRepository:(PBGitRepository *)repo
{
self.repository = repo;
[self window];
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 beginSheetModalForWindow:[self.repository.windowController window]
completionHandler:
^(NSInteger result)
{
[cloneToSheet orderOut:self];
if (result == NSFileHandlingPanelOKButton)
{
NSString *clonePath = [[cloneToSheet URL] path];
DLog(@"clone path = %@", clonePath);
[self.repository cloneRepositoryToPath:clonePath bare:self.isBare];
}
}
];
}
#pragma mark - IBAction methods
- (IBAction) showHideHiddenFiles:(id)sender
{
[cloneToSheet setShowsHiddenFiles:[sender state]];
}
@end