Revision: 5233
http://skim-app.svn.sourceforge.net/skim-app/?rev=5233&view=rev
Author: hofman
Date: 2009-03-02 17:52:42 +0000 (Mon, 02 Mar 2009)
Log Message:
-----------
use bindings for update interval in prefs
Modified Paths:
--------------
trunk/English.lproj/PreferenceWindow.nib/keyedobjects.nib
trunk/SKPreferenceController.h
trunk/SKPreferenceController.m
Modified: trunk/English.lproj/PreferenceWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)
Modified: trunk/SKPreferenceController.h
===================================================================
--- trunk/SKPreferenceController.h 2009-03-02 16:30:13 UTC (rev 5232)
+++ trunk/SKPreferenceController.h 2009-03-02 17:52:42 UTC (rev 5233)
@@ -57,6 +57,7 @@
IBOutlet SKFontWell *anchoredNoteFontWell;
NSDictionary *resettableKeys;
BOOL isCustomTeXEditor;
+ int updateInterval;
NSUserDefaults *sud;
NSUserDefaultsController *sudc;
}
@@ -69,8 +70,10 @@
- (BOOL)isCustomTeXEditor;
- (void)setCustomTeXEditor:(BOOL)flag;
+- (int)updateInterval;
+- (void)setUpdateInterval:(int)interval;
+
- (IBAction)changeDiscreteThumbnailSizes:(id)sender;
-- (IBAction)changeUpdateInterval:(id)sender;
- (IBAction)changeTeXEditorPreset:(id)sender;
- (IBAction)revertPDFViewSettings:(id)sender;
Modified: trunk/SKPreferenceController.m
===================================================================
--- trunk/SKPreferenceController.m 2009-03-02 16:30:13 UTC (rev 5232)
+++ trunk/SKPreferenceController.m 2009-03-02 17:52:42 UTC (rev 5233)
@@ -58,6 +58,11 @@
static void *SKPreferenceWindowDefaultsObservationContext = (void
*)@"SKPreferenceWindowDefaultsObservationContext";
static void *SKPreferenceWindowUpdaterObservationContext = (void
*)@"SKPreferenceWindowUpdaterObservationContext";
+...@interface SKPreferenceController (Private)
+- (void)synchronizeUpdateInterval;
+- (void)updateRevertButtons;
+...@end
+
@implementation SKPreferenceController
static SKPreferenceController *sharedPrefenceController = nil;
@@ -77,6 +82,8 @@
NSString *initialUserDefaultsPath = [[NSBundle mainBundle]
pathForResource:SKPreferenceInitialUserDefaultsFileName ofType:@"plist"];
resettableKeys = [[[NSDictionary
dictionaryWithContentsOfFile:initialUserDefaultsPath]
valueForKey:SKPreferenceResettableKeysKey] retain];
+ [self synchronizeUpdateInterval];
+
sud = [NSUserDefaults standardUserDefaults];
sudc = [NSUserDefaultsController sharedUserDefaultsController];
[sudc addObserver:self forKeys:[NSArray
arrayWithObjects:SKDefaultPDFDisplaySettingsKey,
SKDefaultFullScreenPDFDisplaySettingsKey, nil]
context:SKPreferenceWindowDefaultsObservationContext];
@@ -102,30 +109,6 @@
- (unsigned)retainCount { return UINT_MAX; }
-- (void)updateUpdateIntervalPopUpButton {
- int tag = 0;
- if ([[SUUpdater sharedUpdater] automaticallyChecksForUpdates])
- tag = [[SUUpdater sharedUpdater] updateCheckInterval];
- if ([updateIntervalPopUpButton selectItemWithTag:tag] == NO) {
- int i, iMax = [updateIntervalPopUpButton numberOfItems];
- int itemTag = 0;
- for (i = 0; i < iMax; i++) {
- itemTag = [[updateIntervalPopUpButton itemAtIndex:i] tag];
- if (itemTag >= tag) {
- [[SUUpdater sharedUpdater] setUpdateCheckInterval:itemTag];
- return;
- }
- }
- [[SUUpdater sharedUpdater] setUpdateCheckInterval:itemTag];
- }
-}
-
-- (void)updateRevertButtons {
- NSDictionary *initialValues = [sudc initialValues];
- [revertPDFSettingsButton setEnabled:[[initialValues
objectForKey:SKDefaultPDFDisplaySettingsKey] isEqual:[sud
dictionaryForKey:SKDefaultPDFDisplaySettingsKey]] == NO];
- [revertFullScreenPDFSettingsButton setEnabled:[[initialValues
objectForKey:SKDefaultFullScreenPDFDisplaySettingsKey] isEqual:[sud
dictionaryForKey:SKDefaultFullScreenPDFDisplaySettingsKey]] == NO];
-}
-
#define VALUES_KEY_PATH(key) [@"values." stringByAppendingString:key]
- (void)windowDidLoad {
@@ -150,8 +133,6 @@
[self updateRevertButtons];
- [self updateUpdateIntervalPopUpButton];
-
[textLineWell bind:SKLineWellLineWidthKey toObject:sudc
withKeyPath:VALUES_KEY_PATH(SKFreeTextNoteLineWidthKey) options:nil];
[textLineWell bind:SKLineWellStyleKey toObject:sudc
withKeyPath:VALUES_KEY_PATH(SKFreeTextNoteLineStyleKey) options:nil];
[textLineWell bind:SKLineWellDashPatternKey toObject:sudc
withKeyPath:VALUES_KEY_PATH(SKFreeTextNoteDashPatternKey) options:nil];
@@ -201,6 +182,8 @@
[[self window] endEditingFor:nil];
}
+#pragma mark Accessors
+
- (unsigned int)countOfSizes {
return sizeof(SKDefaultFontSizes) / sizeof(float);
}
@@ -217,6 +200,18 @@
isCustomTeXEditor = flag;
}
+- (int)updateInterval {
+ return updateInterval;
+}
+
+- (void)setUpdateInterval:(int)interval {
+ if (interval > 0)
+ [[SUUpdater sharedUpdater] setUpdateCheckInterval:interval];
+ [[SUUpdater sharedUpdater] setAutomaticallyChecksForUpdates:interval > 0];
+}
+
+#pragma mark Actions
+
- (IBAction)changeDiscreteThumbnailSizes:(id)sender {
if ([sender state] == NSOnState) {
[thumbnailSizeSlider setNumberOfTickMarks:8];
@@ -235,16 +230,6 @@
[snapshotSizeSlider sizeToFit];
}
-- (IBAction)changeUpdateInterval:(id)sender {
- int checkInterval = [[sender selectedItem] tag];
- if (checkInterval > 0) {
- [[SUUpdater sharedUpdater] setAutomaticallyChecksForUpdates:YES];
- [[SUUpdater sharedUpdater] setUpdateCheckInterval:checkInterval];
- } else {
- [[SUUpdater sharedUpdater] setAutomaticallyChecksForUpdates:NO];
- }
-}
-
- (IBAction)changeTeXEditorPreset:(id)sender {
int idx = [sender indexOfSelectedItem];
if (idx < [sender numberOfItems] - 1) {
@@ -326,10 +311,43 @@
[self updateRevertButtons];
}
} else if (context == SKPreferenceWindowUpdaterObservationContext) {
- [self updateUpdateIntervalPopUpButton];
+ [self willChangeValueForKey:@"updateInterval"];
+ [self synchronizeUpdateInterval];
+ [self didChangeValueForKey:@"updateInterval"];
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change
context:context];
}
}
+#pragma mark Private
+
+- (void)synchronizeUpdateInterval {
+ static NSIndexSet *updateIntervals = nil;
+ if (updateIntervals = nil) {
+ NSMutableIndexSet *intervals = [NSMutableIndexSet indexSet];
+ int i = [updateIntervalPopUpButton numberOfItems];
+ while (--i > 0)
+ [intervals addIndex:[[updateIntervalPopUpButton itemAtIndex:i]
tag]];
+ updateIntervals = [intervals copy];
+ }
+
+ unsigned int i = 0;
+ if ([[SUUpdater sharedUpdater] automaticallyChecksForUpdates]) {
+ i = [[SUUpdater sharedUpdater] updateCheckInterval];
+ if ([updateIntervals containsIndex:i] == NO) {
+ i = [updateIntervals indexGreaterThanIndex:i/2];
+ if (i == NSNotFound)
+ i = [updateIntervals lastIndex];
+ [[SUUpdater sharedUpdater] setUpdateCheckInterval:i];
+ }
+ }
+ updateInterval = i;
+}
+
+- (void)updateRevertButtons {
+ NSDictionary *initialValues = [sudc initialValues];
+ [revertPDFSettingsButton setEnabled:[[initialValues
objectForKey:SKDefaultPDFDisplaySettingsKey] isEqual:[sud
dictionaryForKey:SKDefaultPDFDisplaySettingsKey]] == NO];
+ [revertFullScreenPDFSettingsButton setEnabled:[[initialValues
objectForKey:SKDefaultFullScreenPDFDisplaySettingsKey] isEqual:[sud
dictionaryForKey:SKDefaultFullScreenPDFDisplaySettingsKey]] == NO];
+}
+
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit