From 7f90afe7bcf52cf30ddc98e566b12e6b7dae55c4 Mon Sep 17 00:00:00 2001 From: Wolfgang Lux Date: Fri, 14 May 2010 07:42:34 +0000 Subject: [PATCH] Give the application delegate a chance to open documents from the recent documents menu. This makes the menu available to non-document based applications as documented and implemented by Apple. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30386 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/NSDocumentController.m | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6404f3290..82443285a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-05-14 Wolfgang Lux + + * Source/NSDocumentController.m (-_openRecentDocument:): Give the + application delegate a chance to open the document. This makes the + recent documents menu available to non-document based applications + as documented and implemented by Apple. + 2010-05-13 Fred Kiefer * Source/NSToolbarItem.m (-_isFlexibleSpace): Simplify this method. diff --git a/Source/NSDocumentController.m b/Source/NSDocumentController.m index 7a0513cbf..1b17d68b9 100644 --- a/Source/NSDocumentController.m +++ b/Source/NSDocumentController.m @@ -1688,6 +1688,19 @@ static NSString *processName = nil; return; } url = (NSURL *)[_recent_documents objectAtIndex: idx]; + if ([url isFileURL]) + { + /* From Apple's documentation of the -noteNewRecentDocumentURL: method: + "Applications not based on NSDocument must also implement the + application:openFile: method in the application delegate to + handle requests from the Open Recent menu command." */ + id appDelegate = [NSApp delegate]; + if ([appDelegate respondsToSelector: @selector(application:openFile:)]) + { + if ([appDelegate application: NSApp openFile: [url path]]) + return; + } + } [self openDocumentWithContentsOfURL: url display: YES]; }