Revision: 4413
http://skim-app.svn.sourceforge.net/skim-app/?rev=4413&view=rev
Author: hofman
Date: 2008-08-15 15:00:00 +0000 (Fri, 15 Aug 2008)
Log Message:
-----------
Save full window setup for session bookmark.
Modified Paths:
--------------
trunk/SKBookmark.h
trunk/SKBookmark.m
trunk/SKBookmarkController.h
trunk/SKBookmarkController.m
trunk/SKMainWindowController.m
Modified: trunk/SKBookmark.h
===================================================================
--- trunk/SKBookmark.h 2008-08-15 12:52:03 UTC (rev 4412)
+++ trunk/SKBookmark.h 2008-08-15 15:00:00 UTC (rev 4413)
@@ -50,6 +50,7 @@
}
- (id)initWithPath:(NSString *)aPath pageIndex:(unsigned)aPageIndex
label:(NSString *)aLabel;
+- (id)initWithSetup:(NSDictionary *)aSetupDict label:(NSString *)aLabel;
- (id)initFolderWithChildren:(NSArray *)aChildren label:(NSString *)aLabel;
- (id)initSessionWithChildren:(NSArray *)aChildren label:(NSString *)aLabel;
- (id)initFolderWithLabel:(NSString *)aLabel;
Modified: trunk/SKBookmark.m
===================================================================
--- trunk/SKBookmark.m 2008-08-15 12:52:03 UTC (rev 4412)
+++ trunk/SKBookmark.m 2008-08-15 15:00:00 UTC (rev 4413)
@@ -59,6 +59,7 @@
NSData *aliasData;
NSString *label;
unsigned int pageIndex;
+ NSDictionary *setup;
}
- (BDAlias *)alias;
- (NSData *)aliasData;
@@ -107,6 +108,12 @@
return [self initWithAlias:[BDAlias aliasWithPath:aPath]
pageIndex:aPageIndex label:aLabel];
}
+- (id)initWithSetup:(NSDictionary *)aSetupDict label:(NSString *)aLabel {
+ if (self != defaultPlaceholderBookmark)
+ [self release];
+ return [[SKFileBookmark alloc] initWithSetup:aSetupDict label:aLabel];
+}
+
- (id)initFolderWithChildren:(NSArray *)aChildren label:(NSString *)aLabel {
if (self != defaultPlaceholderBookmark)
[self release];
@@ -224,6 +231,7 @@
aliasData = [[alias aliasData] retain];
pageIndex = aPageIndex;
label = [aLabel copy];
+ setup = nil;
} else {
[self release];
self = nil;
@@ -232,6 +240,13 @@
return self;
}
+- (id)initWithSetup:(NSDictionary *)aSetupDict label:(NSString *)aLabel {
+ if (self = [self initWithAlias:[BDAlias aliasWithData:[aSetupDict
objectForKey:SKBookmarkAliasDataKey]] pageIndex:[[aSetupDict
objectForKey:SKBookmarkPageIndexKey] unsignedIntValue] label:aLabel]) {
+ setup = [aSetupDict copy];
+ }
+ return self;
+}
+
- (id)copyWithZone:(NSZone *)aZone {
return [[[self class] allocWithZone:aZone] initWithAlias:alias
pageIndex:pageIndex label:label];
}
@@ -240,6 +255,7 @@
[alias release];
[aliasData release];
[label release];
+ [setup release];
[super dealloc];
}
@@ -248,7 +264,9 @@
}
- (NSDictionary *)properties {
- return [NSDictionary
dictionaryWithObjectsAndKeys:SKBookmarkTypeBookmarkString, SKBookmarkTypeKey,
[self aliasData], SKBookmarkAliasDataKey, [NSNumber
numberWithUnsignedInt:pageIndex], SKBookmarkPageIndexKey, label,
SKBookmarkLabelKey, nil];
+ NSMutableDictionary *properties = [NSMutableDictionary
dictionaryWithDictionary:setup];
+ [properties addEntriesFromDictionary:[NSDictionary
dictionaryWithObjectsAndKeys:SKBookmarkTypeBookmarkString, SKBookmarkTypeKey,
[self aliasData], SKBookmarkAliasDataKey, [NSNumber
numberWithUnsignedInt:pageIndex], SKBookmarkPageIndexKey, label,
SKBookmarkLabelKey, nil]];
+ return properties;
}
- (int)bookmarkType {
Modified: trunk/SKBookmarkController.h
===================================================================
--- trunk/SKBookmarkController.h 2008-08-15 12:52:03 UTC (rev 4412)
+++ trunk/SKBookmarkController.h 2008-08-15 15:00:00 UTC (rev 4413)
@@ -55,7 +55,9 @@
- (SKBookmark *)bookmarkRoot;
- (void)addBookmarkForPath:(NSString *)path pageIndex:(unsigned)pageIndex
label:(NSString *)label toFolder:(SKBookmark *)folder;
+- (void)addBookmarkForSetup:(NSDictionary *)setupDict label:(NSString *)label
toFolder:(SKBookmark *)folder;
- (void)addBookmarkForPaths:(NSArray *)paths pageIndexes:(NSArray
*)pageIndexes label:(NSString *)label toFolder:(SKBookmark *)folder;
+- (void)addBookmarkForSetups:(NSArray *)setupDicts label:(NSString *)label
toFolder:(SKBookmark *)folder;
- (void)openBookmark:(SKBookmark *)bookmark;
- (void)openBookmarks:(NSArray *)items;
Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m 2008-08-15 12:52:03 UTC (rev 4412)
+++ trunk/SKBookmarkController.m 2008-08-15 15:00:00 UTC (rev 4413)
@@ -235,6 +235,15 @@
}
}
+- (void)addBookmarkForSetup:(NSDictionary *)setupDict label:(NSString *)label
toFolder:(SKBookmark *)folder {
+ if (folder == nil) folder = bookmarkRoot;
+ SKBookmark *bookmark = [[SKBookmark alloc] initWithSetup:setupDict
label:label];
+ if (bookmark) {
+ [folder insertObject:bookmark inChildrenAtIndex:[folder
countOfChildren]];
+ [bookmark release];
+ }
+}
+
- (void)addBookmarkForPaths:(NSArray *)paths pageIndexes:(NSArray
*)pageIndexes label:(NSString *)label toFolder:(SKBookmark *)folder {
NSEnumerator *pathEnum = [paths objectEnumerator];
NSEnumerator *pageEnum = [pageIndexes objectEnumerator];
@@ -256,6 +265,25 @@
}
}
+- (void)addBookmarkForSetups:(NSArray *)setupDicts label:(NSString *)label
toFolder:(SKBookmark *)folder {
+ NSEnumerator *setupEnum = [setupDicts objectEnumerator];
+ NSDictionary *setup;
+ NSMutableArray *children = [NSMutableArray array];
+ SKBookmark *bookmark;
+ while (setup = [setupEnum nextObject]) {
+ bookmark = [[SKBookmark alloc] initWithSetup:setup label:@""];
+ if (bookmark) {
+ [children addObject:bookmark];
+ [bookmark release];
+ }
+ }
+ if (folder == nil) folder = bookmarkRoot;
+ if (bookmark = [[SKBookmark alloc] initSessionWithChildren:children
label:label]) {
+ [folder insertObject:bookmark inChildrenAtIndex:[folder
countOfChildren]];
+ [bookmark release];
+ }
+}
+
- (NSArray *)draggedBookmarks {
return draggedBookmarks;
}
@@ -359,8 +387,17 @@
NSError *error;
if (fileURL && NO == SKFileIsInTrash(fileURL)) {
- if (document = [[NSDocumentController sharedDocumentController]
openDocumentWithContentsOfURL:fileURL display:YES error:&error]) {
- [[document mainWindowController] setPageNumber:[bookmark
pageIndex] + 1];
+ NSDictionary *dict = [bookmark properties];
+ BOOL display = [dict objectForKey:@"windowFrame"] == nil;
+ if (document = [[NSDocumentController sharedDocumentController]
openDocumentWithContentsOfURL:fileURL display:display error:&error]) {
+ if (display) {
+ [[document mainWindowController] setPageNumber:[bookmark
pageIndex] + 1];
+ } else {
+ [document makeWindowControllers];
+ if ([document
respondsToSelector:@selector(mainWindowController)])
+ [[document mainWindowController] setInitialSetup:dict];
+ [document showWindows];
+ }
} else {
[NSApp presentError:error];
}
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-08-15 12:52:03 UTC (rev 4412)
+++ trunk/SKMainWindowController.m 2008-08-15 15:00:00 UTC (rev 4413)
@@ -2124,15 +2124,8 @@
if (returnCode == NSAlertDefaultReturn) {
SKBookmarkController *bmController = [SKBookmarkController
sharedBookmarkController];
NSString *label = [controller stringValue];
- NSEnumerator *docEnum = [[NSApp orderedDocuments] objectEnumerator];
- SKPDFDocument *doc;
- NSMutableArray *paths = [NSMutableArray array];
- NSMutableArray *pageIndexes = [NSMutableArray array];
- while (doc = [docEnum nextObject]) {
- [paths addObject:[doc fileName]];
- [pageIndexes addObject:[NSNumber numberWithUnsignedInt:[[[doc
pdfView] currentPage] pageIndex]]];
- }
- [bmController addBookmarkForPaths:paths pageIndexes:pageIndexes
label:label toFolder:[controller selectedFolder]];
+ NSArray *setups = [[NSApp orderedDocuments]
valueForKey:@"currentDocumentSetup"];
+ [bmController addBookmarkForSetups:setups label:label
toFolder:[controller selectedFolder]];
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit