Browse Source

Added RecentlyOpenedFilesList::forgetRecentFileNatively()

tags/2021-05-28
ed 8 years ago
parent
commit
6a453c7f5c
2 changed files with 34 additions and 0 deletions
  1. +27
    -0
      modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp
  2. +7
    -0
      modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h

+ 27
- 0
modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp View File

@@ -149,6 +149,33 @@ void RecentlyOpenedFilesList::registerRecentFileNatively (const File& file)
#endif #endif
} }
void RecentlyOpenedFilesList::forgetRecentFileNatively (const File& file)
{
#if JUCE_MAC
JUCE_AUTORELEASEPOOL
{
// for some reason, OSX doesn't provide a method to just remove a single file
// from the recent list, so we clear them all and add them back excluding
// the specified file
auto* sharedDocController = [NSDocumentController sharedDocumentController];
auto* recentDocumentURLs = [sharedDocController recentDocumentURLs];
[sharedDocController clearRecentDocuments: nil];
auto* nsFile = createNSURLFromFile (file);
auto* reverseEnumerator = [recentDocumentURLs reverseObjectEnumerator];
for (NSURL* url : reverseEnumerator)
if (! [url isEqual:nsFile])
[sharedDocController noteNewRecentDocumentURL:url];
}
#else
ignoreUnused (file);
#endif
}
void RecentlyOpenedFilesList::clearRecentFilesNatively() void RecentlyOpenedFilesList::clearRecentFilesNatively()
{ {
#if JUCE_MAC #if JUCE_MAC


+ 7
- 0
modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h View File

@@ -109,6 +109,13 @@ public:
*/ */
static void registerRecentFileNatively (const File& file); static void registerRecentFileNatively (const File& file);
/** Tells the OS to remove a file from the OS-managed list of recent documents for this app.
Not all OSes maintain a list of recent files for an application, so this
function will have no effect on some OSes. Currently it's just implemented for OSX.
*/
static void forgetRecentFileNatively (const File& file);
/** Tells the OS to clear the OS-managed list of recent documents for this app. /** Tells the OS to clear the OS-managed list of recent documents for this app.
Not all OSes maintain a list of recent files for an application, so this Not all OSes maintain a list of recent files for an application, so this


Loading…
Cancel
Save