[gnome-documents] tracker-controller: make sure to properly reset the offset on refresh



commit d1dba6cd78bb814c08c309710b0324b204ebcd29
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Dec 1 10:23:31 2011 -0500

    tracker-controller: make sure to properly reset the offset on refresh
    
    Make sure we reset the display offset when the model is refreshed, when
    it makes sense to do so (e.g. when navigating to a new collection).

 src/trackerController.js |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/src/trackerController.js b/src/trackerController.js
index d05a414..c8bd8ae 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -108,6 +108,11 @@ TrackerConnectionQueue.prototype = {
     }
 };
 
+const RefreshFlags = {
+    NONE: 0,
+    RESET_OFFSET: 1 << 0
+};
+
 function TrackerController() {
     this._init();
 }
@@ -128,25 +133,27 @@ TrackerController.prototype = {
         this._sourceManager = Global.sourceManager;
         this._sourceManager.connect('item-added', Lang.bind(this, this._onSourceAddedRemoved));
         this._sourceManager.connect('item-removed', Lang.bind(this, this._onSourceAddedRemoved));
-        this._sourceManager.connect('active-changed', Lang.bind(this, this._refresh));
+        this._sourceManager.connect('active-changed',
+                                    Lang.bind(this, this._refreshForObject));
 
         this._offsetController = Global.offsetController;
         this._offsetController.connect('offset-changed',
                                        Lang.bind(this, this._performCurrentQuery));
 
         Global.collectionManager.connect('active-changed',
-                                         Lang.bind(this, this._refresh));
-        Global.searchCategoryManager.connect('active-changed',
-                                             Lang.bind(this, this._refresh));
+                                         Lang.bind(this, this._refreshForObject));
         Global.searchController.connect('search-string-changed',
-                                        Lang.bind(this, this._onSearchRefresh));
+                                        Lang.bind(this, this._refreshForObject));
+        Global.searchCategoryManager.connect('active-changed',
+                                             Lang.bind(this, this._refreshForObject));
+        Global.searchTypeManager.connect('active-changed',
+                                         Lang.bind(this, this._refreshForObject));
+
         Global.searchMatchManager.connect('active-changed',
                                           Lang.bind(this, this._onSearchMatchChanged));
-        Global.searchTypeManager.connect('active-changed',
-                                         Lang.bind(this, this._onSearchRefresh));
 
         // perform initial query
-        this._refresh();
+        this._refreshInternal(RefreshFlags.NONE);
     },
 
     _refreshMinerNow: function() {
@@ -238,7 +245,10 @@ TrackerController.prototype = {
                                    this._cancellable, Lang.bind(this, this._onQueryExecuted));
     },
 
-    _refresh: function() {
+    _refreshInternal: function(flags) {
+        if (flags & RefreshFlags.RESET_OFFSET)
+            Global.offsetController.resetOffset();
+
         if (this.getQueryStatus()) {
             this._cancellable.cancel();
             this._queryQueued = true;
@@ -253,16 +263,15 @@ TrackerController.prototype = {
         this._performCurrentQuery();
     },
 
-    _onSearchRefresh: function() {
-        this._offsetController.resetOffset();
-        this._refresh();
+    _refreshForObject: function(_object, _item) {
+        this._refreshInternal(RefreshFlags.RESET_OFFSET);
     },
 
     _onSearchMatchChanged: function() {
         // when the "match" search setting changes, refresh only if
         // the search string is not empty
         if (Global.searchController.getString() != '')
-            this._onSearchRefresh();
+            this._refreshInternal(RefreshFlags.RESET_OFFSET);
     },
 
     _onSourceAddedRemoved: function(manager, item) {
@@ -272,7 +281,7 @@ TrackerController.prototype = {
         // 'active-changed' signal, so avoid refreshing twice
         if (this._currentQuery.activeSource &&
             this._currentQuery.activeSource.id == 'all')
-            this._refresh();
+            this._refreshInternal(RefreshFlags.NONE);
     }
 };
 Signals.addSignalMethods(TrackerController.prototype);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]