From 4406943fd838c9944bc1b11c6277d3a2680b10fb Mon Sep 17 00:00:00 2001 From: Marina Zhurakhinskaya Date: Thu, 8 Jan 2009 23:31:23 +0000 Subject: [PATCH] Check if the file still exists when displaying matches for the search. Use get_modified() instead of get_visited() for GtkRecentInfo as get_modified() seems to reflect when the file was last modified or visted, while get_visited() stays the same as get_added(). See http://bugzilla.gnome.org/show_bug.cgi?id=567094 svn path=/trunk/; revision=141 --- js/ui/docDisplay.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/ui/docDisplay.js b/js/ui/docDisplay.js index 9644c23fb..e115276ca 100644 --- a/js/ui/docDisplay.js +++ b/js/ui/docDisplay.js @@ -121,9 +121,9 @@ DocDisplay.prototype = { // properties are returned during the iteration in the same order in which they were // defined, but it is not a guarantee according to this // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/for...in - // So while this._allItems associative array seems to always be ordered by last visited, + // While this._allItems associative array seems to always be ordered by last added, // as the results of this._recentManager.get_items() based on which it is constructed are, - // we should do the sorting manually anyway. + // we should do the sorting manually because we want the order to be based on last visited. // TODO: would it be better to store an additional array of doc ids as they are // returned by this._recentManager.get_items() to avoid having to do this sorting? // This function is called each time the search string is set back to '', so we are @@ -152,9 +152,12 @@ DocDisplay.prototype = { itemIds.sort(function (a,b) { let docA = me._allItems[a]; let docB = me._allItems[b]; - if (docA.get_visited() > docB.get_visited()) + // We actually used get_modified() instead of get_visited() here, as GtkRecentInfo + // doesn't updated get_visited() correctly. + // See http://bugzilla.gnome.org/show_bug.cgi?id=567094 + if (docA.get_modified() > docB.get_modified()) return -1; - else if (docA.get_visited() < docB.get_visited()) + else if (docA.get_modified() < docB.get_modified()) return 1; else return 0; @@ -165,8 +168,12 @@ DocDisplay.prototype = { // the name of the document. Item info is expected to be GtkRecentInfo. // Returns a boolean flag indicating if itemInfo is a match. _isInfoMatching : function(itemInfo, search) { + if (!itemInfo.exists()) + return false; + if (search == null || search == '') return true; + let name = itemInfo.get_display_name().toLowerCase(); if (name.indexOf(search) >= 0) return true;