Revision: 3764
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3764&view=rev
Author:   hofman
Date:     2008-04-18 14:22:17 -0700 (Fri, 18 Apr 2008)

Log Message:
-----------
Use observation contexts.

Modified Paths:
--------------
    trunk/SKNoteWindowController.m

Modified: trunk/SKNoteWindowController.m
===================================================================
--- trunk/SKNoteWindowController.m      2008-04-18 21:06:39 UTC (rev 3763)
+++ trunk/SKNoteWindowController.m      2008-04-18 21:22:17 UTC (rev 3764)
@@ -44,12 +44,17 @@
 #import "SKStatusBar.h"
 #import "SKDocument.h"
 #import "NSWindowController_SKExtensions.h"
+#import "NSUserDefaultsController_SKExtensions.h"
 #import "SKStringConstants.h"
 
 static NSString *SKNoteWindowFrameAutosaveName = @"SKNoteWindow";
 
 static NSString *SKKeepNoteWindowsOnTopKey = @"SKKeepNoteWindowsOnTop";
 
+static NSString *SKNoteWindowPageObservationContext = 
@"SKNoteWindowPageObservationContext";
+static NSString *SKNoteWindowBoundsObservationContext = 
@"SKNoteWindowBoundsObservationContext";
+
+
 @implementation SKNoteWindowController
 
 - (id)init {
@@ -64,8 +69,9 @@
         keepOnTop = [[NSUserDefaults standardUserDefaults] 
boolForKey:SKKeepNoteWindowsOnTopKey];
         forceOnTop = NO;
         
-        [note addObserver:self forKeyPath:SKPDFAnnotationPageKey options:0 
context:NULL];
-        [note addObserver:self forKeyPath:SKPDFAnnotationBoundsKey options:0 
context:NULL];
+        [note addObserver:self forKeyPath:SKPDFAnnotationPageKey options:0 
context:SKNoteWindowPageObservationContext];
+        [note addObserver:self forKeyPath:SKPDFAnnotationBoundsKey options:0 
context:SKNoteWindowBoundsObservationContext];
+        [[NSUserDefaultsController sharedUserDefaultsController] 
addObserver:self forKeys:[NSArray arrayWithObjects:SKAnchoredNoteFontNameKey, 
SKAnchoredNoteFontSizeKey, nil]];
     }
     return self;
 }
@@ -73,6 +79,7 @@
 - (void)dealloc {
     [note removeObserver:self forKeyPath:SKPDFAnnotationPageKey];
     [note removeObserver:self forKeyPath:SKPDFAnnotationBoundsKey];
+    [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self 
forKeys:[NSArray arrayWithObjects:SKAnchoredNoteFontNameKey, 
SKAnchoredNoteFontSizeKey, nil]];
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     CFRelease(editors);
     [textViewUndoManager release];
@@ -260,9 +267,8 @@
             if (font)
                 [textView setFont:font];
         }
-    } else if (object == note) {
-        if ([keyPath isEqualToString:SKPDFAnnotationPageKey] || [keyPath 
isEqualToString:SKPDFAnnotationBoundsKey])
-            [self updateStatusMessage];
+    } else if (context == SKNoteWindowBoundsObservationContext || context == 
SKNoteWindowPageObservationContext) {
+        [self updateStatusMessage];
     } else {
         [super observeValueForKeyPath:keyPath ofObject:object change:change 
context:context];
     }


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 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to