diff --git a/FlycutEngine/FlycutStore.h b/FlycutEngine/FlycutStore.h index 9a886c2..6ed4e31 100755 --- a/FlycutEngine/FlycutStore.h +++ b/FlycutEngine/FlycutStore.h @@ -31,6 +31,9 @@ int jcRememberNum; // The max we will allow users to display; 20 int jcDisplayNum; // How many the user actually wants to display; defaults to 10 int jcDisplayLen; // How many characters to display in the menu; defaults to 37 + + // Our status information + bool modifiedSinceLastSaveStore; // hash -- key values to clippings // initially we will use PasteboardCount as the key value, but this will not be guaranteed @@ -49,11 +52,13 @@ -(void) setRememberNum:(int)nowRemembering; -(void) setDisplayNum:(int)nowDisplaying; -(void) setDisplayLen:(int)newDisplayLength; +-(void) clearModifiedSinceLastSaveStore; // Retrieve various values -(int) rememberNum; -(int) displayLen; -(int) jcListCount; +-(bool) modifiedSinceLastSaveStore; -(FlycutClipping *) clippingAtPosition:(int)index; -(NSString *) clippingContentsAtPosition:(int)index; -(NSString *) clippingDisplayStringAtPosition:(int)index; diff --git a/FlycutEngine/FlycutStore.m b/FlycutEngine/FlycutStore.m index 8d5c9e3..6aff843 100755 --- a/FlycutEngine/FlycutStore.m +++ b/FlycutEngine/FlycutStore.m @@ -218,6 +218,11 @@ } } +-(void) clearModifiedSinceLastSaveStore +{ + modifiedSinceLastSaveStore = NO; +} + -(int) rememberNum { return jcRememberNum; @@ -233,6 +238,11 @@ return [jcList count]; } +-(bool) modifiedSinceLastSaveStore +{ + return modifiedSinceLastSaveStore; +} + -(FlycutClipping *) clippingAtPosition:(int)index { if ( index >= [jcList count] ) { @@ -373,24 +383,28 @@ -(void) delegateInsertClippingAtIndex:(int)index { + modifiedSinceLastSaveStore = YES; if ( self.delegate && [self.delegate respondsToSelector:@selector(insertClippingAtIndex:)] ) [self.delegate insertClippingAtIndex:index]; } -(void) delegateDeleteClippingAtIndex:(int)index { + modifiedSinceLastSaveStore = YES; if ( self.delegate && [self.delegate respondsToSelector:@selector(deleteClippingAtIndex:)] ) [self.delegate deleteClippingAtIndex:index]; } -(void) delegateReloadClippingAtIndex:(int)index { + modifiedSinceLastSaveStore = YES; if ( self.delegate && [self.delegate respondsToSelector:@selector(reloadClippingAtIndex:)] ) [self.delegate reloadClippingAtIndex:index]; } -(void) delegateMoveClippingAtIndex:(int)index toIndex:(int)newIndex { + modifiedSinceLastSaveStore = YES; if ( self.delegate && [self.delegate respondsToSelector:@selector(moveClippingAtIndex:toIndex:)] ) [self.delegate moveClippingAtIndex:index toIndex:newIndex]; } diff --git a/FlycutOperator.m b/FlycutOperator.m index 595588d..ea9e64c 100644 --- a/FlycutOperator.m +++ b/FlycutOperator.m @@ -742,9 +742,15 @@ [jcListArray addObject:dict]; } [saveDict setObject:jcListArray forKey:key]; + [store clearModifiedSinceLastSaveStore]; } -(void) saveEngine { + // saveEngine saves to NSUserDefaults. If there have been no modifications, just skip this to avoid busy activity for any observers. + if ( !([clippingStore modifiedSinceLastSaveStore] + || [favoritesStore modifiedSinceLastSaveStore]) ) + return; + NSMutableDictionary *saveDict; saveDict = [NSMutableDictionary dictionaryWithCapacity:3]; [saveDict setObject:@"0.7" forKey:@"version"];