Skip to content

Commit

Permalink
• placed validateToolbarItem: to the item's target in order to be called
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R-packages/trunk/Mac-GUI@6006 694ef91d-65df-0310-b7bb-92e67a308ead
  • Loading branch information
Hans-Jörg Bibiko committed Jan 16, 2012
1 parent f40bd50 commit fb7eae4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 23 deletions.
9 changes: 9 additions & 0 deletions RDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,15 @@ - (void)sheetDidEnd:(id)sheet returnCode:(int)returnCode contextInfo:(NSString*)
[[(RDocumentController*)[NSDocumentController sharedDocumentController] findLastWindowForDocType:ftRSource] makeKeyAndOrderFront:nil];

}
- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
{

NSString *iid = [toolbarItem itemIdentifier];
if ([iid isEqualToString: RETI_Save ] || [iid isEqualToString: RDETI_Save ])
return [self isDocumentEdited];

return YES;
}

@end

1 change: 0 additions & 1 deletion REditorToolbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,5 @@ NSToolbarPrintItemIdentifier, NSToolbarSeparatorItemIdentifier, NSToolbarFlexibl
- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar;
- (void) toolbarWillAddItem: (NSNotification *) notif;
- (void) toolbarDidRemoveItem: (NSNotification *) notif;
- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem;

@end
10 changes: 0 additions & 10 deletions REditorToolbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,4 @@ - (void) toolbarDidRemoveItem: (NSNotification *) notif {
// NSToolbarItem *removedItem = [[notif userInfo] objectForKey: @"item"];
}

- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem {
NSString *iid = [toolbarItem itemIdentifier];
BOOL enable = YES; // default is YES, if there are any that need to be disabled - check for them

if ([iid isEqual: RETI_Save ])
enable = [[winCtrl document] isDocumentEdited];

return enable;
}

@end
1 change: 0 additions & 1 deletion RdEditorToolbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,5 @@ NSToolbarPrintItemIdentifier, NSToolbarSeparatorItemIdentifier, NSToolbarFlexibl
- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar;
- (void) toolbarWillAddItem: (NSNotification *) notif;
- (void) toolbarDidRemoveItem: (NSNotification *) notif;
- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem;

@end
11 changes: 0 additions & 11 deletions RdEditorToolbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,4 @@ - (void) toolbarDidRemoveItem: (NSNotification *) notification
// NSToolbarItem *removedItem = [[notification userInfo] objectForKey: @"item"];
}

- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
{

NSString *iid = [toolbarItem itemIdentifier];

if ([iid isEqual: RETI_Save ])
return [[winCtrl document] isDocumentEdited];

return YES;
}

@end

0 comments on commit fb7eae4

Please sign in to comment.