From 8f132eeb975d08e17530e13c20ed697e338d2883 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Tue, 16 Sep 2008 21:24:50 +0200 Subject: [PATCH] Simplify Services menu All services open a new window by default, unless new files are set to open in the current window in the General preference pane. --- src/MacVim/Info.plist | 25 ++++--------------------- src/MacVim/MMAppController.m | 38 ++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/src/MacVim/Info.plist b/src/MacVim/Info.plist index 2a681fc9..08a181f9 100644 --- a/src/MacVim/Info.plist +++ b/src/MacVim/Info.plist @@ -569,7 +569,7 @@ NSMenuItem default - MacVim/New Tab Containing Selection + MacVim/New Document Containing Selection NSMessage openSelection @@ -584,24 +584,7 @@ NSMenuItem default - MacVim/Open Selected File in Tab - - NSMessage - openFile - NSPortName - MacVim - NSSendTypes - - NSStringPboardType - - NSUserData - Tab - - - NSMenuItem - - default - MacVim/Open Selected File in Window + MacVim/Open Selected File NSMessage openFile @@ -614,7 +597,7 @@ NSUserData Window - + NSMenuItem default @@ -630,7 +613,7 @@ NSUserData Window - + SUFeedURL http://bjorn.winckler.googlepages.com/macvim_latest.xml diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index b80cd256..51d397d3 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -1136,16 +1136,17 @@ fsEventCallback(ConstFSEventStreamRef streamRef, return; } - MMVimController *vc = [self topmostVimController]; - if (vc) { - // Open a new tab first, since dropString: does not do this. + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + BOOL openInCurrentWindow = [ud boolForKey:MMOpenInCurrentWindowKey]; + MMVimController *vc; + + if (openInCurrentWindow && (vc = [self topmostVimController])) { [vc sendMessage:AddNewTabMsgID data:nil]; [vc dropString:[pboard stringForType:NSStringPboardType]]; } else { - // NOTE: There is no window to paste the selection into, so save the - // text, open a new window, and paste the text when the next window - // opens. (If this is called several times in a row, then all but the - // last call might be ignored.) + // Save the text, open a new window, and paste the text when the next + // window opens. (If this is called several times in a row, then all + // but the last call may be ignored.) if (openSelectionString) [openSelectionString release]; openSelectionString = [[pboard stringForType:NSStringPboardType] copy]; @@ -1170,16 +1171,17 @@ fsEventCallback(ConstFSEventStreamRef streamRef, NSArray *filenames = [self filterFilesAndNotify: [NSArray arrayWithObject:string]]; - if ([filenames count] > 0) { - MMVimController *vc = nil; - if (userData && [userData isEqual:@"Tab"]) - vc = [self topmostVimController]; + if ([filenames count] == 0) + return; - if (vc) { - [vc dropFiles:filenames forceOpen:YES]; - } else { - [self openFiles:filenames withArguments:nil]; - } + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + BOOL openInCurrentWindow = [ud boolForKey:MMOpenInCurrentWindowKey]; + MMVimController *vc; + + if (openInCurrentWindow && (vc = [self topmostVimController])) { + [vc dropFiles:filenames forceOpen:YES]; + } else { + [self openFiles:filenames withArguments:nil]; } } @@ -1206,11 +1208,11 @@ fsEventCallback(ConstFSEventStreamRef streamRef, path = [path stringByReplacingOccurrencesOfString:@" " withString:@"\\ "]; - MMVimController *vc = [self topmostVimController]; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; BOOL openInCurrentWindow = [ud boolForKey:MMOpenInCurrentWindowKey]; + MMVimController *vc; - if (vc && openInCurrentWindow) { + if (openInCurrentWindow && (vc = [self topmostVimController])) { NSString *input = [NSString stringWithFormat:@"" ":tabe|cd %@", path]; [vc addVimInput:input]; -- 2.11.4.GIT