From eb8176deeb1ee9ebe9450d19422ecdeb392380b6 Mon Sep 17 00:00:00 2001 From: Marina Zhurakhinskaya Date: Thu, 1 Oct 2009 17:41:17 -0400 Subject: [PATCH] Fix regressions in the item displays Fix displaying documents in the document browse and refreshing the selection when the results have changed. Make sure we are passing the appropriate flag to _redisplay() in GenericDisplay. Make sure we set this._appsStale to true if there was a change in the applications set. Don't call _refreshCache() from the AppDisplay constructor. Don't short-circuit the call to _refreshCache() from _redisplay() on initial load. Rename _redisplayFull() to recreateDisplayItems() and remove adding an actor to the actual result list in _addDisplayItem() because we redo adding the actors to the list in _redisplayReordering() anyway to ensure that we add them in the right order. Based on a patch from Colin Walters. --- js/ui/appDisplay.js | 20 +++++++++----------- js/ui/docDisplay.js | 2 +- js/ui/genericDisplay.js | 20 ++++++++++++++------ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 206cb79a4..3ced54633 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -186,23 +186,21 @@ AppDisplay.prototype = { this._appsStale = true; this._appSystem.connect('installed-changed', Lang.bind(this, function(appSys) { this._appsStale = true; - this._redisplay(0); - this._redisplayMenus(); + this._redisplay(GenericDisplay.RedisplayFlags.NONE); })); this._appSystem.connect('favorites-changed', Lang.bind(this, function(appSys) { - this._redisplay(0); + this._appsStale = true; + this._redisplay(GenericDisplay.RedisplayFlags.NONE); })); this._appMonitor.connect('app-added', Lang.bind(this, function(monitor) { - this._redisplay(0); + this._appsStale = true; + this._redisplay(GenericDisplay.RedisplayFlags.NONE); })); this._appMonitor.connect('app-removed', Lang.bind(this, function(monitor) { - this._redisplay(0); + this._appsStale = true; + this._redisplay(GenericDisplay.RedisplayFlags.NONE); })); - // Load the apps now so it doesn't slow down the first - // transition into the Overview - this._refreshCache(); - this._focusInMenus = true; this._activeMenuIndex = -1; this._activeMenu = null; @@ -210,7 +208,6 @@ AppDisplay.prototype = { this._menuDisplay = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL, spacing: MENU_SPACING }); - this._redisplayMenus(); this.connect('expanded', Lang.bind(this, function (self) { this._filterReset(); @@ -303,7 +300,7 @@ AppDisplay.prototype = { this._activeMenuApps = this._appSystem.get_applications_for_menu(id); } } - this._redisplay(true); + this._redisplay(GenericDisplay.RedisplayFlags.FULL); })); this._menuDisplay.append(display.actor, 0); }, @@ -361,6 +358,7 @@ AppDisplay.prototype = { this._addApp(app); } } + this._redisplayMenus(); } this._appsStale = false; diff --git a/js/ui/docDisplay.js b/js/ui/docDisplay.js index 74e2c3d8b..87c7bf4aa 100644 --- a/js/ui/docDisplay.js +++ b/js/ui/docDisplay.js @@ -136,7 +136,7 @@ DocDisplay.prototype = { // but redisplaying right away is cool when we use Zephyr. // Also, we might be displaying remote documents, like Google Docs, in the future // which might be edited by someone else. - this._redisplay(false); + this._redisplay(GenericDisplay.RedisplayFlags.NONE); })); this.connect('destroy', Lang.bind(this, function (o) { diff --git a/js/ui/genericDisplay.js b/js/ui/genericDisplay.js index 2ca7c5586..e15df20a4 100644 --- a/js/ui/genericDisplay.js +++ b/js/ui/genericDisplay.js @@ -486,15 +486,16 @@ GenericDisplay.prototype = { //// Protected methods //// - _redisplayFull: function() { + _recreateDisplayItems: function() { this._removeAllDisplayItems(); + this._setDefaultList(); for (let itemId in this._allItems) { this._addDisplayItem(itemId); } }, // Creates a display item based on the information associated with itemId - // and adds it to the displayed items. + // and adds it to the list of displayed items, but does not yet display it. _addDisplayItem : function(itemId) { if (this._displayedItems.hasOwnProperty(itemId)) { log("Tried adding a display item for " + itemId + ", but an item with this item id is already among displayed items."); @@ -525,7 +526,6 @@ GenericDisplay.prototype = { this.emit('show-details', index); } })); - this._list.add_actor(displayItem.actor); this._displayedItems[itemId] = displayItem; }, @@ -635,6 +635,7 @@ GenericDisplay.prototype = { * their own while the user was browsing through the result pages. * SUBSEARCH - Indicates that the current _search is a superstring of the previous * one, which implies we only need to re-search through previous results. + * FULL - Indicates that we need refresh all displayed items. */ _redisplay: function(flags) { let resetPage = (flags & RedisplayFlags.RESET_CONTROLS) > 0; @@ -642,13 +643,20 @@ GenericDisplay.prototype = { let fullReload = (flags & RedisplayFlags.FULL) > 0; let hadSelected = this.hasSelected(); + this.unsetSelected(); - if (!this._initialLoadComplete || !this._refreshCache()) + if (!this._initialLoadComplete) fullReload = true; + + if (!this._refreshCache()) + fullReload = true; + if (fullReload) { + this._recreateDisplayItems(); this._initialLoadComplete = true; - this._redisplayFull(); - } if (isSubSearch) { + } + + if (isSubSearch) { this._redisplaySubSearch(); } else { this._redisplayReordering();