~ubuntu-branches/ubuntu/precise/gnome-do/precise-proposed

« back to all changes in this revision

Viewing changes to Do.Addins/src/Do.Addins/SearchContext.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-09-14 10:09:40 UTC
  • mto: (0.1.8 sid)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20080914100940-kyghudg7py14bu2z
Tags: upstream-0.6.0.0
ImportĀ upstreamĀ versionĀ 0.6.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                
35
35
                string query;
36
36
                Type[] searchTypes;
 
37
                Type[] previousSearchTypes;
37
38
                int cursor;
38
39
                IObject[] results;
39
40
                
154
155
                                return !(ActionSearch || ItemsSearch || ModifierItemsSearch);
155
156
                        }
156
157
                }
 
158
        
 
159
                public bool DefaultFilter
 
160
                {
 
161
                        get {
 
162
                                return (SearchTypes.Length == 2 && (
 
163
                                          SearchTypes[0] == typeof (IItem) && SearchTypes[1] == typeof (IAction) ||
 
164
                                          SearchTypes[0] == typeof (IAction) && SearchTypes[1] == typeof (IItem)));
 
165
                        }
 
166
                }
 
167
                
 
168
                public bool TextMode
 
169
                {
 
170
                        get {
 
171
                                if (SearchTypes.Length == 1 && SearchTypes[0] == typeof (ITextItem)) {
 
172
                                    return true;
 
173
                                }
 
174
                                return false;
 
175
                        }
 
176
                        set {
 
177
                                if (value == true && SupportsTextMode) {
 
178
                                        PreviousSearchTypes = SearchTypes;
 
179
                                        SearchTypes = new Type[] {typeof (ITextItem)};
 
180
                                } else if (value == false) {
 
181
                                        if (PreviousSearchTypes != null)
 
182
                                                SearchTypes = PreviousSearchTypes;
 
183
                                        else
 
184
                                                SearchTypes = new Type[] {typeof (IItem), typeof (IAction)};
 
185
                                }
 
186
                        }
 
187
                }
 
188
                
 
189
                private bool SupportsTextMode
 
190
                {
 
191
                        get {
 
192
                                if (results.Length == 0) return true;
 
193
                                foreach (IObject i in results) {
 
194
                                        if (i is ITextItem) {
 
195
                                                return true;
 
196
                                        }
 
197
                                }
 
198
                                return false;
 
199
                        }
 
200
                }
157
201
                
158
202
                public IObject Selection
159
203
                {
168
212
                
169
213
                public Type[] SearchTypes
170
214
                {
171
 
                        get { return searchTypes; }
172
 
                        set { searchTypes = value; }
 
215
                        get { return searchTypes ??
 
216
                                        searchTypes = new Type[] {typeof (IItem), typeof (IAction)}; }
 
217
                        set {
 
218
                                PreviousSearchTypes = searchTypes;
 
219
                                searchTypes = value;
 
220
                        }
 
221
                }
 
222
                
 
223
                private Type[] PreviousSearchTypes
 
224
                {
 
225
                        get { return previousSearchTypes ??
 
226
                                        previousSearchTypes = new Type[] {typeof (IItem), typeof (IAction)}; }
 
227
                        set {
 
228
                                previousSearchTypes = value;
 
229
                        }
173
230
                }
174
231
                
175
232
                public int Cursor
200
257
                        clone.Results = results.Clone () as IObject[];
201
258
                        clone.ChildrenSearch = childrenSearch;
202
259
                        clone.ParentSearch = parentSearch;
 
260
                        clone.SearchTypes = searchTypes;
203
261
                        return clone;
204
262
                }
205
263