2222#import < Sparkle/SUUpdater.h>
2323#import < Sparkle/SUUpdaterDelegate.h>
2424
25- static OpenRecentController* recentsDialog = nil ;
25+ static OpenRecentController * recentsDialog = nil ;
2626
2727@interface ApplicationController () <SUUpdaterDelegate>
2828@end
2929
3030@implementation ApplicationController
3131
32- - (ApplicationController*)init
32+ - (ApplicationController *)init
3333{
3434#ifdef DEBUG_BUILD
3535 [NSApp activateIgnoringOtherApps: YES ];
3636#endif
3737
38- if (!(self = [super init ]))
38+ if (!(self = [super init ]))
3939 return nil ;
4040
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 ])
4343 NSLog (@" Could not load QuickLook" );
4444
4545 /* Value Transformers */
4646 NSValueTransformer *transformer = [[PBNSURLPathUserDefaultsTransfomer alloc ] init ];
4747 [NSValueTransformer setValueTransformer: transformer forName: @" PBNSURLPathUserDefaultsTransfomer" ];
48-
48+
4949 // Make sure the PBGitDefaults is initialized, by calling a random method
5050 [PBGitDefaults class ];
51-
51+
5252 started = NO ;
5353 return self;
5454}
@@ -64,27 +64,27 @@ - (void)registerServices
6464
6565 // Force update the services menu if we have a new services version
6666 NSInteger serviceVersion = [[NSUserDefaults standardUserDefaults ] integerForKey: @" Services Version" ];
67- if (serviceVersion < 2 )
68- {
67+ if (serviceVersion < 2 ) {
6968 NSLog (@" Updating services menu…" );
7069 NSUpdateDynamicServices ();
7170 [[NSUserDefaults standardUserDefaults ] setInteger: 2 forKey: @" Services Version" ];
7271 }
7372}
7473
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) {
8283 if (!document) {
8384 NSLog (@" Error opening repository \" %@ \" : %@ " , repository.path , error);
8485 [controller presentError: error];
8586 [sender replyToOpenOrPrint: NSApplicationDelegateReplyFailure];
86- }
87- else {
87+ } else {
8888 [sender replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
8989 }
9090 }];
@@ -93,60 +93,60 @@ - (void)application:(NSApplication *)sender openFiles:(NSArray <NSString *> *)fi
9393
9494- (BOOL )applicationShouldOpenUntitledFile : (NSApplication *)sender
9595{
96- if (!started || [[[NSDocumentController sharedDocumentController ] documents ] count ])
96+ if (!started || [[[NSDocumentController sharedDocumentController ] documents ] count ])
9797 return NO ;
9898 return YES ;
9999}
100100
101101- (BOOL )applicationOpenUntitledFile : (NSApplication *)theApplication
102102{
103103 recentsDialog = [[OpenRecentController alloc ] init ];
104- if ([recentsDialog.possibleResults count ] > 0 )
105- {
104+ if ([recentsDialog.possibleResults count ] > 0 ) {
106105 [recentsDialog show ];
107106 return YES ;
108- }
109- else
110- {
107+ } else {
111108 return NO ;
112109 }
113110}
114111
115- - (void )applicationDidFinishLaunching : (NSNotification *)notification
112+ - (void )applicationDidFinishLaunching : (NSNotification *)notification
116113{
117114 [[SUUpdater sharedUpdater ] setSendsSystemProfile: YES ];
118- [[SUUpdater sharedUpdater ] setDelegate: self ];
115+ [[SUUpdater sharedUpdater ] setDelegate: self ];
119116
120117 // 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 );
123120
124121 [NSApp registerObserverForAppearanceChanges: self ];
125122 [self registerServices ];
126123 started = YES ;
127124}
128125
129- - (void ) windowWillClose : sender
126+ - (void )windowWillClose :sender
130127{
131- [firstResponder terminate: sender];
128+ [firstResponder terminate: sender];
132129}
133130
134131// 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+
138136 [panel setCanChooseFiles: false ];
139137 [panel setCanChooseDirectories: true ];
140-
138+
141139 [panel beginWithCompletionHandler: ^(NSInteger result) {
142140 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+ }];
150150 }
151151 }];
152152}
@@ -163,16 +163,16 @@ - (IBAction)showAboutPanel:(id)sender
163163 if (gitversion)
164164 [dict addEntriesFromDictionary: [[NSDictionary alloc ] initWithObjectsAndKeys: gitversion, @" Version" , nil ]];
165165
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
169169
170170 [dict addEntriesFromDictionary: [[NSDictionary alloc ] initWithObjectsAndKeys: @" GitX-dev (rowanj fork)" , @" ApplicationName" , nil ]];
171171
172172 [NSApp orderFrontStandardAboutPanelWithOptions: dict];
173173}
174174
175- - (IBAction ) showCloneRepository : (id )sender
175+ - (IBAction )showCloneRepository : (id )sender
176176{
177177 if (!cloneRepositoryPanel)
178178 cloneRepositoryPanel = [PBCloneRepositoryPanel panel ];
@@ -182,19 +182,19 @@ - (IBAction) showCloneRepository:(id)sender
182182
183183- (IBAction )installCliTool : (id )sender ;
184184{
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: @" " ];
189189 if (toolPath) {
190190 AuthorizationRef auth;
191191 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) {
198198 int status;
199199 int pid = wait (&status);
200200 if (pid != -1 && WIFEXITED (status) && WEXITSTATUS (status) == 0 )
@@ -207,7 +207,7 @@ - (IBAction)installCliTool:(id)sender;
207207 }
208208 }
209209
210- NSAlert * alert = [[NSAlert alloc ] init ];
210+ NSAlert *alert = [[NSAlert alloc ] init ];
211211 if (success) {
212212 alert.messageText = NSLocalizedString(@" Installation Complete" , @" Headline for successfully completed installation of the command line tool" );
213213 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:
225225 NSArray *keys = [NSArray arrayWithObjects: @" key" , @" displayKey" , @" value" , @" displayValue" , nil ];
226226 NSMutableArray *feedParameters = [NSMutableArray array ];
227227
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" ];
231231 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 ]
233233 forKeys: keys]];
234234
235- NSString *gitVersion = [PBGitBinary version ];
235+ NSString *gitVersion = [PBGitBinary version ];
236236 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 ]
238238 forKeys: keys]];
239239 }
240240
241- return feedParameters;
241+ return feedParameters;
242242}
243243
244244
@@ -251,7 +251,7 @@ - (IBAction)showHelp:(id)sender
251251
252252- (IBAction )reportAProblem : (id )sender
253253{
254- [[NSWorkspace sharedWorkspace ] openURL: [NSURL URLWithString: @" https://github.com/gitx/gitx/issues" ]];
254+ [[NSWorkspace sharedWorkspace ] openURL: [NSURL URLWithString: @" https://github.com/gitx/gitx/issues" ]];
255255}
256256
257257- (IBAction )showChangeLog : (id )sender
@@ -260,5 +260,4 @@ - (IBAction)showChangeLog:(id)sender
260260}
261261
262262
263-
264263@end
0 commit comments