Revision: 7535 http://skim-app.svn.sourceforge.net/skim-app/?rev=7535&view=rev Author: hofman Date: 2011-11-12 12:13:00 +0000 (Sat, 12 Nov 2011) Log Message: ----------- Add a Restore Previous Setting menu item to the bookmarks menu.
Modified Paths: -------------- trunk/Dutch.lproj/Localizable.strings trunk/English.lproj/Localizable.strings trunk/French.lproj/Localizable.strings trunk/German.lproj/Localizable.strings trunk/Italian.lproj/Localizable.strings trunk/Japanese.lproj/Localizable.strings trunk/SKBookmarkController.h trunk/SKBookmarkController.m trunk/Spanish.lproj/Localizable.strings trunk/pl.lproj/Localizable.strings trunk/ru.lproj/Localizable.strings trunk/zh_TW.lproj/Localizable.strings Modified: trunk/Dutch.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/English.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/French.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/German.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/Italian.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/Japanese.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/SKBookmarkController.h =================================================================== --- trunk/SKBookmarkController.h 2011-11-11 17:53:13 UTC (rev 7534) +++ trunk/SKBookmarkController.h 2011-11-12 12:13:00 UTC (rev 7535) @@ -46,6 +46,7 @@ SKOutlineView *outlineView; SKStatusBar *statusBar; SKBookmark *bookmarkRoot; + SKBookmark *previousSession; NSMutableArray *recentDocuments; NSUndoManager *undoManager; NSArray *draggedBookmarks; Modified: trunk/SKBookmarkController.m =================================================================== --- trunk/SKBookmarkController.m 2011-11-11 17:53:13 UTC (rev 7534) +++ trunk/SKBookmarkController.m 2011-11-12 12:13:00 UTC (rev 7535) @@ -156,6 +156,10 @@ selector:@selector(handleApplicationWillTerminateNotification:) name:NSApplicationWillTerminateNotification object:NSApp]; + + NSArray *lastOpenFiles = [[NSUserDefaults standardUserDefaults] arrayForKey:SKLastOpenFileNamesKey]; + if ([lastOpenFiles count] > 0) + previousSession = [[SKBookmark alloc] initSessionWithSetups:lastOpenFiles label:NSLocalizedString(@"Restore Previous Session", @"Menu item title")]; } sharedBookmarkController = [self retain]; } else if (self != sharedBookmarkController) { @@ -170,6 +174,7 @@ [self stopObservingBookmarks:[NSArray arrayWithObject:bookmarkRoot]]; [[NSNotificationCenter defaultCenter] removeObserver:self]; SKDESTROY(bookmarkRoot); + SKDESTROY(previousSession); SKDESTROY(recentDocuments); SKDESTROY(draggedBookmarks); SKDESTROY(toolbarItems); @@ -358,11 +363,28 @@ #pragma mark NSMenu delegate methods +- (void)addItemForBookmark:(SKBookmark *)bookmark toMenu:(NSMenu *)menu isFolder:(BOOL)isFolder isAlternate:(BOOL)isAlternate { + NSMenuItem *item = nil; + if (isFolder) { + item = [menu addItemWithSubmenuAndTitle:[bookmark label]]; + [[item submenu] setDelegate:self]; + } else { + item = [menu addItemWithTitle:[bookmark label] action:@selector(openBookmark:) target:self]; + } + [item setRepresentedObject:bookmark]; + if (isAlternate) { + [item setKeyEquivalentModifierMask:NSAlternateKeyMask]; + [item setAlternate:YES]; + [item setImageAndSize:[bookmark alternateIcon]]; + } else { + [item setImageAndSize:[bookmark icon]]; + } +} + - (void)menuNeedsUpdate:(NSMenu *)menu { NSMenu *supermenu = [menu supermenu]; NSInteger idx = [supermenu indexOfItemWithSubmenu:menu]; SKBookmark *bm = nil; - NSMenuItem *item; if (supermenu == [NSApp mainMenu]) bm = [self bookmarkRoot]; @@ -374,39 +396,28 @@ NSInteger i = [menu numberOfItems]; while (i-- > 0 && ([[menu itemAtIndex:i] isSeparatorItem] || [[menu itemAtIndex:i] representedObject])) [menu removeItemAtIndex:i]; + if (supermenu == [NSApp mainMenu] && previousSession) { + [menu addItem:[NSMenuItem separatorItem]]; + [self addItemForBookmark:previousSession toMenu:menu isFolder:NO isAlternate:NO]; + [self addItemForBookmark:previousSession toMenu:menu isFolder:YES isAlternate:YES]; + } if ([menu numberOfItems] > 0 && [bookmarks count] > 0) [menu addItem:[NSMenuItem separatorItem]]; for (bm in bookmarks) { switch ([bm bookmarkType]) { case SKBookmarkTypeFolder: - item = [menu addItemWithSubmenuAndTitle:[bm label]]; - [item setRepresentedObject:bm]; - [item setImageAndSize:[bm icon]]; - [[item submenu] setDelegate:self]; - item = [menu addItemWithTitle:[bm label] action:@selector(openBookmark:) target:self]; - [item setRepresentedObject:bm]; - [item setKeyEquivalentModifierMask:NSAlternateKeyMask]; - [item setAlternate:YES]; - [item setImageAndSize:[bm alternateIcon]]; + [self addItemForBookmark:bm toMenu:menu isFolder:YES isAlternate:NO]; + [self addItemForBookmark:bm toMenu:menu isFolder:NO isAlternate:YES]; break; case SKBookmarkTypeSession: - item = [menu addItemWithTitle:[bm label] action:@selector(openBookmark:) target:self]; - [item setRepresentedObject:bm]; - [item setImageAndSize:[bm icon]]; - item = [menu addItemWithSubmenuAndTitle:[bm label]]; - [item setRepresentedObject:bm]; - [item setKeyEquivalentModifierMask:NSAlternateKeyMask]; - [item setAlternate:YES]; - [item setImageAndSize:[bm alternateIcon]]; - [[item submenu] setDelegate:self]; + [self addItemForBookmark:bm toMenu:menu isFolder:NO isAlternate:NO]; + [self addItemForBookmark:bm toMenu:menu isFolder:YES isAlternate:YES]; break; case SKBookmarkTypeSeparator: [menu addItem:[NSMenuItem separatorItem]]; break; default: - item = [menu addItemWithTitle:[bm label] action:@selector(openBookmark:) target:self]; - [item setRepresentedObject:bm]; - [item setImageAndSize:[bm icon]]; + [self addItemForBookmark:bm toMenu:menu isFolder:NO isAlternate:NO]; break; } } Modified: trunk/Spanish.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/pl.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/ru.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/zh_TW.lproj/Localizable.strings =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit