Do

Merge lp:~jassmith/do/itemactionmerge into lp:do

Proposed by Jason Smith
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jassmith/do/itemactionmerge
Merge into: lp:do
Diff against target: None lines
To merge this branch: bzr merge lp:~jassmith/do/itemactionmerge
Reviewer Review Type Date Requested Status
Robert Dyer (community) Needs Fixing
Chris S. Approve
Review via email: mp+7530@code.launchpad.net
To post a comment you must log in.
lp:~jassmith/do/itemactionmerge updated
1233. By Jason Smith <jason@t500>

Merge trunk

1234. By Jason Smith <jason@t500>

Merge el trunko

1235. By Jason Smith <jason@t500>

Merge trunk

1236. By Jason Smith <jason@t500>

Merge trunk

1237. By Jason Smith <jason@t500>

Embarassing, and fix crash

Revision history for this message
Chris S. (cszikszoy) :
review: Approve
Revision history for this message
Chris S. (cszikszoy) wrote :

Not sure if my review matters, but it looks good to me :)

review: Approve
Revision history for this message
Robert Dyer (psybers) wrote :

Note: any line mentioned is the line in the diff attached to the merge request.

All over the place you use 'Do.Universe.Item' instead of adding a 'using' to the files. Unless 'Item' is ambiguous I would change those and add 'using'. Notice how it was 'Element' before?

In Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelGlassRenderClasses.cs 'RenderElement' should be renamed 'RenderItem', which will require tracking the API as well

Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelGlassResults.cs add spaces before 'Surface' in the generic types (lines 116, 125)

Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/DefaultElements.cs was renamed in the comment header, but the file itself was not renamed to DefaultItems.cs!

Do/src/Do.Core/Controller.cs line 1094 you dont need brackets on this if block
again Do/src/Do.Core/SecondSearchController.cs foreach line 1476
again Do/src/Do.Core/SecondSearchController.cs if line 1494

