From feddcf37b2767a015a0ee74d263e7618995aad0d Mon Sep 17 00:00:00 2001 From: elasticthreads Date: Sun, 7 Apr 2013 21:02:08 -0400 Subject: [PATCH] merge dbFixes branch with the "kUseCachesFolderForInterimNoteChanges" compile flag set to 1 nvALT will now store its "Interim Note-Changes" file in '~/Library/Caches/net.elasticthreads.nv/' there's also a fix in here about how nvALT's window activates on launch when the Dock icon is hiding. Though innocous, it's kind of the straw that broke the full 10.6 support. From now on we'll have to release a separate 10.6 build. It requires two small changes to info.plist (see below) info.plist is set for 10.7+ only to build for 10.6 make the following changes to info.plist: - change "Minimum System Version" to 10.6.8 - change "Application is agent (UIElement)" (aka LSUIElement) to true --- AppController.h | 8 +- AppController.m | 149 +++++++++++++++++------------ English.lproj/MainMenu.xib | 23 +++++ Info.plist | 13 +-- Notation.xcodeproj/project.pbxproj | 2 + NotationController.h | 3 + NotationController.m | 33 ++++++- nvaDevConfig.h | 10 ++ 8 files changed, 166 insertions(+), 75 deletions(-) create mode 100644 nvaDevConfig.h diff --git a/AppController.h b/AppController.h index 09522cd8..4d1a1a44 100755 --- a/AppController.h +++ b/AppController.h @@ -229,11 +229,11 @@ void outletObjectAwoke(id sender); - (void)focusControlField:(id)sender activate:(BOOL)shouldActivate; #pragma mark toggling dock icon - (void)togDockIcon:(NSNotification *)notification; -- (void)toggleStatusItem:(NSNotification *)notification; -- (void)relaunchAfterDelay; -- (void)relaunchNV:(id)sender; -- (void)reactivateAfterDelay; +- (void)hideDockIconAfterDelay; +- (void)hideDockIcon; +- (void)showDockIcon; - (void)reActivate:(id)sender; +- (void)toggleStatusItem:(NSNotification *)notification; //- (IBAction)testThing:(id)sender; - (void)setUpStatusBarItem; - (NSArray *)referenceLinksInString:(NSString *)contentString; diff --git a/AppController.m b/AppController.m index 2bbd610f..61d1f6c7 100755 --- a/AppController.m +++ b/AppController.m @@ -87,14 +87,22 @@ - (id)init { hasLaunched=NO; if (![[NSUserDefaults standardUserDefaults] boolForKey:@"ShowDockIcon"]){ - ProcessSerialNumber psn = { 0, kCurrentProcess }; - OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToUIElementApplication); - if( returnCode != 0) { - NSLog(@"Could not bring the application to front. Error %d", returnCode); + if (IsLionOrLater) { + ProcessSerialNumber psn = { 0, kCurrentProcess }; + OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToUIElementApplication); + if( returnCode != 0) { + NSLog(@"Could not bring the application to front. Error %d", returnCode); + } } if (![[NSUserDefaults standardUserDefaults] boolForKey:@"StatusBarItem"]) { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"StatusBarItem"]; } + }else{ + if (!IsLionOrLater) { + enum {NSApplicationActivationPolicyRegular}; + [[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyRegular]; + } + } splitViewAwoke = NO; @@ -1109,7 +1117,10 @@ - (void)applicationWillBecomeActive:(NSNotification *)aNotification { if (IsLeopardOrLater) { SpaceSwitchingContext thisSpaceSwitchCtx; - CurrentContextForWindowNumber([window windowNumber], &thisSpaceSwitchCtx); + if ([window windowNumber]!=-1) { + CurrentContextForWindowNumber([window windowNumber], &thisSpaceSwitchCtx); + + } //what if the app is switched-to in another way? then the last-stored spaceSwitchCtx will cause us to return to the wrong app //unfortunately this notification occurs only after NV has become the front process, but we can still verify the space number @@ -2270,13 +2281,14 @@ - (IBAction)showPreferencesWindow:(id)sender { } - (IBAction)toggleNVActivation:(id)sender { - - if ([NSApp isActive] && [window isMainWindow]) { - + + if ([NSApp isActive] && [window isMainWindow]&&[window isVisible]) { + SpaceSwitchingContext laterSpaceSwitchCtx; - if (IsLeopardOrLater) + if (IsLeopardOrLater){ CurrentContextForWindowNumber([window windowNumber], &laterSpaceSwitchCtx); - + + } if (!IsLeopardOrLater || !CompareContextsAndSwitch(&spaceSwitchCtx, &laterSpaceSwitchCtx)) { //hide only if we didn't need to or weren't able to switch spaces [NSApp hide:sender]; @@ -2301,12 +2313,21 @@ - (void)focusControlField:(id)sender activate:(BOOL)shouldActivate{ [field selectText:sender]; - if (shouldActivate&&(![NSApp isActive])) { - CurrentContextForWindowNumber([window windowNumber], &spaceSwitchCtx); - [NSApp activateIgnoringOtherApps:YES]; + if (!shouldActivate) { + [window makeKeyAndOrderFront:sender]; + [window makeMainWindow]; + if (![NSApp isActive]) { + CurrentContextForWindowNumber([window windowNumber], &spaceSwitchCtx); + } + }else{ + if (![NSApp isActive]) { + CurrentContextForWindowNumber([window windowNumber], &spaceSwitchCtx); + [NSApp activateIgnoringOtherApps:YES]; + } + if (![window isMainWindow]||![window isVisible]){ + [window makeKeyAndOrderFront:sender]; + } } - if (![window isMainWindow]) [window makeKeyAndOrderFront:sender]; - [self setEmptyViewState:currentNote == nil]; self.isEditing = NO; @@ -2349,18 +2370,7 @@ - (NSMenu *)statBarMenu{ - (void)toggleAttachedWindow:(NSNotification *)aNotification { - if (![window isKeyWindow]) { - // [self focusOnCtrlFld:self]; - if (![window isMainWindow]) [window makeKeyAndOrderFront:self]; - - if (![NSApp isActive]) { - [NSApp activateIgnoringOtherApps:YES]; - } - }else { - [NSApp hide:[aNotification object]]; - // [statusItem popUpStatusItemMenu:statBarMenu]; - // return YES; - } + [self toggleNVActivation:[aNotification object]]; } - (void)toggleAttachedMenu:(NSNotification *)aNotification @@ -3316,16 +3326,61 @@ - (void)togDockIcon:(NSNotification *)notification{ [NSApp hide:self]; BOOL showIt=[[notification object]boolValue]; if (showIt) { - [self performSelectorOnMainThread:@selector(reactivateAfterDelay) withObject:nil waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(showDockIcon) withObject:nil waitUntilDone:NO]; }else { - [self performSelectorOnMainThread:@selector(relaunchAfterDelay) withObject:nil waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(hideDockIconAfterDelay) withObject:nil waitUntilDone:NO]; + + } + } + + - (void)showDockIcon{ + if (IsLionOrLater) { + ProcessSerialNumber psn = { 0, kCurrentProcess }; + OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToForegroundApplication); + if( returnCode != 0) { + NSLog(@"Could not bring the application to front. Error %d", returnCode); + } + + }else{ + enum {NSApplicationActivationPolicyRegular}; + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + } + [self performSelector:@selector(reActivate:) withObject:self afterDelay:0.16]; + } + + - (void)hideDockIcon{ + // id fullPath = [[NSBundle mainBundle] executablePath]; + // NSArray *arg = [NSArray arrayWithObjects:nil]; + // [NSTask launchedTaskWithLaunchPath:fullPath arguments:arg]; + // [NSApp terminate:sender]; + if (IsLionOrLater) { + ProcessSerialNumber psn = { 0, kCurrentProcess }; + OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToUIElementApplication); + if( returnCode != 0) { + NSLog(@"Could not bring the application to front. Error %d", returnCode); + } + if (!statusItem) { + [self setUpStatusBarItem]; + } + [self performSelector:@selector(reActivate:) withObject:self afterDelay:0.36]; + }else{ + NSLog(@"hiding dock incon in snow leopard"); + id fullPath = [[NSBundle mainBundle] executablePath]; + NSArray *arg = [NSArray arrayWithObjects:nil]; + [NSTask launchedTaskWithLaunchPath:fullPath arguments:arg]; + [NSApp terminate:self]; } + } - - (void)relaunchAfterDelay{ + - (void)reActivate:(id)sender{ + [NSApp activateIgnoringOtherApps:YES]; + } + + - (void)hideDockIconAfterDelay{ - [self performSelector:@selector(relaunchNV:) withObject:self afterDelay:0.22]; + [self performSelector:@selector(hideDockIcon) withObject:nil afterDelay:0.22]; } - (void)setUpStatusBarItem{ @@ -3347,38 +3402,10 @@ - (void)toggleStatusItem:(NSNotification *)notification{ } } - - (void)relaunchNV:(id)sender{ - // id fullPath = [[NSBundle mainBundle] executablePath]; - // NSArray *arg = [NSArray arrayWithObjects:nil]; - // [NSTask launchedTaskWithLaunchPath:fullPath arguments:arg]; - // [NSApp terminate:sender]; - - ProcessSerialNumber psn = { 0, kCurrentProcess }; - OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToUIElementApplication); - if( returnCode != 0) { - NSLog(@"Could not bring the application to front. Error %d", returnCode); - } - if (!statusItem) { - [self setUpStatusBarItem]; - } - - - [self performSelector:@selector(reActivate:) withObject:self afterDelay:0.36]; - } + - - (void)reactivateAfterDelay{ - - ProcessSerialNumber psn = { 0, kCurrentProcess }; - OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToForegroundApplication); - if( returnCode != 0) { - NSLog(@"Could not bring the application to front. Error %d", returnCode); - } - [self performSelector:@selector(reActivate:) withObject:self afterDelay:0.16]; - } + - - (void)reActivate:(id)sender{ - [NSApp activateIgnoringOtherApps:YES]; - } #pragma mark NSPREDICATE TO FIND MARKDOWN REFERENCE LINKS // - (IBAction)testThing:(id)sender{ diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index fd68249f..a89e51dc 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -5193,6 +5193,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA id id id + id id id id @@ -5304,6 +5305,10 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA tagNote: id + + testThing: + id + toggleCollapse: id @@ -5644,6 +5649,24 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA ./Classes/StatusItemView.h + + WebView + + reloadFromOrigin: + id + + + reloadFromOrigin: + + reloadFromOrigin: + id + + + + IBProjectSource + ./Classes/WebView.h + + WordCountToken NSTokenField diff --git a/Info.plist b/Info.plist index c4d999f2..3541ab13 100755 --- a/Info.plist +++ b/Info.plist @@ -160,7 +160,7 @@ CFBundleVersion - 106 + 107 LSApplicationCategoryType public.app-category.productivity LSArchitecturePriority @@ -169,16 +169,9 @@ i386 LSMinimumSystemVersion - 10.6 + 10.7 CFBundleName - LSMinimumSystemVersionByArchitecture - - i386 - 10.5.8 - x86_64 - 10.6.0 - NSAppleScriptEnabled NSMainNibFile @@ -229,6 +222,8 @@ 345600 SmartCrashReports_CompanyName Notational.net + LSUIElement + SmartCrashReports_EmailTicket SCR-51ED0F7B2A diff --git a/Notation.xcodeproj/project.pbxproj b/Notation.xcodeproj/project.pbxproj index f3ccaa39..381e1be7 100755 --- a/Notation.xcodeproj/project.pbxproj +++ b/Notation.xcodeproj/project.pbxproj @@ -591,6 +591,7 @@ 5C2CD036132ED47900CA0D7C /* ETScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ETScrollView.m; sourceTree = ""; }; 5C38E2C214223D6900131682 /* ETOverlayScroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ETOverlayScroller.h; sourceTree = ""; }; 5C38E2C314223D6900131682 /* ETOverlayScroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ETOverlayScroller.m; sourceTree = ""; }; + 5C4479DF17020153000AA45A /* nvaDevConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = nvaDevConfig.h; sourceTree = ""; }; 5C48A28113A54FBD006B73DD /* zh */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh; path = zh.lproj/PassphrasePicker.nib; sourceTree = ""; }; 5C48A28413A54FCA006B73DD /* zh */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh; path = zh.lproj/PassphraseChanger.nib; sourceTree = ""; }; 5C48A28813A54FE1006B73DD /* zh */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh; path = zh.lproj/KeyDerivationManager.nib; sourceTree = ""; }; @@ -1295,6 +1296,7 @@ 214495040ADC7F4F00E2A2B6 /* SFPasswordAssistantInspectorController.h */, 213FAD510B3C6B52004C74BD /* FSExchangeObjectsCompat.h */, 213FAD520B3C6B52004C74BD /* FSExchangeObjectsCompat.c */, + 5C4479DF17020153000AA45A /* nvaDevConfig.h */, ); name = "Other Sources"; sourceTree = ""; diff --git a/NotationController.h b/NotationController.h index 77e2e24b..f732269a 100755 --- a/NotationController.h +++ b/NotationController.h @@ -193,6 +193,9 @@ typedef struct _NoteCatalogEntry { - (void)dealloc; +#pragma mark nvALT stuff +- (NSString *)createCachesFolderString; + @end diff --git a/NotationController.m b/NotationController.m index 6fb07596..17b5ebb2 100755 --- a/NotationController.m +++ b/NotationController.m @@ -41,6 +41,7 @@ #import "SyncSessionController.h" #import "BookmarksController.h" #import "DeletionManager.h" +#import "nvaDevConfig.h" @implementation NotationController @@ -347,8 +348,15 @@ - (BOOL)initializeJournaling { UInt8 *convertedPath = (UInt8*)malloc(maxPathSize * sizeof(UInt8)); OSStatus err = noErr; NSData *walSessionKey = [notationPrefs WALSessionKey]; - + + //nvALT change to store Interim Note-Changes in ~/Library/Caches/ +#if kUseCachesFolderForInterimNoteChanges + NSString *cPath=[self createCachesFolder]; + if (cPath) { + convertedPath=[cPath UTF8String]; +#else if ((err = FSRefMakePath(¬eDirectoryRef, convertedPath, maxPathSize)) == noErr) { +#endif //initialize the journal if necessary if (!(walWriter = [[WALStorageController alloc] initWithParentFSRep:(char*)convertedPath encryptionKey:walSessionKey])) { //journal file probably already exists, so try to recover it @@ -1574,6 +1582,29 @@ - (void)dealloc { [super dealloc]; } +#pragma mark nvALT stuff +- (NSString *)createCachesFolder{ + NSString *path = nil; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + if ([paths count]) + { + NSString *bundleName = + [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]; + path = [[paths objectAtIndex:0] stringByAppendingPathComponent:bundleName]; + NSError *theError; + if ((path)&&([[NSFileManager defaultManager]createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&theError])) { +// NSLog(@"cache folder :>%@<",path); + return path; + + }else{ + NSLog(@"error creating cache folder :>%@<",[theError description]); + } + }else{ + NSLog(@"Unable to find or create cache folder:\n%@", path); + } + return nil; +} + @end diff --git a/nvaDevConfig.h b/nvaDevConfig.h new file mode 100644 index 00000000..9cc65283 --- /dev/null +++ b/nvaDevConfig.h @@ -0,0 +1,10 @@ +// +// nvaDevConfig.h +// Notation +// +// Created by David Halter on 3/26/13. +// +// you can put compiler flags here to let devs play with +// experimental features. + +#define kUseCachesFolderForInterimNoteChanges 1