Skip to content

Commit 5090d4f

Browse files
author
Pieter de Bie
committed
Merge branch '5a88e3d' (early part)
* '5a88e3d' (early part): keyboardNavigation: Fix keys 'c' and 'v' from webView PBGitWindowController: Use beginSheetModalForWindow instead of runModal
2 parents 58ac6ed + ab870c6 commit 5090d4f

File tree

6 files changed

+30
-41
lines changed

6 files changed

+30
-41
lines changed

PBGitCommitController.m

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -287,32 +287,20 @@ - (void) commitFailedBecause:(NSString *)reason
287287
{
288288
self.busy--;
289289
self.status = [@"Commit failed: " stringByAppendingString:reason];
290-
[[NSAlert alertWithMessageText:@"Commit failed"
291-
defaultButton:nil
292-
alternateButton:nil
293-
otherButton:nil
294-
informativeTextWithFormat:reason] runModal];
290+
[[repository windowController] showMessageSheet:@"Commit failed" infoText:reason];
295291
return;
296292
}
297293

298294
- (IBAction) commit:(id) sender
299295
{
300296
if ([[cachedFilesController arrangedObjects] count] == 0) {
301-
[[NSAlert alertWithMessageText:@"No changes to commit"
302-
defaultButton:nil
303-
alternateButton:nil
304-
otherButton:nil
305-
informativeTextWithFormat:@"You must first stage some changes before committing"] runModal];
297+
[[repository windowController] showMessageSheet:@"No changes to commit" infoText:@"You must first stage some changes before committing"];
306298
return;
307299
}
308300

309301
NSString *commitMessage = [commitMessageView string];
310302
if ([commitMessage length] < 3) {
311-
[[NSAlert alertWithMessageText:@"Commitmessage missing"
312-
defaultButton:nil
313-
alternateButton:nil
314-
otherButton:nil
315-
informativeTextWithFormat:@"Please enter a commit message before committing"] runModal];
303+
[[repository windowController] showMessageSheet:@"Commitmessage missing" infoText:@"Please enter a commit message before committing"];
316304
return;
317305
}
318306

PBGitIndexController.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ - (void) ignoreFiles:(NSArray *)files
113113
} else {
114114
ignoreFile = [NSMutableString stringWithContentsOfFile:gitIgnoreName usedEncoding:&enc error:&error];
115115
if (error) {
116-
[[NSAlert alertWithError:error] runModal];
116+
[[commitController.repository windowController] showErrorSheet:error];
117117
return;
118118
}
119119
// Add a newline if not yet present
@@ -124,7 +124,7 @@ - (void) ignoreFiles:(NSArray *)files
124124

125125
[ignoreFile writeToFile:gitIgnoreName atomically:YES encoding:enc error:&error];
126126
if (error)
127-
[[NSAlert alertWithError:error] runModal];
127+
[[commitController.repository windowController] showErrorSheet:error];
128128
}
129129

130130
# pragma mark Displaying diffs
@@ -166,11 +166,7 @@ - (void) forceRevertChangesForFiles:(NSArray *)files
166166
int ret = 1;
167167
[commitController.repository outputForArguments:arguments inputString:input retValue:&ret];
168168
if (ret) {
169-
[[NSAlert alertWithMessageText:@"Reverting changes failed"
170-
defaultButton:nil
171-
alternateButton:nil
172-
otherButton:nil
173-
informativeTextWithFormat:@"Reverting changes failed with error code %i", ret] runModal];
169+
[[commitController.repository windowController] showMessageSheet:@"Reverting changes failed" infoText:[NSString stringWithFormat:@"Reverting changes failed with error code %i", ret]];
174170
return;
175171
}
176172

PBGitWindowController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
- (void)changeViewController:(NSInteger)whichViewTag;
3131
- (void)useToolbar:(NSToolbar *)toolbar;
32+
- (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText;
33+
- (void)showErrorSheet:(NSError *)error;
3234

3335
- (IBAction) showCommitView:(id)sender;
3436
- (IBAction) showHistoryView:(id)sender;

PBGitWindowController.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@ - (void) showHistoryView:(id)sender
122122
self.selectedViewIndex = 0;
123123
}
124124

125+
- (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText
126+
{
127+
[[NSAlert alertWithMessageText:messageText
128+
defaultButton:nil
129+
alternateButton:nil
130+
otherButton:nil
131+
informativeTextWithFormat:infoText] beginSheetModalForWindow: [self window] modalDelegate:self didEndSelector:nil contextInfo:nil];
132+
}
133+
134+
- (void)showErrorSheet:(NSError *)error
135+
{
136+
[[NSAlert alertWithError:error] beginSheetModalForWindow: [self window] modalDelegate:self didEndSelector:nil contextInfo:nil];
137+
}
138+
139+
125140
#pragma mark -
126141
#pragma mark Toolbar Delegates
127142

PBRefController.m

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ - (void) checkoutRef:(PBRefMenuItem *)sender
6060
int ret = 1;
6161
[historyController.repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"checkout", [[sender ref] shortName], nil] retValue: &ret];
6262
if (ret) {
63-
[[NSAlert alertWithMessageText:@"Checking out branch failed"
64-
defaultButton:@"OK"
65-
alternateButton:nil
66-
otherButton:nil
67-
informativeTextWithFormat:@"There was an error checking out the branch. Perhaps your working directory is not clean?"] runModal];
63+
[[historyController.repository windowController] showMessageSheet:@"Checking out branch failed" infoText:@"There was an error checking out the branch. Perhaps your working directory is not clean?"];
6864
return;
6965
}
7066
[historyController.repository reloadRefs];
@@ -79,11 +75,7 @@ - (void) tagInfo:(PBRefMenuItem *)sender
7975
NSString *info = [historyController.repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"tag", @"-n50", @"-l", [[sender ref] shortName], nil] retValue: &ret];
8076

8177
if (!ret) {
82-
[[NSAlert alertWithMessageText:message
83-
defaultButton:@"OK"
84-
alternateButton:nil
85-
otherButton:nil
86-
informativeTextWithFormat:info] runModal];
78+
[[historyController.repository windowController] showMessageSheet:message infoText:info];
8779
}
8880
return;
8981
}

html/lib/keyboardNavigation.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ var handleKeys = function(event) {
1717
return changeFile(true);
1818
else if (event.keyCode == 38 && event.ctrlKey == true) // ctrl-up_arrow
1919
return changeFile(false);
20-
else if (event.keyCode == 86) {// 'v'
21-
showDiffs();
22-
return false;
23-
}
20+
else if (event.keyCode == 86) // 'v'
21+
showDiff();
22+
else if (event.keyCode == 67) // 'c'
23+
Controller.copySource();
2424
return true;
2525
}
2626

@@ -29,12 +29,8 @@ var handleKeyFromCocoa = function(key) {
2929
changeHunk(true);
3030
else if (key == 'k')
3131
changeHunk(false);
32-
else if (event.keyCode == 40 && event.ctrlKey == true) // ctrl-down_arrow
33-
changeFile(true);
34-
else if (event.keyCode == 38 && event.ctrlKey == true) // ctrl-up_arrow
35-
changeFile(false);
3632
else if (key == 'v')
37-
showDiffs();
33+
showDiff();
3834
else if (key == 'c')
3935
Controller.copySource();
4036
}

0 commit comments

Comments
 (0)