From: Nathan Kinsinger <[email protected]>

---
 PBWebChangesController.m |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/PBWebChangesController.m b/PBWebChangesController.m
index 933fecc..3216725 100644
--- a/PBWebChangesController.m
+++ b/PBWebChangesController.m
@@ -85,21 +85,35 @@ - (void)stageHunk:(NSString *)hunk reverse:(BOOL)reverse
        [self refresh];
 }
 
+- (void) discardHunk:(NSString *)hunk
+{
+    [controller.index applyPatch:hunk stage:NO reverse:YES];
+    [self refresh];
+}
+
+- (void) discardHunkAlertDidEnd:(NSAlert *)alert 
returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
+{
+    [[alert window] orderOut:nil];
+
+       if (returnCode == NSAlertDefaultReturn)
+               [self discardHunk:contextInfo];
+}
+
 - (void)discardHunk:(NSString *)hunk altKey:(BOOL)altKey
 {
-       int ret = NSAlertDefaultReturn;
        if (!altKey) {
-               ret = [[NSAlert alertWithMessageText:@"Discard hunk"
-                       defaultButton:nil
-                       alternateButton:@"Cancel"
-                       otherButton:nil
-                       informativeTextWithFormat:@"Are you sure you wish to 
discard the changes in this hunk?\n\nYou cannot undo this operation."] 
runModal];
-       }
-
-       if (ret == NSAlertDefaultReturn) {
-               [controller.index applyPatch:hunk stage:NO reverse:YES];
-               [self refresh];
-       }
+        NSAlert *alert = [NSAlert alertWithMessageText:@"Discard hunk"
+                                         defaultButton:nil
+                                       alternateButton:@"Cancel"
+                                           otherButton:nil
+                             informativeTextWithFormat:@"Are you sure you wish 
to discard the changes in this hunk?\n\nYou cannot undo this operation."];
+               [alert beginSheetModalForWindow:[[controller view] window]
+                          modalDelegate:self
+                         
didEndSelector:@selector(discardHunkAlertDidEnd:returnCode:contextInfo:)
+                            contextInfo:hunk];
+       } else {
+        [self discardHunk:hunk];
+    }
 }
 
 - (void) setStateMessage:(NSString *)state
-- 
1.7.0

To unsubscribe from this group, send email to gitx+unsubscribegooglegroups.com 
or reply to this email with the words "REMOVE ME" as the subject.

Reply via email to