Do/src/Do.Core/SimpleSearchContext.cs line 1559, either make the spacing line up with the others or only put a single space before the {'s

line 1845 has a comment 'FIXME' so why dont you investigate and resolve that issue

review: Needs Fixing
lp:~jassmith/do/itemactionmerge updated
1238. By Jason Smith <jason@t500>

Fix summon mode renderer and histogramrelevanceprovider to properly check for action with proxy items

1239. By Jason Smith <jason@t500>

Rename file

1240. By Jason Smith <jason@t500>

RenderElement -> RenderItem

1241. By Jason Smith <jason@t500>

Fix build

1242. By Jason Smith <jason@t500>

Cosmetic issues

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingArea.cs'
2--- Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingArea.cs 2009-05-28 14:13:10 +0000
3+++ Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingArea.cs 2009-06-14 02:03:35 +0000
4@@ -506,7 +506,7 @@
5 return DrawState.None;
6 }
7
8- public void BezelSetPaneObject (Pane pane, Element obj)
9+ public void BezelSetPaneObject (Pane pane, Do.Universe.Item obj)
10 {
11 if (Context.GetPaneObject (pane) == obj && obj != null)
12 return;
13@@ -767,7 +767,7 @@
14
15 private void RenderPixbuf (Pane pane, Context cr)
16 {
17- Element obj = Context.GetPaneObject (pane);
18+ Do.Universe.Item obj = Context.GetPaneObject (pane);
19 RenderPixbuf (pane, cr, obj.Icon, 1);
20 }
21
22
23=== modified file 'Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingContext.cs'
24--- Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingContext.cs 2009-04-19 22:45:56 +0000
25+++ Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingContext.cs 2009-06-14 02:03:35 +0000
26@@ -26,7 +26,7 @@
27 {
28 public class BezelDrawingContext
29 {
30- private Element [] objects = new Element [3];
31+ private Item [] objects = new Item [3];
32 private string [] queries = new string [3];
33 private bool [] text_mode = new bool [3];
34
35@@ -38,11 +38,11 @@
36 text_mode [(int) pane] = textMode;
37 }
38
39- public Element GetPaneObject (Pane pane) {
40+ public Item GetPaneObject (Pane pane) {
41 return objects [(int) pane];
42 }
43
44- public void SetPaneObject (Pane pane, Element obj) {
45+ public void SetPaneObject (Pane pane, Item obj) {
46 objects [(int) pane] = obj;
47 }
48
49
50=== modified file 'Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelGlassRenderClasses.cs'
51--- Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelGlassRenderClasses.cs 2009-04-19 22:45:56 +0000
52+++ Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelGlassRenderClasses.cs 2009-06-14 02:03:35 +0000
53@@ -34,7 +34,7 @@
54 public interface IBezelResultItemRenderer
55 {
56 int Height { get; }
57- void RenderElement (Context cr, Gdk.Point renderAnchor, int width, Element item, bool drawArrow);
58+ void RenderElement (Context cr, Gdk.Point renderAnchor, int width, Do.Universe.Item item, bool drawArrow);
59 }
60
61 public class BezelFullResultItemRenderer : IBezelResultItemRenderer
62@@ -50,7 +50,7 @@
63 this.parent = parent;
64 }
65
66- public void RenderElement (Context cr, Gdk.Point renderAnchor, int width, Element item, bool drawArrow)
67+ public void RenderElement (Context cr, Gdk.Point renderAnchor, int width, Do.Universe.Item item, bool drawArrow)
68 {
69 cr.Rectangle (renderAnchor.X, renderAnchor.Y, width, Height);
70 cr.Color = new Cairo.Color (0, 0, 0, 0);
71@@ -120,7 +120,7 @@
72 this.parent = parent;
73 }
74
75- public void RenderElement (Context cr, Gdk.Point renderAnchor, int width, Element item, bool drawArrow)
76+ public void RenderElement (Context cr, Gdk.Point renderAnchor, int width, Do.Universe.Item item, bool drawArrow)
77 {
78 cr.Rectangle (renderAnchor.X, renderAnchor.Y, width, Height);
79 cr.Color = new Cairo.Color (0, 0, 0, 0);
80
81=== modified file 'Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelGlassResults.cs'
82--- Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelGlassResults.cs 2009-04-26 21:00:06 +0000
83+++ Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelGlassResults.cs 2009-06-14 02:03:35 +0000
84@@ -43,7 +43,7 @@
85 int num_results;
86 int width, height;
87 int border_width, top_border_width;
88- Dictionary <Element, Surface> surface_buffer;
89+ Dictionary <Do.Universe.Item, Surface> surface_buffer;
90 Surface highlight_surface, backbuffer, child_inout_surface, triplebuffer, background;
91
92 DateTime delta_time;
93@@ -58,7 +58,7 @@
94 IUIContext context = null;
95 BezelColors colors;
96
97- IList<Element> results;
98+ IList<Do.Universe.Item> results;
99
100 public int X { get; set; }
101
102@@ -127,7 +127,7 @@
103 }
104 }
105
106- public IList<Element> Results {
107+ public IList<Do.Universe.Item> Results {
108 get {
109 return results;
110 }
111@@ -282,7 +282,7 @@
112 break;
113 }
114
115- surface_buffer = new Dictionary <Element,Surface> ();
116+ surface_buffer = new Dictionary <Do.Universe.Item,Surface> ();
117 secondary = new int[0];
118 border_width = 12;
119 top_border_width = 20;
120@@ -392,7 +392,7 @@
121 foreach (Surface s in surface_buffer.Values)
122 s.Destroy ();
123
124- surface_buffer = new Dictionary<Element,Surface> ();
125+ surface_buffer = new Dictionary<Do.Universe.Item,Surface> ();
126 Draw ();
127 }
128
129@@ -717,14 +717,14 @@
130 return base.OnExposeEvent (evnt);
131 }
132
133- void BufferItem (Element item)
134+ void BufferItem (Do.Universe.Item item)
135 {
136 if (!IsDrawable)
137 return;
138 Context cr = Gdk.CairoHelper.Create (GdkWindow);
139 Surface surface = cr.Target.CreateSimilar (cr.Target.Content, InternalWidth, SurfaceHeight);
140 Context cr2 = new Context (surface);
141- ItemRenderer.RenderElement (cr2, new Gdk.Point (border_width, 0), InternalWidth, item, controller.ElementHasChildren (item));
142+ ItemRenderer.RenderElement (cr2, new Gdk.Point (border_width, 0), InternalWidth, item, controller.ItemHasChildren (item));
143
144 surface_buffer[item] = surface;
145
146
147=== modified file 'Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelResultsDrawingArea.cs'
148--- Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelResultsDrawingArea.cs 2009-04-19 22:45:56 +0000
149+++ Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelResultsDrawingArea.cs 2009-06-14 02:03:35 +0000
150@@ -40,7 +40,7 @@
151
152 int num_results;
153 int width, height;
154- Dictionary <Element, Surface> surface_buffer;
155+ Dictionary <Do.Universe.Item, Surface> surface_buffer;
156 Surface highlight_surface, backbuffer, child_inout_surface, triplebuffer;
157
158 DateTime delta_time;
159@@ -50,10 +50,10 @@
160
161 Cairo.Color odd_color, even_color;
162
163- Element[] results;
164-
165-
166- public Element[] Results {
167+ Do.Universe.Item[] results;
168+
169+
170+ public Do.Universe.Item[] Results {
171 get {
172 return results;
173 }
174@@ -124,7 +124,7 @@
175 public BezelResultsDrawingArea(int numberResults, int width) : base ()
176 {
177 num_results = numberResults;
178- surface_buffer = new Dictionary <Element,Surface> ();
179+ surface_buffer = new Dictionary <Do.Universe.Item,Surface> ();
180
181 this.width = width;
182 height = num_results * SurfaceHeight;
183@@ -198,7 +198,7 @@
184 foreach (Surface s in surface_buffer.Values)
185 (s as IDisposable).Dispose ();
186
187- surface_buffer = new Dictionary<Element,Surface> ();
188+ surface_buffer = new Dictionary<Do.Universe.Item,Surface> ();
189 }
190
191 private void Paint ()
192@@ -311,7 +311,7 @@
193 return base.OnExposeEvent (evnt);
194 }
195
196- void BufferItem (Element item)
197+ void BufferItem (Do.Universe.Item item)
198 {
199 if (!IsDrawable)
200 return;
201
202=== modified file 'Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/ItemsService.cs'
203--- Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/ItemsService.cs 2009-06-01 20:37:58 +0000
204+++ Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/ItemsService.cs 2009-06-14 02:03:35 +0000
205@@ -286,7 +286,7 @@
206 customItem = new ItemDockItem (o);
207 }
208 } else {
209- Item e = Services.Core.GetElement (identifier) as Item;
210+ Item e = Services.Core.GetItem (identifier);
211 if (e != null)
212 customItem = new ItemDockItem (e);
213 else
214@@ -459,7 +459,7 @@
215 #endregion
216
217 #region Item Management
218- bool InternalAddItemToDock (Element item, int position)
219+ bool InternalAddItemToDock (Item item, int position)
220 {
221 if (!(item is Item)) {
222 Log<ItemsService>.Error ("Could not add {0} to custom items for dock", item.Safe.Name);
223@@ -640,7 +640,7 @@
224 }
225 }
226
227- public void AddItemToDock (Element item)
228+ public void AddItemToDock (Item item)
229 {
230 AddItemToDock (item, LastPosition + 1);
231 }
232@@ -650,7 +650,7 @@
233 AddItemToDock (identifier, LastPosition + 1);
234 }
235
236- public void AddItemToDock (Element item, int position)
237+ public void AddItemToDock (Item item, int position)
238 {
239 position = DockItems [position].Position;
240 if (InternalAddItemToDock (item, position)) {
241
242=== modified file 'Do.Interface.Linux.Docky/src/Docky.Core/IItemsService.cs'
243--- Do.Interface.Linux.Docky/src/Docky.Core/IItemsService.cs 2009-06-01 20:37:58 +0000
244+++ Do.Interface.Linux.Docky/src/Docky.Core/IItemsService.cs 2009-06-14 02:03:35 +0000
245@@ -50,11 +50,11 @@
246 ReadOnlyCollection<AbstractDockItem> DockItems { get; }
247
248 #region AddItem Overloads
249- void AddItemToDock (Element item);
250+ void AddItemToDock (Item item);
251
252 void AddItemToDock (string identifier);
253
254- void AddItemToDock (Element item, int position);
255+ void AddItemToDock (Item item, int position);
256
257 void AddItemToDock (string identifier, int position);
258 #endregion
259
260=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/DockState.cs'
261--- Do.Interface.Linux.Docky/src/Docky.Interface/DockState.cs 2009-04-07 05:13:44 +0000
262+++ Do.Interface.Linux.Docky/src/Docky.Interface/DockState.cs 2009-06-14 02:03:35 +0000
263@@ -37,8 +37,8 @@
264
265 public event EventHandler StateChanged;
266
267- Element [] current_items = new Element [3];
268- Element [] old_items = new Element [3];
269+ Item [] current_items = new Item [3];
270+ Item [] old_items = new Item [3];
271
272 string [] queries = new string [3];
273
274@@ -54,8 +54,8 @@
275 DateTime [] cursor_timestamps = new DateTime [3];
276 DateTime [] text_mode_timestamps = new DateTime [3];
277
278- IList<Element> [] results = new IList<Element> [3];
279- IList<Element> [] results_prev = new IList<Element> [3];
280+ IList<Item> [] results = new IList<Item> [3];
281+ IList<Item> [] results_prev = new IList<Item> [3];
282
283 Pane currentPane, previousPane = Pane.Second;
284
285@@ -65,7 +65,7 @@
286
287 bool third_pane_visible;
288
289- Element IntroObject { get; set; }
290+ Item IntroObject { get; set; }
291
292 public Pane CurrentPane {
293 get {
294@@ -103,19 +103,19 @@
295 get { return third_pane_visibility_change; }
296 }
297
298- public Element First {
299+ public Item First {
300 get {
301 return GetPaneItem (Pane.First);
302 }
303 }
304
305- public Element Second {
306+ public Item Second {
307 get {
308 return GetPaneItem (Pane.Second);
309 }
310 }
311
312- public Element Third {
313+ public Item Third {
314 get {
315 return GetPaneItem (Pane.Third);
316 }
317@@ -153,7 +153,7 @@
318 }
319 #endregion
320
321- public Element this [Pane pane] {
322+ public Item this [Pane pane] {
323 get {
324 return GetPaneItem (pane);
325 }
326@@ -166,10 +166,10 @@
327 DockState ()
328 {
329 third_pane_visible = false;
330- IntroObject = new DefaultLabelBoxElement ();
331+ IntroObject = new DefaultLabelBoxItem ();
332 }
333
334- void SetItem (Element item, Pane pane)
335+ void SetItem (Item item, Pane pane)
336 {
337 if (current_items [(int) pane] == item)
338 return;
339@@ -186,7 +186,7 @@
340 OnStateChanged ();
341 }
342
343- void SetResults (IList<Element> resultList, Pane pane)
344+ void SetResults (IList<Item> resultList, Pane pane)
345 {
346 if (results [(int) pane] != null && resultList.Count == results [(int) pane].Count) {
347 bool same = true;
348@@ -234,14 +234,14 @@
349 OnStateChanged ();
350 }
351
352- public Element GetPaneItem (Pane pane)
353+ public Item GetPaneItem (Pane pane)
354 {
355 if (pane == Pane.First && current_items [(int) pane] == null)
356 return IntroObject;
357 return current_items [(int) pane];
358 }
359
360- public Element GetOldPaneItem (Pane pane)
361+ public Item GetOldPaneItem (Pane pane)
362 {
363 return old_items [(int) pane];
364 }
365@@ -251,12 +251,12 @@
366 return queries [(int) pane] ?? "";
367 }
368
369- public IList<Element> GetPaneResults (Pane pane)
370+ public IList<Item> GetPaneResults (Pane pane)
371 {
372 return results [(int) pane];
373 }
374
375- public IList<Element> GetPanePreviousResults (Pane pane)
376+ public IList<Item> GetPanePreviousResults (Pane pane)
377 {
378 return results_prev [(int) pane];
379 }
380@@ -293,11 +293,11 @@
381
382 public void Clear ()
383 {
384- current_items = new Element [3];
385- results = new IList<Element> [3];
386+ current_items = new Item [3];
387+ results = new IList<Item> [3];
388 result_timestamps = new DateTime [3];
389 queries = new string [3];
390- old_items = new Element [3];
391+ old_items = new Item [3];
392 timestamps = new DateTime [3];
393
394 text_mode = new bool [3];
395
396=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Painters/SummonModeRenderer.cs'
397--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Painters/SummonModeRenderer.cs 2009-06-16 06:01:28 +0000
398+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Painters/SummonModeRenderer.cs 2009-06-16 23:21:33 +0000
399@@ -288,7 +288,7 @@
400 int base_x = dockArea.X + 15;
401
402 string text;
403- Element current = State [State.CurrentPane];
404+ Item current = State [State.CurrentPane];
405
406 if (current == null)
407 text = State.GetPaneQuery (State.CurrentPane);
408@@ -323,7 +323,7 @@
409 int base_x = dockArea.X + 15;
410
411 string text;
412- Element current = State [State.CurrentPane];
413+ Item current = State [State.CurrentPane];
414
415 if (current == null)
416 text = State.GetPaneQuery (State.CurrentPane);
417
418=== modified file 'Do.Interface.Linux/src/Do.Interface/ClassicInterface/ClassicWindow.cs'
419--- Do.Interface.Linux/src/Do.Interface/ClassicInterface/ClassicWindow.cs 2009-03-31 17:24:27 +0000
420+++ Do.Interface.Linux/src/Do.Interface/ClassicInterface/ClassicWindow.cs 2009-06-14 02:03:35 +0000
421@@ -347,7 +347,7 @@
422 Resize (1, 1);
423 Reposition ();
424
425- iconbox[0].DisplayObject = new Do.Interface.Widgets.DefaultIconBoxElement ();
426+ iconbox[0].DisplayObject = new Do.Interface.Widgets.DefaultIconBoxItem ();
427 label.SetDisplayLabel (Catalog.GetString ("Type to begin searching"),
428 Catalog.GetString ("Type to start searching."));
429 }
430@@ -381,11 +381,11 @@
431 if (!context.Results.Any () && !context.LargeTextDisplay) {
432 if (pane == Pane.First && context.ParentContext == null) {
433 iconbox[0].TextOverlay = context.LargeTextDisplay;
434- iconbox[0].DisplayObject = new Do.Interface.Widgets.DefaultIconBoxElement ();
435+ iconbox[0].DisplayObject = new Do.Interface.Widgets.DefaultIconBoxItem ();
436 label.SetDisplayLabel (Catalog.GetString ("Type to begin searching"),
437 Catalog.GetString ("Type to start searching."));
438 } else {
439- Element noRes = new NoResultsFoundElement (context.Query);
440+ Do.Universe.Item noRes = new NoResultsFoundItem (context.Query);
441 for (int i = (int) pane; i < 3; i++) {
442 iconbox[i].Clear ();
443 iconbox[i].DisplayObject = noRes;
444@@ -400,7 +400,7 @@
445
446 if (string.IsNullOrEmpty (context.Query) && context.LargeTextDisplay) {
447 iconbox[(int) pane].TextOverlay = context.LargeTextDisplay;
448- iconbox[(int) pane].DisplayObject = new TextItem ("Enter Text") as Element;
449+ iconbox[(int) pane].DisplayObject = new TextItem ("Enter Text") as Do.Universe.Item;
450
451 if (!context.Results.Any ()) return;
452 } else {
453
454=== modified file 'Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/DefaultElements.cs'
455--- Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/DefaultElements.cs 2008-12-20 00:31:54 +0000
456+++ Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/DefaultElements.cs 2009-06-14 02:03:35 +0000
457@@ -1,4 +1,4 @@
458-// DefaultElements.cs
459+// DefaultItems.cs
460 //
461 // Copyright (C) 2008 Jason Smith
462 //
463@@ -26,11 +26,11 @@
464 namespace Do.Interface.Widgets
465 {
466
467- public class NoResultsFoundElement : Element
468+ public class NoResultsFoundItem : Item
469 {
470 string query;
471
472- public NoResultsFoundElement (string query)
473+ public NoResultsFoundItem (string query)
474 {
475 this.query = query;
476 }
477@@ -44,14 +44,14 @@
478 }
479 }
480
481- public class DefaultIconBoxElement : Element
482+ public class DefaultIconBoxItem : Item
483 {
484 public override string Icon { get { return "search"; } }
485 public override string Name { get { return ""; } }
486 public override string Description { get { return ""; } }
487 }
488
489- public class DefaultLabelBoxElement : Element
490+ public class DefaultLabelBoxItem : Item
491 {
492 public override string Icon { get { return "search"; } }
493 public override string Name { get { return Catalog.GetString ("Type to begin searching"); } }
494
495=== modified file 'Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/IconBox.cs'
496--- Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/IconBox.cs 2008-12-20 00:31:54 +0000
497+++ Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/IconBox.cs 2009-06-14 02:03:35 +0000
498@@ -187,7 +187,7 @@
499 }
500 }
501
502- public Element DisplayObject
503+ public Do.Universe.Item DisplayObject
504 {
505 set {
506 string name, icon;
507
508=== modified file 'Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/ResultsWindow.cs'
509--- Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/ResultsWindow.cs 2008-12-20 00:31:54 +0000
510+++ Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/ResultsWindow.cs 2009-06-14 02:03:35 +0000
511@@ -62,7 +62,7 @@
512
513 protected ScrolledWindow resultsScrolledWindow;
514 protected TreeView resultsTreeview;
515- protected IList<Element> results, stunted_results;
516+ protected IList<Do.Universe.Item> results, stunted_results;
517 protected int startResult, endResult;
518 protected Frame frame;
519 protected string query;
520@@ -85,7 +85,7 @@
521 this.NumberResultsDisplayed = NumberResults;
522
523 Build ();
524- results = new Element[0];
525+ results = new Do.Universe.Item[0];
526 }
527
528 public ResultsWindow (Gdk.Color backgroundColor, int DefaultIconSize,
529@@ -98,7 +98,7 @@
530 this.NumberResultsDisplayed = NumberResults;
531
532 Build ();
533- results = new Element[0];
534+ results = new Do.Universe.Item[0];
535 }
536
537 protected void NotifySelectionChanged ()
538@@ -180,7 +180,7 @@
539 resultsTreeview.Show ();
540
541 resultsTreeview.Model = new ListStore (new Type[] {
542- typeof (Element),
543+ typeof (Do.Universe.Item),
544 typeof (string),
545 });
546
547@@ -223,7 +223,7 @@
548 TreeModel model, TreeIter iter)
549 {
550 CellRendererPixbuf renderer = cell as CellRendererPixbuf;
551- Element o = (resultsTreeview.Model as ListStore).GetValue (iter, 0) as Element;
552+ Do.Universe.Item o = (resultsTreeview.Model as ListStore).GetValue (iter, 0) as Do.Universe.Item;
553 bool isSecondary = false;
554 foreach (int i in secondary)
555 if (model.GetStringFromIter (iter) == i.ToString ())
556@@ -287,7 +287,7 @@
557
558 pushedUpdate = true;
559 if (value == null || !value.Results.Any ()) {
560- Results = new Element [0];
561+ Results = new Do.Universe.Item [0];
562 return;
563 }
564
565@@ -305,7 +305,7 @@
566 if (endResult > results.Count)
567 endResult = results.Count;
568
569- Element[] resultsArray = new Element[endResult - startResult];
570+ Do.Universe.Item[] resultsArray = new Do.Universe.Item[endResult - startResult];
571 Array.Copy (results.ToArray (), startResult, resultsArray, 0, resultsArray.Length);
572
573 cursor = value.Cursor - offset;
574@@ -376,7 +376,7 @@
575 });
576 }
577
578- public Element SelectedObject
579+ public Do.Universe.Item SelectedObject
580 {
581 get {
582 try {
583@@ -387,11 +387,11 @@
584 }
585 }
586
587- public IList<Element> Results
588+ public IList<Do.Universe.Item> Results
589 {
590 get {
591 if (stunted_results == null)
592- stunted_results = new List<Element> (0);
593+ stunted_results = new List<Do.Universe.Item> (0);
594 return stunted_results;
595 }
596 set {
597@@ -412,7 +412,7 @@
598 store = resultsTreeview.Model as ListStore;
599 store.Clear ();
600
601- foreach (Element result in value) {
602+ foreach (Do.Universe.Item result in value) {
603
604 info = string.Format (ResultInfoFormat,
605 GLib.Markup.EscapeText (result.Name),
606
607=== modified file 'Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/SymbolDisplayLabel.cs'
608--- Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/SymbolDisplayLabel.cs 2008-12-20 00:31:54 +0000
609+++ Do.Interface.Linux/src/Do.Interface/Do.Interface.Widgets/SymbolDisplayLabel.cs 2009-06-14 02:03:35 +0000
610@@ -51,10 +51,10 @@
611 new Gdk.Color (byte.MaxValue, byte.MaxValue, byte.MaxValue));
612 }
613
614- public Element DisplayObject
615+ public Do.Universe.Item DisplayObject
616 {
617 set {
618- Element displayObject;
619+ Do.Universe.Item displayObject;
620
621 displayObject = value;
622 name = description = highlight = "";
623
624=== modified file 'Do.Interface.Linux/src/Do.Interface/IDoController.cs'
625--- Do.Interface.Linux/src/Do.Interface/IDoController.cs 2008-12-22 20:17:15 +0000
626+++ Do.Interface.Linux/src/Do.Interface/IDoController.cs 2009-06-14 02:03:35 +0000
627@@ -62,12 +62,12 @@
628 /// <summary>
629 /// Check and see if an object likely has children
630 /// </summary>
631- /// <param name="element">
632- /// A <see cref="Element"/>
633+ /// <param name="item">
634+ /// A <see cref="Item"/>
635 /// </param>
636 /// <returns>
637 /// A <see cref="System.Boolean"/>
638 /// </returns>
639- bool ElementHasChildren (Element element);
640+ bool ItemHasChildren (Item item);
641 }
642 }
643
644=== modified file 'Do.Interface.Linux/src/Do.Interface/IDoWindow.cs'
645--- Do.Interface.Linux/src/Do.Interface/IDoWindow.cs 2009-01-05 21:11:58 +0000
646+++ Do.Interface.Linux/src/Do.Interface/IDoWindow.cs 2009-06-13 20:22:14 +0000
647@@ -25,6 +25,7 @@
648 {
649 public enum Pane
650 {
651+ None = -1,
652 First = 0,
653 Second = 1,
654 Third = 2,
655
656=== modified file 'Do.Interface.Linux/src/Do.Interface/IUIContext.cs'
657--- Do.Interface.Linux/src/Do.Interface/IUIContext.cs 2008-12-18 02:33:48 +0000
658+++ Do.Interface.Linux/src/Do.Interface/IUIContext.cs 2009-06-14 02:03:35 +0000
659@@ -37,12 +37,12 @@
660 /// <value>
661 /// The current selection
662 /// </value>
663- Element Selection {get;}
664+ Item Selection {get;}
665
666 /// <value>
667 /// The results list
668 /// </value>
669- IList<Element> Results {get;}
670+ IList<Item> Results {get;}
671
672 /// <value>
673 /// Integer index of the selection in the results list
674
675=== modified file 'Do.Interface.Linux/src/Do.Interface/ResultsWindowSelectionEventArgs.cs'
676--- Do.Interface.Linux/src/Do.Interface/ResultsWindowSelectionEventArgs.cs 2008-12-18 02:33:48 +0000
677+++ Do.Interface.Linux/src/Do.Interface/ResultsWindowSelectionEventArgs.cs 2009-06-14 02:03:35 +0000
678@@ -23,9 +23,9 @@
679 public class ResultsWindowSelectionEventArgs : EventArgs
680 {
681 int index;
682- Element selection;
683+ Item selection;
684
685- public ResultsWindowSelectionEventArgs (int index, Element selection)
686+ public ResultsWindowSelectionEventArgs (int index, Item selection)
687 {
688 this.index = index;
689 this.selection = selection;
690@@ -36,7 +36,7 @@
691 get { return index; }
692 }
693
694- public Element SelectedObject
695+ public Item SelectedObject
696 {
697 get {
698 return selection;
699
700=== modified file 'Do.Interface.Linux/src/Do.Interface/SearchFinishState.cs'
701--- Do.Interface.Linux/src/Do.Interface/SearchFinishState.cs 2008-12-18 02:33:48 +0000
702+++ Do.Interface.Linux/src/Do.Interface/SearchFinishState.cs 2009-06-14 02:03:35 +0000
703@@ -28,7 +28,7 @@
704 {
705 private bool selection_changed, query_changed;
706 private string query;
707- private Element selection;
708+ private Item selection;
709
710 public bool SelectionChanged {
711 get {
712@@ -46,13 +46,13 @@
713 }
714 }
715
716- public Element Selection {
717+ public Item Selection {
718 get {
719 return selection;
720 }
721 }
722
723- public SearchFinishState(bool selectionChanged, bool queryChanged, Element selection, string query)
724+ public SearchFinishState(bool selectionChanged, bool queryChanged, Item selection, string query)
725 {
726 selection_changed = selectionChanged;
727 query_changed = queryChanged;
728
729=== modified file 'Do.Interface.Linux/src/Do.Interface/UIContext.cs'
730--- Do.Interface.Linux/src/Do.Interface/UIContext.cs 2008-12-18 02:33:48 +0000
731+++ Do.Interface.Linux/src/Do.Interface/UIContext.cs 2009-06-14 02:03:35 +0000
732@@ -28,8 +28,8 @@
733
734 public class UIContext : IUIContext
735 {
736- private Element selection;
737- private IList<Element> results;
738+ private Item selection;
739+ private IList<Item> results;
740
741 private int cursor;
742 private int[] secondary;
743@@ -40,13 +40,13 @@
744
745 private IUIContext parentContext;
746
747- public Element Selection {
748+ public Item Selection {
749 get {
750 return selection;
751 }
752 }
753
754- public IList<Element> Results {
755+ public IList<Item> Results {
756 get {
757 return results;
758 }
759@@ -88,7 +88,7 @@
760 }
761 }
762
763- public UIContext(Element selection, IList<Element> results, int cursor, int[] secondaryCursors,
764+ public UIContext(Item selection, IList<Item> results, int cursor, int[] secondaryCursors,
765 string query, bool largeTextDisplay, TextModeType type, IUIContext parentContext)
766 {
767 this.selection = selection;
768
769=== modified file 'Do.Platform.Linux/gtk-gui/Do.Platform.Linux.AbstractLoginWidget.cs'
770--- Do.Platform.Linux/gtk-gui/Do.Platform.Linux.AbstractLoginWidget.cs 2009-05-29 10:26:49 +0000
771+++ Do.Platform.Linux/gtk-gui/Do.Platform.Linux.AbstractLoginWidget.cs 2009-06-12 23:10:48 +0000
772@@ -130,7 +130,6 @@
773 w6.Fill = false;
774 // Container child account_vbox.Gtk.Box+BoxChild
775 this.hbuttonbox1 = new Gtk.HButtonBox();
776- this.hbuttonbox1.Name = "hbuttonbox1";
777 this.hbuttonbox1.LayoutStyle = ((Gtk.ButtonBoxStyle)(4));
778 // Container child hbuttonbox1.Gtk.ButtonBox+ButtonBoxChild
779 this.validate_btn = new Gtk.Button();
780
781=== modified file 'Do.Platform/src/Do.Platform/Do.Platform.Default/CoreService.cs'
782--- Do.Platform/src/Do.Platform/Do.Platform.Default/CoreService.cs 2009-01-08 22:18:14 +0000
783+++ Do.Platform/src/Do.Platform/Do.Platform.Default/CoreService.cs 2009-06-14 02:03:35 +0000
784@@ -41,15 +41,15 @@
785 }
786 }
787
788- public Element GetElement (string uid)
789+ public Item GetItem (string uid)
790 {
791- Log.Debug ("Default ICoreService cannot get Elements.");
792- return new EmptyElement ();
793+ Log.Debug ("Default ICoreService cannot get Items.");
794+ return new EmptyItem ();
795 }
796
797 public IEnumerable<Item> GetItemsOrderedByRelevance ()
798 {
799- Log.Debug ("Default ICoreService cannot get Elements.");
800+ Log.Debug ("Default ICoreService cannot get Items.");
801 yield break;
802 }
803
804
805=== modified file 'Do.Platform/src/Do.Platform/ICoreService.cs'
806--- Do.Platform/src/Do.Platform/ICoreService.cs 2009-01-08 22:18:14 +0000
807+++ Do.Platform/src/Do.Platform/ICoreService.cs 2009-06-14 02:03:35 +0000
808@@ -30,7 +30,7 @@
809 {
810 event EventHandler UniverseInitialized;
811
812- Element GetElement (string uniqueId);
813+ Item GetItem (string uniqueId);
814
815 IEnumerable<Item> GetItemsOrderedByRelevance ();
816
817
818=== modified file 'Do.Universe/src/Do.Universe/Act.cs'
819--- Do.Universe/src/Do.Universe/Act.cs 2008-12-20 01:37:52 +0000
820+++ Do.Universe/src/Do.Universe/Act.cs 2009-06-12 23:10:48 +0000
821@@ -26,7 +26,7 @@
822 namespace Do.Universe
823 {
824
825- public abstract class Act : Element
826+ public abstract class Act : Item
827 {
828 static SafeAct safe_act = new SafeAct ();
829
830
831=== modified file 'Do.Universe/src/Do.Universe/ItemSource.cs'
832--- Do.Universe/src/Do.Universe/ItemSource.cs 2008-12-20 01:37:52 +0000
833+++ Do.Universe/src/Do.Universe/ItemSource.cs 2009-06-14 02:03:35 +0000
834@@ -30,7 +30,7 @@
835 /// Example: A "EpiphanyBookmarkItemSource" could provide Items representing
836 /// Epiphany web browser bookmarks.
837 /// </summary>
838- public abstract class ItemSource : Element
839+ public abstract class ItemSource : Item
840 {
841
842 static SafeItemSource safe_item_source = new SafeItemSource ();
843
844=== modified file 'Do/Do.mdp'
845--- Do/Do.mdp 2009-06-05 19:45:45 +0000
846+++ Do/Do.mdp 2009-06-17 01:44:57 +0000
847@@ -56,7 +56,6 @@
848 <File name="gtk-gui/Do.UI.ColorConfigurationWidget.cs" subtype="Code" buildaction="Compile" />
849 <File name="src/Do.UI/PluginErrorDialog.cs" subtype="Code" buildaction="Compile" />
850 <File name="gtk-gui/Do.UI.PluginErrorDialog.cs" subtype="Code" buildaction="Compile" />
851- <File name="src/Do.Core/ElementExtensions.cs" subtype="Code" buildaction="Compile" />
852 <File name="src/Do.Platform" subtype="Directory" buildaction="Compile" />
853 <File name="Resources/Do.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
854 <File name="src/Do.Core/UniverseManager.cs" subtype="Code" buildaction="Compile" />
855
856=== modified file 'Do/Makefile.am'
857--- Do/Makefile.am 2009-06-05 19:45:45 +0000
858+++ Do/Makefile.am 2009-06-17 01:44:57 +0000
859@@ -24,7 +24,6 @@
860 src/Do.Core/Do.Core.Addins/DockletAddinClassifier.cs \
861 src/Do.Core/Controller.cs \
862 src/Do.Core/DoAddinInstaller.cs \
863- src/Do.Core/ElementExtensions.cs \
864 src/Do.Core/FirstSearchController.cs \
865 src/Do.Core/HistogramRelevanceProvider.cs \
866 src/Do.Core/ISearchController.cs \
867
868=== modified file 'Do/src/Do.Core/Controller.cs'
869--- Do/src/Do.Core/Controller.cs 2009-05-16 06:15:14 +0000
870+++ Do/src/Do.Core/Controller.cs 2009-06-17 01:44:57 +0000
871@@ -309,6 +309,68 @@
872 }
873 }
874
875+ Pane WorkingActionPane {
876+ get {
877+ Item first, second;
878+ first = GetSelection (Pane.First);
879+ second = GetSelection (Pane.Second);
880+
881+ if (first != null && second != null) {
882+ if (first.IsAction () && first.AsAction ().Safe.SupportsItem (second)) {
883+ return Pane.First;
884+ } else if (second.IsAction () && second.AsAction ().Safe.SupportsItem (first)) {
885+ return Pane.Second;
886+ }
887+ }
888+ return Pane.None;
889+ }
890+ }
891+
892+ Pane WorkingItemPane {
893+ get {
894+ Item first, second;
895+ first = GetSelection (Pane.First);
896+ second = GetSelection (Pane.Second);
897+
898+ if (first != null && second != null) {
899+ if (first.IsAction () && first.AsAction ().Safe.SupportsItem (second)) {
900+ return Pane.Second;
901+ } else if (second.IsAction () && second.AsAction ().Safe.SupportsItem (first)) {
902+ return Pane.First;
903+ }
904+ }
905+ return Pane.None;
906+ }
907+ }
908+
909+ Act WorkingAction {
910+ get {
911+ return GetSelection (WorkingActionPane).AsAction ();
912+ }
913+ }
914+
915+ Item WorkingItem {
916+ get {
917+ return GetSelection (WorkingItemPane);
918+ }
919+ }
920+
921+ IEnumerable<Item> WorkingItems {
922+ get {
923+ Pane workingPane = WorkingItemPane;
924+ if (workingPane == Pane.None)
925+ return null;
926+
927+ return controllers [(int) workingPane].FullSelection;
928+ }
929+ }
930+
931+ IEnumerable<Item> WorkingModItems {
932+ get {
933+ return controllers [(int) Pane.Third].FullSelection;
934+ }
935+ }
936+
937 /// <summary>
938 /// Sets/Unsets third pane visibility if possible.
939 /// </summary>
940@@ -345,12 +407,8 @@
941 /// </summary>
942 bool ThirdPaneAllowed {
943 get {
944- Act action;
945- Element first, second;
946-
947- first = GetSelection (Pane.First);
948- second = GetSelection (Pane.Second);
949- action = first as Act ?? second as Act;
950+ Act action = WorkingAction;
951+
952 return action != null &&
953 action.SupportedModifierItemTypes.Any () &&
954 controllers [1].Results.Any ();
955@@ -363,14 +421,9 @@
956 /// </value>
957 bool ThirdPaneRequired {
958 get {
959- Item item;
960- Act action;
961- Element first, second;
962-
963- first = GetSelection (Pane.First);
964- second = GetSelection (Pane.Second);
965- action = first as Act ?? second as Act;
966- item = first as Item ?? second as Item;
967+ Item item = WorkingItem;
968+ Act action = WorkingAction;
969+
970 return action != null && item != null &&
971 action.SupportedModifierItemTypes.Any () &&
972 !action.ModifierItemsOptional &&
973@@ -395,9 +448,9 @@
974 /// Summons a window with elements in it... seems to work
975 /// </summary>
976 /// <param name="elements">
977- /// A <see cref="Element"/>
978+ /// A <see cref="Item"/>
979 /// </param>
980- public void SummonWithElements (IEnumerable<Element> elements)
981+ public void SummonWithItems (IEnumerable<Item> elements)
982 {
983 if (!IsSummonable) return;
984
985@@ -758,7 +811,7 @@
986 /// This method determines what to do when a search is completed and takes the appropriate action
987 /// </summary>
988 /// <param name="o">
989- /// A <see cref="System.Element"/>
990+ /// A <see cref="System.Item"/>
991 /// </param>
992 /// <param name="state">
993 /// A <see cref="SearchFinishState"/>
994@@ -856,9 +909,9 @@
995 results_grown = false;
996 }
997
998- Element GetSelection (Pane pane)
999+ Item GetSelection (Pane pane)
1000 {
1001- Element o;
1002+ Item o;
1003
1004 try {
1005 o = controllers [(int) pane].Selection;
1006@@ -871,72 +924,59 @@
1007 void PerformAction (bool vanish)
1008 {
1009 Act action;
1010- Element first, second, third;
1011+ Item first, second, third;
1012 string actionQuery, itemQuery, modItemQuery;
1013- ICollection<Item> items, modItems;
1014+ IEnumerable<Item> items, modItems;
1015
1016 if (vanish) Vanish ();
1017 // Flush main thread queue to get Vanish to complete.
1018 Services.Application.FlushMainThreadQueue ();
1019
1020- items = new List<Item> ();
1021- modItems = new List<Item> ();
1022- first = GetSelection (Pane.First);
1023- second = GetSelection (Pane.Second);
1024- third = GetSelection (Pane.Third);
1025- action = first as Act ?? second as Act;
1026-
1027+ action = WorkingAction;
1028+ items = WorkingItems;
1029+ modItems = WorkingModItems;
1030+
1031 // If the current state of the controller is invalid, warn and return
1032 // early.
1033- if (first == null || second == null || action == null) {
1034+ if (items == null || action == null) {
1035 Log<Controller>
1036 .Warn ("Controller state was not valid, so the action could not be performed.");
1037 if (vanish) Reset ();
1038 return;
1039 }
1040-
1041- if (first is Item) {
1042- foreach (Item item in controllers [0].FullSelection)
1043- items.Add (item);
1044- itemQuery = controllers [0].Query;
1045- actionQuery = controllers [1].Query;
1046- } else {
1047- foreach (Item item in controllers [1].FullSelection)
1048- items.Add (item);
1049- itemQuery = controllers [1].Query;
1050- actionQuery = controllers [0].Query;
1051- }
1052-
1053- modItemQuery = null;
1054- if (third != null && ThirdPaneVisible) {
1055- foreach (Item item in controllers [2].FullSelection)
1056- modItems.Add (item);
1057- modItemQuery = controllers [2].Query;
1058- }
1059+
1060+ actionQuery = controllers [(int) WorkingActionPane].Query;
1061+ itemQuery = controllers [(int) WorkingItemPane].Query;
1062+ modItemQuery = controllers [(int) Pane.Third].Query;
1063+
1064+ if (modItems != null && ThirdPaneVisible)
1065+ modItemQuery = controllers [(int) Pane.Third].Query;
1066
1067 /////////////////////////////////////////////////////////////
1068 /// Relevance accounting
1069 /////////////////////////////////////////////////////////////
1070
1071- if (first is Item) {
1072+ if (WorkingActionPane == Pane.Second) {
1073 // Act is in second pane.
1074 // Increase the relevance of the items.
1075- foreach (Element item in items)
1076+ foreach (Item item in items)
1077 item.IncreaseRelevance (itemQuery, null);
1078
1079 // Increase the relevance of the action /for each item/:
1080- foreach (Element item in items)
1081+ foreach (Item item in items)
1082 action.IncreaseRelevance (actionQuery, item);
1083 } else {
1084 // Act is in first pane.
1085 // Increase the relevance of each item for the action.
1086- foreach (Element item in items)
1087+ foreach (Item item in items)
1088 item.IncreaseRelevance (itemQuery, action);
1089 action.IncreaseRelevance (actionQuery, null);
1090 }
1091
1092- if (third != null && ThirdPaneVisible)
1093- third.IncreaseRelevance (modItemQuery, action);
1094+ if (modItems != null && ThirdPaneVisible) {
1095+ foreach (Item item in modItems)
1096+ item.IncreaseRelevance (modItemQuery, action);
1097+ }
1098
1099 if (vanish) Reset ();
1100
1101@@ -946,13 +986,13 @@
1102
1103 void PerformAction (Act action, IEnumerable<Item> items, IEnumerable<Item> modItems)
1104 {
1105- if (action == null) throw new ArgumentNullException ("action");
1106- if (items == null) throw new ArgumentNullException ("items");
1107+ if (action == null) throw new ArgumentNullException ("action");
1108+ if (items == null) throw new ArgumentNullException ("items");
1109 if (modItems == null) throw new ArgumentNullException ("modItems");
1110
1111 IEnumerable<Item> results = action.Safe.Perform (items, modItems);
1112 if (results.Any ()) {
1113- SummonWithElements (results.OfType<Element> ());
1114+ SummonWithItems (results);
1115 }
1116 }
1117
1118@@ -1046,9 +1086,9 @@
1119
1120 public ControlOrientation Orientation { get; set; }
1121
1122- public bool ElementHasChildren (Element element)
1123+ public bool ItemHasChildren (Item item)
1124 {
1125- return element is Item && (element as Item).HasChildren ();
1126+ return item.HasChildren ();
1127 }
1128
1129 #endregion
1130
1131=== removed file 'Do/src/Do.Core/ElementExtensions.cs'
1132--- Do/src/Do.Core/ElementExtensions.cs 2008-12-18 23:16:14 +0000
1133+++ Do/src/Do.Core/ElementExtensions.cs 1970-01-01 00:00:00 +0000
1134@@ -1,88 +0,0 @@
1135-// Element_RelevanceProvider.cs
1136-//
1137-// GNOME Do is the legal property of its developers. Please refer to the
1138-// COPYRIGHT file distributed with this source distribution.
1139-//
1140-// This program is free software: you can redistribute it and/or modify
1141-// it under the terms of the GNU General Public License as published by
1142-// the Free Software Foundation, either version 3 of the License, or
1143-// (at your option) any later version.
1144-//
1145-// This program is distributed in the hope that it will be useful,
1146-// but WITHOUT ANY WARRANTY; without even the implied warranty of
1147-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1148-// GNU General Public License for more details.
1149-//
1150-// You should have received a copy of the GNU General Public License
1151-// along with this program. If not, see <http://www.gnu.org/licenses/>.
1152-//
1153-
1154-using System;
1155-
1156-using Do.Universe;
1157-
1158-namespace Do.Core
1159-{
1160-
1161- /// <summary>
1162- /// Relevance related extension methods on Element class.
1163- /// </summary>
1164- public static class Element_RelevanceProvider
1165- {
1166-
1167- static readonly IRelevanceProvider provider = RelevanceProvider.DefaultProvider;
1168-
1169- /// <summary>
1170- /// Increase the relevance of receiver for string match and other Element.
1171- /// </summary>
1172- /// <param name="self">
1173- /// A <see cref="Element"/> whose relevance is to be increased.
1174- /// </param>
1175- /// <param name="match">
1176- /// A <see cref="System.String"/> of user input for which the receiver should become more relevant.
1177- /// </param>
1178- /// <param name="other">
1179- /// A <see cref="Element"/> (maybe null) context.
1180- /// </param>
1181- public static void IncreaseRelevance (this Element self, string match, Element other)
1182- {
1183- provider.IncreaseRelevance (self, match, other);
1184- }
1185-
1186- /// <summary>
1187- /// Decrease the relevance of receiver for string match and other Element.
1188- /// </summary>
1189- /// <param name="self">
1190- /// A <see cref="Element"/> whose relevance is to be increased.
1191- /// </param>
1192- /// <param name="match">
1193- /// A <see cref="System.String"/> of user input for which the receiver should become less relevant.
1194- /// </param>
1195- /// <param name="other">
1196- /// A <see cref="Element"/> (maybe null) context.
1197- /// </param>
1198- public static void DecreaseRelevance (this Element self, string match, Element other)
1199- {
1200- provider.DecreaseRelevance (self, match, other);
1201- }
1202-
1203- /// <summary>
1204- /// Simply retrieves the receivers relevance and updates the receivers state
1205- /// (Element.Relevance is set).
1206- /// </summary>
1207- /// <param name="self">
1208- /// A <see cref="Element"/> whose relevance should be updated to reflect
1209- /// the state of the world.
1210- /// </param>
1211- /// <param name="match">
1212- /// A <see cref="System.String"/> to retrieve relevance info for.
1213- /// </param>
1214- /// <param name="other">
1215- /// A <see cref="Element"/> (maybe null) to retrieve relevance info for.
1216- /// </param>
1217- public static void UpdateRelevance (this Element self, string match, Element other)
1218- {
1219- self.Relevance = provider.GetRelevance (self, match, other);
1220- }
1221- }
1222-}
1223
1224=== modified file 'Do/src/Do.Core/HistogramRelevanceProvider.cs'
1225--- Do/src/Do.Core/HistogramRelevanceProvider.cs 2009-01-19 23:06:59 +0000
1226+++ Do/src/Do.Core/HistogramRelevanceProvider.cs 2009-06-14 02:03:35 +0000
1227@@ -49,7 +49,7 @@
1228 hits = new Dictionary<string, RelevanceRecord> ();
1229 }
1230
1231- void UpdateMaxHits (RelevanceRecord rec, Element e)
1232+ void UpdateMaxHits (RelevanceRecord rec, Item e)
1233 {
1234 if (e is Act)
1235 max_action_hits = Math.Max (max_action_hits, rec.Hits);
1236@@ -57,7 +57,7 @@
1237 max_item_hits = Math.Max (max_item_hits, rec.Hits);
1238 }
1239
1240- public override void IncreaseRelevance (Element element, string match, Element other)
1241+ public override void IncreaseRelevance (Item element, string match, Item other)
1242 {
1243 RelevanceRecord rec;
1244
1245@@ -78,7 +78,7 @@
1246 UpdateMaxHits (rec, element);
1247 }
1248
1249- public override void DecreaseRelevance (Element element, string match, Element other)
1250+ public override void DecreaseRelevance (Item element, string match, Item other)
1251 {
1252 RelevanceRecord rec;
1253
1254@@ -92,7 +92,7 @@
1255 }
1256 }
1257
1258- public override float GetRelevance (Element e, string match, Element other)
1259+ public override float GetRelevance (Item e, string match, Item other)
1260 {
1261 RelevanceRecord rec;
1262 bool isAction;
1263@@ -175,7 +175,7 @@
1264 public DateTime LastHit;
1265 public string FirstChars;
1266
1267- public RelevanceRecord (Element o)
1268+ public RelevanceRecord (Item o)
1269 {
1270 LastHit = DateTime.Now;
1271 FirstChars = "";
1272
1273=== modified file 'Do/src/Do.Core/ISearchController.cs'
1274--- Do/src/Do.Core/ISearchController.cs 2008-12-29 02:37:54 +0000
1275+++ Do/src/Do.Core/ISearchController.cs 2009-06-14 02:03:35 +0000
1276@@ -36,19 +36,19 @@
1277 IUIContext UIContext {get;}
1278
1279 /// <value>
1280- /// Element Results from the current Query
1281+ /// Item Results from the current Query
1282 /// </value>
1283- IList<Element> Results {get; set;}
1284+ IList<Item> Results {get; set;}
1285
1286 /// <value>
1287 /// The full selection, including secondary selections
1288 /// </value>
1289- IList<Element> FullSelection {get;}
1290+ IList<Item> FullSelection {get;}
1291
1292 /// <value>
1293 /// The primary selection from the user curosr
1294 /// </value>
1295- Element Selection {get;}
1296+ Item Selection {get;}
1297
1298 /// <value>
1299 /// The location of the cursor in the results list
1300
1301=== modified file 'Do/src/Do.Core/ItemExtensions.cs'
1302--- Do/src/Do.Core/ItemExtensions.cs 2008-12-20 00:31:54 +0000
1303+++ Do/src/Do.Core/ItemExtensions.cs 2009-06-17 01:44:57 +0000
1304@@ -29,7 +29,7 @@
1305
1306 static class ItemExtensions
1307 {
1308-
1309+ static readonly IRelevanceProvider provider = RelevanceProvider.DefaultProvider;
1310 static IDictionary<Item, bool> has_children;
1311
1312 static ItemExtensions ()
1313@@ -45,5 +45,67 @@
1314 return has_children [self];
1315 }
1316
1317+ public static bool IsAction (this Item self)
1318+ {
1319+ return ProxyItem.Unwrap (self) is Act;
1320+ }
1321+
1322+ public static Act AsAction (this Item self)
1323+ {
1324+ return ProxyItem.Unwrap (self) as Act;
1325+ }
1326+
1327+ /// <summary>
1328+ /// Increase the relevance of receiver for string match and other Item.
1329+ /// </summary>
1330+ /// <param name="self">
1331+ /// A <see cref="Item"/> whose relevance is to be increased.
1332+ /// </param>
1333+ /// <param name="match">
1334+ /// A <see cref="System.String"/> of user input for which the receiver should become more relevant.
1335+ /// </param>
1336+ /// <param name="other">
1337+ /// A <see cref="Item"/> (maybe null) context.
1338+ /// </param>
1339+ public static void IncreaseRelevance (this Item self, string match, Item other)
1340+ {
1341+ provider.IncreaseRelevance (self, match, other);
1342+ }
1343+
1344+ /// <summary>
1345+ /// Decrease the relevance of receiver for string match and other Item.
1346+ /// </summary>
1347+ /// <param name="self">
1348+ /// A <see cref="Item"/> whose relevance is to be increased.
1349+ /// </param>
1350+ /// <param name="match">
1351+ /// A <see cref="System.String"/> of user input for which the receiver should become less relevant.
1352+ /// </param>
1353+ /// <param name="other">
1354+ /// A <see cref="Item"/> (maybe null) context.
1355+ /// </param>
1356+ public static void DecreaseRelevance (this Item self, string match, Item other)
1357+ {
1358+ provider.DecreaseRelevance (self, match, other);
1359+ }
1360+
1361+ /// <summary>
1362+ /// Simply retrieves the receivers relevance and updates the receivers state
1363+ /// (Item.Relevance is set).
1364+ /// </summary>
1365+ /// <param name="self">
1366+ /// A <see cref="Item"/> whose relevance should be updated to reflect
1367+ /// the state of the world.
1368+ /// </param>
1369+ /// <param name="match">
1370+ /// A <see cref="System.String"/> to retrieve relevance info for.
1371+ /// </param>
1372+ /// <param name="other">
1373+ /// A <see cref="Item"/> (maybe null) to retrieve relevance info for.
1374+ /// </param>
1375+ public static float UpdateRelevance (this Item self, string match, Item other)
1376+ {
1377+ return self.Relevance = provider.GetRelevance (self, match, other);
1378+ }
1379 }
1380 }
1381
1382=== modified file 'Do/src/Do.Core/RelevanceProvider.cs'
1383--- Do/src/Do.Core/RelevanceProvider.cs 2009-01-19 23:27:07 +0000
1384+++ Do/src/Do.Core/RelevanceProvider.cs 2009-06-14 02:03:35 +0000
1385@@ -31,9 +31,9 @@
1386
1387 public interface IRelevanceProvider
1388 {
1389- void IncreaseRelevance (Element target, string match, Element other);
1390- void DecreaseRelevance (Element target, string match, Element other);
1391- float GetRelevance (Element target, string match, Element other);
1392+ void IncreaseRelevance (Item target, string match, Item other);
1393+ void DecreaseRelevance (Item target, string match, Item other);
1394+ float GetRelevance (Item target, string match, Item other);
1395 }
1396
1397 [Serializable]
1398@@ -228,15 +228,15 @@
1399 return bestMatch;
1400 }
1401
1402- public virtual void IncreaseRelevance (Element r, string match, Element other)
1403- {
1404- }
1405-
1406- public virtual void DecreaseRelevance (Element r, string match, Element other)
1407- {
1408- }
1409-
1410- public virtual float GetRelevance (Element r, string match, Element other)
1411+ public virtual void IncreaseRelevance (Item r, string match, Item other)
1412+ {
1413+ }
1414+
1415+ public virtual void DecreaseRelevance (Item r, string match, Item other)
1416+ {
1417+ }
1418+
1419+ public virtual float GetRelevance (Item r, string match, Item other)
1420 {
1421 return StringScoreForAbbreviation (r.Safe.Name, match);
1422 }
1423
1424=== modified file 'Do/src/Do.Core/SecondSearchController.cs'
1425--- Do/src/Do.Core/SecondSearchController.cs 2009-05-18 22:01:43 +0000
1426+++ Do/src/Do.Core/SecondSearchController.cs 2009-06-17 01:44:57 +0000
1427@@ -42,7 +42,7 @@
1428 }
1429 }
1430
1431- public override Element Selection {
1432+ public override Item Selection {
1433 get {
1434 if (IsSearching)
1435 FastSearch ();
1436@@ -78,16 +78,16 @@
1437 base.OnSearchFinished (true, true, Selection, Query);
1438 }
1439
1440- protected override List<Element> InitialResults ()
1441+ protected override List<Item> InitialResults ()
1442 {
1443 // We continue off our previous results if possible
1444 if (context.LastContext != null && context.LastContext.Results.Any ()) {
1445- return new List<Element> (
1446+ return new List<Item> (
1447 Do.UniverseManager.Search (context.Query, SearchTypes, context.LastContext.Results, FirstController.Selection));
1448 } else if (context.ParentContext != null && context.Results.Any ()) {
1449- return new List<Element> (context.Results);
1450+ return new List<Item> (context.Results);
1451 } else {
1452- return new List<Element> (
1453+ return new List<Item> (
1454 Do.UniverseManager.Search (context.Query, SearchTypes, FirstController.Selection));
1455 }
1456 }
1457@@ -114,26 +114,28 @@
1458 /// Set up our results list.
1459 /// </summary>
1460 /// <returns>
1461- /// A <see cref="Element"/>
1462+ /// A <see cref="Item"/>
1463 /// </returns>
1464- private Element[] GetContextResults ()
1465+ private Item [] GetContextResults ()
1466 {
1467- List<Element> results = new List<Element> ();
1468- if (FirstController.Selection is Item) {
1469- Item item = FirstController.Selection as Item;
1470+ List<Item> results = new List<Item> ();
1471+ Item first = FirstController.Selection;
1472+
1473+ if (first.IsAction ()) {
1474+ // We need to find items for this action
1475+ Act action = first.AsAction ();
1476+ foreach (Item item in InitialResults ()) {
1477+ if (action.Safe.SupportsItem (item) || (item.IsAction () && item.AsAction ().Safe.SupportsItem (action)))
1478+ results.Add (item);
1479+ }
1480+ } else {
1481 // We need to find actions for this item
1482 // TODO -- Make this work for multiple items
1483- foreach (Act action in InitialResults ()) {
1484- if (action.Safe.SupportsItem (item)) {
1485- results.Add (action);
1486- }
1487- }
1488- } else if (FirstController.Selection is Act) {
1489- // We need to find items for this action
1490- Act action = FirstController.Selection as Act;
1491 foreach (Item item in InitialResults ()) {
1492- if (action.Safe.SupportsItem (item))
1493+ Act action = item.AsAction ();
1494+ if (action != null && action.Safe.SupportsItem (first)) {
1495 results.Add (item);
1496+ }
1497 }
1498 }
1499
1500@@ -204,9 +206,11 @@
1501
1502 public override IEnumerable<Type> SearchTypes {
1503 get {
1504- if (FirstController.Selection is Act) {
1505- foreach (Type t in (FirstController.Selection as Act).SupportedItemTypes)
1506+ Item item = FirstController.Selection;
1507+ if (item.IsAction ()) {
1508+ foreach (Type t in item.AsAction ().Safe.SupportedItemTypes)
1509 yield return t;
1510+ yield return typeof (Act);
1511 } else if (TextMode) {
1512 yield return typeof (ITextItem);
1513 } else {
1514@@ -238,8 +242,8 @@
1515 if (!value) {
1516 textMode = value;
1517 textModeFinalize = false;
1518- } else if (FirstController.Selection is Act) {
1519- Act action = FirstController.Selection as Act;
1520+ } else if (FirstController.Selection.IsAction ()) {
1521+ Act action = FirstController.Selection.AsAction ();
1522 if (action.Safe.SupportsItem (new ImplicitTextItem (Query))) {
1523 textMode = value;
1524 textModeFinalize = false;
1525@@ -278,8 +282,8 @@
1526
1527 protected override bool AcceptChildItem (Item item)
1528 {
1529- if (FirstController.Selection is Act) {
1530- Act action = FirstController.Selection as Act;
1531+ if (FirstController.Selection.IsAction ()) {
1532+ Act action = FirstController.Selection.AsAction ();
1533 return action.Safe.SupportsItem (item);
1534 }
1535 return true;
1536
1537=== modified file 'Do/src/Do.Core/SimpleSearchContext.cs'
1538--- Do/src/Do.Core/SimpleSearchContext.cs 2008-12-29 02:37:54 +0000
1539+++ Do/src/Do.Core/SimpleSearchContext.cs 2009-06-14 02:03:35 +0000
1540@@ -30,18 +30,18 @@
1541 {
1542 string query;
1543 int cursor;
1544- IList<Element> results;
1545+ IList<Item> results;
1546
1547 public SimpleSearchContext ()
1548 {
1549- SecondaryCursors = new Element[0];
1550+ SecondaryCursors = new Item[0];
1551 query = "";
1552- results = new Element[0];
1553+ results = new Item[0];
1554 }
1555
1556 public SimpleSearchContext LastContext { get; set; }
1557 public SimpleSearchContext ParentContext { get; set; }
1558- public Element[] SecondaryCursors { get; set; }
1559+ public Item[] SecondaryCursors { get; set; }
1560
1561 public string Query
1562 {
1563@@ -53,23 +53,23 @@
1564 set { query = value; }
1565 }
1566
1567- public IList<Element> Results
1568+ public IList<Item> Results
1569 {
1570 get {
1571 if (results == null)
1572- results = new Element[0];
1573+ results = new Item[0];
1574 return results;
1575 }
1576 set {
1577- results = value ?? new List<Element> (0);
1578+ results = value ?? new List<Item> (0);
1579
1580 cursor = 0;
1581
1582 if (SecondaryCursors.Length == 0) return;
1583
1584- List<Element> secondary = new List<Element> ();
1585- foreach (Element obj in SecondaryCursors) {
1586- foreach (Element robj in Results) {
1587+ List<Item> secondary = new List<Item> ();
1588+ foreach (Item obj in SecondaryCursors) {
1589+ foreach (Item robj in Results) {
1590 if (obj == robj) {
1591 secondary.Add (obj);
1592 }
1593@@ -80,7 +80,7 @@
1594 }
1595 }
1596
1597- public Element Selection
1598+ public Item Selection
1599 {
1600 get {
1601 try {
1602@@ -91,10 +91,10 @@
1603 }
1604 }
1605
1606- public Element[] FullSelection
1607+ public Item[] FullSelection
1608 {
1609 get {
1610- List<Element> outList = new List<Element> ();
1611+ List<Item> outList = new List<Item> ();
1612 outList.AddRange (SecondaryCursors);
1613
1614 //Juggle our selection to front to give best possible legacy plugin support. Ideally this
1615@@ -152,7 +152,7 @@
1616 return new int[0];
1617 List<int> cursors = new List<int> ();
1618
1619- foreach (Element obj in SecondaryCursors) {
1620+ foreach (Item obj in SecondaryCursors) {
1621 for (int i = 0; i < Results.Count; i++) {
1622 if (Results[i] == obj)
1623 cursors.Add (i);
1624@@ -172,8 +172,8 @@
1625 clone.ParentContext = ParentContext;
1626 clone.Cursor = Cursor;
1627 clone.SecondaryCursors = SecondaryCursors; //Cloning these makes no sense
1628-// clone.Results = results.Clone () as Element[];
1629- clone.Results = new List<Element> (results);
1630+// clone.Results = results.Clone () as Item[];
1631+ clone.Results = new List<Item> (results);
1632 return clone;
1633 }
1634
1635
1636=== modified file 'Do/src/Do.Core/SimpleSearchController.cs'
1637--- Do/src/Do.Core/SimpleSearchController.cs 2009-05-18 22:01:43 +0000
1638+++ Do/src/Do.Core/SimpleSearchController.cs 2009-06-14 02:03:35 +0000
1639@@ -61,7 +61,7 @@
1640 }
1641 }
1642
1643- public IList<Element> Results {
1644+ public IList<Item> Results {
1645 get {
1646 return context.Results;
1647 }
1648@@ -71,13 +71,13 @@
1649 }
1650 }
1651
1652- public IList<Element> FullSelection {
1653+ public IList<Item> FullSelection {
1654 get {
1655 return context.FullSelection;
1656 }
1657 }
1658
1659- public virtual Element Selection {
1660+ public virtual Item Selection {
1661 get {
1662 return context.Selection;
1663 }
1664@@ -88,7 +88,7 @@
1665 return context.Cursor;
1666 }
1667 set {
1668- Element tmp = Selection;
1669+ Item tmp = Selection;
1670 int ctmp = context.Cursor;
1671 context.Cursor = value;
1672 if (tmp != Selection || context.Cursor != ctmp) {
1673@@ -143,14 +143,14 @@
1674
1675 protected abstract void UpdateResults ();
1676
1677- protected virtual List<Element> InitialResults ()
1678+ protected virtual List<Item> InitialResults ()
1679 {
1680 if (context.ParentContext != null) {
1681 if (context.LastContext != null && context.LastContext.Results.Any ())
1682- return new List<Element> (Do.UniverseManager.Search (context.Query, SearchTypes, context.LastContext.Results));
1683- return new List<Element> (context.Results);
1684+ return new List<Item> (Do.UniverseManager.Search (context.Query, SearchTypes, context.LastContext.Results));
1685+ return new List<Item> (context.Results);
1686 } else {
1687- return new List<Element> (Do.UniverseManager.Search (context.Query, SearchTypes));
1688+ return new List<Item> (Do.UniverseManager.Search (context.Query, SearchTypes));
1689 }
1690 }
1691
1692@@ -160,7 +160,7 @@
1693 return;
1694 }
1695
1696- Element tmp = context.Selection;
1697+ Item tmp = context.Selection;
1698 context = context.LastContext;
1699 OnSearchFinished (tmp != context.Selection, true, Selection, Query);
1700 }
1701@@ -169,10 +169,10 @@
1702 {
1703 if (Results.Count - 1 < cursorLocation) return false;
1704
1705- List<Element> secondary;
1706- secondary = new List<Element> (context.SecondaryCursors);
1707+ List<Item> secondary;
1708+ secondary = new List<Item> (context.SecondaryCursors);
1709
1710- Element newObject = Results[cursorLocation];
1711+ Item newObject = Results[cursorLocation];
1712
1713 if (secondary.Contains (newObject))
1714 secondary.Remove (newObject);
1715@@ -191,11 +191,11 @@
1716 if (context.Selection is Act)
1717 return false;
1718
1719- Item item = context.Selection as Item;
1720- List<Element> children = new List<Element> ();
1721+ Item item = context.Selection;
1722+ List<Item> children = new List<Item> ();
1723
1724 foreach (ItemSource source in PluginManager.ItemSources) {
1725- foreach (Element child in source.Safe.ChildrenOfItem (item).Where (i => AcceptChildItem (i)))
1726+ foreach (Item child in source.Safe.ChildrenOfItem (item).Where (i => AcceptChildItem (i)))
1727 children.Add (child);
1728 }
1729
1730@@ -245,7 +245,7 @@
1731 SearchStarted (upstream_search);
1732 }
1733
1734- protected void OnSearchFinished (bool selection_changed, bool query_changed, Element selection, string query)
1735+ protected void OnSearchFinished (bool selection_changed, bool query_changed, Item selection, string query)
1736 {
1737 SearchFinished (this, new SearchFinishState (selection_changed, query_changed, selection, query));
1738 }
1739
1740=== modified file 'Do/src/Do.Core/ThirdSearchController.cs'
1741--- Do/src/Do.Core/ThirdSearchController.cs 2009-06-07 23:53:40 +0000
1742+++ Do/src/Do.Core/ThirdSearchController.cs 2009-06-17 01:44:57 +0000
1743@@ -31,27 +31,62 @@
1744
1745 public class ThirdSearchController : SimpleSearchController
1746 {
1747- private ISearchController FirstController, SecondController;
1748- private uint timer = 0;
1749+ ISearchController FirstController, SecondController;
1750+ uint timer = 0;
1751
1752- private bool SearchNeeded {
1753+ bool SearchNeeded {
1754 get {
1755- if (FirstController.Selection == null || SecondController.Selection == null)
1756- return false;
1757+ Act act = null;
1758
1759- Act action;
1760- if (FirstController.Selection is Act) {
1761- action = FirstController.Selection as Act;
1762- } else if (SecondController.Selection is Act) {
1763- action = SecondController.Selection as Act;
1764- } else {
1765- return false;
1766+ try {
1767+ act = GetContextualAction ();
1768+ } catch (Exception e) {
1769+ Log<ThirdSearchController>.Error (e.Message);
1770 }
1771
1772- return action.SupportedModifierItemTypes.Any ();
1773+ if (act == null)
1774+ return false;
1775+
1776+ return act.SupportedModifierItemTypes.Any ();
1777 }
1778 }
1779
1780+ Act GetContextualAction ()
1781+ {
1782+ // fixme : This really should have a buffer to it that gets reset when an upstream selection changes
1783+ if (FirstController.Selection == null || SecondController.Selection == null)
1784+ return null;
1785+
1786+ Item first, second;
1787+ first = FirstController.Selection;
1788+ second = SecondController.Selection;
1789+
1790+ if (first.IsAction () && first.AsAction ().Safe.SupportsItem (second))
1791+ return first.AsAction ();
1792+ else if (second.IsAction () && second.AsAction ().SupportsItem (first))
1793+ return second.AsAction ();
1794+ // fixme
1795+ throw new Exception ("Something strange happened");
1796+ }
1797+
1798+ Item GetContextualItem ()
1799+ {
1800+ // fixme : This really should have a buffer to it that gets reset when an upstream selection changes
1801+ if (FirstController.Selection == null || SecondController.Selection == null)
1802+ return null;
1803+
1804+ Item first, second;
1805+ first = FirstController.Selection;
1806+ second = SecondController.Selection;
1807+
1808+ if (first.IsAction () && first.AsAction ().Safe.SupportsItem (second))
1809+ return second;
1810+ else if (second.IsAction () && second.AsAction ().SupportsItem (first))
1811+ return first;
1812+ // fixme
1813+ throw new Exception ("Something strange happened");
1814+ }
1815+
1816 public ThirdSearchController(ISearchController FirstController, ISearchController SecondController) : base ()
1817 {
1818 this.FirstController = FirstController;
1819@@ -82,12 +117,15 @@
1820 textMode = value;
1821 textModeFinalize = false;
1822 } else {
1823- Act action;
1824- if (FirstController.Selection is Act)
1825- action = FirstController.Selection as Act;
1826- else if (SecondController.Selection is Act)
1827- action = SecondController.Selection as Act;
1828- else
1829+ Act action = null;
1830+
1831+ try {
1832+ action = GetContextualAction ();
1833+ } catch (Exception e) {
1834+ Log<ThirdSearchController>.Error (e.Message);
1835+ }
1836+
1837+ if (action == null)
1838 return; //you have done something weird, ignore it!
1839
1840 foreach (Type t in action.SupportedModifierItemTypes) {
1841@@ -106,6 +144,7 @@
1842 private void OnUpstreamSelectionChanged ()
1843 {
1844 if (!SearchNeeded) {
1845+ //fixme - could be doing this a lot when its not needed? causing lots of UI draws?
1846 context.Destroy ();
1847 context = new SimpleSearchContext ();
1848
1849@@ -126,44 +165,57 @@
1850 });
1851 }
1852
1853- protected override List<Element> InitialResults ()
1854+ protected override List<Item> InitialResults ()
1855 {
1856+ Item other = null;
1857+ try {
1858+ other = GetContextualItem ();
1859+ } catch {
1860+ return new List<Item> ();
1861+ }
1862+
1863 // We continue off our previous results if possible
1864 if (context.LastContext != null && context.LastContext.Results.Any ()) {
1865- return new List<Element> (Do.UniverseManager.Search (context.Query,
1866- SearchTypes, context.LastContext.Results, FirstController.Selection));
1867+ return new List<Item> (Do.UniverseManager.Search (context.Query, SearchTypes, context.LastContext.Results, other));
1868 } else if (context.ParentContext != null && context.Results.Any ()) {
1869- return new List<Element> (context.Results);
1870+ return new List<Item> (context.Results);
1871 } else {
1872 // else we do things the slow way
1873- return new List<Element> (
1874- Do.UniverseManager.Search (context.Query, SearchTypes, FirstController.Selection));
1875+ return new List<Item> (Do.UniverseManager.Search (context.Query, SearchTypes, other));
1876 }
1877 }
1878
1879- private IList<Element> GetContextResults ()
1880+ private IList<Item> GetContextResults ()
1881 {
1882 Item item = null;
1883 Act action = null;
1884 IEnumerable<Item> items = null;
1885 List<Item> modItems = new List<Item> ();
1886-
1887- if (FirstController.Selection is Act) {
1888- action = FirstController.Selection as Act;
1889- item = SecondController.Selection as Item;
1890- items = SecondController.FullSelection.OfType<Item> ();
1891- } else if (SecondController.Selection is Act) {
1892- action = SecondController.Selection as Act;
1893- item = FirstController.Selection as Item;
1894- items = FirstController.FullSelection.OfType<Item> ();
1895+
1896+ try {
1897+ action = GetContextualAction ();
1898+ } catch (Exception e) {
1899+ Log<ThirdSearchController>.Error (e.Message);
1900+ return modItems;
1901+ }
1902+
1903+ if (action == null)
1904+ return modItems;
1905+
1906+ if (FirstController.Selection == action) {
1907+ item = SecondController.Selection;
1908+ items = SecondController.FullSelection;
1909+ } else if (SecondController.Selection == action) {
1910+ item = FirstController.Selection;
1911+ items = FirstController.FullSelection;
1912 } else {
1913- Log.Debug ("No action found. The interface is out of sync.");
1914- return new List<Element> ();
1915+ Log<ThirdSearchController>.Debug ("No action found. The interface is out of sync.");
1916+ return modItems;
1917 }
1918-
1919- // If we don't support modifier items, don't search.
1920- if (!action.Safe.SupportedModifierItemTypes.Any ())
1921- return new List<Element> ();
1922+
1923+ // If we don't support modifier items, don't search.
1924+ if (!action.Safe.SupportedModifierItemTypes.Any ())
1925+ return modItems;
1926
1927 // Add appropriate modifier items from universe.
1928 foreach (Item modItem in InitialResults ()) {
1929@@ -179,7 +231,7 @@
1930 }
1931 // Sort modifier items before we potentially add a text item.
1932 modItems.Sort ();
1933- return modItems.OfType<Element> ().ToList<Element> ();
1934+ return modItems;
1935 }
1936
1937 public override void Reset ()
1938@@ -242,12 +294,13 @@
1939
1940 protected override bool AcceptChildItem (Item item)
1941 {
1942- if (FirstController.Selection is Act) {
1943- Act action = FirstController.Selection as Act;
1944- return action.Safe.SupportsModifierItemForItems (SecondController.FullSelection.Cast<Item> (), item);
1945- } else if (SecondController.Selection is Act) {
1946- Act action = SecondController.Selection as Act;
1947- return action.Safe.SupportsModifierItemForItems (FirstController.FullSelection.Cast<Item> (), item);
1948+ //fixme
1949+ if (FirstController.Selection.IsAction () && FirstController.Selection.AsAction ().SupportsItem (SecondController.Selection)) {
1950+ Act action = FirstController.Selection.AsAction ();
1951+ return action.Safe.SupportsModifierItemForItems (SecondController.FullSelection, item);
1952+ } else if (SecondController.Selection.IsAction ()) {
1953+ Act action = SecondController.Selection.AsAction ();
1954+ return action.Safe.SupportsModifierItemForItems (FirstController.FullSelection, item);
1955 }
1956 return true;
1957 }
1958
1959=== modified file 'Do/src/Do.Core/UniverseManager.cs'
1960--- Do/src/Do.Core/UniverseManager.cs 2009-01-25 20:32:52 +0000
1961+++ Do/src/Do.Core/UniverseManager.cs 2009-06-17 01:44:57 +0000
1962@@ -35,7 +35,7 @@
1963 {
1964
1965 Thread update_thread;
1966- Dictionary<string, Element> universe;
1967+ Dictionary<string, Item> universe;
1968 EventHandler initialized;
1969
1970 const float epsilon = 0.00001f;
1971@@ -75,7 +75,7 @@
1972
1973 public UniverseManager ()
1974 {
1975- universe = new Dictionary<string, Element> ();
1976+ universe = new Dictionary<string, Item> ();
1977
1978 update_thread = new Thread (new ThreadStart (UniverseUpdateLoop));
1979 update_thread.IsBackground = true;
1980@@ -103,41 +103,31 @@
1981 update_thread.Start ();
1982 }
1983
1984- public IEnumerable<Element> Search (string query, IEnumerable<Type> filter)
1985+ public IEnumerable<Item> Search (string query, IEnumerable<Type> filter)
1986 {
1987- return Search (query, filter, (Element) null);
1988+ return Search (query, filter, (Item) null);
1989 }
1990
1991- public IEnumerable<Element> Search (string query, IEnumerable<Type> filter, Element other)
1992+ public IEnumerable<Item> Search (string query, IEnumerable<Type> filter, Item other)
1993 {
1994- if (filter.Count () == 1 && filter.First () == typeof (Act))
1995- return Search (query, filter, PluginManager.Actions.OfType<Element> (), other);
1996- else
1997- lock (universe)
1998- return Search (query, filter, universe.Values, other);
1999+ lock (universe)
2000+ return Search (query, filter, universe.Values, other);
2001 }
2002
2003- public IEnumerable<Element> Search (string query, IEnumerable<Type> filter, IEnumerable<Element> objects)
2004+ public IEnumerable<Item> Search (string query, IEnumerable<Type> filter, IEnumerable<Item> objects)
2005 {
2006 return Search (query, filter, objects, null);
2007 }
2008
2009- public IEnumerable<Element> Search (string query, IEnumerable<Type> filter, IEnumerable<Element> elements, Element other)
2010+ public IEnumerable<Item> Search (string query, IEnumerable<Type> filter, IEnumerable<Item> elements, Item other)
2011 {
2012- Element text = new ImplicitTextItem (query);
2013-
2014+ Item text = new ImplicitTextItem (query);
2015 string lquery = query.ToLower ();
2016
2017- foreach (Element element in elements)
2018- element.UpdateRelevance (lquery, other);
2019-
2020 return elements
2021- .Where (element => epsilon < Math.Abs (element.Relevance) && element.PassesTypeFilter (filter))
2022+ .Where (element => element.PassesTypeFilter (filter) && epsilon < Math.Abs (element.UpdateRelevance (lquery, other)))
2023 .OrderByDescending (element => element.Relevance)
2024- .Concat (text.PassesTypeFilter (filter)
2025- ? new [] { text }
2026- : Enumerable.Empty<Element> ()
2027- )
2028+ .Concat (text.PassesTypeFilter (filter) ? new [] { text } : Enumerable.Empty<Item> ())
2029 .ToArray ();
2030 }
2031
2032@@ -145,14 +135,14 @@
2033 /// Returns if an object likely contains children.
2034 /// </summary>
2035 /// <param name="o">
2036- /// A <see cref="Element"/>
2037+ /// A <see cref="Item"/>
2038 /// </param>
2039 /// <returns>
2040 /// A <see cref="System.Boolean"/>
2041 /// </returns>
2042- public bool ElementHasChildren (Element element)
2043+ public bool ItemHasChildren (Item item)
2044 {
2045- return element is Item && (element as Item).HasChildren ();
2046+ return item.HasChildren ();
2047 }
2048
2049 /// <summary>
2050@@ -270,15 +260,15 @@
2051 }
2052
2053 /// <summary>
2054- /// Attempts to get an Element for a given UniqueId.
2055+ /// Attempts to get an Item for a given UniqueId.
2056 /// </summary>
2057 /// <param name="UniqueId">
2058 /// A <see cref="System.String"/>
2059 /// </param>
2060 /// <param name="item">
2061- /// A <see cref="Element"/>
2062+ /// A <see cref="Item"/>
2063 /// </param>
2064- public bool TryGetElementForUniqueId (string uid, out Element element)
2065+ public bool TryGetItemForUniqueId (string uid, out Item element)
2066 {
2067 lock (universe) {
2068 if (universe.ContainsKey (uid)) {
2069
2070=== modified file 'Do/src/Do.Platform/CoreService.cs'
2071--- Do/src/Do.Platform/CoreService.cs 2009-01-08 22:18:14 +0000
2072+++ Do/src/Do.Platform/CoreService.cs 2009-06-14 02:03:35 +0000
2073@@ -39,16 +39,16 @@
2074 remove { Do.UniverseManager.Initialized -= value; }
2075 }
2076
2077- public Element GetElement (string uniqueId)
2078+ public Item GetItem (string uniqueId)
2079 {
2080- Element element;
2081- Do.UniverseManager.TryGetElementForUniqueId (uniqueId, out element);
2082+ Item element;
2083+ Do.UniverseManager.TryGetItemForUniqueId (uniqueId, out element);
2084 return element;
2085 }
2086
2087 public IEnumerable<Item> GetItemsOrderedByRelevance ()
2088 {
2089- return Do.UniverseManager.Search ("", typeof (Item).Cons (null)).Cast<Item> ();
2090+ return Do.UniverseManager.Search ("", typeof (Item).Cons (null));
2091 }
2092
2093 public void PerformDefaultAction (Item item, IEnumerable<Type> filter)