adium 5424:9e31c6d752d7: Added a menu item to search selected te...
commits at adium.im
commits at adium.im
Wed Apr 17 15:21:13 UTC 2013
details: http://hg.adium.im/adium/rev/9e31c6d752d7
revision: 5424:9e31c6d752d7
branch: adium-1.6
author: Thijs Alkemade <me at thijsalkema.de>
date: Wed Apr 17 17:20:25 2013 +0200
Added a menu item to search selected text in the message view with DDG, similar to the Search with Google option that's included by default.
diffs (38 lines):
diff -r 37fb8f8a23c8 -r 9e31c6d752d7 Plugins/WebKit Message View/AIWebKitMessageViewController.m
--- a/Plugins/WebKit Message View/AIWebKitMessageViewController.m Tue Apr 16 17:05:41 2013 +0200
+++ b/Plugins/WebKit Message View/AIWebKitMessageViewController.m Wed Apr 17 17:20:25 2013 +0200
@@ -851,6 +851,20 @@
}
/*!
+ * @brief Search the selected text with DDG, similar to the Search with Google option that's included by default.
+ */
+- (void)searchDDG
+{
+ DOMRange *range = [webView selectedDOMRange];
+ NSString *query = [[range toString] stringByAddingPercentEscapesForAllCharacters];
+
+ if (query && query.length > 0) {
+ NSURL *ddgURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://duckduckgo.com/?q=%@", query]];
+ [[NSWorkspace sharedWorkspace] openURL:ddgURL];
+ }
+}
+
+/*!
* @brief Append our own menu items to the webview's contextual menus
*/
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
@@ -973,6 +987,13 @@
[webViewMenuItems addObject:menuItem];
[menuItem release];
+ menuItem = [[NSMenuItem alloc] initWithTitle:AILocalizedString(@"Search with DuckDuckGo", nil)
+ target:self
+ action:@selector(searchDDG)
+ keyEquivalent:@""];
+ [webViewMenuItems insertObject:menuItem atIndex:1];
+ [menuItem release];
+
return webViewMenuItems;
}
More information about the commits
mailing list