From 6a1b3413367c2eda31a7803b95c681c1662d8f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 31 Jan 2013 15:32:02 +0100 Subject: [PATCH] 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 file changed, 25 insertions(+), 4 deletions(-) diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index e45c166bc..3aad5b022 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,