From 9e8002a97e78085e8754d341196f15c3ef0328d4 Mon Sep 17 00:00:00 2001 From: Nathan Kinsinger Date: Sun, 27 Jun 2010 06:10:29 -0600 Subject: [PATCH] Only allow the "Copy Image" menu item for images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit André Berg pointed out that the "Open Image in New Window" and "Download Image" items from the contextual menu for images in the web view does not work and may cause crashes. So limit the menu to either just show "Copy Image" or don't have a menu at all. --- PBWebHistoryController.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index 98de77b..e3467c0 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -127,6 +127,15 @@ contextMenuItemsForElement:(NSDictionary *)element } if ([node hasAttributes] && [[node attributes] getNamedItem:@"representedFile"]) return [historyController menuItemsForPaths:[NSArray arrayWithObject:[[[node attributes] getNamedItem:@"representedFile"] value]]]; + else if ([[node class] isEqual:[DOMHTMLImageElement class]]) { + // Copy Image is the only menu item that makes sense here since we don't need + // to download the image or open it in a new window (besides with the + // current implementation these two entries can crash GitX anyway) + for (NSMenuItem *item in defaultMenuItems) + if ([item tag] == WebMenuItemTagCopyImageToClipboard) + return [NSArray arrayWithObject:item]; + return nil; + } node = [node parentNode]; }