Revision: 3341
http://skim-app.svn.sourceforge.net/skim-app/?rev=3341&view=rev
Author: hofman
Date: 2007-12-30 07:18:10 -0800 (Sun, 30 Dec 2007)
Log Message:
-----------
Avoid setup twice for initial windows at startup.
Modified Paths:
--------------
trunk/SKApplicationController.m
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m 2007-12-28 18:34:58 UTC (rev 3340)
+++ trunk/SKApplicationController.m 2007-12-30 15:18:10 UTC (rev 3341)
@@ -142,7 +142,7 @@
if (document = [[NSDocumentController
sharedDocumentController] openDocumentWithContentsOfURL:fileURL display:NO
error:&error]) {
[document makeWindowControllers];
if ([document
respondsToSelector:@selector(mainWindowController)])
- [[document mainWindowController] setupWindow:dict];
+ [[document mainWindowController] setInitialSetup:dict];
[document showWindows];
} else {
[NSApp presentError:error];
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2007-12-28 18:34:58 UTC (rev 3340)
+++ trunk/SKMainWindowController.h 2007-12-30 15:18:10 UTC (rev 3341)
@@ -380,7 +380,7 @@
- (void)addAnnotationsFromDictionaries:(NSArray *)noteDicts
undoable:(BOOL)undoable;
- (void)setAnnotationsFromDictionaries:(NSArray *)noteDicts
undoable:(BOOL)undoable;
-- (void)setupWindow:(NSDictionary *)setup;
+- (void)setInitialSetup:(NSDictionary *)setup;
- (NSDictionary *)currentSetup;
- (void)applyPDFSettings:(NSDictionary *)setup;
- (NSDictionary *)currentPDFSettings;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2007-12-28 18:34:58 UTC (rev 3340)
+++ trunk/SKMainWindowController.m 2007-12-30 15:18:10 UTC (rev 3341)
@@ -309,6 +309,7 @@
- (void)windowDidLoad{
NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
+ BOOL hasWindowSetup = [savedNormalSetup count] > 0;
NSRect frame;
settingUpWindow = YES;
@@ -393,24 +394,36 @@
[[self window] setBackgroundColor:[NSColor colorWithCalibratedWhite:0.9
alpha:1.0]];
- int windowSizeOption = [sud integerForKey:SKInitialWindowSizeOptionKey];
- if (windowSizeOption == SKMaximizeWindowOption)
- [[self window] setFrame:[[NSScreen mainScreen] visibleFrame]
display:NO];
-
if ([sud boolForKey:SKShowStatusBarKey])
[self toggleStatusBar:nil];
+ int windowSizeOption = [sud integerForKey:SKInitialWindowSizeOptionKey];
+ if (hasWindowSetup) {
+ NSString *rectString = [savedNormalSetup
objectForKey:WINDOW_FRAME_KEY];
+ if (rectString)
+ [[self window] setFrame:NSRectFromString(rectString) display:NO];
+ } else if (windowSizeOption == SKMaximizeWindowOption) {
+ [[self window] setFrame:[[NSScreen mainScreen] visibleFrame]
display:NO];
+ }
+
[[self window] makeFirstResponder:[pdfView documentView]];
// Set up the PDF
- [self applyPDFSettings:[sud
dictionaryForKey:SKDefaultPDFDisplaySettingsKey]];
+ [self applyPDFSettings:hasWindowSetup ? savedNormalSetup : [sud
dictionaryForKey:SKDefaultPDFDisplaySettingsKey]];
[pdfView setShouldAntiAlias:[sud boolForKey:SKShouldAntiAliasKey]];
[pdfView setGreekingThreshold:[sud floatForKey:SKGreekingThresholdKey]];
[pdfView setBackgroundColor:[sud colorForKey:SKBackgroundColorKey]];
- if ([sud objectForKey:SKLeftSidePaneWidthKey]) {
- float width = [sud floatForKey:SKLeftSidePaneWidthKey];
+ NSNumber *leftWidth = [savedNormalSetup
objectForKey:LEFT_SIDE_PANE_WIDTH_KEY];
+ NSNumber *rightWidth = [savedNormalSetup
objectForKey:RIGHT_SIDE_PANE_WIDTH_KEY];
+ if (leftWidth == nil)
+ leftWidth = [sud objectForKey:SKLeftSidePaneWidthKey];
+ if (rightWidth == nil)
+ rightWidth = [sud objectForKey:SKRightSidePaneWidthKey];
+
+ if (leftWidth && rightWidth) {
+ float width = [leftWidth floatValue];
if (width >= 0.0) {
frame = [leftSideContentView frame];
frame.size.width = width;
@@ -423,7 +436,7 @@
[leftSideDrawer close];
}
}
- width = [sud floatForKey:SKRightSidePaneWidthKey];
+ width = [rightWidth floatValue];
if (width >= 0.0) {
frame = [rightSideContentView frame];
frame.size.width = width;
@@ -476,14 +489,16 @@
[leftSideButton setEnabled:NO forSegment:SKOutlineSidePaneState];
// Go to page?
- if ([sud boolForKey:SKRememberLastPageViewedKey]) {
- unsigned int pageIndex = [[SKBookmarkController
sharedBookmarkController] pageIndexForRecentDocumentAtPath:[[[self document]
fileURL] path]];
- if (pageIndex != NSNotFound && [[pdfView document] pageCount] >
pageIndex)
- [pdfView goToPage:[[pdfView document] pageAtIndex:pageIndex]];
- }
+ unsigned int pageIndex = NSNotFound;
+ if (hasWindowSetup)
+ pageIndex = [[savedNormalSetup objectForKey:PAGE_INDEX_KEY]
unsignedIntValue];
+ else if ([sud boolForKey:SKRememberLastPageViewedKey])
+ pageIndex = [[SKBookmarkController sharedBookmarkController]
pageIndexForRecentDocumentAtPath:[[[self document] fileURL] path]];
+ if (pageIndex != NSNotFound && [[pdfView document] pageCount] > pageIndex)
+ [pdfView goToPage:[[pdfView document] pageAtIndex:pageIndex]];
// We can fit only after the PDF has been loaded
- if (windowSizeOption == SKFitWindowOption)
+ if (windowSizeOption == SKFitWindowOption && hasWindowSetup == NO)
[self performFit:self];
// Open snapshots?
@@ -520,6 +535,9 @@
[self registerForNotifications];
[self registerAsObserver];
+ if (hasWindowSetup)
+ [savedNormalSetup removeAllObjects];
+
settingUpWindow = NO;
}
@@ -604,48 +622,11 @@
SKTableFontSizeKey, nil]];
}
-- (void)setupWindow:(NSDictionary *)setup{
- NSString *rectString;
- NSNumber *number;
- NSRect frame;
-
- if (rectString = [setup objectForKey:WINDOW_FRAME_KEY])
- [[self window] setFrame:NSRectFromString(rectString) display:NO];
- if (number = [setup objectForKey:LEFT_SIDE_PANE_WIDTH_KEY]) {
- frame = [leftSideContentView frame];
- frame.size.width = [number floatValue];
- if (usesDrawers == NO) {
- [leftSideContentView setFrame:frame];
- } else if (NSWidth(frame) > 0.0) {
- [leftSideDrawer setContentSize:frame.size];
- [leftSideDrawer openOnEdge:NSMinXEdge];
- } else {
- [leftSideDrawer close];
- }
- }
- if (number = [setup objectForKey:RIGHT_SIDE_PANE_WIDTH_KEY]) {
- frame = [rightSideContentView frame];
- frame.size.width = [number floatValue];
- frame.origin.x = NSMaxX([splitView frame]) - NSWidth(frame);
- if (usesDrawers == NO) {
- [rightSideContentView setFrame:frame];
- } else if (NSWidth(frame) > 0.0) {
- [rightSideDrawer setContentSize:frame.size];
- [rightSideDrawer openOnEdge:NSMaxXEdge];
- } else {
- [rightSideDrawer close];
- }
- }
- if (usesDrawers == NO) {
- frame = [pdfSplitView frame];
- frame.size.width = NSWidth([splitView frame]) -
NSWidth([leftSideContentView frame]) - NSWidth([rightSideContentView frame]) -
2 * [splitView dividerThickness];
- frame.origin.x = NSMaxX([leftSideContentView frame]) + [splitView
dividerThickness];
- [pdfSplitView setFrame:frame];
- }
-
- [self applyPDFSettings:setup];
- if (number = [setup objectForKey:PAGE_INDEX_KEY])
- [pdfView goToPage:[[pdfView document] pageAtIndex:[number intValue]]];
+- (void)setInitialSetup:(NSDictionary *)setup{
+ if ([self isWindowLoaded] == NO)
+ [savedNormalSetup setDictionary:setup];
+ else
+ NSLog(@"-[NSMainWindowController setupWindow:] called after window was
loaded");
}
- (NSDictionary *)currentSetup {
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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit