22
22
#import < Sparkle/SUUpdater.h>
23
23
#import < Sparkle/SUUpdaterDelegate.h>
24
24
25
- static OpenRecentController* recentsDialog = nil ;
25
+ static OpenRecentController * recentsDialog = nil ;
26
26
27
27
@interface ApplicationController () <SUUpdaterDelegate>
28
28
@end
29
29
30
30
@implementation ApplicationController
31
31
32
- - (ApplicationController*)init
32
+ - (ApplicationController *)init
33
33
{
34
34
#ifdef DEBUG_BUILD
35
35
[NSApp activateIgnoringOtherApps: YES ];
36
36
#endif
37
37
38
- if (!(self = [super init ]))
38
+ if (!(self = [super init ]))
39
39
return nil ;
40
40
41
- if (![[NSBundle bundleWithPath: @" /System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework" ] load ])
42
- if (![[NSBundle bundleWithPath: @" /System/Library/PrivateFrameworks/QuickLookUI.framework" ] load ])
41
+ if (![[NSBundle bundleWithPath: @" /System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework" ] load ])
42
+ if (![[NSBundle bundleWithPath: @" /System/Library/PrivateFrameworks/QuickLookUI.framework" ] load ])
43
43
NSLog (@" Could not load QuickLook" );
44
44
45
45
/* Value Transformers */
46
46
NSValueTransformer *transformer = [[PBNSURLPathUserDefaultsTransfomer alloc ] init ];
47
47
[NSValueTransformer setValueTransformer: transformer forName: @" PBNSURLPathUserDefaultsTransfomer" ];
48
-
48
+
49
49
// Make sure the PBGitDefaults is initialized, by calling a random method
50
50
[PBGitDefaults class ];
51
-
51
+
52
52
started = NO ;
53
53
return self;
54
54
}
@@ -64,27 +64,27 @@ - (void)registerServices
64
64
65
65
// Force update the services menu if we have a new services version
66
66
NSInteger serviceVersion = [[NSUserDefaults standardUserDefaults ] integerForKey: @" Services Version" ];
67
- if (serviceVersion < 2 )
68
- {
67
+ if (serviceVersion < 2 ) {
69
68
NSLog (@" Updating services menu…" );
70
69
NSUpdateDynamicServices ();
71
70
[[NSUserDefaults standardUserDefaults ] setInteger: 2 forKey: @" Services Version" ];
72
71
}
73
72
}
74
73
75
- - (void )application : (NSApplication *)sender openFiles : (NSArray <NSString *> *)filenames {
76
- PBRepositoryDocumentController * controller = [PBRepositoryDocumentController sharedDocumentController ];
77
-
78
- for (NSString * filename in filenames) {
79
- NSURL * repository = [NSURL fileURLWithPath: filename];
80
- [controller openDocumentWithContentsOfURL: repository display: YES
81
- completionHandler: ^void (NSDocument *document, BOOL documentWasAlreadyOpen, NSError *error) {
74
+ - (void )application : (NSApplication *)sender openFiles : (NSArray <NSString *> *)filenames
75
+ {
76
+ PBRepositoryDocumentController *controller = [PBRepositoryDocumentController sharedDocumentController ];
77
+
78
+ for (NSString *filename in filenames) {
79
+ NSURL *repository = [NSURL fileURLWithPath: filename];
80
+ [controller openDocumentWithContentsOfURL: repository
81
+ display: YES
82
+ completionHandler: ^void (NSDocument *document, BOOL documentWasAlreadyOpen, NSError *error) {
82
83
if (!document) {
83
84
NSLog (@" Error opening repository \" %@ \" : %@ " , repository.path , error);
84
85
[controller presentError: error];
85
86
[sender replyToOpenOrPrint: NSApplicationDelegateReplyFailure];
86
- }
87
- else {
87
+ } else {
88
88
[sender replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
89
89
}
90
90
}];
@@ -93,60 +93,60 @@ - (void)application:(NSApplication *)sender openFiles:(NSArray <NSString *> *)fi
93
93
94
94
- (BOOL )applicationShouldOpenUntitledFile : (NSApplication *)sender
95
95
{
96
- if (!started || [[[NSDocumentController sharedDocumentController ] documents ] count ])
96
+ if (!started || [[[NSDocumentController sharedDocumentController ] documents ] count ])
97
97
return NO ;
98
98
return YES ;
99
99
}
100
100
101
101
- (BOOL )applicationOpenUntitledFile : (NSApplication *)theApplication
102
102
{
103
103
recentsDialog = [[OpenRecentController alloc ] init ];
104
- if ([recentsDialog.possibleResults count ] > 0 )
105
- {
104
+ if ([recentsDialog.possibleResults count ] > 0 ) {
106
105
[recentsDialog show ];
107
106
return YES ;
108
- }
109
- else
110
- {
107
+ } else {
111
108
return NO ;
112
109
}
113
110
}
114
111
115
- - (void )applicationDidFinishLaunching : (NSNotification *)notification
112
+ - (void )applicationDidFinishLaunching : (NSNotification *)notification
116
113
{
117
114
[[SUUpdater sharedUpdater ] setSendsSystemProfile: YES ];
118
- [[SUUpdater sharedUpdater ] setDelegate: self ];
115
+ [[SUUpdater sharedUpdater ] setDelegate: self ];
119
116
120
117
// Make sure Git's SSH password requests get forwarded to our little UI tool:
121
- setenv ( " SSH_ASKPASS" , [[[NSBundle mainBundle ] pathForResource: @" gitx_askpasswd" ofType: @" " ] UTF8String ], 1 );
122
- setenv ( " DISPLAY" , " localhost:0" , 1 );
118
+ setenv (" SSH_ASKPASS" , [[[NSBundle mainBundle ] pathForResource: @" gitx_askpasswd" ofType: @" " ] UTF8String ], 1 );
119
+ setenv (" DISPLAY" , " localhost:0" , 1 );
123
120
124
121
[NSApp registerObserverForAppearanceChanges: self ];
125
122
[self registerServices ];
126
123
started = YES ;
127
124
}
128
125
129
- - (void ) windowWillClose : sender
126
+ - (void )windowWillClose :sender
130
127
{
131
- [firstResponder terminate: sender];
128
+ [firstResponder terminate: sender];
132
129
}
133
130
134
131
// Override the default behavior
135
- - (IBAction )openDocument : (id )sender {
136
- NSOpenPanel * panel = [[NSOpenPanel alloc ] init ];
137
-
132
+ - (IBAction )openDocument : (id )sender
133
+ {
134
+ NSOpenPanel *panel = [[NSOpenPanel alloc ] init ];
135
+
138
136
[panel setCanChooseFiles: false ];
139
137
[panel setCanChooseDirectories: true ];
140
-
138
+
141
139
[panel beginWithCompletionHandler: ^(NSInteger result) {
142
140
if (result == NSFileHandlingPanelOKButton ) {
143
- PBRepositoryDocumentController* controller = [PBRepositoryDocumentController sharedDocumentController ];
144
- [controller openDocumentWithContentsOfURL: panel.URL display: true completionHandler: ^(NSDocument * _Nullable document, BOOL documentWasAlreadyOpen, NSError * _Nullable error) {
145
- if (!document) {
146
- NSLog (@" Error opening repository \" %@ \" : %@ " , panel.URL .path , error);
147
- [controller presentError: error];
148
- }
149
- }];
141
+ PBRepositoryDocumentController *controller = [PBRepositoryDocumentController sharedDocumentController ];
142
+ [controller openDocumentWithContentsOfURL: panel.URL
143
+ display: true
144
+ completionHandler: ^(NSDocument *_Nullable document, BOOL documentWasAlreadyOpen, NSError *_Nullable error) {
145
+ if (!document) {
146
+ NSLog (@" Error opening repository \" %@ \" : %@ " , panel.URL .path , error);
147
+ [controller presentError: error];
148
+ }
149
+ }];
150
150
}
151
151
}];
152
152
}
@@ -163,16 +163,16 @@ - (IBAction)showAboutPanel:(id)sender
163
163
if (gitversion)
164
164
[dict addEntriesFromDictionary: [[NSDictionary alloc ] initWithObjectsAndKeys: gitversion, @" Version" , nil ]];
165
165
166
- #ifdef DEBUG_BUILD
167
- [dict addEntriesFromDictionary: [[NSDictionary alloc ] initWithObjectsAndKeys: @" GitX-dev (DEBUG)" , @" ApplicationName" , nil ]];
168
- #endif
166
+ #ifdef DEBUG_BUILD
167
+ [dict addEntriesFromDictionary: [[NSDictionary alloc ] initWithObjectsAndKeys: @" GitX-dev (DEBUG)" , @" ApplicationName" , nil ]];
168
+ #endif
169
169
170
170
[dict addEntriesFromDictionary: [[NSDictionary alloc ] initWithObjectsAndKeys: @" GitX-dev (rowanj fork)" , @" ApplicationName" , nil ]];
171
171
172
172
[NSApp orderFrontStandardAboutPanelWithOptions: dict];
173
173
}
174
174
175
- - (IBAction ) showCloneRepository : (id )sender
175
+ - (IBAction )showCloneRepository : (id )sender
176
176
{
177
177
if (!cloneRepositoryPanel)
178
178
cloneRepositoryPanel = [PBCloneRepositoryPanel panel ];
@@ -182,19 +182,19 @@ - (IBAction) showCloneRepository:(id)sender
182
182
183
183
- (IBAction )installCliTool : (id )sender ;
184
184
{
185
- BOOL success = NO ;
186
- NSString * installationPath = @" /usr/local/bin/" ;
187
- NSString * installationName = @" gitx" ;
188
- NSString * toolPath = [[NSBundle mainBundle ] pathForResource: @" gitx" ofType: @" " ];
185
+ BOOL success = NO ;
186
+ NSString * installationPath = @" /usr/local/bin/" ;
187
+ NSString * installationName = @" gitx" ;
188
+ NSString * toolPath = [[NSBundle mainBundle ] pathForResource: @" gitx" ofType: @" " ];
189
189
if (toolPath) {
190
190
AuthorizationRef auth;
191
191
if (AuthorizationCreate (NULL , kAuthorizationEmptyEnvironment , kAuthorizationFlagDefaults , &auth) == errAuthorizationSuccess) {
192
- char const * mkdir_arg[] = { " -p" , [installationPath UTF8String ], NULL };
193
- char const * mkdir = " /bin/mkdir" ;
194
- AuthorizationExecuteWithPrivileges (auth, mkdir, kAuthorizationFlagDefaults , (char **)mkdir_arg, NULL );
195
- char const * arguments[] = { " -f" , " -s" , [toolPath UTF8String ], [[installationPath stringByAppendingString: installationName] UTF8String ], NULL };
196
- char const * helperTool = " /bin/ln" ;
197
- if (AuthorizationExecuteWithPrivileges (auth, helperTool, kAuthorizationFlagDefaults , (char **)arguments, NULL ) == errAuthorizationSuccess) {
192
+ char const * mkdir_arg[] = {" -p" , [installationPath UTF8String ], NULL };
193
+ char const * mkdir = " /bin/mkdir" ;
194
+ AuthorizationExecuteWithPrivileges (auth, mkdir, kAuthorizationFlagDefaults , (char **)mkdir_arg, NULL );
195
+ char const * arguments[] = {" -f" , " -s" , [toolPath UTF8String ], [[installationPath stringByAppendingString: installationName] UTF8String ], NULL };
196
+ char const * helperTool = " /bin/ln" ;
197
+ if (AuthorizationExecuteWithPrivileges (auth, helperTool, kAuthorizationFlagDefaults , (char **)arguments, NULL ) == errAuthorizationSuccess) {
198
198
int status;
199
199
int pid = wait (&status);
200
200
if (pid != -1 && WIFEXITED (status) && WEXITSTATUS (status) == 0 )
@@ -207,7 +207,7 @@ - (IBAction)installCliTool:(id)sender;
207
207
}
208
208
}
209
209
210
- NSAlert * alert = [[NSAlert alloc ] init ];
210
+ NSAlert *alert = [[NSAlert alloc ] init ];
211
211
if (success) {
212
212
alert.messageText = NSLocalizedString(@" Installation Complete" , @" Headline for successfully completed installation of the command line tool" );
213
213
alert.informativeText = [NSString stringWithFormat: NSLocalizedString(@" The gitx tool has been installed to %@ ." , @" Informative text for successfully completed installation of the command line tool at the location %@ " ), installationPath];
@@ -225,20 +225,20 @@ - (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:
225
225
NSArray *keys = [NSArray arrayWithObjects: @" key" , @" displayKey" , @" value" , @" displayValue" , nil ];
226
226
NSMutableArray *feedParameters = [NSMutableArray array ];
227
227
228
- // only add parameters if the profile is being sent this time
229
- if (sendingProfile) {
230
- NSString *CFBundleGitVersion = [[[NSBundle mainBundle ] infoDictionary ] valueForKey: @" CFBundleGitVersion" ];
228
+ // only add parameters if the profile is being sent this time
229
+ if (sendingProfile) {
230
+ NSString *CFBundleGitVersion = [[[NSBundle mainBundle ] infoDictionary ] valueForKey: @" CFBundleGitVersion" ];
231
231
if (CFBundleGitVersion)
232
- [feedParameters addObject: [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects: @" CFBundleGitVersion" , @" Full Version" , CFBundleGitVersion, CFBundleGitVersion, nil ]
232
+ [feedParameters addObject: [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects: @" CFBundleGitVersion" , @" Full Version" , CFBundleGitVersion, CFBundleGitVersion, nil ]
233
233
forKeys: keys]];
234
234
235
- NSString *gitVersion = [PBGitBinary version ];
235
+ NSString *gitVersion = [PBGitBinary version ];
236
236
if (gitVersion)
237
- [feedParameters addObject: [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects: @" gitVersion" , @" git Version" , gitVersion, gitVersion, nil ]
237
+ [feedParameters addObject: [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects: @" gitVersion" , @" git Version" , gitVersion, gitVersion, nil ]
238
238
forKeys: keys]];
239
239
}
240
240
241
- return feedParameters;
241
+ return feedParameters;
242
242
}
243
243
244
244
@@ -251,7 +251,7 @@ - (IBAction)showHelp:(id)sender
251
251
252
252
- (IBAction )reportAProblem : (id )sender
253
253
{
254
- [[NSWorkspace sharedWorkspace ] openURL: [NSURL URLWithString: @" https://github.com/gitx/gitx/issues" ]];
254
+ [[NSWorkspace sharedWorkspace ] openURL: [NSURL URLWithString: @" https://github.com/gitx/gitx/issues" ]];
255
255
}
256
256
257
257
- (IBAction )showChangeLog : (id )sender
@@ -260,5 +260,4 @@ - (IBAction)showChangeLog:(id)sender
260
260
}
261
261
262
262
263
-
264
263
@end
0 commit comments