[gnome-documents/gnome-3-4] tag: Porting Documents to Lang.Class()



commit 62648df45e06c00faab7d1ca9214adc2148caf5b
Author: Anna Zacchi <azzurroverde gmail com>
Date:   Tue May 22 11:07:30 2012 -0400

    tag: Porting Documents to Lang.Class()
    
    The Lang module in gjs has recently gained a small yet powerful
    Class framework, that should help improve the readability of code
    when using complex inheritance.
    This commit ports gnome-documents code, by rewriting all prototypes
    to Lang.Class.
    
    tag: fixed and error in the porting of "DeleteItemJob"
    
    fixed and error in the porting of "DeleteItemJob" prototype to Lang.Class()
    
    tag: using spaces instead of tabs
    
    Replaced spaces instead of tab for indentation.
    
    FIXED coding style (space missing)

 src/application.js         |   11 +++--
 src/changeMonitor.js       |   30 +++++++-------
 src/documents.js           |   94 ++++++++++++++++++++-----------------------
 src/embed.js               |    9 ++--
 src/error.js               |    9 ++--
 src/errorBox.js            |   10 ++--
 src/gDataMiner.js          |   10 ++--
 src/loadMore.js            |   11 +++--
 src/mainToolbar.js         |   41 ++++++++++---------
 src/mainWindow.js          |    9 ++--
 src/manager.js             |   29 +++++++-------
 src/notifications.js       |   22 ++++++-----
 src/offsetController.js    |   11 +++--
 src/preview.js             |   29 +++++++-------
 src/query.js               |   21 +++++-----
 src/searchbar.js           |   93 +++++++++++++++++++------------------------
 src/selections.js          |   88 ++++++++++++++++++-----------------------
 src/shellSearchProvider.js |   36 +++++++---------
 src/sources.js             |   22 ++++------
 src/spinnerBox.js          |    9 ++--
 src/trackerController.js   |   18 ++++-----
 src/view.js                |   18 ++++-----
 src/windowMode.js          |   11 +++--
 23 files changed, 300 insertions(+), 341 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index afab1f4..ace2442 100644
--- a/src/application.js
+++ b/src/application.js
@@ -55,11 +55,12 @@ const WindowMode = imports.windowMode;
 
 const MINER_REFRESH_TIMEOUT = 60; /* seconds */
 
-function Application() {
-    this._init();
-}
 
-Application.prototype = {
+
+const Application = new Lang.Class({
+    Name: 'Application',
+
+
     _init: function() {
         Gettext.bindtextdomain('gnome-documents', Path.LOCALE_DIR);
         Gettext.textdomain('gnome-documents');
@@ -223,4 +224,4 @@ Application.prototype = {
 
         return 0;
     }
-};
+});
diff --git a/src/changeMonitor.js b/src/changeMonitor.js
index 3276908..4d38f52 100644
--- a/src/changeMonitor.js
+++ b/src/changeMonitor.js
@@ -31,17 +31,17 @@ const TrackerResourcesServiceIface = {
                 inSignature: 'sa(iiii)a(iiii)' }]
 };
 
-function TrackerResourcesService() {
-    this._init();
-}
 
