Revision: 22267 http://sourceforge.net/p/bibdesk/svn/22267 Author: hofman Date: 2018-05-31 13:14:36 +0000 (Thu, 31 May 2018) Log Message: ----------- Set Local-Url or Url field when choosing a file or URL from the editor and ear don't use linked files
Modified Paths: -------------- trunk/bibdesk/BDSKEditor.m Modified: trunk/bibdesk/BDSKEditor.m =================================================================== --- trunk/bibdesk/BDSKEditor.m 2018-05-31 12:36:29 UTC (rev 22266) +++ trunk/bibdesk/BDSKEditor.m 2018-05-31 13:14:36 UTC (rev 22267) @@ -578,6 +578,8 @@ - (IBAction)chooseLocalFile:(id)sender{ NSUInteger anIndex = NSNotFound; NSNumber *indexNumber = [sender representedObject]; + BOOL useLocalUrl = [[NSUserDefaults standardUserDefaults] boolForKey:BDSKUseLocalUrlAndUrlKey]; + BOOL setLocalUrl = useLocalUrl && indexNumber == nil; NSURL *url = nil; if (indexNumber) { anIndex = [indexNumber unsignedIntegerValue]; @@ -593,7 +595,7 @@ [oPanel setNameFieldStringValue:[url lastPathComponent]]; } - if ([[NSUserDefaults standardUserDefaults] boolForKey:BDSKFilePapersAutomaticallyKey]) { + if ([[NSUserDefaults standardUserDefaults] boolForKey:BDSKFilePapersAutomaticallyKey] && useLocalUrl == setLocalUrl) { if (disableAutoFileButton == nil) { disableAutoFileButton = [[NSButton alloc] init]; [disableAutoFileButton setBezelStyle:NSRoundedBezelStyle]; @@ -608,7 +610,7 @@ [oPanel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger result){ if(result == NSFileHandlingPanelOKButton){ NSURL *aURL = [[oPanel URLs] objectAtIndex:0]; - BOOL shouldAutoFile = [disableAutoFileButton state] == NSOffState && [[NSUserDefaults standardUserDefaults] boolForKey:BDSKFilePapersAutomaticallyKey]; + BOOL shouldAutoFile = disableAutoFileButton && [oPanel accessoryView] == disableAutoFileButton && [disableAutoFileButton state] == NSOffState; if (anIndex != NSNotFound) { BDSKLinkedFile *aFile = [BDSKLinkedFile linkedFileWithURL:aURL delegate:publication]; if (aFile == nil) @@ -623,6 +625,11 @@ [[self document] userAddedURL:aURL forPublication:publication]; if (shouldAutoFile) [publication autoFileLinkedFile:aFile]; + } else if (setLocalUrl) { + [publication setField:BDSKLocalUrlString toValue:[aURL absoluteString]]; + if (shouldAutoFile) + [publication autoFileLocalUrl]; + [[self undoManager] setActionName:NSLocalizedString(@"Edit Publication", @"Undo action name")]; } else { [publication addFileForURL:aURL autoFile:shouldAutoFile runScriptHook:YES]; [[self undoManager] setActionName:NSLocalizedString(@"Edit Publication", @"Undo action name")]; @@ -640,6 +647,8 @@ - (IBAction)chooseRemoteURL:(id)sender{ NSUInteger anIndex = NSNotFound; NSNumber *indexNumber = [sender representedObject]; + BOOL useUrl = [[NSUserDefaults standardUserDefaults] boolForKey:BDSKUseLocalUrlAndUrlKey]; + BOOL setUrl = useUrl && indexNumber == nil; NSString *urlString = @"https://"; if (indexNumber) { anIndex = [indexNumber unsignedIntegerValue]; @@ -670,6 +679,14 @@ [[self document] userAddedURL:aURL forPublication:publication]; if ([aFile isFile]) [publication autoFileLinkedFile:aFile]; + } else if (setUrl) { + if ([aURL isFileURL]) { + [publication setField:BDSKLocalUrlString toValue:[aURL absoluteString]]; + [publication autoFileLocalUrl]; + } else { + [publication setField:BDSKUrlString toValue:[aURL absoluteString]]; + } + [[self undoManager] setActionName:NSLocalizedString(@"Edit Publication", @"Undo action name")]; } else { [publication addFileForURL:aURL autoFile:NO runScriptHook:YES]; [[self undoManager] setActionName:NSLocalizedString(@"Edit Publication", @"Undo action name")]; @@ -1245,9 +1262,10 @@ [menu addItem:[NSMenuItem separatorItem]]; - [menu addItemWithTitle:[NSLocalizedString(@"Choose File", @"Menu item title") stringByAppendingEllipsis] - action:@selector(chooseLocalFile:) - keyEquivalent:@""]; + item = [menu addItemWithTitle:[NSLocalizedString(@"Choose File", @"Menu item title") stringByAppendingEllipsis] + action:@selector(chooseLocalFile:) + keyEquivalent:@""]; + [item setRepresentedObject:[NSNumber numberWithUnsignedInteger:NSNotFound]]; // get Safari recent downloads [menu addItemWithTitle:NSLocalizedString(@"Safari Recent Downloads", @"Menu item title") @@ -1268,9 +1286,10 @@ [menu addItem:[NSMenuItem separatorItem]]; - [menu addItemWithTitle:[NSLocalizedString(@"Choose URL", @"Menu item title") stringByAppendingEllipsis] - action:@selector(chooseRemoteURL:) - keyEquivalent:@""]; + item = [menu addItemWithTitle:[NSLocalizedString(@"Choose URL", @"Menu item title") stringByAppendingEllipsis] + action:@selector(chooseRemoteURL:) + keyEquivalent:@""]; + [item setRepresentedObject:[NSNumber numberWithUnsignedInteger:NSNotFound]]; // get Safari recent URLs [menu addItemWithTitle:NSLocalizedString(@"Link to Download URL", @"Menu item title") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit