adium 5427:23208f58a656: Fix the DDG item to only show up when G...

commits at adium.im commits at adium.im
Wed Apr 17 19:00:31 UTC 2013


details:	http://hg.adium.im/adium/rev/23208f58a656
revision:	5427:23208f58a656
branch:		adium-1.6
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Wed Apr 17 20:59:26 2013 +0200

Fix the DDG item to only show up when Google is there too (i.e., the user probably has some text selected).

diffs (35 lines):

diff -r ad16b17fcde5 -r 23208f58a656 Plugins/WebKit Message View/AIWebKitMessageViewController.m
--- a/Plugins/WebKit Message View/AIWebKitMessageViewController.m	Wed Apr 17 18:12:11 2013 +0200
+++ b/Plugins/WebKit Message View/AIWebKitMessageViewController.m	Wed Apr 17 20:59:26 2013 +0200
@@ -859,7 +859,7 @@
 	NSString *query = [[range toString] stringByAddingPercentEscapesForAllCharacters];
 	
 	if (query && query.length > 0) {
-		NSURL *ddgURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://duckduckgo.com/?q=%@", query]];
+		NSURL *ddgURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://duckduckgo.com/?q=%@&t=adium", query]];
 		[[NSWorkspace sharedWorkspace] openURL:ddgURL];
 	}
 }
@@ -987,12 +987,16 @@
 	[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];
+	for (NSMenuItem *searchItem in defaultMenuItems) {
+		if ([searchItem tag] == WebMenuItemTagSearchWeb) {
+			menuItem = [[NSMenuItem alloc] initWithTitle:AILocalizedString(@"Search with DuckDuckGo", nil)
+												  target:self
+												  action:@selector(searchDDG)
+										   keyEquivalent:@""];
+			[webViewMenuItems insertObject:menuItem atIndex:[webViewMenuItems indexOfObject:searchItem] + 1];
+			[menuItem release];
+		}
+	}
 	
 	return webViewMenuItems;
 }




More information about the commits mailing list