[gnome-shell/app-picker-refresh: 12/16] appDisplay: Add AllView.addFolder() method
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/app-picker-refresh: 12/16] appDisplay: Add AllView.addFolder() method
- Date: Tue, 19 Feb 2013 23:23:04 +0000 (UTC)
commit 6a1b3413367c2eda31a7803b95c681c1662d8f4d
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jan 31 15:32:02 2013 +0100
appDisplay: Add AllView.addFolder() method
Adjust AllView to be able to hold both apps and folders, and add an
addFolder() method to insert a folder.
https://bugzilla.gnome.org/show_bug.cgi?id=694192
js/ui/appDisplay.js | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index e45c166..3aad5b0 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -184,15 +184,29 @@ const AllView = new Lang.Class({
},
_getItemId: function(item) {
- return item.get_id();
+ if (item instanceof Shell.App)
+ return item.get_id();
+ else if (item instanceof GMenu.TreeDirectory)
+ return item.get_menu_id();
+ else
+ return null;
},
_createItemIcon: function(item) {
- return new AppIcon(item);
+ if (item instanceof Shell.App)
+ return new AppIcon(item);
+ else if (item instanceof GMenu.TreeDirectory)
+ return new FolderIcon(item, this);
+ else
+ return null;
},
- _compareItems: function(a, b) {
- return a.compare_by_name(b);
+ _compareItems: function(itemA, itemB) {
+ // bit of a hack: rely on both ShellApp and GMenuTreeDirectory
+ // having a get_name() method
+ let nameA = GLib.utf8_collate_key(itemA.get_name(), -1);
+ let nameB = GLib.utf8_collate_key(itemB.get_name(), -1);
+ return (nameA > nameB) ? 1 : (nameA < nameB ? -1 : 0);
},
addApp: function(app) {
@@ -202,6 +216,13 @@ const AllView = new Lang.Class({
Lang.bind(this, this._ensureIconVisible));
},
+ addFolder: function(dir) {
+ let folderIcon = this._addItem(dir);
+ if (folderIcon)
+ folderIcon.actor.connect('key-focus-in',
+ Lang.bind(this, this._ensureIconVisible));
+ },
+
addFolderPopup: function(popup) {
this._stack.add_actor(popup.actor);
popup.connect('open-state-changed', Lang.bind(this,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]