Convert some variable and file names to lowerCamelCase.

Remove unused variables in AppDisplay::_filterAdd().

svn path=/trunk/; revision=123
This commit is contained in:
Marina Zhurakhinskaya 2008-12-09 22:10:43 +00:00
parent d42bce21c5
commit 98860733bb
5 changed files with 75 additions and 77 deletions

View File

@ -54,13 +54,13 @@ function AppDisplayItem(node, width) {
} }
AppDisplayItem.prototype = { AppDisplayItem.prototype = {
_init: function(appinfo, width) { _init: function(appInfo, width) {
let me = this; let me = this;
this._appinfo = appinfo; this._appInfo = appInfo;
let name = appinfo.get_name(); let name = appInfo.get_name();
let icontheme = Gtk.IconTheme.get_default(); let iconTheme = Gtk.IconTheme.get_default();
this._group = new Clutter.Group({reactive: true, this._group = new Clutter.Group({reactive: true,
width: width, width: width,
@ -76,10 +76,10 @@ AppDisplayItem.prototype = {
this._group.add_actor(this._bg); this._group.add_actor(this._bg);
this._icon = new Clutter.Texture({ width: 48, height: 48, x: 0, y: 0 }); this._icon = new Clutter.Texture({ width: 48, height: 48, x: 0, y: 0 });
let gicon = appinfo.get_icon(); let gicon = appInfo.get_icon();
let path = null; let path = null;
if (gicon != null) { if (gicon != null) {
let iconinfo = icontheme.lookup_by_gicon(gicon, 48, Gtk.IconLookupFlags.NO_SVG); let iconinfo = iconTheme.lookup_by_gicon(gicon, 48, Gtk.IconLookupFlags.NO_SVG);
if (iconinfo) if (iconinfo)
path = iconinfo.get_filename(); path = iconinfo.get_filename();
} }
@ -88,7 +88,7 @@ AppDisplayItem.prototype = {
this._icon.set_from_file(path); this._icon.set_from_file(path);
this._group.add_actor(this._icon); this._group.add_actor(this._icon);
let comment = appinfo.get_description(); let comment = appInfo.get_description();
let text_width = width - (me._icon.width + 4); let text_width = width - (me._icon.width + 4);
this._name = new Clutter.Label({ color: APPDISPLAY_NAME_COLOR, this._name = new Clutter.Label({ color: APPDISPLAY_NAME_COLOR,
font_name: "Sans 14px", font_name: "Sans 14px",
@ -109,10 +109,10 @@ AppDisplayItem.prototype = {
this.actor = this._group; this.actor = this._group;
}, },
launch: function() { launch: function() {
this._appinfo.launch([], null); this._appInfo.launch([], null);
}, },
appinfo: function () { appInfo: function () {
return this._appinfo; return this._appInfo;
}, },
markSelected: function(isSelected) { markSelected: function(isSelected) {
let color; let color;
@ -137,16 +137,16 @@ AppDisplay.prototype = {
this._search = ''; this._search = '';
this._width = width; this._width = width;
this._height = height; this._height = height;
this._appmonitor = new Shell.AppMonitor(); this._appMonitor = new Shell.AppMonitor();
this._appsStale = true; this._appsStale = true;
this._appmonitor.connect('changed', function(mon) { this._appMonitor.connect('changed', function(mon) {
me._appsStale = true; me._appsStale = true;
}); });
this._grid = new Tidy.Grid({width: width, height: height}); this._grid = new Tidy.Grid({width: width, height: height});
this._appset = {}; // Map<appid, appinfo> this._appSet = {}; // Map<appId, appInfo>
this._displayed = {}; // Map<appid, AppDisplay> this._displayed = {}; // Map<appId, AppDisplay>
this._selectedIndex = -1; this._selectedIndex = -1;
this._max_items = this._height / (APPDISPLAY_HEIGHT + APPDISPLAY_PADDING); this._maxItems = this._height / (APPDISPLAY_HEIGHT + APPDISPLAY_PADDING);
this.actor = this._grid; this.actor = this._grid;
}, },
@ -157,38 +157,38 @@ AppDisplay.prototype = {
return; return;
for (id in this._displayed) for (id in this._displayed)
this._displayed[id].destroy(); this._displayed[id].destroy();
this._appset = {}; this._appSet = {};
this._displayed = {}; this._displayed = {};
this._selectedIndex = -1; this._selectedIndex = -1;
let apps = Gio.app_info_get_all(); let apps = Gio.app_info_get_all();
for (let i = 0; i < apps.length; i++) { for (let i = 0; i < apps.length; i++) {
let appinfo = apps[i]; let appInfo = apps[i];
let appid = appinfo.get_id(); let appId = appInfo.get_id();
this._appset[appid] = appinfo; this._appSet[appId] = appInfo;
} }
this._appsStale = false; this._appsStale = false;
}, },
_removeItem: function(appid) { _removeItem: function(appId) {
let item = this._displayed[appid]; let item = this._displayed[appId];
let group = item.actor; let group = item.actor;
group.destroy(); group.destroy();
delete this._displayed[appid]; delete this._displayed[appId];
}, },
_removeAll: function() { _removeAll: function() {
for (appid in this._displayed) for (appId in this._displayed)
this._removeItem(appid); this._removeItem(appId);
}, },
_setDefaultList: function() { _setDefaultList: function() {
this._removeAll(); this._removeAll();
let added = 0; let added = 0;
for (let i = 0; i < DEFAULT_APPLICATIONS.length && added < this._max_items; i++) { for (let i = 0; i < DEFAULT_APPLICATIONS.length && added < this._maxItems; i++) {
let appid = DEFAULT_APPLICATIONS[i]; let appId = DEFAULT_APPLICATIONS[i];
let appinfo = this._appset[appid]; let appInfo = this._appSet[appId];
if (appinfo) { if (appInfo) {
this._filterAdd(appid); this._filterAdd(appId);
added += 1; added += 1;
} }
} }
@ -200,52 +200,50 @@ AppDisplay.prototype = {
return c; return c;
}, },
_filterAdd: function(appid) { _filterAdd: function(appId) {
let me = this; let me = this;
let appinfo = this._appset[appid]; let appInfo = this._appSet[appId];
let name = appinfo.get_name();
let index = this._getNDisplayed();
let appdisplay = new AppDisplayItem(appinfo, this._width); let appDisplayItem = new AppDisplayItem(appInfo, this._width);
appdisplay.connect('activate', function() { appDisplayItem.connect('activate', function() {
appdisplay.launch(); appDisplayItem.launch();
me.emit('activated'); me.emit('activated');
}); });
let group = appdisplay.actor; let group = appDisplayItem.actor;
this._grid.add_actor(group); this._grid.add_actor(group);
this._displayed[appid] = appdisplay; this._displayed[appId] = appDisplayItem;
}, },
_filterRemove: function(appid) { _filterRemove: function(appId) {
// In the future, do some sort of fade out or other effect here // In the future, do some sort of fade out or other effect here
let item = this._displayed[appid]; let item = this._displayed[appId];
this._removeItem(item); this._removeItem(item);
}, },
_appinfoMatches: function(appinfo, search) { _appInfoMatches: function(appInfo, search) {
if (search == null || search == '') if (search == null || search == '')
return true; return true;
let name = appinfo.get_name().toLowerCase(); let name = appInfo.get_name().toLowerCase();
if (name.indexOf(search) >= 0) if (name.indexOf(search) >= 0)
return true; return true;
let description = appinfo.get_description(); let description = appInfo.get_description();
if (description) { if (description) {
description = description.toLowerCase(); description = description.toLowerCase();
if (description.indexOf(search) >= 0) if (description.indexOf(search) >= 0)
return true; return true;
} }
let exec = appinfo.get_executable().toLowerCase(); let exec = appInfo.get_executable().toLowerCase();
if (exec.indexOf(search) >= 0) if (exec.indexOf(search) >= 0)
return true; return true;
return false; return false;
}, },
_sortApps: function(appids) { _sortApps: function(appIds) {
let me = this; let me = this;
return appids.sort(function (a,b) { return appIds.sort(function (a,b) {
let appA = me._appset[a]; let appA = me._appSet[a];
let appB = me._appset[b]; let appB = me._appSet[b];
return appA.get_name().localeCompare(appB.get_name()); return appA.get_name().localeCompare(appB.get_name());
}); });
}, },
@ -253,14 +251,14 @@ AppDisplay.prototype = {
_doSearchFilter: function() { _doSearchFilter: function() {
this._removeAll(); this._removeAll();
let matchedApps = []; let matchedApps = [];
for (appid in this._appset) { for (appId in this._appSet) {
if (matchedApps.length >= this._max_items) if (matchedApps.length >= this._maxItems)
break; break;
if (this._displayed[appid]) if (this._displayed[appId])
continue; continue;
let app = this._appset[appid]; let app = this._appSet[appId];
if (this._appinfoMatches(app, this._search)) if (this._appInfoMatches(app, this._search))
matchedApps.push(appid); matchedApps.push(appId);
} }
this._sortApps(matchedApps); this._sortApps(matchedApps);
for (let i = 0; i < matchedApps.length; i++) { for (let i = 0; i < matchedApps.length; i++) {
@ -288,8 +286,8 @@ AppDisplay.prototype = {
}, },
_findDisplayedByActor: function(actor) { _findDisplayedByActor: function(actor) {
for (appid in this._displayed) { for (appId in this._displayed) {
let item = this._displayed[appid]; let item = this._displayed[appId];
if (item.actor == actor) { if (item.actor == actor) {
return item; return item;
} }

View File

@ -8,8 +8,8 @@ const Tweener = imports.tweener.tweener;
const Panel = imports.ui.panel; const Panel = imports.ui.panel;
const Overlay = imports.ui.overlay; const Overlay = imports.ui.overlay;
const RunDialog = imports.ui.run_dialog; const RunDialog = imports.ui.runDialog;
const WindowManager = imports.ui.windowmanager; const WindowManager = imports.ui.windowManager;
const DEFAULT_BACKGROUND_COLOR = new Clutter.Color(); const DEFAULT_BACKGROUND_COLOR = new Clutter.Color();
DEFAULT_BACKGROUND_COLOR.from_pixel(0x2266bbff); DEFAULT_BACKGROUND_COLOR.from_pixel(0x2266bbff);
@ -17,7 +17,7 @@ DEFAULT_BACKGROUND_COLOR.from_pixel(0x2266bbff);
let panel = null; let panel = null;
let overlay = null; let overlay = null;
let overlayActive = false; let overlayActive = false;
let run_dialog = null; let runDialog = null;
let wm = null; let wm = null;
// The "FrameTicker" object is an object used to feed new frames to Tweener // The "FrameTicker" object is an object used to feed new frames to Tweener
@ -103,15 +103,15 @@ function start() {
global.connect('panel-run-dialog', function(panel) { global.connect('panel-run-dialog', function(panel) {
// Make sure not more than one run dialog is shown. // Make sure not more than one run dialog is shown.
if (!run_dialog) { if (!runDialog) {
run_dialog = new RunDialog.RunDialog(); runDialog = new RunDialog.RunDialog();
let end_handler = function() { let end_handler = function() {
run_dialog.destroy(); runDialog.destroy();
run_dialog = null; runDialog = null;
}; };
run_dialog.connect('run', end_handler); runDialog.connect('run', end_handler);
run_dialog.connect('cancel', end_handler); runDialog.connect('cancel', end_handler);
if (!run_dialog.show()) if (!runDialog.show())
end_handler(); end_handler();
} }
}); });

View File

@ -13,7 +13,7 @@ const Panel = imports.ui.panel;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Big = imports.gi.Big; const Big = imports.gi.Big;
const AppDisplay = imports.ui.appdisplay; const AppDisplay = imports.ui.appDisplay;
const OVERLAY_BACKGROUND_COLOR = new Clutter.Color(); const OVERLAY_BACKGROUND_COLOR = new Clutter.Color();
OVERLAY_BACKGROUND_COLOR.from_pixel(0x000000ff); OVERLAY_BACKGROUND_COLOR.from_pixel(0x000000ff);
@ -75,13 +75,13 @@ Sideshow.prototype = {
let text = me._searchEntry.text; let text = me._searchEntry.text;
me._searchQueued = false; me._searchQueued = false;
me._searchActive = text != ''; me._searchActive = text != '';
me._appdisplay.setSearch(text); me._appDisplay.setSearch(text);
return false; return false;
}); });
}); });
this._searchEntry.connect('activate', function (se) { this._searchEntry.connect('activate', function (se) {
me._searchEntry.text = ''; me._searchEntry.text = '';
me._appdisplay.searchActivate(); me._appDisplay.searchActivate();
return true; return true;
}); });
this._searchEntry.connect('key-press-event', function (se, e) { this._searchEntry.connect('key-press-event', function (se, e) {
@ -90,10 +90,10 @@ Sideshow.prototype = {
me._searchEntry.text = ''; me._searchEntry.text = '';
return true; return true;
} else if (code == 111) { } else if (code == 111) {
me._appdisplay.selectUp(); me._appDisplay.selectUp();
return true; return true;
} else if (code == 116) { } else if (code == 116) {
me._appdisplay.selectDown(); me._appDisplay.selectDown();
return true; return true;
} }
return false; return false;
@ -108,19 +108,19 @@ Sideshow.prototype = {
this.actor.add_actor(appsText); this.actor.add_actor(appsText);
let menuY = appsText.y + appsText.height + 6; let menuY = appsText.y + appsText.height + 6;
this._appdisplay = new AppDisplay.AppDisplay(width, global.screen_height - menuY); this._appDisplay = new AppDisplay.AppDisplay(width, global.screen_height - menuY);
this._appdisplay.actor.x = SIDESHOW_PAD; this._appDisplay.actor.x = SIDESHOW_PAD;
this._appdisplay.actor.y = menuY; this._appDisplay.actor.y = menuY;
this.actor.add_actor(this._appdisplay.actor); this.actor.add_actor(this._appDisplay.actor);
/* Proxy the activated signal */ /* Proxy the activated signal */
this._appdisplay.connect('activated', function(appdisplay) { this._appDisplay.connect('activated', function(appDisplay) {
me.emit('activated'); me.emit('activated');
}); });
}, },
show: function() { show: function() {
this._appdisplay.show(); this._appDisplay.show();
}, },
hide: function() { hide: function() {