Skip to content

Commit 065a83b

Browse files
committed
Merge branch 'master' into devel
2 parents 16cdb6f + b4d3093 commit 065a83b

File tree

161 files changed

+18312
-7721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+18312
-7721
lines changed

.gitmodules

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[submodule "libgit2"]
2-
path = libgit2
3-
url = git://repo.or.cz/libgit2.git
2+
path = libgit2
3+
url = git://github.com/pieter/libgit2.git
4+
5+
# Please don't change the submodule link since we really need the
6+
# "saved" libgit2 from Pieter's repo as GitX uses a deprecated function
7+
# to calculate the realSha

ApplicationController.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
//
88

99
#import <Cocoa/Cocoa.h>
10-
#import <Quartz/Quartz.h> /* for QLPreviewPanel */
1110
#import "PBGitRepository.h"
1211

1312
@class PBCLIProxy;
13+
@class PBCloneRepositoryPanel;
1414

1515
@interface ApplicationController : NSObject
1616
{
@@ -21,6 +21,7 @@
2121
NSManagedObjectContext *managedObjectContext;
2222

2323
PBCLIProxy *cliProxy;
24+
PBCloneRepositoryPanel *cloneRepositoryPanel;
2425
}
2526
@property (retain) PBCLIProxy* cliProxy;
2627

@@ -36,6 +37,5 @@
3637
- (IBAction)saveAction:sender;
3738
- (IBAction) showHelp:(id) sender;
3839

39-
- (IBAction)togglePreviewPanel:(id)previewPanel;
40-
40+
- (IBAction) showCloneRepository:(id)sender;
4141
@end

ApplicationController.m

+59-34
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#import "PBPrefsWindowController.h"
1717
#import "PBNSURLPathUserDefaultsTransfomer.h"
1818
#import "PBGitDefaults.h"
19+
#import "PBCloneRepositoryPanel.h"
1920

2021
@implementation ApplicationController
2122
@synthesize cliProxy;
@@ -27,11 +28,10 @@ - (ApplicationController*)init
2728
#endif
2829

