Revision: 3734
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3734&view=rev
Author:   hofman
Date:     2008-04-15 10:41:57 -0700 (Tue, 15 Apr 2008)

Log Message:
-----------
Workaround for Tiger crasher. Unfortunately, the target for the font manager 
cannot be changed on Tiger. In fact, there is no way to observe changes from 
the font manager if you're not the first responder. Very stupid.

Modified Paths:
--------------
    trunk/SKFontPicker.h
    trunk/SKFontPicker.m
    trunk/SKPreferenceController.h
    trunk/SKPreferenceController.m

Modified: trunk/SKFontPicker.h
===================================================================
--- trunk/SKFontPicker.h        2008-04-15 08:58:38 UTC (rev 3733)
+++ trunk/SKFontPicker.h        2008-04-15 17:41:57 UTC (rev 3734)
@@ -57,6 +57,8 @@
     BOOL updatingFromBinding;
 }
 
++ (SKFontPicker *)activeFontPicker;
+
 - (void)activate;
 - (void)deactivate;
 
@@ -71,4 +73,6 @@
 - (float)fontSize;
 - (void)setFontSize:(float)pointSize;
 
+- (void)changeFontFromFontManager;
+
 @end

Modified: trunk/SKFontPicker.m
===================================================================
--- trunk/SKFontPicker.m        2008-04-15 08:58:38 UTC (rev 3733)
+++ trunk/SKFontPicker.m        2008-04-15 17:41:57 UTC (rev 3734)
@@ -63,6 +63,8 @@
 
 @implementation SKFontPicker
 
+static SKFontPicker *activeFontPicker = nil;
+
 + (void)initialize {
     OBINITIALIZE;
     
@@ -77,6 +79,10 @@
     [self setKeys:[NSArray arrayWithObjects:SKFontPickerFontKey, nil] 
triggerChangeNotificationsForDependentKey:SKFontPickerFontSizeKey];
 }
 
++ (SKFontPicker *)activeFontPicker {
+    return activeFontPicker;
+}
+
 - (Class)valueClassForBinding:(NSString *)binding {
     if ([binding isEqualToString:SKFontPickerFontNameKey])
         return [NSString class];
@@ -219,7 +225,7 @@
     }
 }
 
-- (void)changeFont:(id)sender {
+- (void)changeFontFromFontManager {
     if ([self isActive]) {
         NSFontManager *fm = [NSFontManager sharedFontManager];
         BOOL savedUpdatingFromFontPanel = updatingFromFontPanel;
@@ -239,7 +245,7 @@
     [fm setSelectedFont:[self font] isMultiple:NO];
     [fm orderFrontFontPanel:self];
     
-    [fm setTarget:self];
+    activeFontPicker = self;
     [nc addObserver:self selector:@selector(fontPickerWillBecomeActive:)
                name:SKFontPickerWillBecomeActiveNotification object:nil];
     [nc addObserver:self selector:@selector(fontPanelWillClose:)
@@ -251,8 +257,7 @@
 }
 
 - (void)deactivate {
-    NSFontManager *fm = [NSFontManager sharedFontManager];
-    if ([fm target] == self) [fm setTarget:nil];
+    if (activeFontPicker == self) activeFontPicker = nil;
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [self setState:NSOffState];
     [self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]];

Modified: trunk/SKPreferenceController.h
===================================================================
--- trunk/SKPreferenceController.h      2008-04-15 08:58:38 UTC (rev 3733)
+++ trunk/SKPreferenceController.h      2008-04-15 17:41:57 UTC (rev 3734)
@@ -74,6 +74,8 @@
 - (IBAction)revertPDFViewSettings:(id)sender;
 - (IBAction)revertFullScreenPDFViewSettings:(id)sender;
 
+- (IBAction)changeFont:(id)sender;
+
 - (IBAction)resetAll:(id)sender;
 - (IBAction)resetCurrent:(id)sender;
 

Modified: trunk/SKPreferenceController.m
===================================================================
--- trunk/SKPreferenceController.m      2008-04-15 08:58:38 UTC (rev 3733)
+++ trunk/SKPreferenceController.m      2008-04-15 17:41:57 UTC (rev 3734)
@@ -238,6 +238,10 @@
     }
 }
 
+- (IBAction)changeFont:(id)sender {
+    [[SKFontPicker activeFontPicker] changeFontFromFontManager];
+}
+
 - (IBAction)resetAll:(id)sender {
     NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Reset 
all preferences to their original values?", @"Message in alert dialog when 
pressing Reset All button") 
                                      defaultButton:NSLocalizedString(@"Reset", 
@"Button title")


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