mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
PBRefController: Switch the app modal Delete Remote panel to a window modal sheet.
This commit is contained in:
+13
-11
@@ -34,27 +34,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) removeRef:(PBRefMenuItem *) sender
|
||||
- (void) removeRefSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
|
||||
{
|
||||
NSString *ref_desc = [NSString stringWithFormat:@"%@ %@", [[sender ref] type], [[sender ref] shortName]];
|
||||
NSString *question = [NSString stringWithFormat:@"Are you sure you want to remove the %@?", ref_desc];
|
||||
int choice = NSRunAlertPanel([NSString stringWithFormat:@"Delete %@?", ref_desc], question, @"Delete", @"Cancel", nil);
|
||||
// TODO: Use a non-modal alert here, so we don't block all the GitX windows
|
||||
|
||||
if(choice) {
|
||||
if (returnCode == NSAlertDefaultReturn) {
|
||||
int ret = 1;
|
||||
[historyController.repository outputForArguments:[NSArray arrayWithObjects:@"update-ref", @"-d", [[sender ref] ref], nil] retValue: &ret];
|
||||
PBRefMenuItem *refMenuItem = contextInfo;
|
||||
[historyController.repository outputForArguments:[NSArray arrayWithObjects:@"update-ref", @"-d", [[refMenuItem ref] ref], nil] retValue: &ret];
|
||||
if (ret) {
|
||||
NSLog(@"Removing ref failed!");
|
||||
return;
|
||||
}
|
||||
[historyController.repository removeBranch:[[PBGitRevSpecifier alloc] initWithRef:[sender ref]]];
|
||||
[[sender commit] removeRef:[sender ref]];
|
||||
[historyController.repository removeBranch:[[PBGitRevSpecifier alloc] initWithRef:[refMenuItem ref]]];
|
||||
[[refMenuItem commit] removeRef:[refMenuItem ref]];
|
||||
[commitController rearrangeObjects];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) removeRef:(PBRefMenuItem *)sender
|
||||
{
|
||||
NSString *ref_desc = [NSString stringWithFormat:@"%@ %@", [[sender ref] type], [[sender ref] shortName]];
|
||||
NSString *question = [NSString stringWithFormat:@"Are you sure you want to remove the %@?", ref_desc];
|
||||
NSBeginAlertSheet([NSString stringWithFormat:@"Delete %@?", ref_desc], @"Delete", @"Cancel", nil, [[historyController view] window], self, @selector(removeRefSheetDidEnd:returnCode:contextInfo:), NULL, sender, question);
|
||||
}
|
||||
|
||||
- (void) checkoutRef:(PBRefMenuItem *)sender
|
||||
{
|
||||
int ret = 1;
|
||||
|
||||
Reference in New Issue
Block a user