2009-06-16 16:20:12 +00:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
|
2010-02-09 17:42:07 +00:00
|
|
|
const St = imports.gi.St;
|
2009-11-29 22:45:30 +00:00
|
|
|
const Search = imports.ui.search;
|
2009-06-16 16:20:12 +00:00
|
|
|
|
2011-01-28 23:11:58 +00:00
|
|
|
function ZeitgeistItemInfo(event) {
|
|
|
|
this._init(event);
|
2009-06-16 16:20:12 +00:00
|
|
|
}
|
|
|
|
|
2011-01-28 23:11:58 +00:00
|
|
|
ZeitgeistItemInfo.prototype = {
|
|
|
|
_init : function(event) {
|
|
|
|
this.event = event;
|
|
|
|
this.subject = event.subjects[0];
|
|
|
|
this.timestamp = event.timestamp;
|
|
|
|
this.name = this.subject.text;
|
2009-11-29 22:45:30 +00:00
|
|
|
this._lowerName = this.name.toLowerCase();
|
2011-01-28 23:11:58 +00:00
|
|
|
this.uri = this.subject.uri;
|
|
|
|
this.mimeType = this.subject.mimetype;
|
|
|
|
this.interpretation = this.subject.interpretation;
|
2009-06-16 16:20:12 +00:00
|
|
|
},
|
|
|
|
|
2009-06-29 19:08:48 +00:00
|
|
|
createIcon : function(size) {
|
2011-01-28 23:11:58 +00:00
|
|
|
return St.TextureCache.get_default().load_thumbnail(size, this.uri, this.subject.mimetype);
|
|
|
|
// FIXME: We should consider caching icons
|
2009-06-16 16:20:12 +00:00
|
|
|
},
|
|
|
|
|
2011-01-28 23:11:58 +00:00
|
|
|
launch : function() {
|
|
|
|
Gio.app_info_launch_default_for_uri(this.uri,
|
|
|
|
global.create_app_launch_context());
|
2009-06-16 16:20:12 +00:00
|
|
|
},
|
|
|
|
|
2009-11-29 22:45:30 +00:00
|
|
|
matchTerms: function(terms) {
|
|
|
|
let mtype = Search.MatchType.NONE;
|
|
|
|
for (let i = 0; i < terms.length; i++) {
|
|
|
|
let term = terms[i];
|
|
|
|
let idx = this._lowerName.indexOf(term);
|
|
|
|
if (idx == 0) {
|
|
|
|
mtype = Search.MatchType.PREFIX;
|
|
|
|
} else if (idx > 0) {
|
2010-06-06 23:09:15 +00:00
|
|
|
if (mtype == Search.MatchType.NONE)
|
|
|
|
mtype = Search.MatchType.SUBSTRING;
|
2009-11-29 22:45:30 +00:00
|
|
|
} else {
|
2010-06-06 23:09:15 +00:00
|
|
|
return Search.MatchType.NONE;
|
2009-11-29 22:45:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return mtype;
|
|
|
|
},
|
2010-05-19 17:26:41 +00:00
|
|
|
};
|