2930
if(self = [super init]) {
30-
/* Location of QuickLookUI.framework - it's public now */
31-
if(![[NSBundle bundleWithPath:@"/System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework"] load])
32-
{
33-
NSLog(@"Could not load QuickLook");
34-
}
31+
if(![[NSBundle bundleWithPath:@"/System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework"] load])
32+
if(![[NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/QuickLookUI.framework"] load])
33+
NSLog(@"Could not load QuickLook");
34+
3535
self.cliProxy = [PBCLIProxy new];
3636
}
3737

@@ -65,34 +65,53 @@ - (void)registerServices
6565

6666
- (void)applicationDidFinishLaunching:(NSNotification*)notification
6767
{
68+
// Make sure Git's SSH password requests get forwarded to our little UI tool:
69+
setenv( "SSH_ASKPASS", [[[NSBundle mainBundle] pathForResource: @"gitx_askpasswd" ofType: @""] UTF8String], 1 );
70+
setenv( "DISPLAY", "localhost:0", 1 );
71+
6872
[self registerServices];
6973

74+
BOOL hasOpenedDocuments = NO;
75+
NSArray *launchedDocuments = [[[PBRepositoryDocumentController sharedDocumentController] documents] copy];
76+
7077
// Only try to open a default document if there are no documents open already.
7178
// For example, the application might have been launched by double-clicking a .git repository,
7279
// or by dragging a folder to the app icon
73-
if ([[[PBRepositoryDocumentController sharedDocumentController] documents] count])
74-
return;
75-
76-
if (![[NSApplication sharedApplication] isActive])
77-
return;
78-
79-
NSURL *url = nil;
80+
if ([launchedDocuments count])
81+
hasOpenedDocuments = YES;
82+
83+
// open any documents that were open the last time the app quit
84+
if ([PBGitDefaults openPreviousDocumentsOnLaunch]) {
85+
for (NSString *path in [PBGitDefaults previousDocumentPaths]) {
86+
NSURL *url = [NSURL fileURLWithPath:path isDirectory:YES];
87+
NSError *error = nil;
88+
if (url && [[PBRepositoryDocumentController sharedDocumentController] openDocumentWithContentsOfURL:url display:YES error:&error])
89+
hasOpenedDocuments = YES;
90+
}
91+
}
8092

8193
// Try to find the current directory, to open that as a repository
82-
if ([PBGitDefaults openCurDirOnLaunch]) {
94+
if ([PBGitDefaults openCurDirOnLaunch] && !hasOpenedDocuments) {
8395
NSString *curPath = [[[NSProcessInfo processInfo] environment] objectForKey:@"PWD"];
96+
NSURL *url = nil;
8497
if (curPath)
8598
url = [NSURL fileURLWithPath:curPath];
99+
// Try to open the found URL
100+
NSError *error = nil;
101+
if (url && [[PBRepositoryDocumentController sharedDocumentController] openDocumentWithContentsOfURL:url display:YES error:&error])
102+
hasOpenedDocuments = YES;
86103
}
87104

88-
// Try to open the found URL
89-
NSError *error = nil;
90-
if (url && [[PBRepositoryDocumentController sharedDocumentController] openDocumentWithContentsOfURL:url display:YES error:&error])
105+
// to bring the launched documents to the front
106+
for (PBGitRepository *document in launchedDocuments)
107+
[document showWindows];
108+
109+
if (![[NSApplication sharedApplication] isActive])
91110
return;
92111

93112
// The current directory was not enabled or could not be opened (most likely it’s not a git repository).
94113
// show an open panel for the user to select a repository to view
95-
if ([PBGitDefaults showOpenPanelOnLaunch])
114+
if ([PBGitDefaults showOpenPanelOnLaunch] && !hasOpenedDocuments)
96115
[[PBRepositoryDocumentController sharedDocumentController] openDocument:self];
97116
}
98117

@@ -120,6 +139,14 @@ - (IBAction)showAboutPanel:(id)sender
120139
[NSApp orderFrontStandardAboutPanelWithOptions:dict];
121140
}
122141

142+
- (IBAction) showCloneRepository:(id)sender
143+
{
144+
if (!cloneRepositoryPanel)
145+
cloneRepositoryPanel = [PBCloneRepositoryPanel panel];
146+
147+
[cloneRepositoryPanel showWindow:self];
148+
}
149+
123150
- (IBAction)installCliTool:(id)sender;
124151
{
125152
BOOL success = NO;
@@ -193,7 +220,7 @@ - (NSManagedObjectModel *)managedObjectModel {
193220
return managedObjectModel;
194221
}
195222

196-
managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
223+
managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
197224
return managedObjectModel;
198225
}
199226

@@ -270,12 +297,14 @@ - (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window {
270297
*/
271298

272299
- (IBAction) saveAction:(id)sender {
300+
273301
NSError *error = nil;
274302
if (![[self managedObjectContext] save:&error]) {
275303
[[NSApplication sharedApplication] presentError:error];
276304
}
277305
}
278306

307+
279308
/**
280309
Implementation of the applicationShouldTerminate: method, used here to
281310
handle the saving of changes in the application managed object context
@@ -324,24 +353,20 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende
324353
return reply;
325354
}
326355

327-
// QuickLook preview panel
328-
329-
- (IBAction)togglePreviewPanel:(id)previewPanel
356+
- (void)applicationWillTerminate:(NSNotification *)aNotification
330357
{
331-
if ([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible]) {
332-
[[QLPreviewPanel sharedPreviewPanel] orderOut:nil];
333-
} else {
334-
[[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil];
335-
}
336-
}
358+
[PBGitDefaults removePreviousDocumentPaths];
337359

338-
- (BOOL) validateMenuItem:(NSMenuItem *)item {
339-
if ([item action] == @selector(saveAction:)) {
340-
// disable the Save menu item if there is no repository document open
341-
return ([[PBRepositoryDocumentController sharedDocumentController] currentDocument] != nil);
342-
} else {
343-
return [NSApp validateMenuItem:item];
344-
}
360+
if ([PBGitDefaults openPreviousDocumentsOnLaunch]) {
361+
NSArray *documents = [[PBRepositoryDocumentController sharedDocumentController] documents];
362+
if ([documents count] > 0) {
363+
NSMutableArray *paths = [NSMutableArray array];
364+
for (PBGitRepository *repository in documents)
365+
[paths addObject:[repository workingDirectory]];
366+
367+
[PBGitDefaults setPreviousDocumentPaths:paths];
368+
}
369+
}
345370
}
346371

347372
/**

CWQuickLook.h

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
@interface QLPreviewPanel : NSPanel
22
+ (id)sharedPreviewPanel;
3+
4+
// part of the public QL API
5+
+ (BOOL)sharedPreviewPanelExists;
6+
- (void)reloadData;
7+
- (void)setDataSource:(id)source;
8+
9+
// the private QL API
310
+ (id)_previewPanel;
411
+ (BOOL)isSharedPreviewPanelLoaded;
512
- (id)initWithContentRect:(struct _NSRect)fp8 styleMask:(unsigned int)fp24 backing:(unsigned int)fp28 defer:(BOOL)fp32;

DBPrefsWindowController.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#import <Cocoa/Cocoa.h>
4343

4444

45-
@interface DBPrefsWindowController : NSWindowController <NSAnimationDelegate, NSToolbarDelegate> {
45+
@interface DBPrefsWindowController : NSWindowController {
4646
NSMutableArray *toolbarIdentifiers;
4747
NSMutableDictionary *toolbarViews;
4848
NSMutableDictionary *toolbarItems;
@@ -71,5 +71,6 @@
7171
- (void)crossFadeView:(NSView *)oldView withView:(NSView *)newView;
7272
- (NSRect)frameForView:(NSView *)view;
7373

74+
- (NSString *)defaultViewIdentifier;
7475

7576
@end

DBPrefsWindowController.m

+15-3
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ - (IBAction)showWindow:(id)sender
211211
[toolbar release];
212212
}
213213

214-
NSString *firstIdentifier = [toolbarIdentifiers objectAtIndex:0];
215-
[[[self window] toolbar] setSelectedItemIdentifier:firstIdentifier];
216-
[self displayViewForIdentifier:firstIdentifier animate:NO];
214+
NSString *identifier = [self defaultViewIdentifier];
215+
[[[self window] toolbar] setSelectedItemIdentifier:identifier];
216+
[self displayViewForIdentifier:identifier animate:NO];
217217

218218
[[self window] center];
219219

@@ -406,4 +406,16 @@ - (NSRect)frameForView:(NSView *)view
406406

407407

408408

409+
#pragma mark -
410+
#pragma mark Default View
411+
412+
413+
- (NSString *)defaultViewIdentifier
414+
{
415+
return [toolbarIdentifiers objectAtIndex:0];
416+
}
417+
418+
419+
420+
409421
@end

0 commit comments

Comments
 (0)