From df9892c6506cff40718f938e7bd8a8330d70bf84 Mon Sep 17 00:00:00 2001 From: Yutaka Tsutano Date: Fri, 25 Mar 2016 08:03:59 -0500 Subject: [PATCH] Allow relative URL in Graphviz.app --- macosx/GVWindowController.h | 2 ++ macosx/GVWindowController.m | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/macosx/GVWindowController.h b/macosx/GVWindowController.h index 5a1b7c297..d6491f29f 100644 --- a/macosx/GVWindowController.h +++ b/macosx/GVWindowController.h @@ -34,6 +34,8 @@ - (IBAction)printGraphDocument:(id)sender; +- (void)PDFViewWillClickOnLink:(PDFView *)sender withURL:(NSURL *)URL; + - (BOOL)validateUserInterfaceItem:(id )anItem; - (void)dealloc; diff --git a/macosx/GVWindowController.m b/macosx/GVWindowController.m index 502204e86..43b3be6bd 100644 --- a/macosx/GVWindowController.m +++ b/macosx/GVWindowController.m @@ -43,6 +43,8 @@ NSWindow *window = [self window]; if (![window isZoomed]) [window zoom:self]; + + [documentView setDelegate:self]; } - (void)graphDocumentDidChange:(NSNotification*)notification @@ -89,6 +91,13 @@ [documentView printWithInfo:[[self document] printInfo] autoRotate:NO]; } +- (void)PDFViewWillClickOnLink:(PDFView *)sender withURL:(NSURL *)URL +{ + NSURL* baseURL = [[self document] fileURL]; + NSURL* targetURL = [NSURL URLWithString:[URL absoluteString] relativeToURL:baseURL]; + [[NSWorkspace sharedWorkspace] openURL:targetURL]; +} + - (BOOL)validateUserInterfaceItem:(id )anItem { /* validate toolbar or menu items */ -- 2.40.0