mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Add an attribute to NSDocumentController to maintain the recent
documents menu. Make the methods to access that menu available to other classes in -gui. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30362 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
20a4078572
commit
e0d603b2ae
4 changed files with 34 additions and 16 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2010-05-12 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSDocumentController.h:
|
||||
* Source/NSDocumentFrameworkPrivate.h:
|
||||
* Source/NSDocumentController.m (-_recentDocumentsMenu,
|
||||
-_setRecentDocumentsMenu:, -_updateRecentDocumentsMenu):
|
||||
Add an attribute to NSDocumentController to maintain the recent
|
||||
documents menu. Make the methods to access that menu available to
|
||||
other classes in -gui.
|
||||
|
||||
2010-05-12 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/GSNibLoading.m (-nibInstantiateWithOwner:topLevelObjects:):
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
@class NSString;
|
||||
|
||||
@class NSDocument;
|
||||
@class NSMenu;
|
||||
@class NSMenuItem;
|
||||
@class NSOpenPanel;
|
||||
@class NSWindow;
|
||||
|
@ -59,7 +60,7 @@
|
|||
unsigned int should_create_ui:1;
|
||||
unsigned int RESERVED:31;
|
||||
} _controller_flags;
|
||||
void *_reserved1;
|
||||
NSMenu *_recent_documents_menu;
|
||||
}
|
||||
|
||||
+ (id) sharedDocumentController;
|
||||
|
|
|
@ -126,12 +126,6 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
}
|
||||
|
||||
|
||||
@interface NSDocumentController (RecentsMenu)
|
||||
- (NSMenu *) _recentMenu;
|
||||
- (void) _updateOpenRecentMenu;
|
||||
- (IBAction) _openRecentDocument: (id)sender;
|
||||
@end
|
||||
|
||||
/** <p>
|
||||
NSDocumentController is a class that controls a set of NSDocuments
|
||||
for an application. As an application delegate, it responds to the
|
||||
|
@ -325,6 +319,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
RELEASE (_documents);
|
||||
RELEASE (_recent_documents);
|
||||
RELEASE (_types);
|
||||
RELEASE (_recent_documents_menu);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -1280,7 +1275,7 @@ static BOOL _shouldClose = YES;
|
|||
[_recent_documents removeAllObjects];
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
setObject: _recent_documents forKey: NSRecentDocuments];
|
||||
[self _updateOpenRecentMenu];
|
||||
[self _updateRecentDocumentsMenu];
|
||||
}
|
||||
|
||||
// The number of remembered recent documents
|
||||
|
@ -1326,7 +1321,7 @@ static BOOL _shouldClose = YES;
|
|||
[[NSUserDefaults standardUserDefaults]
|
||||
setObject: a forKey: NSRecentDocuments];
|
||||
RELEASE(a);
|
||||
[self _updateOpenRecentMenu];
|
||||
[self _updateRecentDocumentsMenu];
|
||||
}
|
||||
|
||||
- (NSArray *) recentDocumentURLs
|
||||
|
@ -1585,21 +1580,26 @@ static NSString *processName = nil;
|
|||
@end
|
||||
|
||||
|
||||
@implementation NSDocumentController (RecentsMenu)
|
||||
@implementation NSDocumentController (RecentDocumentsMenu)
|
||||
|
||||
- (NSMenu *) _recentMenu
|
||||
- (NSMenu *) _recentDocumentsMenu
|
||||
{
|
||||
// FIXME
|
||||
return nil;
|
||||
return _recent_documents_menu;
|
||||
}
|
||||
|
||||
- (void) _setRecentDocumentsMenu: (NSMenu *)aMenu
|
||||
{
|
||||
ASSIGN(_recent_documents_menu, aMenu);
|
||||
[self _updateRecentDocumentsMenu];
|
||||
}
|
||||
|
||||
// should be handled by making us the delegate of the recent's menu
|
||||
- (void) _updateOpenRecentMenu
|
||||
- (void) _updateRecentDocumentsMenu
|
||||
{
|
||||
NSMenu *recentMenu;
|
||||
int i;
|
||||
|
||||
recentMenu = [self _recentMenu];
|
||||
recentMenu = [self _recentDocumentsMenu];
|
||||
if (!recentMenu)
|
||||
{
|
||||
return;
|
||||
|
@ -1666,7 +1666,7 @@ static NSString *processName = nil;
|
|||
if (idx < 0 || idx >= [_recent_documents count])
|
||||
{
|
||||
// something went wrong, ignore
|
||||
[self _updateOpenRecentMenu];
|
||||
[self _updateRecentDocumentsMenu];
|
||||
return;
|
||||
}
|
||||
url = (NSURL *)[_recent_documents objectAtIndex: idx];
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
- (void)_recordAutosavedDocument: (NSDocument *)document;
|
||||
@end
|
||||
|
||||
@interface NSDocumentController (RecentDocumentsMenu)
|
||||
- (NSMenu *) _recentDocumentsMenu;
|
||||
- (void) _setRecentDocumentsMenu: (NSMenu *)menu;
|
||||
- (void) _updateRecentDocumentsMenu;
|
||||
- (IBAction) _openRecentDocument: (id)sender;
|
||||
@end
|
||||
|
||||
|
||||
#include <AppKit/NSDocument.h>
|
||||
|
||||
|
|
Loading…
Reference in a new issue