2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-06-16 12:20:12 -04:00
|
|
|
const DocInfo = imports.misc.docInfo;
|
2011-11-20 11:07:14 -05:00
|
|
|
const Lang = imports.lang;
|
2011-01-30 16:09:58 -05:00
|
|
|
const Params = imports.misc.params;
|
2009-11-29 17:45:30 -05:00
|
|
|
const Search = imports.ui.search;
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2011-11-20 11:07:14 -05:00
|
|
|
const DocSearchProvider = new Lang.Class({
|
|
|
|
Name: 'DocSearchProvider',
|
|
|
|
Extends: Search.SearchProvider,
|
2009-11-29 17:45:30 -05:00
|
|
|
|
|
|
|
_init: function(name) {
|
2011-11-20 11:07:14 -05:00
|
|
|
this.parent(_("RECENT ITEMS"));
|
2009-11-29 17:45:30 -05:00
|
|
|
this._docManager = DocInfo.getDocManager();
|
|
|
|
},
|
|
|
|
|
|
|
|
getResultMeta: function(resultId) {
|
|
|
|
let docInfo = this._docManager.lookupByUri(resultId);
|
|
|
|
if (!docInfo)
|
|
|
|
return null;
|
|
|
|
return { 'id': resultId,
|
|
|
|
'name': docInfo.name,
|
2011-02-28 14:36:52 -05:00
|
|
|
'createIcon': function(size) {
|
|
|
|
return docInfo.createIcon(size);
|
|
|
|
}
|
|
|
|
};
|
2009-11-29 17:45:30 -05:00
|
|
|
},
|
|
|
|
|
2011-01-30 16:09:58 -05:00
|
|
|
activateResult: function(id, params) {
|
2011-08-11 05:35:23 -04:00
|
|
|
params = Params.parse(params, { workspace: -1,
|
|
|
|
timestamp: 0 });
|
2011-01-30 16:09:58 -05:00
|
|
|
|
2009-11-29 17:45:30 -05:00
|
|
|
let docInfo = this._docManager.lookupByUri(id);
|
2011-08-11 05:35:23 -04:00
|
|
|
docInfo.launch(params.workspace);
|
2009-11-29 17:45:30 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
getInitialResultSet: function(terms) {
|
|
|
|
return this._docManager.initialSearch(terms);
|
|
|
|
},
|
|
|
|
|
|
|
|
getSubsearchResultSet: function(previousResults, terms) {
|
|
|
|
return this._docManager.subsearch(previousResults, terms);
|
|
|
|
}
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|