appDisplay: Merge AppIcon and AppWellIcon

AppIcon is just a tiny wrapper around BaseIcon, which does not add
anything over using BaseIcon directly, so merge its code with
AppWellIcon. As the concept of the "app well" has not been used
since well before 3.0, use AppIcon as name for the merged class.

https://bugzilla.gnome.org/show_bug.cgi?id=694192
This commit is contained in:
Florian Müllner 2013-01-30 23:51:43 +01:00
parent 77d8ff3620
commit 2658754295
2 changed files with 18 additions and 26 deletions

View File

@ -71,7 +71,7 @@ const AlphabeticalView = new Lang.Class({
if (this._appIcons[id] !== undefined) if (this._appIcons[id] !== undefined)
return; return;
let appIcon = new AppWellIcon(app); let appIcon = new AppIcon(app);
let pos = Util.insertSorted(this._allApps, app, function(a, b) { let pos = Util.insertSorted(this._allApps, app, function(a, b) {
return a.compare_by_name(b); return a.compare_by_name(b);
}); });
@ -250,30 +250,14 @@ const AppSearchProvider = new Lang.Class({
createResultActor: function (resultMeta, terms) { createResultActor: function (resultMeta, terms) {
let app = resultMeta['id']; let app = resultMeta['id'];
let icon = new AppWellIcon(app); let icon = new AppIcon(app);
return icon.actor; return icon.actor;
} }
}); });
const AppIcon = new Lang.Class({ const AppIcon = new Lang.Class({
Name: 'AppIcon', Name: 'AppIcon',
Extends: IconGrid.BaseIcon,
_init : function(app, params) {
this.app = app;
let label = this.app.get_name();
this.parent(label, params);
},
createIcon: function(iconSize) {
return this.app.create_icon_texture(iconSize);
}
});
const AppWellIcon = new Lang.Class({
Name: 'AppWellIcon',
_init : function(app, iconParams) { _init : function(app, iconParams) {
this.app = app; this.app = app;
@ -285,7 +269,11 @@ const AppWellIcon = new Lang.Class({
y_fill: true }); y_fill: true });
this.actor._delegate = this; this.actor._delegate = this;
this.icon = new AppIcon(app, iconParams); if (!iconParams)
iconParams = {};
iconParams['createIcon'] = Lang.bind(this, this._createIcon);
this.icon = new IconGrid.BaseIcon(app.get_name(), iconParams);
this.actor.set_child(this.icon.actor); this.actor.set_child(this.icon.actor);
this.actor.label_actor = this.icon.label; this.actor.label_actor = this.icon.label;
@ -328,6 +316,10 @@ const AppWellIcon = new Lang.Class({
this._removeMenuTimeout(); this._removeMenuTimeout();
}, },
_createIcon: function(iconSize) {
return this.app.create_icon_texture(iconSize);
},
_removeMenuTimeout: function() { _removeMenuTimeout: function() {
if (this._menuTimeoutId > 0) { if (this._menuTimeoutId > 0) {
Mainloop.source_remove(this._menuTimeoutId); Mainloop.source_remove(this._menuTimeoutId);
@ -453,7 +445,7 @@ const AppWellIcon = new Lang.Class({
return this.icon.icon; return this.icon.icon;
} }
}); });
Signals.addSignalMethods(AppWellIcon.prototype); Signals.addSignalMethods(AppIcon.prototype);
const AppIconMenu = new Lang.Class({ const AppIconMenu = new Lang.Class({
Name: 'AppIconMenu', Name: 'AppIconMenu',

View File

@ -22,7 +22,7 @@ const DASH_ITEM_LABEL_HIDE_TIME = 0.1;
const DASH_ITEM_HOVER_TIMEOUT = 300; const DASH_ITEM_HOVER_TIMEOUT = 300;
function getAppFromSource(source) { function getAppFromSource(source) {
if (source instanceof AppDisplay.AppWellIcon) { if (source instanceof AppDisplay.AppIcon) {
return source.app; return source.app;
} else { } else {
return null; return null;
@ -486,9 +486,9 @@ const Dash = new Lang.Class({
}, },
_createAppItem: function(app) { _createAppItem: function(app) {
let appIcon = new AppDisplay.AppWellIcon(app, let appIcon = new AppDisplay.AppIcon(app,
{ setSizeManually: true, { setSizeManually: true,
showLabel: false }); showLabel: false });
appIcon._draggable.connect('drag-begin', appIcon._draggable.connect('drag-begin',
Lang.bind(this, function() { Lang.bind(this, function() {
appIcon.actor.opacity = 50; appIcon.actor.opacity = 50;
@ -505,7 +505,7 @@ const Dash = new Lang.Class({
let item = new DashItemContainer(); let item = new DashItemContainer();
item.setChild(appIcon.actor); item.setChild(appIcon.actor);
// Override default AppWellIcon label_actor, now the // Override default AppIcon label_actor, now the
// accessible_name is set at DashItemContainer.setLabelText // accessible_name is set at DashItemContainer.setLabelText
appIcon.actor.label_actor = null; appIcon.actor.label_actor = null;
item.setLabelText(app.get_name()); item.setLabelText(app.get_name());