Revision: 7079 http://skim-app.svn.sourceforge.net/skim-app/?rev=7079&view=rev Author: hofman Date: 2011-01-24 11:03:32 +0000 (Mon, 24 Jan 2011)
Log Message: ----------- move bookmark opening code to bookmark class Modified Paths: -------------- trunk/SKBookmark.h trunk/SKBookmark.m trunk/SKBookmarkController.h trunk/SKBookmarkController.m Modified: trunk/SKBookmark.h =================================================================== --- trunk/SKBookmark.h 2011-01-21 18:23:02 UTC (rev 7078) +++ trunk/SKBookmark.h 2011-01-24 11:03:32 UTC (rev 7079) @@ -93,4 +93,6 @@ - (BOOL)isDescendantOf:(SKBookmark *)bookmark; - (BOOL)isDescendantOfArray:(NSArray *)bookmarks; +- (void)open; + @end Modified: trunk/SKBookmark.m =================================================================== --- trunk/SKBookmark.m 2011-01-21 18:23:02 UTC (rev 7078) +++ trunk/SKBookmark.m 2011-01-24 11:03:32 UTC (rev 7079) @@ -39,9 +39,12 @@ #import "SKBookmark.h" #import "BDAlias.h" #import "NSImage_SKExtensions.h" -#import "SKBookmarkController.h" #import "NSDocument_SKExtensions.h" #import "SKDocumentController.h" +#import "NSFileManager_SKExtensions.h" +#import "SKMainDocument.h" +#import "SKMainWindowController.h" +#import "NSError_SKExtensions.h" #define BOOKMARK_STRING @"bookmark" #define SESSION_STRING @"session" @@ -291,6 +294,8 @@ return NO; } +- (void)open {} + @end #pragma mark - @@ -505,6 +510,23 @@ } } +- (void)open { + id document = nil; + NSError *error = nil; + if (setup) { + document = [[NSDocumentController sharedDocumentController] openDocumentWithSetup:[self properties] error:&error]; + } else { + NSString *path = [self path]; + NSURL *fileURL = path ? [NSURL fileURLWithPath:path] : nil; + if (fileURL && NO == [[NSFileManager defaultManager] isTrashedFileAtURL:fileURL] && + (document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:fileURL display:YES error:&error]) && + [document isPDFDocument] && [self pageIndex] != NSNotFound) + [[document mainWindowController] setPageNumber:[self pageIndex] + 1]; + } + if (document == nil && error && [error isUserCancelledError] == NO) + [NSApp presentError:error]; +} + @end #pragma mark - @@ -658,6 +680,12 @@ return [super newScriptingObjectOfClass:objectClass forValueForKey:key withContentsValue:contentsValue properties:properties]; } +- (void)open { + NSInteger i = [children count]; + while (i--) + [[children objectAtIndex:i] open]; +} + @end #pragma mark - Modified: trunk/SKBookmarkController.h =================================================================== --- trunk/SKBookmarkController.h 2011-01-21 18:23:02 UTC (rev 7078) +++ trunk/SKBookmarkController.h 2011-01-24 11:03:32 UTC (rev 7079) @@ -64,10 +64,8 @@ - (void)addBookmarkForSetup:(NSDictionary *)setupDict label:(NSString *)label toFolder:(SKBookmark *)folder; - (void)addBookmarkForSetups:(NSArray *)setupDicts label:(NSString *)label toFolder:(SKBookmark *)folder; -- (void)openBookmark:(SKBookmark *)bookmark; +- (IBAction)openBookmark:(id)sender; -- (IBAction)openBookmarkAction:(id)sender; - - (IBAction)doubleClickBookmark:(id)sender; - (IBAction)insertBookmarkFolder:(id)sender; - (IBAction)insertBookmarkSeparator:(id)sender; Modified: trunk/SKBookmarkController.m =================================================================== --- trunk/SKBookmarkController.m 2011-01-21 18:23:02 UTC (rev 7078) +++ trunk/SKBookmarkController.m 2011-01-24 11:03:32 UTC (rev 7079) @@ -39,19 +39,14 @@ #import "SKBookmarkController.h" #import "SKBookmark.h" #import "BDAlias.h" -#import "SKMainDocument.h" -#import "SKMainWindowController.h" -#import "NSFileManager_SKExtensions.h" #import "SKTypeSelectHelper.h" #import "SKStatusBar.h" #import "SKTextWithIconCell.h" #import "SKToolbarItem.h" #import "NSImage_SKExtensions.h" #import "SKStringConstants.h" -#import "SKDocumentController.h" #import "SKSeparatorCell.h" #import "NSMenu_SKExtensions.h" -#import "NSError_SKExtensions.h" #define SKBookmarkRowsPboardType @"SKBookmarkRowsPboardType" @@ -344,50 +339,17 @@ *indexPtr = idx; } -- (void)openFileBookmark:(SKBookmark *)bookmark { - id document = nil; - NSError *error = nil; - NSDictionary *dict = [bookmark properties]; - if ([dict objectForKey:@"windowFrame"]) { - document = [[NSDocumentController sharedDocumentController] openDocumentWithSetup:dict error:&error]; - } else { - NSString *path = [bookmark path]; - NSURL *fileURL = path ? [NSURL fileURLWithPath:path] : nil; - if (fileURL && NO == [[NSFileManager defaultManager] isTrashedFileAtURL:fileURL] && - (document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:fileURL display:YES error:&error]) && - [document isPDFDocument] && - [bookmark pageIndex] != NSNotFound) - [[document mainWindowController] setPageNumber:[bookmark pageIndex] + 1]; - } - if (document == nil && error && [error isUserCancelledError] == NO) - [NSApp presentError:error]; +- (IBAction)openBookmark:(id)sender { + [[sender representedObject] open]; } -- (void)openBookmark:(SKBookmark *)bookmark { - if ([bookmark bookmarkType] == SKBookmarkTypeSession) { - NSInteger i = [bookmark countOfChildren]; - while (i--) - [self openFileBookmark:[bookmark objectInChildrenAtIndex:i]]; - } else if ([bookmark bookmarkType] == SKBookmarkTypeBookmark) { - [self openFileBookmark:bookmark]; - } else if ([bookmark bookmarkType] == SKBookmarkTypeFolder) { - NSInteger i = [bookmark countOfChildren]; - while (i--) - [self openBookmark:[bookmark objectInChildrenAtIndex:i]]; - } -} - -- (IBAction)openBookmarkAction:(id)sender { - [self openBookmark:[sender representedObject]]; -} - - (IBAction)doubleClickBookmark:(id)sender { NSInteger row = [outlineView clickedRow]; if (row == -1) row = [outlineView selectedRow]; SKBookmark *bm = row == -1 ? nil : [outlineView itemAtRow:row]; if (bm && ([bm bookmarkType] == SKBookmarkTypeBookmark || [bm bookmarkType] == SKBookmarkTypeSession)) - [self openBookmark:bm]; + [bm open]; } - (IBAction)insertBookmarkFolder:(id)sender { @@ -451,7 +413,7 @@ [item setRepresentedObject:bm]; [item setImageAndSize:[bm icon]]; [[item submenu] setDelegate:self]; - item = [menu addItemWithTitle:[bm label] action:@selector(openBookmarkAction:) target:self]; + item = [menu addItemWithTitle:[bm label] action:@selector(openBookmark:) target:self]; [item setRepresentedObject:bm]; [item setKeyEquivalentModifierMask:NSAlternateKeyMask]; [item setAlternate:YES]; @@ -461,7 +423,7 @@ [menu addItem:[NSMenuItem separatorItem]]; break; default: - item = [menu addItemWithTitle:[bm label] action:@selector(openBookmarkAction:) target:self]; + item = [menu addItemWithTitle:[bm label] action:@selector(openBookmark:) target:self]; [item setRepresentedObject:bm]; [item setImageAndSize:[bm icon]]; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit