[gnome-documents] global: factor out an initSearch() method



commit d77cc89daa2a0b7121d6b5e6f7cb1afcf37113e9
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Mar 12 12:22:35 2012 -0400

    global: factor out an initSearch() method
    
    Initializes the common modules needed for searching, all at once.

 src/application.js         |   15 +++------------
 src/global.js              |   21 +++++++++++++++++++++
 src/shellSearchProvider.js |   17 +----------------
 3 files changed, 25 insertions(+), 28 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 5ca910e..194e914 100644
--- a/src/application.js
+++ b/src/application.js
@@ -44,10 +44,8 @@ const Main = imports.main;
 const MainWindow = imports.mainWindow;
 const Manager = imports.manager;
 const Notifications = imports.notifications;
-const OffsetController = imports.offsetController;
 const Path = imports.path;
 const Query = imports.query;
-const Searchbar = imports.searchbar;
 const Selections = imports.selections;
 const Sources = imports.sources;
 const TrackerController = imports.trackerController;
@@ -165,9 +163,6 @@ Application.prototype = {
         Tweener.init();
 
         Global.application = this;
-        Global.offsetController = new OffsetController.OffsetController();
-        Global.searchController = new Searchbar.SearchController();
-        Global.errorHandler = new Error.ErrorHandler();
 
         // connect to tracker
         try {
@@ -184,15 +179,11 @@ Application.prototype = {
             return;
         }
 
-        Global.connectionQueue = new TrackerController.TrackerConnectionQueue();
-        Global.sourceManager = new Sources.SourceManager();
-        Global.searchCategoryManager = new Searchbar.SearchCategoryManager();
-        Global.searchMatchManager = new Searchbar.SearchMatchManager();
-        Global.searchTypeManager = new Searchbar.SearchTypeManager();
-        Global.queryBuilder = new Query.QueryBuilder();
+        Global.initSearch();
+
         Global.changeMonitor = new ChangeMonitor.TrackerChangeMonitor();
-        Global.collectionManager = new Manager.BaseManager();
         Global.documentManager = new Documents.DocumentManager();
+        Global.errorHandler = new Error.ErrorHandler();
         Global.trackerController = new TrackerController.TrackerController();
         Global.selectionController = new Selections.SelectionController();
         Global.modeController = new WindowMode.ModeController();
diff --git a/src/global.js b/src/global.js
index c71892c..abb90e2 100644
--- a/src/global.js
+++ b/src/global.js
@@ -19,6 +19,13 @@
  *
  */
 
+const Manager = imports.manager;
+const OffsetController = imports.offsetController;
+const Query = imports.query;
+const Searchbar = imports.searchbar;
+const Sources = imports.sources;
+const TrackerController = imports.trackerController;
+
 let application = null;
 let collectionManager = null;
 let connection = null;
@@ -38,3 +45,17 @@ let selectionController = null;
 let settings = null;
 let sourceManager = null;
 let trackerController = null;
+
+function initSearch() {
+    sourceManager = new Sources.SourceManager();
+    collectionManager = new Manager.BaseManager();
+
+    searchCategoryManager = new Searchbar.SearchCategoryManager();
+    searchMatchManager = new Searchbar.SearchMatchManager();
+    searchTypeManager = new Searchbar.SearchTypeManager();
+    searchController = new Searchbar.SearchController();
+
+    offsetController = new OffsetController.OffsetController();
+    queryBuilder = new Query.QueryBuilder();
+    connectionQueue = new TrackerController.TrackerConnectionQueue();
+}
diff --git a/src/shellSearchProvider.js b/src/shellSearchProvider.js
index e25ee13..f5949e1 100644
--- a/src/shellSearchProvider.js
+++ b/src/shellSearchProvider.js
@@ -31,18 +31,11 @@ const Gtk = imports.gi.Gtk;
 const GLib = imports.gi.GLib;
 const Tracker = imports.gi.Tracker;
 
-const ChangeMonitor = imports.changeMonitor;
 const Documents = imports.documents;
-const Error = imports.error;
 const Format = imports.format;
 const Global = imports.global;
-const Manager = imports.manager;
 const Path = imports.path;
-const OffsetController = imports.offsetController;
 const Query = imports.query;
-const Searchbar = imports.searchbar;
-const Sources = imports.sources;
-const TrackerController = imports.trackerController;
 const Utils = imports.utils;
 
 const MAINLOOP_ID = "documents-search-provider";
@@ -394,8 +387,6 @@ ShellSearchProvider.prototype = {
 
         Global.application = this;
         Global.settings = new Gio.Settings({ schema: 'org.gnome.documents' });
-        Global.offsetController = new OffsetController.OffsetController();
-        Global.searchController = new Searchbar.SearchController();
 
         // connect to tracker
         try {
@@ -412,13 +403,7 @@ ShellSearchProvider.prototype = {
             this.quit();
         }
 
-        Global.connectionQueue = new TrackerController.TrackerConnectionQueue();
-        Global.sourceManager = new Sources.SourceManager();
-        Global.searchCategoryManager = new Searchbar.SearchCategoryManager();
-        Global.searchMatchManager = new Searchbar.SearchMatchManager();
-        Global.searchTypeManager = new Searchbar.SearchTypeManager();
-        Global.queryBuilder = new Query.QueryBuilder();
-        Global.collectionManager = new Manager.BaseManager();
+        Global.initSearch();
     },
 
     _resetTimeout: function() {



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