Skip to content

Commit

Permalink
merge dbFixes branch
Browse files Browse the repository at this point in the history
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
  • Loading branch information
elasticthreads committed Apr 8, 2013
1 parent f97a92d commit feddcf3
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 75 deletions.
8 changes: 4 additions & 4 deletions AppController.h
Expand Up @@ -229,11 +229,11 @@ void outletObjectAwoke(id sender);
- (void)focusControlField:(id)sender activate:(BOOL)shouldActivate; - (void)focusControlField:(id)sender activate:(BOOL)shouldActivate;
#pragma mark toggling dock icon #pragma mark toggling dock icon
- (void)togDockIcon:(NSNotification *)notification; - (void)togDockIcon:(NSNotification *)notification;
- (void)toggleStatusItem:(NSNotification *)notification; - (void)hideDockIconAfterDelay;
- (void)relaunchAfterDelay; - (void)hideDockIcon;
- (void)relaunchNV:(id)sender; - (void)showDockIcon;
- (void)reactivateAfterDelay;
- (void)reActivate:(id)sender; - (void)reActivate:(id)sender;
- (void)toggleStatusItem:(NSNotification *)notification;
//- (IBAction)testThing:(id)sender; //- (IBAction)testThing:(id)sender;
- (void)setUpStatusBarItem; - (void)setUpStatusBarItem;
- (NSArray *)referenceLinksInString:(NSString *)contentString; - (NSArray *)referenceLinksInString:(NSString *)contentString;
Expand Down
149 changes: 88 additions & 61 deletions AppController.m
Expand Up @@ -87,14 +87,22 @@ - (id)init {
hasLaunched=NO; hasLaunched=NO;


if (![[NSUserDefaults standardUserDefaults] boolForKey:@"ShowDockIcon"]){ if (![[NSUserDefaults standardUserDefaults] boolForKey:@"ShowDockIcon"]){
ProcessSerialNumber psn = { 0, kCurrentProcess }; if (IsLionOrLater) {
OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToUIElementApplication); ProcessSerialNumber psn = { 0, kCurrentProcess };
if( returnCode != 0) { OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToUIElementApplication);
NSLog(@"Could not bring the application to front. Error %d", returnCode); if( returnCode != 0) {
NSLog(@"Could not bring the application to front. Error %d", returnCode);
}
} }
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"StatusBarItem"]) { if (![[NSUserDefaults standardUserDefaults] boolForKey:@"StatusBarItem"]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"StatusBarItem"]; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"StatusBarItem"];
} }
}else{
if (!IsLionOrLater) {
enum {NSApplicationActivationPolicyRegular};
[[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyRegular];
}

} }


