2008-12-01 14:51:43 -05:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
const Big = imports.gi.Big;
|
2008-11-20 19:53:11 -05:00
|
|
|
const Clutter = imports.gi.Clutter;
|
2009-04-01 15:51:17 -04:00
|
|
|
const Pango = imports.gi.Pango;
|
2008-11-20 19:53:11 -05:00
|
|
|
const Gio = imports.gi.Gio;
|
|
|
|
const Gtk = imports.gi.Gtk;
|
|
|
|
const Shell = imports.gi.Shell;
|
2009-04-01 15:51:17 -04:00
|
|
|
const Lang = imports.lang;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Signals = imports.signals;
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2009-06-16 12:20:12 -04:00
|
|
|
const AppInfo = imports.misc.appInfo;
|
2008-12-19 23:27:57 -05:00
|
|
|
const GenericDisplay = imports.ui.genericDisplay;
|
2009-04-01 15:51:17 -04:00
|
|
|
|
|
|
|
const ENTERED_MENU_COLOR = new Clutter.Color();
|
|
|
|
ENTERED_MENU_COLOR.from_pixel(0x00ff0022);
|
|
|
|
|
|
|
|
const MENU_ICON_SIZE = 24;
|
|
|
|
const MENU_SPACING = 15;
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2009-04-23 10:41:24 -04:00
|
|
|
const MAX_ITEMS = 30;
|
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
/* This class represents a single display item containing information about an application.
|
|
|
|
*
|
2009-06-16 12:20:12 -04:00
|
|
|
* appInfo - AppInfo object containing information about the application
|
2008-12-19 23:27:57 -05:00
|
|
|
* availableWidth - total width available for the item
|
|
|
|
*/
|
|
|
|
function AppDisplayItem(appInfo, availableWidth) {
|
|
|
|
this._init(appInfo, availableWidth);
|
2008-11-20 19:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
AppDisplayItem.prototype = {
|
2008-12-19 23:27:57 -05:00
|
|
|
__proto__: GenericDisplay.GenericDisplayItem.prototype,
|
|
|
|
|
|
|
|
_init : function(appInfo, availableWidth) {
|
|
|
|
GenericDisplay.GenericDisplayItem.prototype._init.call(this, availableWidth);
|
2008-12-09 17:10:43 -05:00
|
|
|
this._appInfo = appInfo;
|
2008-12-01 14:51:43 -05:00
|
|
|
|
2009-06-16 12:20:12 -04:00
|
|
|
this._setItemInfo(appInfo.name, appInfo.description,
|
|
|
|
appInfo.getIcon(GenericDisplay.ITEM_DISPLAY_ICON_SIZE));
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
2008-12-19 23:27:57 -05:00
|
|
|
|
|
|
|
//// Public method overrides ////
|
|
|
|
|
|
|
|
// Opens an application represented by this display item.
|
|
|
|
launch : function() {
|
2009-06-16 12:20:12 -04:00
|
|
|
this._appInfo.launch();
|
2009-03-20 12:06:34 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
//// Protected method overrides ////
|
|
|
|
|
|
|
|
// Ensures the preview icon is created.
|
|
|
|
_ensurePreviewIconCreated : function() {
|
2009-03-21 10:37:15 -04:00
|
|
|
if (!this._showPreview || this._previewIcon)
|
2009-03-20 12:06:34 -04:00
|
|
|
return;
|
|
|
|
|
2009-06-16 12:20:12 -04:00
|
|
|
let previewIconPath = this._appInfo.getIconPath(GenericDisplay.PREVIEW_ICON_SIZE);
|
2009-03-20 12:06:34 -04:00
|
|
|
if (previewIconPath) {
|
|
|
|
try {
|
|
|
|
this._previewIcon = new Clutter.Texture({ width: GenericDisplay.PREVIEW_ICON_SIZE, height: GenericDisplay.PREVIEW_ICON_SIZE});
|
|
|
|
this._previewIcon.set_from_file(previewIconPath);
|
|
|
|
} catch (e) {
|
|
|
|
// we can get an error here if the file path doesn't exist on the system
|
|
|
|
log('Error loading AppDisplayItem preview icon ' + e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-19 23:27:57 -05:00
|
|
|
};
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
const MENU_UNSELECTED = 0;
|
|
|
|
const MENU_SELECTED = 1;
|
|
|
|
const MENU_ENTERED = 2;
|
|
|
|
|
2009-05-02 18:33:13 -04:00
|
|
|
function MenuItem(name, id, iconName) {
|
|
|
|
this._init(name, id, iconName);
|
2009-04-01 15:51:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MenuItem:
|
|
|
|
* Shows the list of menus in the sidebar.
|
|
|
|
*/
|
|
|
|
MenuItem.prototype = {
|
2009-05-02 18:33:13 -04:00
|
|
|
_init: function(name, id, iconName) {
|
2009-04-01 15:51:17 -04:00
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
|
|
|
spacing: 4,
|
|
|
|
corner_radius: 4,
|
|
|
|
padding_right: 4,
|
|
|
|
reactive: true });
|
|
|
|
this.actor.connect('button-press-event', Lang.bind(this, function (a, e) {
|
|
|
|
this.setState(MENU_SELECTED);
|
|
|
|
}));
|
|
|
|
|
|
|
|
let iconTheme = Gtk.IconTheme.get_default();
|
|
|
|
let pixbuf = null;
|
|
|
|
this._icon = new Clutter.Texture({ width: MENU_ICON_SIZE,
|
|
|
|
height: MENU_ICON_SIZE });
|
|
|
|
// Wine manages not to have an icon
|
|
|
|
try {
|
2009-05-02 18:33:13 -04:00
|
|
|
pixbuf = iconTheme.load_icon(iconName, MENU_ICON_SIZE, 0 /* flags */);
|
2009-04-01 15:51:17 -04:00
|
|
|
} catch (e) {
|
|
|
|
pixbuf = iconTheme.load_icon('gtk-file', MENU_ICON_SIZE, 0);
|
|
|
|
}
|
|
|
|
if (pixbuf != null)
|
|
|
|
Shell.clutter_texture_set_from_pixbuf(this._icon, pixbuf);
|
|
|
|
this.actor.append(this._icon, 0);
|
|
|
|
this._text = new Clutter.Text({ color: GenericDisplay.ITEM_DISPLAY_NAME_COLOR,
|
|
|
|
font_name: "Sans 14px",
|
|
|
|
ellipsize: Pango.EllipsizeMode.END,
|
|
|
|
text: name });
|
|
|
|
this.actor.append(this._text, Big.BoxPackFlags.EXPAND);
|
|
|
|
|
|
|
|
let box = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
|
|
|
y_align: Big.BoxAlignment.CENTER
|
|
|
|
});
|
|
|
|
|
|
|
|
this._arrow = new Shell.Arrow({ surface_width: MENU_ICON_SIZE/2,
|
|
|
|
surface_height: MENU_ICON_SIZE/2,
|
|
|
|
direction: Gtk.ArrowType.RIGHT,
|
|
|
|
opacity: 0
|
|
|
|
});
|
|
|
|
box.append(this._arrow, 0);
|
|
|
|
this.actor.append(box, 0);
|
|
|
|
},
|
|
|
|
|
|
|
|
getState: function() {
|
|
|
|
return this._state;
|
|
|
|
},
|
|
|
|
|
|
|
|
setState: function (state) {
|
|
|
|
if (state == this._state)
|
|
|
|
return;
|
|
|
|
this._state = state;
|
|
|
|
if (this._state == MENU_UNSELECTED) {
|
|
|
|
this.actor.background_color = null;
|
|
|
|
this._arrow.set_opacity(0);
|
|
|
|
} else if (this._state == MENU_ENTERED) {
|
|
|
|
this.actor.background_color = ENTERED_MENU_COLOR;
|
|
|
|
this._arrow.set_opacity(0xFF/2);
|
|
|
|
} else {
|
|
|
|
this.actor.background_color = GenericDisplay.ITEM_DISPLAY_SELECTED_BACKGROUND_COLOR;
|
|
|
|
this._arrow.set_opacity(0xFF);
|
|
|
|
}
|
|
|
|
this.emit('state-changed')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Signals.addSignalMethods(MenuItem.prototype);
|
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
/* This class represents a display containing a collection of application items.
|
|
|
|
* The applications are sorted based on their popularity by default, and based on
|
|
|
|
* their name if some search filter is applied.
|
|
|
|
*
|
|
|
|
* width - width available for the display
|
|
|
|
* height - height available for the display
|
|
|
|
*/
|
2009-02-10 17:38:06 -05:00
|
|
|
function AppDisplay(width, height, numberOfColumns, columnGap) {
|
|
|
|
this._init(width, height, numberOfColumns, columnGap);
|
2008-11-20 19:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
AppDisplay.prototype = {
|
2008-12-19 23:27:57 -05:00
|
|
|
__proto__: GenericDisplay.GenericDisplay.prototype,
|
|
|
|
|
2009-02-10 17:38:06 -05:00
|
|
|
_init : function(width, height, numberOfColumns, columnGap) {
|
|
|
|
GenericDisplay.GenericDisplay.prototype._init.call(this, width, height, numberOfColumns, columnGap);
|
2009-01-21 16:50:57 -05:00
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
this._menus = [];
|
|
|
|
this._menuDisplays = [];
|
|
|
|
|
2009-01-21 16:50:57 -05:00
|
|
|
// map<itemId, array of category names>
|
2009-04-01 15:51:17 -04:00
|
|
|
this._appCategories = {};
|
2009-04-23 10:41:24 -04:00
|
|
|
|
2009-06-18 12:27:19 -04:00
|
|
|
this._appMonitor = Shell.AppMonitor.get_default();
|
|
|
|
this._appSystem = Shell.AppSystem.get_default();
|
2008-12-01 14:51:43 -05:00
|
|
|
this._appsStale = true;
|
2009-04-23 10:41:24 -04:00
|
|
|
this._appSystem.connect('changed', Lang.bind(this, function(appSys) {
|
|
|
|
this._appsStale = true;
|
2008-12-19 23:27:57 -05:00
|
|
|
// We still need to determine what events other than search can trigger
|
|
|
|
// a change in the set of applications that are being shown while the
|
|
|
|
// user in in the overlay mode, however let's redisplay just in case.
|
2009-04-23 10:41:24 -04:00
|
|
|
this._redisplay(false);
|
|
|
|
this._redisplayMenus();
|
|
|
|
}));
|
|
|
|
this._appMonitor.connect('changed', Lang.bind(this, function(monitor) {
|
2009-06-17 18:42:05 -04:00
|
|
|
this._appsStale = true;
|
2009-05-14 14:14:18 -04:00
|
|
|
this._redisplay(false);
|
2009-04-23 10:41:24 -04:00
|
|
|
}));
|
2009-01-13 15:45:54 -05:00
|
|
|
|
|
|
|
// Load the GAppInfos now so it doesn't slow down the first
|
|
|
|
// transition into the overlay
|
|
|
|
this._refreshCache();
|
2009-04-01 15:51:17 -04:00
|
|
|
|
|
|
|
this._focusInMenus = true;
|
|
|
|
this._activeMenuIndex = -1;
|
|
|
|
this._activeMenu = null;
|
|
|
|
this._activeMenuApps = null;
|
|
|
|
this._menuDisplay = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
|
|
|
spacing: MENU_SPACING
|
|
|
|
});
|
|
|
|
this._redisplayMenus();
|
|
|
|
|
|
|
|
this.connect('expanded', Lang.bind(this, function (self) {
|
|
|
|
this._filterReset();
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
moveRight: function() {
|
|
|
|
if (this._expanded && this._focusInMenu) {
|
|
|
|
this._focusInMenu = false;
|
|
|
|
this._activeMenu.setState(MENU_ENTERED);
|
|
|
|
this.selectFirstItem();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
moveLeft: function() {
|
|
|
|
if (this._expanded && !this._focusInMenu) {
|
|
|
|
this._activeMenu.setState(MENU_SELECTED);
|
|
|
|
this.unsetSelected();
|
|
|
|
this._focusInMenu = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Override genericDisplay.js
|
|
|
|
getSideArea: function() {
|
|
|
|
return this._menuDisplay;
|
|
|
|
},
|
|
|
|
|
|
|
|
selectUp: function() {
|
|
|
|
if (!(this._expanded && this._focusInMenu))
|
|
|
|
return GenericDisplay.GenericDisplay.prototype.selectUp.call(this);
|
|
|
|
this._selectMenuIndex(this._activeMenuIndex - 1);
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
selectDown: function() {
|
|
|
|
if (!(this._expanded && this._focusInMenu))
|
|
|
|
return GenericDisplay.GenericDisplay.prototype.selectDown.call(this);
|
|
|
|
this._selectMenuIndex(this._activeMenuIndex+1);
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Protected overrides
|
|
|
|
|
|
|
|
_filterActive: function() {
|
|
|
|
return !!this._search || this._activeMenuIndex >= 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
_filterReset: function() {
|
|
|
|
GenericDisplay.GenericDisplay.prototype._filterReset.call(this);
|
|
|
|
if (this._activeMenu != null)
|
|
|
|
this._activeMenu.setState(MENU_UNSELECTED);
|
|
|
|
this._activeMenuIndex = -1;
|
|
|
|
this._activeMenu = null;
|
|
|
|
this._focusInMenu = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
//// Private ////
|
|
|
|
|
|
|
|
_emitStateChange: function() {
|
|
|
|
this.emit('state-changed');
|
|
|
|
},
|
|
|
|
|
|
|
|
_selectMenuIndex: function(index) {
|
|
|
|
if (index < 0 || index >= this._menus.length)
|
|
|
|
return;
|
2009-04-13 15:41:13 -04:00
|
|
|
this._menuDisplays[index].setState(MENU_SELECTED);
|
2009-04-01 15:51:17 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_redisplayMenus: function() {
|
|
|
|
this._menuDisplay.remove_all();
|
|
|
|
for (let i = 0; i < this._menus.length; i++) {
|
|
|
|
let menu = this._menus[i];
|
|
|
|
let display = new MenuItem(menu.name, menu.id, menu.icon);
|
|
|
|
this._menuDisplays.push(display);
|
|
|
|
let menuIndex = i;
|
|
|
|
display.connect('state-changed', Lang.bind(this, function (display) {
|
|
|
|
let activated = display.getState() != MENU_UNSELECTED;
|
|
|
|
if (!activated && display == this._activeMenu) {
|
|
|
|
this._activeMenuIndex = -1;
|
|
|
|
this._activeMenu = null;
|
|
|
|
} else if (activated) {
|
2009-04-13 15:41:13 -04:00
|
|
|
if (display != this._activeMenu && this._activeMenu != null)
|
|
|
|
this._activeMenu.setState(MENU_UNSELECTED);
|
2009-04-01 15:51:17 -04:00
|
|
|
this._activeMenuIndex = menuIndex;
|
|
|
|
this._activeMenu = display;
|
2009-04-22 15:21:35 -04:00
|
|
|
this._activeMenuApps = this._appSystem.get_applications_for_menu(menu.id);
|
2009-04-01 15:51:17 -04:00
|
|
|
}
|
|
|
|
this._redisplay();
|
|
|
|
}));
|
|
|
|
this._menuDisplay.append(display.actor, 0);
|
|
|
|
}
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
|
|
|
|
2009-06-17 18:42:05 -04:00
|
|
|
_addAppForId: function(appId) {
|
2009-06-16 12:20:12 -04:00
|
|
|
let appInfo = AppInfo.getAppInfo(appId);
|
2009-05-14 14:14:18 -04:00
|
|
|
if (appInfo != null) {
|
2009-06-17 18:42:05 -04:00
|
|
|
this._addApp(appInfo);
|
2009-05-14 14:14:18 -04:00
|
|
|
} else {
|
|
|
|
log("appInfo for " + appId + " was not found.");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-06-17 18:42:05 -04:00
|
|
|
_addApp: function(appInfo) {
|
|
|
|
let appId = appInfo.id;
|
|
|
|
this._allItems[appId] = appInfo;
|
|
|
|
// [] is returned if we could not get the categories or the list of categories was empty
|
|
|
|
let categories = Shell.get_categories_for_desktop_file(appId);
|
|
|
|
this._appCategories[appId] = categories;
|
|
|
|
},
|
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
//// Protected method overrides ////
|
2008-12-01 14:51:43 -05:00
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
// Gets information about all applications by calling Gio.app_info_get_all().
|
|
|
|
_refreshCache : function() {
|
|
|
|
let me = this;
|
2008-12-01 14:51:43 -05:00
|
|
|
if (!this._appsStale)
|
|
|
|
return;
|
2008-12-19 23:27:57 -05:00
|
|
|
this._allItems = {};
|
2009-04-01 15:51:17 -04:00
|
|
|
this._appCategories = {};
|
|
|
|
|
2009-04-22 15:21:35 -04:00
|
|
|
this._menus = this._appSystem.get_menus();
|
2009-04-01 15:51:17 -04:00
|
|
|
|
2009-05-14 14:14:18 -04:00
|
|
|
// Loop over the toplevel menu items, load the set of desktop file ids
|
|
|
|
// associated with each one
|
|
|
|
for (let i = 0; i < this._menus.length; i++) {
|
|
|
|
let menu = this._menus[i];
|
|
|
|
let menuApps = this._appSystem.get_applications_for_menu(menu.id);
|
|
|
|
for (let j = 0; j < menuApps.length; j++) {
|
|
|
|
let appId = menuApps[j];
|
2009-06-17 18:42:05 -04:00
|
|
|
this._addAppForId(appId);
|
2009-05-14 14:14:18 -04:00
|
|
|
}
|
2008-12-01 14:51:43 -05:00
|
|
|
}
|
2009-05-14 14:14:18 -04:00
|
|
|
|
|
|
|
// Now grab the desktop file ids for settings/preferences.
|
|
|
|
// These show up in search, but not with the rest of apps.
|
|
|
|
let settings = this._appSystem.get_all_settings();
|
|
|
|
for (let i = 0; i < settings.length; i++) {
|
|
|
|
let appId = settings[i];
|
2009-06-17 18:42:05 -04:00
|
|
|
this._addAppForId(appId);
|
2009-05-14 14:14:18 -04:00
|
|
|
}
|
|
|
|
|
2009-06-17 18:42:05 -04:00
|
|
|
// Some applications, such as Evince, might not be in the menus,
|
|
|
|
// but might be returned by the applications monitor as most used
|
|
|
|
// applications, in which case we include them.
|
|
|
|
let mostUsedAppInfos = AppInfo.getMostUsedApps(MAX_ITEMS);
|
|
|
|
for (let i = 0; i < mostUsedAppInfos.length; i++) {
|
|
|
|
let appInfo = mostUsedAppInfos[i];
|
|
|
|
this._addApp(appInfo);
|
|
|
|
}
|
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
this._appsStale = false;
|
|
|
|
},
|
|
|
|
|
2009-04-23 10:41:24 -04:00
|
|
|
// Sets the list of the displayed items based on the most used apps.
|
2008-12-19 23:27:57 -05:00
|
|
|
_setDefaultList : function() {
|
2009-06-16 12:20:12 -04:00
|
|
|
let matchedInfos = AppInfo.getMostUsedApps(MAX_ITEMS);
|
|
|
|
this._matchedItems = matchedInfos.map(function(info) { return info.appId; });
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
|
|
|
|
2009-02-10 14:12:13 -05:00
|
|
|
// Compares items associated with the item ids based on the alphabetical order
|
|
|
|
// of the item names.
|
|
|
|
// Returns an integer value indicating the result of the comparison.
|
|
|
|
_compareItems : function(itemIdA, itemIdB) {
|
|
|
|
let appA = this._allItems[itemIdA];
|
|
|
|
let appB = this._allItems[itemIdB];
|
2009-06-17 12:37:54 -04:00
|
|
|
return appA.name.localeCompare(appB.name);
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
// Checks if the item info can be a match for the search string by checking
|
2009-01-21 16:50:57 -05:00
|
|
|
// the name, description, execution command, and categories for the application.
|
2008-12-19 23:27:57 -05:00
|
|
|
// Item info is expected to be GAppInfo.
|
|
|
|
// Returns a boolean flag indicating if itemInfo is a match.
|
|
|
|
_isInfoMatching : function(itemInfo, search) {
|
2009-04-01 15:51:17 -04:00
|
|
|
// Search takes precedence; not typically useful to search within a
|
|
|
|
// menu
|
|
|
|
if (this._activeMenu == null || search != "")
|
|
|
|
return this._isInfoMatchingSearch(itemInfo, search);
|
|
|
|
else
|
|
|
|
return this._isInfoMatchingMenu(itemInfo, search);
|
|
|
|
},
|
|
|
|
|
|
|
|
_isInfoMatchingMenu : function(itemInfo, search) {
|
2009-06-17 12:37:54 -04:00
|
|
|
let id = itemInfo.id;
|
2009-04-01 15:51:17 -04:00
|
|
|
for (let i = 0; i < this._activeMenuApps.length; i++) {
|
|
|
|
let activeId = this._activeMenuApps[i];
|
|
|
|
if (activeId == id)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
_isInfoMatchingSearch: function(itemInfo, search) {
|
2008-12-01 14:51:43 -05:00
|
|
|
if (search == null || search == '')
|
|
|
|
return true;
|
2009-01-21 16:50:57 -05:00
|
|
|
|
2009-06-17 12:37:54 -04:00
|
|
|
let name = itemInfo.name.toLowerCase();
|
2008-12-01 14:51:43 -05:00
|
|
|
if (name.indexOf(search) >= 0)
|
|
|
|
return true;
|
2009-01-21 16:50:57 -05:00
|
|
|
|
2009-06-17 12:37:54 -04:00
|
|
|
let description = itemInfo.description;
|
2008-12-01 14:51:43 -05:00
|
|
|
if (description) {
|
|
|
|
description = description.toLowerCase();
|
|
|
|
if (description.indexOf(search) >= 0)
|
|
|
|
return true;
|
|
|
|
}
|
2009-01-21 16:50:57 -05:00
|
|
|
|
2009-06-17 12:37:54 -04:00
|
|
|
if (itemInfo.executable == null) {
|
|
|
|
log("Missing an executable for " + itemInfo.name);
|
2009-01-22 16:28:19 -05:00
|
|
|
} else {
|
2009-06-17 12:37:54 -04:00
|
|
|
let exec = itemInfo.executable.toLowerCase();
|
2009-01-22 16:28:19 -05:00
|
|
|
if (exec.indexOf(search) >= 0)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-17 12:37:54 -04:00
|
|
|
// we expect this._appCategories.hasOwnProperty(itemInfo.id) to always be true here
|
|
|
|
let categories = this._appCategories[itemInfo.id];
|
2009-05-26 12:56:38 -04:00
|
|
|
for (let i = 0; i < categories.length; i++) {
|
|
|
|
let category = categories[i].toLowerCase();
|
|
|
|
if (category.indexOf(search) >= 0)
|
|
|
|
return true;
|
2009-01-21 16:50:57 -05:00
|
|
|
}
|
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2009-06-16 12:20:12 -04:00
|
|
|
// Creates an AppDisplayItem based on itemInfo, which is expected be an AppInfo object.
|
2008-12-19 23:27:57 -05:00
|
|
|
_createDisplayItem: function(itemInfo) {
|
2009-02-03 17:58:33 -05:00
|
|
|
return new AppDisplayItem(itemInfo, this._columnWidth);
|
2009-04-01 15:51:17 -04:00
|
|
|
}
|
2008-12-01 14:51:43 -05:00
|
|
|
};
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
Signals.addSignalMethods(AppDisplay.prototype);
|