~do-plugins/do-plugins/future

« back to all changes in this revision

Viewing changes to GoogleSearch/src/InlineGoogleSearch.cs

  • Committer: David Siegel
  • Date: 2008-12-23 21:55:54 UTC
  • Revision ID: david@david-desktop-20081223215554-gm74etk2mty18v6s
Fix inline google search plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
using System;
24
24
using System.Collections.Generic;
25
25
using System.Linq;
 
26
 
26
27
using Do.Universe;
 
28
using Do.Universe.Common;
 
29
using Do.Platform;
 
30
using Do.Platform.Linux;
27
31
 
28
32
using Mono.Unix;
29
33
 
92
96
                /// </returns>
93
97
                public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) 
94
98
                {
95
 
                        List<Item> retItems = new List<Item> ();
96
 
                        
97
99
                        GoogleSearch googleSearch = new GoogleSearch ();
98
 
                        googleSearch.setSafeSearchLevel
99
 
                                 (InlineGoogleSearchConfig.SearchRestrictions);
100
 
                        googleSearch.setQuery ( (items.First () as ITextItem).Text);
101
 
                        GoogleSearchResult [] googleSearchResult = 
102
 
                                googleSearch.search ();
 
100
                        googleSearch.setSafeSearchLevel (InlineGoogleSearchConfig.SearchRestrictions);
 
101
                        googleSearch.setQuery ((items.First () as ITextItem).Text);
 
102
                        GoogleSearchResult [] results = googleSearch.search ();
103
103
 
104
 
                        if (googleSearchResult.Length == 0) {
105
 
                                Do.Addins.NotificationBridge.ShowMessage (
106
 
                                                            "Google Search",
107
 
                                                            "No Results Found");
108
 
                        }
109
 
                        
110
 
                        for (int i = 0; i < googleSearchResult.Length; i++) {
111
 
                                retItems.Add (new BookmarkItem 
112
 
                                      (googleSearchResult [i].titleNoFormatting,
113
 
                                       googleSearchResult [i].url));
114
 
                        }
115
 
                        
116
 
                        return retItems.ToArray ();     
 
104
                        if (results.Length == 0) {
 
105
                                Services.Notifications.Notify ("Google Search", "No Results Found");
 
106
                        }
 
107
                        
 
108
                        foreach (GoogleSearchResult result in results) {
 
109
                                yield return new BookmarkItem (result.titleNoFormatting, result.url);
 
110
                        }       
117
111
                }
118
112
 
119
113
                /// <summary>