-TrackerResourcesService.prototype = {
+const TrackerResourcesService = new Lang.Class({
+    Name: 'TrackerResourcesService',
+	
+
     _init: function() {
         DBus.session.proxifyObject(this,
                                    'org.freedesktop.Tracker1',
                                    '/org/freedesktop/Tracker1/Resources');
     }
-};
+});
 DBus.proxifyPrototype(TrackerResourcesService.prototype, TrackerResourcesServiceIface);
 
 const ChangeEventType = {
@@ -52,11 +52,10 @@ const ChangeEventType = {
 
 const _RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";;
 
-function ChangeEvent(urn, predicate, isDelete) {
-    this._init(urn, predicate, isDelete);
-}
 
-ChangeEvent.prototype = {
+const ChangeEvent = new Lang.Class({
+    Name: 'ChangeEvent',
+
     _init: function(urn, predicate, isDelete) {
         this.urn = urn;
 
@@ -77,13 +76,14 @@ ChangeEvent.prototype = {
             this.type = event.type;
         }
     }
-};
+});
+
 
-function TrackerChangeMonitor() {
-    this._init();
-}
 
-TrackerChangeMonitor.prototype = {
+const TrackerChangeMonitor = new Lang.Class({
+    Name: 'TrackerChangeMonitor',
+	
+	
     _init: function() {
         this._outstandingOps = 0;
         this._pendingChanges = [];
@@ -153,5 +153,5 @@ TrackerChangeMonitor.prototype = {
             this._pendingChanges = {};
         }
     }
-};
+});
 Signals.addSignalMethods(TrackerChangeMonitor.prototype);
diff --git a/src/documents.js b/src/documents.js
index b12090b..c3ec8a8 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -41,11 +41,10 @@ const Searchbar = imports.searchbar;
 const TrackerUtils = imports.trackerUtils;
 const Utils = imports.utils;
 
-function SingleItemJob(doc) {
-    this._init(doc);
-}
 
-SingleItemJob.prototype = {
+const SingleItemJob = new Lang.Class({
+    Name: 'SingleItemJob',
+
     _init: function(urn) {
         this._urn = urn;
         this._cursor = null;
@@ -91,14 +90,13 @@ SingleItemJob.prototype = {
     _emitCallback: function() {
         this._callback(this._cursor);
     }
-};
+});
 
-function DeleteItemJob(urn) {
-    this._init(urn);
-}
 
+const DeleteItemJob = new Lang.Class({
+    Name: 'DeleteItemJob',
+	
 // deletes the given resource
-DeleteItemJob.prototype = {
     _init: function(urn) {
         this._urn = urn;
     },
@@ -119,13 +117,12 @@ DeleteItemJob.prototype = {
                     this._callback();
             }));
     }
-};
+});
+
 
-function CollectionIconWatcher(collection) {
-    this._init(collection);
-}
+const CollectionIconWatcher = new Lang.Class({
+    Name: 'CollectionIconWatcher',
 
-CollectionIconWatcher.prototype = {
     _init: function(collection) {
         this._collection = collection;
         this._pixbuf = null;
@@ -265,14 +262,13 @@ CollectionIconWatcher.prototype = {
         this.destroy();
         this._start();
     }
-};
+});
 Signals.addSignalMethods(CollectionIconWatcher.prototype);
 
-function DocCommon(cursor) {
-    this._init(cursor);
-}
 
-DocCommon.prototype = {
+const DocCommon = new Lang.Class({
+    Name: 'DocCommon',
+
     _init: function(cursor) {
         this.id = null;
         this.uri = null;
@@ -604,21 +600,20 @@ DocCommon.prototype = {
 
         return retval;
     }
-};
+});
 Signals.addSignalMethods(DocCommon.prototype);
 
-function LocalDocument(cursor) {
-    this._init(cursor);
-}
 
-LocalDocument.prototype = {
-    __proto__: DocCommon.prototype,
+const LocalDocument = new Lang.Class({
+    Name: 'LocalDocument',
+    Extends: DocCommon,
+
 
     _init: function(cursor) {
         this._failedThumbnailing = false;
         this._triedThumbnailing = false;
 
-        DocCommon.prototype._init.call(this, cursor);
+        this.parent(cursor);
 
         this.sourceName = _("Local");
 
@@ -657,23 +652,22 @@ LocalDocument.prototype = {
             job.run(null);
         }
     }
-};
+});
 
 const _GOOGLE_DOCS_SCHEME_LABELS = "http://schemas.google.com/g/2005/labels";;
 const _GOOGLE_DOCS_TERM_STARRED = "http://schemas.google.com/g/2005/labels#starred";;
 
-function GoogleDocument(cursor) {
-    this._init(cursor);
-}
 
-GoogleDocument.prototype = {
-    __proto__: DocCommon.prototype,
+const GoogleDocument = new Lang.Class({
+    Name: 'GoogleDocument',
+    Extends: DocCommon,
+	
 
     _init: function(cursor) {
         this._triedThumbnailing = true;
         this._failedThumbnailing = true;
 
-        DocCommon.prototype._init.call(this, cursor);
+        this.parent(cursor);
 
         // overridden
         this.defaultAppName = _("Google Docs");
@@ -760,11 +754,11 @@ GoogleDocument.prototype = {
     populateFromCursor: function(cursor) {
         this.shared = cursor.get_boolean(Query.QueryColumns.SHARED);
 
-        DocCommon.prototype.populateFromCursor.call(this, cursor);
+        this.parent(cursor);
     },
 
     setFavorite: function(favorite) {
-        DocCommon.prototype.setFavorite.call(this, favorite);
+        this.parent(favorite);
 
         this._createGDataEntry(null, Lang.bind(this,
             function(entry, service, exception) {
@@ -806,17 +800,17 @@ GoogleDocument.prototype = {
     canTrash: function() {
         return false;
     }
-};
+});
 
-function DocumentManager() {
-    this._init();
-}
 
-DocumentManager.prototype = {
-    __proto__: Manager.BaseManager.prototype,
+
+const DocumentManager = new Lang.Class({
+    Name: 'DocumentManager',
+    Extends: Manager.BaseManager,
+
 
     _init: function() {
-        Manager.BaseManager.prototype._init.call(this);
+        this.parent();
 
         this._model = new DocumentModel();
 
@@ -896,12 +890,12 @@ DocumentManager.prototype = {
             items[idx].destroy();
         };
 
-        Manager.BaseManager.prototype.clear.call(this);
+        this.parent();
         this._model.clear();
     },
 
     setActiveItem: function(doc) {
-        if (Manager.BaseManager.prototype.setActiveItem.call(this, doc)) {
+        if (this.parent(doc)) {
 
             if (doc && !doc.collection) {
                 let recentManager = Gtk.RecentManager.get_default();
@@ -913,13 +907,13 @@ DocumentManager.prototype = {
     getModel: function() {
         return this._model;
     }
-};
+});
+
 
-function DocumentModel() {
-    this._init();
-}
+const DocumentModel = new Lang.Class({
+    Name: 'DocumentModel',
+	
 
-DocumentModel.prototype = {
     _init: function() {
         this.model = Gd.create_list_store();
         this.model.set_sort_column_id(Gd.MainColumns.MTIME,
@@ -969,4 +963,4 @@ DocumentModel.prototype = {
                 return false;
             }));
     }
-};
+});
diff --git a/src/embed.js b/src/embed.js
index 4f93438..2cc9632 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -43,11 +43,10 @@ const GtkClutter = imports.gi.GtkClutter;
 
 const _PDF_LOADER_TIMEOUT = 400;
 
-function ViewEmbed() {
-    this._init();
-}
 
-ViewEmbed.prototype  = {
+const ViewEmbed = new Lang.Class({
+    Name: 'ViewEmbed',
+
     _init: function() {
         this._adjustmentValueId = 0;
         this._adjustmentChangedId = 0;
@@ -381,4 +380,4 @@ ViewEmbed.prototype  = {
         let errorBox = new ErrorBox.ErrorBox(message, exception.message);
         this._scrolledWinPreview.add_with_viewport(errorBox.widget);
     }
-};
+});
diff --git a/src/error.js b/src/error.js
index bdb8baa..8c11f2f 100644
--- a/src/error.js
+++ b/src/error.js
@@ -24,11 +24,10 @@ const Signals = imports.signals;
 
 const _ = imports.gettext.gettext;
 
-function ErrorHandler() {
-    this._init();
-}
 
-ErrorHandler.prototype = {
+const ErrorHandler = new Lang.Class({
+    Name: 'ErrorHandler',
+
     _init: function() {
     },
 
@@ -54,5 +53,5 @@ ErrorHandler.prototype = {
 
         this.emit('query-error', message, exception);
     }
-};
+});
 Signals.addSignalMethods(ErrorHandler.prototype);
diff --git a/src/errorBox.js b/src/errorBox.js
index 7a48237..d4deecb 100644
--- a/src/errorBox.js
+++ b/src/errorBox.js
@@ -21,14 +21,14 @@
 
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
 
 const _ICON_SIZE = 128;
 
-function ErrorBox(primary, secondary) {
-    this._init(primary, secondary);
-}
 
-ErrorBox.prototype = {
+const ErrorBox = new Lang.Class({
+    Name: 'ErrorBox',
+
     _init: function(primary, secondary) {
         this.widget = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,
                                      row_spacing: 12,
@@ -60,4 +60,4 @@ ErrorBox.prototype = {
 
         this.widget.show_all();
     }
-};
+});
diff --git a/src/gDataMiner.js b/src/gDataMiner.js
index 8ce9a5c..3172aa5 100644
--- a/src/gDataMiner.js
+++ b/src/gDataMiner.js
@@ -20,6 +20,7 @@
  */
 
 const DBus = imports.dbus;
+const Lang = imports.lang;
 
 const GDataMinerIface = {
     name: 'org.gnome.Documents.GDataMiner',
@@ -27,15 +28,14 @@ const GDataMinerIface = {
                 inSignature: '' }]
 };
 
-const GDataMiner = function() {
-    this._init();
-};
 
-GDataMiner.prototype = {
+const GDataMiner = new Lang.Class({
+    Name: 'GDataMiner',
+
     _init: function() {
         DBus.session.proxifyObject(this,
                                    'org.gnome.Documents.GDataMiner',
                                    '/org/gnome/Documents/GDataMiner');
     }
-};
+});
 DBus.proxifyPrototype(GDataMiner.prototype, GDataMinerIface);
diff --git a/src/loadMore.js b/src/loadMore.js
index 149e8c6..f59bde8 100644
--- a/src/loadMore.js
+++ b/src/loadMore.js
@@ -27,11 +27,12 @@ const _ = imports.gettext.gettext;
 
 const Lang = imports.lang;
 
-function LoadMoreButton() {
-    this._init();
-};
 
-LoadMoreButton.prototype = {
+
+const LoadMoreButton = new Lang.Class({
+    Name: 'LoadMoreButton',
+	
+	
     _init: function() {
         this._block = false;
 
@@ -80,4 +81,4 @@ LoadMoreButton.prototype = {
         this._block = block;
         this._onItemCountChanged();
     }
-};
+});
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 7c074a6..40a5ddb 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -38,11 +38,11 @@ const Searchbar = imports.searchbar;
 const Tweener = imports.util.tweener;
 const WindowMode = imports.windowMode;
 
-function MainToolbar() {
-    this._init();
-}
 
-MainToolbar.prototype = {
+const MainToolbar = new Lang.Class({
+    Name: 'MainToolbar',
+
+
     _init: function() {
         this._model = null;
 
@@ -291,17 +291,18 @@ MainToolbar.prototype = {
 
         this._setToolbarTitle();
     }
-};
+});
+
+;
+
+const PreviewToolbar = new Lang.Class({
+    Name: 'PreviewToolbar',
+    Extends: MainToolbar,
 
-function PreviewToolbar() {
-    this._init();
-};
 
-PreviewToolbar.prototype = {
-    __proto__: MainToolbar.prototype,
 
     _init: function() {
-        MainToolbar.prototype._init.call(this);
+        this.parent();
 
         this.actor.y = -(this.widget.get_preferred_height()[1]);
     },
@@ -319,17 +320,17 @@ PreviewToolbar.prototype = {
                            time: 0.20,
                            transition: 'easeOutQuad' });
     }
-};
+});
+
+
 
-function OverviewToolbar() {
-    this._init();
-};
+const OverviewToolbar = new Lang.Class({
+    Name: 'OverviewToolbar',
+    Extends: MainToolbar,
 
-OverviewToolbar.prototype = {
-    __proto__: MainToolbar.prototype,
 
     _init: function() {
-        MainToolbar.prototype._init.call(this);
+        this.parent();
 
         this.searchbar = new Searchbar.Searchbar();
         this.layout.pack_start = true;
@@ -338,7 +339,7 @@ OverviewToolbar.prototype = {
     },
 
     _onWindowModeChanged: function() {
-        MainToolbar.prototype._onWindowModeChanged.call(this);
+        this.parent();
 
         let mode = Global.modeController.getWindowMode();
 
@@ -348,4 +349,4 @@ OverviewToolbar.prototype = {
                    Global.searchController.getString() != '')
             this.searchbar.show();
     }
-};
+});
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 04722e9..9a3a64a 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -39,11 +39,10 @@ const _ = imports.gettext.gettext;
 
 const _CONFIGURE_ID_TIMEOUT = 100; // msecs
 
-function MainWindow(app) {
-    this._init(app);
-}
 
-MainWindow.prototype = {
+const MainWindow = new Lang.Class({
+    Name: 'MainWindow',
+
     _init: function(app) {
         this._configureId = 0;
 
@@ -247,4 +246,4 @@ MainWindow.prototype = {
             aboutDialog.destroy();
         });
     }
-};
+});
diff --git a/src/manager.js b/src/manager.js
index c6edb9b..70613ec 100644
--- a/src/manager.js
+++ b/src/manager.js
@@ -27,11 +27,11 @@ const Pango = imports.gi.Pango;
 const Lang = imports.lang;
 const Signals = imports.signals;
 
-function BaseManager(title) {
-    this._init(title);
-};
 
-BaseManager.prototype = {
+
+const BaseManager = new Lang.Class({
+    Name: 'BaseManager',
+
     _init: function(title) {
         this._items = {};
         this._activeItem = null;
@@ -164,7 +164,7 @@ BaseManager.prototype = {
 
         // TODO: merge existing item properties with new values
     }
-};
+});
 Signals.addSignalMethods(BaseManager.prototype);
 
 // GTK+ implementations
@@ -175,11 +175,11 @@ const BaseModelColumns = {
     HEADING_TEXT: 2
 };
 
-function BaseModel(manager) {
-    this._init(manager);
-}
 
-BaseModel.prototype = {
+
+const BaseModel = new Lang.Class({
+    Name: 'BaseModel',
+
     _init: function(manager) {
         this.model = Gd.create_item_store();
         this._manager = manager;
@@ -209,13 +209,12 @@ BaseModel.prototype = {
                               item.id, item.name, '');
         }
     }
-};
+});
 
-function BaseView(manager) {
-    this._init(manager);
-}
 
-BaseView.prototype = {
+const BaseView = new Lang.Class({
+    Name: 'BaseView',
+	
     _init: function(manager) {
         this._model = new BaseModel(manager);
         this._manager = manager;
@@ -286,5 +285,5 @@ BaseView.prototype = {
         if (additionalFunc)
             additionalFunc(col, cell, model, iter);
     }
-};
+});
 Signals.addSignalMethods(BaseView.prototype);
diff --git a/src/notifications.js b/src/notifications.js
index 0607a05..7b6ab6d 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -30,11 +30,12 @@ const Global = imports.global;
 const Lang = imports.lang;
 const Signals = imports.signals;
 
-function PrintNotification(printOp, doc) {
-    this._init(printOp, doc);
-}
 
-PrintNotification.prototype = {
+
+const PrintNotification = new Lang.Class({
+    Name: 'PrintNotification',
+
+
     _init: function(printOp, doc) {
         this.widget = null;
         this._printOp = printOp;
@@ -90,13 +91,14 @@ PrintNotification.prototype = {
         if (fraction == 1)
             this.widget.destroy();
     }
-};
+});
+
+
+
+const NotificationManager = new Lang.Class({
+    Name: 'NotificationManager',
 
-function NotificationManager() {
-    this._init();
-}
 
-NotificationManager.prototype = {
     _init: function() {
         this.widget = new Gd.Notification({ timeout: -1,
                                             show_close_button: false });
@@ -132,5 +134,5 @@ NotificationManager.prototype = {
 
     _onNotificationDismissed: function() {
     }
-};
+});
 Signals.addSignalMethods(NotificationManager.prototype);
diff --git a/src/offsetController.js b/src/offsetController.js
index 5160225..0251eec 100644
--- a/src/offsetController.js
+++ b/src/offsetController.js
@@ -30,11 +30,12 @@ const GLib = imports.gi.GLib;
 
 const _OFFSET_STEP = 50;
 
-function OffsetController() {
-    this._init();
-};
 
-OffsetController.prototype = {
+
+const OffsetController = new Lang.Class({
+    Name: 'OffsetController',
+
+
     _init: function() {
         this._offset = 0;
         this._itemCount = 0;
@@ -91,5 +92,5 @@ OffsetController.prototype = {
     getOffset: function() {
         return this._offset;
     }
-};
+});
 Signals.addSignalMethods(OffsetController.prototype);
diff --git a/src/preview.js b/src/preview.js
index f588867..7eb6674 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -36,11 +36,11 @@ const View = imports.view;
 
 const _FULLSCREEN_TOOLBAR_TIMEOUT = 2; // seconds
 
-function PreviewView(model) {
-    this._init(model);
-}
 
-PreviewView.prototype = {
+
+const PreviewView = new Lang.Class({
+    Name: 'PreviewView',
+
     _init: function(model) {
         this._model = model;
 
@@ -97,13 +97,12 @@ PreviewView.prototype = {
     destroy: function() {
         this.widget.destroy();
     }
-};
+});
+
 
-function PreviewThumbnails(model) {
-    this._init(model);
-}
+const PreviewThumbnails = new Lang.Class({
+    Name: 'PreviewThumbnails',
 
-PreviewThumbnails.prototype = {
     _init: function(model) {
         this.view = new Gd.SidebarThumbnails({ model: model });
         this.widget = new Gd.ThumbNav({ thumbview: this.view });
@@ -132,13 +131,13 @@ PreviewThumbnails.prototype = {
               },
               onCompleteScope: this });
     }
-};
+});
+
+
 
-function PreviewEmbed(model, layout, parentActor, scrolledWindow) {
-    this._init(model, layout, parentActor, scrolledWindow);
-}
+const PreviewEmbed = new Lang.Class({
+    Name: 'PreviewEmbed',
 
-PreviewEmbed.prototype = {
     _init: function(model, layout, parentActor, scrolledWindow) {
         this._layout = layout;
         this._parentActor = parentActor;
@@ -250,4 +249,4 @@ PreviewEmbed.prototype = {
                     return false;
             }));
     }
-};
+});
diff --git a/src/query.js b/src/query.js
index 7596512..3c1b0b3 100644
--- a/src/query.js
+++ b/src/query.js
@@ -24,6 +24,7 @@ const Global = imports.global;
 const Gd = imports.gi.Gd;
 const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
+const Lang = imports.lang;
 
 const QueryColumns = {
     URN: 0,
@@ -47,22 +48,20 @@ const QueryFlags = {
 
 const LOCAL_COLLECTIONS_IDENTIFIER = 'gd:collection:local:';
 
-function Query(sparql) {
-    this._init(sparql);
-}
-
-Query.prototype = {
+const Query = new Lang.Class({
+    Name: 'Query',
+	
     _init: function(sparql) {
         this.sparql = sparql;
         this.activeSource = Global.sourceManager.getActiveItem();
     }
-};
+});
 
-function QueryBuilder() {
-    this._init();
-}
 
-QueryBuilder.prototype = {
+
+const QueryBuilder = new Lang.Class({
+    Name: 'QueryBuilder',
+	
     _init: function() {
     },
 
@@ -262,4 +261,4 @@ QueryBuilder.prototype = {
 
         return new Query(sparql);
     }
-};
+});
diff --git a/src/searchbar.js b/src/searchbar.js
index 4a8d53d..13a8767 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -45,11 +45,10 @@ const SearchCategoryStock = {
     PRIVATE: 'private'
 };
 
-function SearchCategory(params) {
-    this._init(params);
-};
 
-SearchCategory.prototype = {
+const SearchCategory = new Lang.Class({
+    Name: 'SearchCategory',
+
     _init: function(params) {
         this.id = params.id;
         this.name = params.name;
@@ -74,17 +73,16 @@ SearchCategory.prototype = {
 
         return '(true)';
     }
-};
+});
 
-function SearchCategoryManager() {
-    this._init();
-};
 
-SearchCategoryManager.prototype = {
-    __proto__: Manager.BaseManager.prototype,
+
+const SearchCategoryManager = new Lang.Class({
+    Name: 'SearchCategoryManager',
+    Extends: Manager.BaseManager,
 
     _init: function() {
-        Manager.BaseManager.prototype._init.call(this, _("Category"));
+        this.parent(_("Category"));
 
         let category, recent;
         // Translators: this refers to new and recent documents
@@ -110,13 +108,12 @@ SearchCategoryManager.prototype = {
 
         this.setActiveItem(recent);
     }
-};
+});
 
-function SearchType(params) {
-    this._init(params);
-}
 
-SearchType.prototype = {
+const SearchType = new Lang.Class({
+    Name: 'SearchType',
+
     _init: function(params) {
         this.id = params.id;
         this.name = params.name;
@@ -126,17 +123,15 @@ SearchType.prototype = {
     getFilter: function() {
         return this._filter;
     }
-};
+});
 
-function SearchTypeManager() {
-    this._init();
-}
 
-SearchTypeManager.prototype = {
-    __proto__: Manager.BaseManager.prototype,
+const SearchTypeManager = new Lang.Class({
+    Name: 'SearchTypeManager',
+    Extends: Manager.BaseManager,
 
     _init: function() {
-        Manager.BaseManager.prototype._init.call(this, _("Type"));
+        this.parent(_("Type"));
 
         this.addItem(new SearchType({ id: 'all',
                                       name: _("All") }));
@@ -159,7 +154,7 @@ SearchTypeManager.prototype = {
 
         this.setActiveItemById('all');
     }
-};
+});
 
 const SearchMatchStock = {
     ALL: 'all',
@@ -167,11 +162,10 @@ const SearchMatchStock = {
     AUTHOR: 'author'
 };
 
-function SearchMatch(params) {
-    this._init(params);
-}
 
-SearchMatch.prototype = {
+const SearchMatch = new Lang.Class({
+    Name: 'SearchMatch',
+	
     _init: function(params) {
         this.id = params.id;
         this.name = params.name;
@@ -193,19 +187,17 @@ SearchMatch.prototype = {
                     '"%s")').format(this._term);
         return '';
     }
-};
+});
 
-function SearchMatchManager() {
-    this._init();
-}
 
-SearchMatchManager.prototype = {
-    __proto__: Manager.BaseManager.prototype,
+const SearchMatchManager = new Lang.Class({
+    Name: 'SearchMatchManager',
+    Extends: Manager.BaseManager,
 
     _init: function() {
         // Translators: this is a verb that refers to "All", "Title" and "Author",
         // as in "Match All", "Match Title" and "Match Author"
-        Manager.BaseManager.prototype._init.call(this, _("Match"));
+        this.parent(_("Match"));
 
         this.addItem(new SearchMatch({ id: SearchMatchStock.ALL,
                                        name: _("All") }));
@@ -225,17 +217,16 @@ SearchMatchManager.prototype = {
             this.forEachItem(function(item) {
                 item.setFilterTerm(terms[i]);
             });
-            filters.push(Manager.BaseManager.prototype.getFilter.call(this));
+            filters.push(this.parent());
         }
         return filters.length ? '( ' + filters.join(' && ') + ')' : '';
     }
-};
+});
 
-function SearchController() {
-    this._init();
-};
 
-SearchController.prototype = {
+const SearchController = new Lang.Class({
+    Name: 'SearchController',
+	
     _init: function() {
         this._dropdownState = false;
         this._string = '';
@@ -269,14 +260,13 @@ SearchController.prototype = {
     getDropdownState: function() {
         return this._dropdownState;
     }
-};
+});
 Signals.addSignalMethods(SearchController.prototype);
 
-function Dropdown() {
-    this._init();
-}
 
-Dropdown.prototype = {
+const Dropdown = new Lang.Class({
+    Name: 'Dropdown',
+	
     _init: function() {
         this._sourceView = new Manager.BaseView(Global.sourceManager);
         this._typeView = new Manager.BaseView(Global.searchTypeManager);
@@ -341,13 +331,12 @@ Dropdown.prototype = {
                                        },
                                        onCompleteScope: this });
     }
-};
+});
 
-function Searchbar() {
-    this._init();
-}
 
-Searchbar.prototype = {
+const Searchbar = new Lang.Class({
+    Name: 'Searchbar',
+	
     _init: function() {
         this._searchEventId = 0;
         this._searchFocusId = 0;
@@ -616,4 +605,4 @@ Searchbar.prototype = {
                                        },
                                        onCompleteScope: this });
     }
-};
+});
diff --git a/src/selections.js b/src/selections.js
index 5153221..c499a3b 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -41,11 +41,9 @@ const Signals = imports.signals;
 const _COLLECTION_PLACEHOLDER_ID = 'collection-placeholder';
 
 // fetch all the collections a given item is part of
-function FetchCollectionsJob(urn) {
-    this._init(urn);
-}
+const FetchCollectionsJob = new Lang.Class({
+    Name: 'FetchCollectionsJob',
 
-FetchCollectionsJob.prototype = {
     _init: function(urn) {
         this._urn = urn;
         this._collections = [];
@@ -95,7 +93,7 @@ FetchCollectionsJob.prototype = {
         if (this._callback)
             this._callback(this._collections);
     }
-};
+});
 
 // fetch the state of every collection applicable to the selected items
 const OrganizeCollectionState = {
@@ -105,11 +103,11 @@ const OrganizeCollectionState = {
     HIDDEN: 1 << 2
 };
 
-function FetchCollectionStateForSelectionJob() {
-    this._init();
-}
 
-FetchCollectionStateForSelectionJob.prototype = {
+
+const FetchCollectionStateForSelectionJob = new Lang.Class({
+    Name: 'FetchCollectionStateForSelectionJob',
+
     _init: function() {
         this._collectionsForItems = {};
         this._runningJobs = 0;
@@ -192,14 +190,12 @@ FetchCollectionStateForSelectionJob.prototype = {
         if (this._callback)
             this._callback(collectionState);
     }
-};
+});
 
 // updates the mtime for the given resource to the current system time
-function UpdateMtimeJob(urn) {
-    this._init(urn);
-}
+const UpdateMtimeJob = new Lang.Class({
+    Name: 'UpdateMtimeJob',
 
-UpdateMtimeJob.prototype = {
     _init: function(urn) {
         this._urn = urn;
     },
@@ -220,14 +216,12 @@ UpdateMtimeJob.prototype = {
                     this._callback();
             }));
     }
-};
+});
 
 // adds or removes the selected items to the given collection
-function SetCollectionForSelectionJob(collectionUrn, setting) {
-    this._init(collectionUrn, setting);
-}
+const SetCollectionForSelectionJob = new Lang.Class({
+    Name: 'SetCollectionForSelectionJob',
 
-SetCollectionForSelectionJob.prototype = {
     _init: function(collectionUrn, setting) {
         this._collectionUrn = collectionUrn;
         this._setting = setting;
@@ -274,14 +268,12 @@ SetCollectionForSelectionJob.prototype = {
                 }));
         }
     }
-};
+});
 
 // creates an (empty) collection with the given name
-function CreateCollectionJob(name) {
-    this._init(name);
-}
+const CreateCollectionJob = new Lang.Class({
+    Name: 'CreateCollectionJob',
 
-CreateCollectionJob.prototype = {
     _init: function(name) {
         this._name = name;
         this._createdUrn = null;
@@ -314,7 +306,7 @@ CreateCollectionJob.prototype = {
                     this._callback(this._createdUrn);
             }));
     }
-};
+});
 
 const OrganizeModelColumns = {
     ID: 0,
@@ -322,11 +314,10 @@ const OrganizeModelColumns = {
     STATE: 2
 };
 
-function OrganizeCollectionModel() {
-    this._init();
-}
 
-OrganizeCollectionModel.prototype = {
+const OrganizeCollectionModel = new Lang.Class({
+    Name: 'OrganizeCollectionModel',
+
     _init: function() {
         this.model = Gd.create_organize_store();
         this._placeholderRef = null;
@@ -452,13 +443,12 @@ OrganizeCollectionModel.prototype = {
             this._collRemovedId = 0;
         }
     }
-};
+});
+
 
-function OrganizeCollectionView() {
-    this._init();
-}
+const OrganizeCollectionView = new Lang.Class({
+    Name: 'OrganizeCollectionView',
 
-OrganizeCollectionView.prototype = {
     _init: function() {
         this._choiceConfirmed = false;
 
@@ -603,17 +593,17 @@ OrganizeCollectionView.prototype = {
     confirmedChoice: function() {
         this._choiceConfirmed = true;
     }
-};
+});
 
 const OrganizeCollectionDialogResponse = {
     ADD: 1
 };
 
-function OrganizeCollectionDialog(toplevel) {
-    this._init(toplevel);
-};
 
-OrganizeCollectionDialog.prototype = {
+const OrganizeCollectionDialog = new Lang.Class({
+    Name: 'OrganizeCollectionDialog',
+
+
     _init: function(toplevel) {
         this.widget = new Gtk.Dialog({ transient_for: toplevel,
                                        modal: true,
@@ -657,13 +647,12 @@ OrganizeCollectionDialog.prototype = {
 
         this.widget.show_all();
     }
-};
+});
 
-function SelectionController() {
-    this._init();
-};
 
-SelectionController.prototype = {
+const SelectionController = new Lang.Class({
+    Name: 'SelectionController',
+
     _init: function() {
         this._selection = [];
         this._selectionMode = false;
@@ -722,14 +711,13 @@ SelectionController.prototype = {
     getSelectionMode: function() {
         return this._selectionMode;
     }
-};
+});
 Signals.addSignalMethods(SelectionController.prototype);
 
-function SelectionToolbar() {
-    this._init();
-}
 
-SelectionToolbar.prototype = {
+const SelectionToolbar = new Lang.Class({
+    Name: 'SelectionToolbar',
+	
     _init: function() {
         this._itemListeners = {};
         this._insideRefresh = false;
@@ -993,4 +981,4 @@ SelectionToolbar.prototype = {
               },
               onCompleteScope: this });
     }
-};
+});
diff --git a/src/shellSearchProvider.js b/src/shellSearchProvider.js
index 6ddcb05..e84dba0 100644
--- a/src/shellSearchProvider.js
+++ b/src/shellSearchProvider.js
@@ -113,11 +113,10 @@ function _createGIcon(cursor) {
     return gicon;
 }
 
-function CreateCollectionIconJob(id) {
-    this._init(id);
-}
 
-CreateCollectionIconJob.prototype = {
+const CreateCollectionIconJob = new Lang.Class({
+    Name: 'CreateCollectionIconJob',
+
     _init: function(id) {
         this._id = id;
         this._itemIcons = [];
@@ -225,13 +224,12 @@ CreateCollectionIconJob.prototype = {
     _returnPixbuf: function() {
         this._callback(Gd.create_collection_icon(_SHELL_SEARCH_ICON_SIZE, this._itemIcons));
     }
-};
+});
 
-function FetchMetasJob(ids) {
-    this._init(ids);
-}
 
-FetchMetasJob.prototype = {
+const FetchMetasJob = new Lang.Class({
+    Name: 'FetchMetasJob',
+
     _init: function(ids) {
         this._ids = ids;
         this._metas = [];
@@ -295,13 +293,12 @@ FetchMetasJob.prototype = {
                     }));
             }));
     }
-};
+});
 
-function FetchIdsJob(terms) {
-    this._init(terms);
-}
 
-FetchIdsJob.prototype = {
+const FetchIdsJob = new Lang.Class({
+    Name: 'FetchIdsJob',
+
     _init: function(terms) {
         this._terms = terms;
         this._ids = [];
@@ -347,13 +344,12 @@ FetchIdsJob.prototype = {
             this._callback(this._ids);
         }
     }
-};
+});
 
-function ShellSearchProvider() {
-    this._init();
-}
 
-ShellSearchProvider.prototype = {
+const ShellSearchProvider = new Lang.Class({
+    Name: 'ShellSearchProvider',
+
     _init: function() {
         Gio.DBus.own_name(Gio.BusType.SESSION,
                           SEARCH_PROVIDER_NAME,
@@ -519,7 +515,7 @@ ShellSearchProvider.prototype = {
     run: function() {
         Mainloop.run(MAINLOOP_ID);
     }
-};
+});
 
 function start() {
     let searchProvider = new ShellSearchProvider();
diff --git a/src/sources.js b/src/sources.js
index c2e5331..7361924 100644
--- a/src/sources.js
+++ b/src/sources.js
@@ -31,13 +31,11 @@ const Manager = imports.manager;
 const SourceStock = {
     ALL: 'all',
     LOCAL: 'local'
-}
-
-function Source(params) {
-    this._init(params);
 };
 
-Source.prototype = {
+const Source = new Lang.Class({
+    Name: 'Source',
+
     _init: function(params) {
         this.id = null;
         this.name = null;
@@ -77,17 +75,15 @@ Source.prototype = {
 
         return filter;
     }
-};
+});
 
-function SourceManager() {
-    this._init();
-};
 
-SourceManager.prototype = {
-    __proto__: Manager.BaseManager.prototype,
+const SourceManager = new Lang.Class({
+    Name: 'SourceManager',
+    Extends: Manager.BaseManager,
 
     _init: function() {
-        Manager.BaseManager.prototype._init.call(this, _("Sources"));
+        this.parent(_("Sources"));
 
         // Translators: this refers to documents
         let source = new Source({ id: SourceStock.ALL,
@@ -127,4 +123,4 @@ SourceManager.prototype = {
 
         this.processNewItems(newItems);
     }
-};
+});
diff --git a/src/spinnerBox.js b/src/spinnerBox.js
index cf101da..a8d0629 100644
--- a/src/spinnerBox.js
+++ b/src/spinnerBox.js
@@ -30,11 +30,10 @@ const Mainloop = imports.mainloop;
 
 const _SPINNER_SIZE = 128;
 
-function SpinnerBox() {
-    this._init();
-}
 
-SpinnerBox.prototype = {
+const SpinnerBox = new Lang.Class({
+    Name: 'SpinnerBox',
+
     _init: function() {
         this._delayedMoveId = 0;
 
@@ -101,4 +100,4 @@ SpinnerBox.prototype = {
                 return false;
             }));
     }
-};
+});
diff --git a/src/trackerController.js b/src/trackerController.js
index 045122f..23798ae 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -35,11 +35,10 @@ const QueryType = {
     UPDATE_BLANK: 2
 };
 
-function TrackerConnectionQueue() {
-    this._init();
-}
 
-TrackerConnectionQueue.prototype = {
+const TrackerConnectionQueue = new Lang.Class({
+    Name: 'TrackerConnectionQueue',
+	
     _init: function() {
         this._queue = [];
         this._running = false;
@@ -101,18 +100,17 @@ TrackerConnectionQueue.prototype = {
         this._running = false;
         this._checkQueue();
     }
-};
+});
 
 const RefreshFlags = {
     NONE: 0,
     RESET_OFFSET: 1 << 0
 };
 
-function TrackerController() {
-    this._init();
-}
 
-TrackerController.prototype = {
+const TrackerController = new Lang.Class({
+    Name: 'TrackerController',
+
     _init: function() {
         this._currentQuery = null;
         this._cancellable = new Gio.Cancellable();
@@ -270,5 +268,5 @@ TrackerController.prototype = {
 
         this._refreshInternal(RefreshFlags.NONE);
     }
-};
+});
 Signals.addSignalMethods(TrackerController.prototype);
diff --git a/src/view.js b/src/view.js
index e5923a8..ba4158b 100644
--- a/src/view.js
+++ b/src/view.js
@@ -35,11 +35,10 @@ const TrackerUtils = imports.trackerUtils;
 const WindowMode = imports.windowMode;
 const Utils = imports.utils;
 
-function ContextMenu(urns) {
-    this._init(urns);
-}
 
-ContextMenu.prototype = {
+const ContextMenu = new Lang.Class({
+    Name: 'ContextMenu',
+	
     _init: function(urns) {
         let favCount = 0;
         let apps = [];
@@ -103,13 +102,12 @@ ContextMenu.prototype = {
 
         this.widget.show_all();
     }
-};
+});
 
-function View() {
-    this._init();
-}
 
-View.prototype = {
+const View = new Lang.Class({
+    Name: 'View',
+
     _init: function() {
         this.widget = new Gd.MainView();
 
@@ -296,4 +294,4 @@ View.prototype = {
                                                   this._treeModel);
         Global.selectionController.setSelection(selectedURNs);
     }
-};
+});
diff --git a/src/windowMode.js b/src/windowMode.js
index b489163..d1e09f2 100644
--- a/src/windowMode.js
+++ b/src/windowMode.js
@@ -20,6 +20,7 @@
  */
 
 const Signals = imports.signals;
+const Lang = imports.lang;
 
 const WindowMode = {
     NONE: 0,
@@ -27,11 +28,11 @@ const WindowMode = {
     PREVIEW: 2
 };
 
-function ModeController() {
-    this._init();
-};
 
-ModeController.prototype = {
+
+const ModeController = new Lang.Class({
+    Name: 'ModeController',
+
     _init: function() {
         this._mode = WindowMode.NONE;
         this._fullscreen = false;
@@ -89,5 +90,5 @@ ModeController.prototype = {
     getCanFullscreen: function() {
         return this._canFullscreen;
     }
-};
+});
 Signals.addSignalMethods(ModeController.prototype);



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