splitViewAwoke = NO; splitViewAwoke = NO;
Expand Down Expand Up @@ -1109,7 +1117,10 @@ - (void)applicationWillBecomeActive:(NSNotification *)aNotification {


if (IsLeopardOrLater) { if (IsLeopardOrLater) {
SpaceSwitchingContext thisSpaceSwitchCtx; 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 //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 //unfortunately this notification occurs only after NV has become the front process, but we can still verify the space number


Expand Down Expand Up @@ -2270,13 +2281,14 @@ - (IBAction)showPreferencesWindow:(id)sender {
} }


- (IBAction)toggleNVActivation:(id)sender { - (IBAction)toggleNVActivation:(id)sender {
if ([NSApp isActive] && [window isMainWindow]) { if ([NSApp isActive] && [window isMainWindow]&&[window isVisible]) {
SpaceSwitchingContext laterSpaceSwitchCtx; SpaceSwitchingContext laterSpaceSwitchCtx;
if (IsLeopardOrLater) if (IsLeopardOrLater){
CurrentContextForWindowNumber([window windowNumber], &laterSpaceSwitchCtx); CurrentContextForWindowNumber([window windowNumber], &laterSpaceSwitchCtx);


}
if (!IsLeopardOrLater || !CompareContextsAndSwitch(&spaceSwitchCtx, &laterSpaceSwitchCtx)) { if (!IsLeopardOrLater || !CompareContextsAndSwitch(&spaceSwitchCtx, &laterSpaceSwitchCtx)) {
//hide only if we didn't need to or weren't able to switch spaces //hide only if we didn't need to or weren't able to switch spaces
[NSApp hide:sender]; [NSApp hide:sender];
Expand All @@ -2301,12 +2313,21 @@ - (void)focusControlField:(id)sender activate:(BOOL)shouldActivate{


[field selectText:sender]; [field selectText:sender];


if (shouldActivate&&(![NSApp isActive])) { if (!shouldActivate) {
CurrentContextForWindowNumber([window windowNumber], &spaceSwitchCtx); [window makeKeyAndOrderFront:sender];
[NSApp activateIgnoringOtherApps:YES]; [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 setEmptyViewState:currentNote == nil];
self.isEditing = NO; self.isEditing = NO;


Expand Down Expand Up @@ -2349,18 +2370,7 @@ - (NSMenu *)statBarMenu{


- (void)toggleAttachedWindow:(NSNotification *)aNotification - (void)toggleAttachedWindow:(NSNotification *)aNotification
{ {
if (![window isKeyWindow]) { [self toggleNVActivation:[aNotification object]];
// [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;
}
} }


- (void)toggleAttachedMenu:(NSNotification *)aNotification - (void)toggleAttachedMenu:(NSNotification *)aNotification
Expand Down Expand Up @@ -3316,16 +3326,61 @@ - (void)togDockIcon:(NSNotification *)notification{
[NSApp hide:self]; [NSApp hide:self];
BOOL showIt=[[notification object]boolValue]; BOOL showIt=[[notification object]boolValue];
if (showIt) { if (showIt) {
[self performSelectorOnMainThread:@selector(reactivateAfterDelay) withObject:nil waitUntilDone:NO]; [self performSelectorOnMainThread:@selector(showDockIcon) withObject:nil waitUntilDone:NO];
}else { }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{ - (void)setUpStatusBarItem{
Expand All @@ -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 #pragma mark NSPREDICATE TO FIND MARKDOWN REFERENCE LINKS
// - (IBAction)testThing:(id)sender{ // - (IBAction)testThing:(id)sender{
Expand Down
23 changes: 23 additions & 0 deletions English.lproj/MainMenu.xib
Expand Up @@ -5193,6 +5193,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<string key="switchViewLayout:">id</string> <string key="switchViewLayout:">id</string>
<string key="syncWaitQuit:">id</string> <string key="syncWaitQuit:">id</string>
<string key="tagNote:">id</string> <string key="tagNote:">id</string>
<string key="testThing:">id</string>
<string key="toggleCollapse:">id</string> <string key="toggleCollapse:">id</string>
<string key="toggleNVActivation:">id</string> <string key="toggleNVActivation:">id</string>
<string key="togglePreview:">id</string> <string key="togglePreview:">id</string>
Expand Down Expand Up @@ -5304,6 +5305,10 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<string key="name">tagNote:</string> <string key="name">tagNote:</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
</object> </object>
<object class="IBActionInfo" key="testThing:">
<string key="name">testThing:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="toggleCollapse:"> <object class="IBActionInfo" key="toggleCollapse:">
<string key="name">toggleCollapse:</string> <string key="name">toggleCollapse:</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
Expand Down Expand Up @@ -5644,6 +5649,24 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<string key="minorKey">./Classes/StatusItemView.h</string> <string key="minorKey">./Classes/StatusItemView.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">WebView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">reloadFromOrigin:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">reloadFromOrigin:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">reloadFromOrigin:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/WebView.h</string>
</object>
</object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">WordCountToken</string> <string key="className">WordCountToken</string>
<string key="superclassName">NSTokenField</string> <string key="superclassName">NSTokenField</string>
Expand Down
13 changes: 4 additions & 9 deletions Info.plist
Expand Up @@ -160,7 +160,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>106</string> <string>107</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string> <string>public.app-category.productivity</string>
<key>LSArchitecturePriority</key> <key>LSArchitecturePriority</key>
Expand All @@ -169,16 +169,9 @@
<string>i386</string> <string>i386</string>
</array> </array>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>10.6</string> <string>10.7</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string></string> <string></string>
<key>LSMinimumSystemVersionByArchitecture</key>
<dict>
<key>i386</key>
<string>10.5.8</string>
<key>x86_64</key>
<string>10.6.0</string>
</dict>
<key>NSAppleScriptEnabled</key> <key>NSAppleScriptEnabled</key>
<true/> <true/>
<key>NSMainNibFile</key> <key>NSMainNibFile</key>
Expand Down Expand Up @@ -229,6 +222,8 @@
<real>345600</real> <real>345600</real>
<key>SmartCrashReports_CompanyName</key> <key>SmartCrashReports_CompanyName</key>
<string>Notational.net</string> <string>Notational.net</string>
<key>LSUIElement</key>
<false/>
<key>SmartCrashReports_EmailTicket</key> <key>SmartCrashReports_EmailTicket</key>
<string>SCR-51ED0F7B2A</string> <string>SCR-51ED0F7B2A</string>
</dict> </dict>
Expand Down
2 changes: 2 additions & 0 deletions Notation.xcodeproj/project.pbxproj
Expand Up @@ -591,6 +591,7 @@
5C2CD036132ED47900CA0D7C /* ETScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ETScrollView.m; sourceTree = "<group>"; }; 5C2CD036132ED47900CA0D7C /* ETScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ETScrollView.m; sourceTree = "<group>"; };
5C38E2C214223D6900131682 /* ETOverlayScroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ETOverlayScroller.h; sourceTree = "<group>"; }; 5C38E2C214223D6900131682 /* ETOverlayScroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ETOverlayScroller.h; sourceTree = "<group>"; };
5C38E2C314223D6900131682 /* ETOverlayScroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ETOverlayScroller.m; sourceTree = "<group>"; }; 5C38E2C314223D6900131682 /* ETOverlayScroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ETOverlayScroller.m; sourceTree = "<group>"; };
5C4479DF17020153000AA45A /* nvaDevConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = nvaDevConfig.h; sourceTree = "<group>"; };
5C48A28113A54FBD006B73DD /* zh */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh; path = zh.lproj/PassphrasePicker.nib; sourceTree = "<group>"; }; 5C48A28113A54FBD006B73DD /* zh */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh; path = zh.lproj/PassphrasePicker.nib; sourceTree = "<group>"; };
5C48A28413A54FCA006B73DD /* zh */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh; path = zh.lproj/PassphraseChanger.nib; sourceTree = "<group>"; }; 5C48A28413A54FCA006B73DD /* zh */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh; path = zh.lproj/PassphraseChanger.nib; sourceTree = "<group>"; };
5C48A28813A54FE1006B73DD /* zh */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh; path = zh.lproj/KeyDerivationManager.nib; sourceTree = "<group>"; }; 5C48A28813A54FE1006B73DD /* zh */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh; path = zh.lproj/KeyDerivationManager.nib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1295,6 +1296,7 @@
214495040ADC7F4F00E2A2B6 /* SFPasswordAssistantInspectorController.h */, 214495040ADC7F4F00E2A2B6 /* SFPasswordAssistantInspectorController.h */,
213FAD510B3C6B52004C74BD /* FSExchangeObjectsCompat.h */, 213FAD510B3C6B52004C74BD /* FSExchangeObjectsCompat.h */,
213FAD520B3C6B52004C74BD /* FSExchangeObjectsCompat.c */, 213FAD520B3C6B52004C74BD /* FSExchangeObjectsCompat.c */,
5C4479DF17020153000AA45A /* nvaDevConfig.h */,
); );
name = "Other Sources"; name = "Other Sources";
sourceTree = "<group>"; sourceTree = "<group>";
Expand Down
3 changes: 3 additions & 0 deletions NotationController.h
Expand Up @@ -193,6 +193,9 @@ typedef struct _NoteCatalogEntry {


- (void)dealloc; - (void)dealloc;


#pragma mark nvALT stuff
- (NSString *)createCachesFolderString;

@end @end




Expand Down
33 changes: 32 additions & 1 deletion NotationController.m
Expand Up @@ -41,6 +41,7 @@
#import "SyncSessionController.h" #import "SyncSessionController.h"
#import "BookmarksController.h" #import "BookmarksController.h"
#import "DeletionManager.h" #import "DeletionManager.h"
#import "nvaDevConfig.h"


@implementation NotationController @implementation NotationController


Expand Down Expand Up @@ -347,8 +348,15 @@ - (BOOL)initializeJournaling {
UInt8 *convertedPath = (UInt8*)malloc(maxPathSize * sizeof(UInt8)); UInt8 *convertedPath = (UInt8*)malloc(maxPathSize * sizeof(UInt8));
OSStatus err = noErr; OSStatus err = noErr;
NSData *walSessionKey = [notationPrefs WALSessionKey]; 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(&noteDirectoryRef, convertedPath, maxPathSize)) == noErr) { if ((err = FSRefMakePath(&noteDirectoryRef, convertedPath, maxPathSize)) == noErr) {
#endif
//initialize the journal if necessary //initialize the journal if necessary
if (!(walWriter = [[WALStorageController alloc] initWithParentFSRep:(char*)convertedPath encryptionKey:walSessionKey])) { if (!(walWriter = [[WALStorageController alloc] initWithParentFSRep:(char*)convertedPath encryptionKey:walSessionKey])) {
//journal file probably already exists, so try to recover it //journal file probably already exists, so try to recover it
Expand Down Expand Up @@ -1574,6 +1582,29 @@ - (void)dealloc {
[super 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 @end




0 comments on commit feddcf3

Please sign in to comment.