[gnome-shell/app-picker-refresh: 8/16] appDisplay: Make AlphabeticalView an abstract base class of AllView
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/app-picker-refresh: 8/16] appDisplay: Make AlphabeticalView an abstract base class of AllView
- Date: Tue, 19 Feb 2013 23:22:42 +0000 (UTC)
commit 426b227f0356584b9166202fff9c84ec79052104
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Feb 19 23:23:41 2013 +0100
appDisplay: Make AlphabeticalView an abstract base class of AllView
We are going to introduce app folders, which will also present an
alphabetical list of applications, but use a different UI. In
preparation for that, split out the item logic into an abstract
base class.
https://bugzilla.gnome.org/show_bug.cgi?id=694192
js/ui/appDisplay.js | 76 +++++++++++++++++++++++++++++++++++++++------------
1 files changed, 58 insertions(+), 18 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index da87640..2d6a241 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -50,13 +50,55 @@ function _loadCategory(dir, view) {
const AlphabeticalView = new Lang.Class({
Name: 'AlphabeticalView',
+ Abstract: true,
_init: function() {
this._grid = new IconGrid.IconGrid({ xAlign: St.Align.MIDDLE,
columnLimit: MAX_COLUMNS });
- this._appIcons = {}; // desktop file id
- this._allApps = [];
+ this._items = {};
+ this._allItems = [];
+ },
+
+ removeAll: function() {
+ this._grid.removeAll();
+ this._items = {};
+ this._allItems = [];
+ },
+
+ _getItemId: function(item) {
+ throw new Error('Not implemented');
+ },
+
+ _createItemIcon: function(item) {
+ throw new Error('Not implemented');
+ },
+
+ _compareItems: function(a, b) {
+ throw new Error('Not implemented');
+ },
+
+ _addItem: function(item) {
+ let id = this._getItemId(item);
+ if (this._items[id] !== undefined)
+ return null;
+
+ let itemIcon = this._createItemIcon(item);
+ let pos = Util.insertSorted(this._allItems, item, this._compareItems);
+ this._grid.addItem(itemIcon.actor, pos);
+
+ this._items[id] = itemIcon;
+
+ return itemIcon;
+ }
+});
+
+const AllView = new Lang.Class({
+ Name: 'AllView',
+ Extends: AlphabeticalView,
+
+ _init: function() {
+ this.parent();
let box = new St.BoxLayout({ vertical: true });
box.add(this._grid.actor, { y_align: St.Align.START, expand: true });
@@ -80,25 +122,23 @@ const AlphabeticalView = new Lang.Class({
return false;
},
- removeAll: function() {
- this._grid.removeAll();
- this._appIcons = {};
- this._allApps = [];
+ _getItemId: function(item) {
+ return item.get_id();
},
- addApp: function(app) {
- var id = app.get_id();
- if (this._appIcons[id] !== undefined)
- return;
+ _createItemIcon: function(item) {
+ return new AppIcon(item);
+ },
- let appIcon = new AppIcon(app);
- let pos = Util.insertSorted(this._allApps, app, function(a, b) {
- return a.compare_by_name(b);
- });
- this._grid.addItem(appIcon.actor, pos);
- appIcon.actor.connect('key-focus-in', Lang.bind(this, this._ensureIconVisible));
+ _compareItems: function(a, b) {
+ return a.compare_by_name(b);
+ },
- this._appIcons[id] = appIcon;
+ addApp: function(app) {
+ let appIcon = this._addItem(app);
+ if (appIcon)
+ appIcon.actor.connect('key-focus-in',
+ Lang.bind(this, this._ensureIconVisible));
},
_ensureIconVisible: function(icon) {
@@ -142,7 +182,7 @@ const AppDisplay = new Lang.Class({
style_class: 'app-display',
x_fill: true, y_fill: true });
- this._view = new AlphabeticalView();
+ this._view = new AllView();
box.add(this._view.actor, { expand: true });
// We need a dummy actor to catch the keyboard focus if the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]