[gnome-documents] Porting to Lang.Class()
- From: Anna Zacchi <annazacchi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] Porting to Lang.Class()
- Date: Mon, 4 Jun 2012 15:11:13 +0000 (UTC)
commit c235d2c23830a9178753adc964fa67d8c9305b5f
Author: Anna Zacchi <annazacchi src gnome org>
Date: Sun Jun 3 23:19:10 2012 +0200
Porting 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.
src/application.js | 8 +--
src/changeMonitor.js | 25 +++++-------
src/documents.js | 89 ++++++++++++++++++--------------------------
src/embed.js | 8 +--
src/error.js | 8 +--
src/errorBox.js | 9 ++--
src/gDataMiner.js | 9 ++--
src/loadMore.js | 8 +--
src/mainToolbar.js | 36 +++++++-----------
src/mainWindow.js | 8 +--
src/manager.js | 24 ++++-------
src/notifications.js | 16 +++-----
src/offsetController.js | 8 +--
src/preview.js | 24 ++++-------
src/query.js | 17 +++-----
src/searchbar.js | 89 +++++++++++++++++---------------------------
src/selections.js | 80 +++++++++++++++------------------------
src/shellSearchProvider.js | 32 ++++++----------
src/sources.js | 21 ++++------
src/spinnerBox.js | 8 +--
src/trackerController.js | 16 +++-----
src/view.js | 16 +++-----
src/windowMode.js | 9 ++--
23 files changed, 220 insertions(+), 348 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 7bcdb28..3ad529c 100644
--- a/src/application.js
+++ b/src/application.js
@@ -55,11 +55,9 @@ const WindowMode = imports.windowMode;
const MINER_REFRESH_TIMEOUT = 60; /* seconds */
-function Application() {
- this._init();
-}
+const Application = new Lang.Class({
+ Name: 'Application',
-Application.prototype = {
_init: function() {
Gettext.bindtextdomain('gnome-documents', Path.LOCALE_DIR);
Gettext.textdomain('gnome-documents');
@@ -230,4 +228,4 @@ Application.prototype = {
return 0;
}
-};
+});
diff --git a/src/changeMonitor.js b/src/changeMonitor.js
index 3276908..f341d19 100644
--- a/src/changeMonitor.js
+++ b/src/changeMonitor.js
@@ -31,17 +31,15 @@ const TrackerResourcesServiceIface = {
inSignature: 'sa(iiii)a(iiii)' }]
};
-function TrackerResourcesService() {
- this._init();
-}
+const TrackerResourcesService = new Lang.Class({
+ Name: 'TrackerResourcesService',
-TrackerResourcesService.prototype = {
_init: function() {
DBus.session.proxifyObject(this,
'org.freedesktop.Tracker1',
'/org/freedesktop/Tracker1/Resources');
}
-};
+});
DBus.proxifyPrototype(TrackerResourcesService.prototype, TrackerResourcesServiceIface);
const ChangeEventType = {
@@ -52,11 +50,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 +74,11 @@ ChangeEvent.prototype = {
this.type = event.type;
}
}
-};
+});
-function TrackerChangeMonitor() {
- this._init();
-}
+const TrackerChangeMonitor = new Lang.Class({
+ Name: 'TrackerChangeMonitor',
-TrackerChangeMonitor.prototype = {
_init: function() {
this._outstandingOps = 0;
this._pendingChanges = [];
@@ -153,5 +148,5 @@ TrackerChangeMonitor.prototype = {
this._pendingChanges = {};
}
}
-};
+});
Signals.addSignalMethods(TrackerChangeMonitor.prototype);
diff --git a/src/documents.js b/src/documents.js
index b12090b..8ce708d 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -41,11 +41,9 @@ const Searchbar = imports.searchbar;
const TrackerUtils = imports.trackerUtils;
const Utils = imports.utils;
-function SingleItemJob(doc) {
- this._init(doc);
-}
+const SingleItemJob = new Lang.Class({
+ Name: 'SingleItemJob',
-SingleItemJob.prototype = {
_init: function(urn) {
this._urn = urn;
this._cursor = null;
@@ -91,14 +89,12 @@ 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 +115,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 +260,12 @@ CollectionIconWatcher.prototype = {
this.destroy();
this._start();
}
-};
+});
Signals.addSignalMethods(CollectionIconWatcher.prototype);
-function DocCommon(cursor) {
- this._init(cursor);
-}
+const DocCommon = new Lang.Class({
+ Name: 'DocCommon',
-DocCommon.prototype = {
_init: function(cursor) {
this.id = null;
this.uri = null;
@@ -604,21 +597,18 @@ 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 +647,20 @@ 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 +747,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 +793,15 @@ 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 +881,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 +898,11 @@ 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 +952,4 @@ DocumentModel.prototype = {
return false;
}));
}
-};
+});
diff --git a/src/embed.js b/src/embed.js
index 4f93438..e018b74 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -43,11 +43,9 @@ const GtkClutter = imports.gi.GtkClutter;
const _PDF_LOADER_TIMEOUT = 400;
-function ViewEmbed() {
- this._init();
-}
+const ViewEmbed = new Lang.Class({
+ Name: 'ViewEmbed',
-ViewEmbed.prototype = {
_init: function() {
this._adjustmentValueId = 0;
this._adjustmentChangedId = 0;
@@ -381,4 +379,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..70a76f1 100644
--- a/src/error.js
+++ b/src/error.js
@@ -24,11 +24,9 @@ const Signals = imports.signals;
const _ = imports.gettext.gettext;
-function ErrorHandler() {
- this._init();
-}
+const ErrorHandler = new Lang.Class({
+ Name: 'ErrorHandler',
-ErrorHandler.prototype = {
_init: function() {
},
@@ -54,5 +52,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..7dc64ba 100644
--- a/src/errorBox.js
+++ b/src/errorBox.js
@@ -21,14 +21,13 @@
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);
-}
+const ErrorBox = new Lang.Class({
+ Name: 'ErrorBox',
-ErrorBox.prototype = {
_init: function(primary, secondary) {
this.widget = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,
row_spacing: 12,
@@ -60,4 +59,4 @@ ErrorBox.prototype = {
this.widget.show_all();
}
-};
+});
diff --git a/src/gDataMiner.js b/src/gDataMiner.js
index 8ce9a5c..ad04b41 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,13 @@ const GDataMinerIface = {
inSignature: '' }]
};
-const GDataMiner = function() {
- this._init();
-};
+const GDataMiner = new Lang.Class({
+ Name: 'GDataMiner',
-GDataMiner.prototype = {
_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..15115f3 100644
--- a/src/loadMore.js
+++ b/src/loadMore.js
@@ -27,11 +27,9 @@ const _ = imports.gettext.gettext;
const Lang = imports.lang;
-function LoadMoreButton() {
- this._init();
-};
+const LoadMoreButton = new Lang.Class({
+ Name: 'LoadMoreButton',
-LoadMoreButton.prototype = {
_init: function() {
this._block = false;
@@ -80,4 +78,4 @@ LoadMoreButton.prototype = {
this._block = block;
this._onItemCountChanged();
}
-};
+});
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 6d9ad39..72bb740 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -38,11 +38,9 @@ const Searchbar = imports.searchbar;
const Tweener = imports.util.tweener;
const WindowMode = imports.windowMode;
-function MainToolbar() {
- this._init();
-}
+const MainToolbar = new Lang.Class({
+ Name: 'MainToolbar',
-MainToolbar.prototype = {
_init: function() {
this._model = null;
@@ -308,17 +306,14 @@ MainToolbar.prototype = {
this._setToolbarTitle();
}
-};
+});
-function PreviewToolbar() {
- this._init();
-};
-
-PreviewToolbar.prototype = {
- __proto__: MainToolbar.prototype,
+const PreviewToolbar = new Lang.Class({
+ Name: 'PreviewToolbar',
+ Extends: MainToolbar,
_init: function() {
- MainToolbar.prototype._init.call(this);
+ this.parent();
this.actor.y = -(this.widget.get_preferred_height()[1]);
},
@@ -336,17 +331,14 @@ PreviewToolbar.prototype = {
time: 0.20,
transition: 'easeOutQuad' });
}
-};
-
-function OverviewToolbar() {
- this._init();
-};
+});
-OverviewToolbar.prototype = {
- __proto__: MainToolbar.prototype,
+const OverviewToolbar = new Lang.Class({
+ Name: 'OverviewToolbar',
+ Extends: MainToolbar,
_init: function() {
- MainToolbar.prototype._init.call(this);
+ this.parent();
this.searchbar = new Searchbar.Searchbar();
this.layout.pack_start = true;
@@ -355,7 +347,7 @@ OverviewToolbar.prototype = {
},
_resetToolbarMode: function() {
- MainToolbar.prototype._resetToolbarMode.call(this);
+ this.parent();
let mode = Global.modeController.getWindowMode();
@@ -365,4 +357,4 @@ OverviewToolbar.prototype = {
Global.searchController.getString() != '')
this.searchbar.show();
}
-};
+});
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 2e54080..b66f4d0 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -39,11 +39,9 @@ const _ = imports.gettext.gettext;
const _CONFIGURE_ID_TIMEOUT = 100; // msecs
-function MainWindow(app) {
- this._init(app);
-}
+const MainWindow = new Lang.Class({
+ Name: 'MainWindow',
-MainWindow.prototype = {
_init: function(app) {
this._configureId = 0;
@@ -247,4 +245,4 @@ MainWindow.prototype = {
aboutDialog.destroy();
});
}
-};
+});
diff --git a/src/manager.js b/src/manager.js
index c6edb9b..5e8574a 100644
--- a/src/manager.js
+++ b/src/manager.js
@@ -27,11 +27,9 @@ const Pango = imports.gi.Pango;
const Lang = imports.lang;
const Signals = imports.signals;
-function BaseManager(title) {
- this._init(title);
-};
+const BaseManager = new Lang.Class({
+ Name: 'BaseManager',
-BaseManager.prototype = {
_init: function(title) {
this._items = {};
this._activeItem = null;
@@ -164,7 +162,7 @@ BaseManager.prototype = {
// TODO: merge existing item properties with new values
}
-};
+});
Signals.addSignalMethods(BaseManager.prototype);
// GTK+ implementations
@@ -175,11 +173,9 @@ const BaseModelColumns = {
HEADING_TEXT: 2
};
-function BaseModel(manager) {
- this._init(manager);
-}
+const BaseModel = new Lang.Class({
+ Name: 'BaseModel',
-BaseModel.prototype = {
_init: function(manager) {
this.model = Gd.create_item_store();
this._manager = manager;
@@ -209,13 +205,11 @@ BaseModel.prototype = {
item.id, item.name, '');
}
}
-};
+});
-function BaseView(manager) {
- this._init(manager);
-}
+const BaseView = new Lang.Class({
+ Name: 'BaseView',
-BaseView.prototype = {
_init: function(manager) {
this._model = new BaseModel(manager);
this._manager = manager;
@@ -286,5 +280,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 554838e..65cb293 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -31,11 +31,9 @@ const Utils = imports.utils;
const Lang = imports.lang;
const Signals = imports.signals;
-function PrintNotification(printOp, doc) {
- this._init(printOp, doc);
-}
+const PrintNotification = new Lang.Class({
+ Name: 'PrintNotification',
-PrintNotification.prototype = {
_init: function(printOp, doc) {
this.widget = null;
this._printOp = printOp;
@@ -91,13 +89,11 @@ PrintNotification.prototype = {
if (fraction == 1)
this.widget.destroy();
}
-};
+});
-function NotificationManager() {
- this._init();
-}
+const NotificationManager = new Lang.Class({
+ Name: 'NotificationManager',
-NotificationManager.prototype = {
_init: function() {
this.widget = new Gd.Notification({ timeout: -1,
show_close_button: false });
@@ -132,5 +128,5 @@ NotificationManager.prototype = {
_onNotificationDismissed: function() {
}
-};
+});
Signals.addSignalMethods(NotificationManager.prototype);
diff --git a/src/offsetController.js b/src/offsetController.js
index 5160225..9d29a58 100644
--- a/src/offsetController.js
+++ b/src/offsetController.js
@@ -30,11 +30,9 @@ const GLib = imports.gi.GLib;
const _OFFSET_STEP = 50;
-function OffsetController() {
- this._init();
-};
+const OffsetController = new Lang.Class({
+ Name: 'OffsetController',
-OffsetController.prototype = {
_init: function() {
this._offset = 0;
this._itemCount = 0;
@@ -91,5 +89,5 @@ OffsetController.prototype = {
getOffset: function() {
return this._offset;
}
-};
+});
Signals.addSignalMethods(OffsetController.prototype);
diff --git a/src/preview.js b/src/preview.js
index 1a90c83..646820d 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -36,11 +36,9 @@ const View = imports.view;
const _FULLSCREEN_TOOLBAR_TIMEOUT = 2; // seconds
-function PreviewView(model) {
- this._init(model);
-}
+const PreviewView = new Lang.Class({
+ Name: 'PreviewView',
-PreviewView.prototype = {
_init: function(model) {
this._model = model;
@@ -116,13 +114,11 @@ 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 });
@@ -151,13 +147,11 @@ 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;
@@ -269,4 +263,4 @@ PreviewEmbed.prototype = {
return false;
}));
}
-};
+});
diff --git a/src/query.js b/src/query.js
index 7596512..6e7e2e5 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,18 @@ const QueryFlags = {
const LOCAL_COLLECTIONS_IDENTIFIER = 'gd:collection:local:';
-function Query(sparql) {
- this._init(sparql);
-}
+const Query = new Lang.Class({
+ Name: 'Query',
-Query.prototype = {
_init: function(sparql) {
this.sparql = sparql;
this.activeSource = Global.sourceManager.getActiveItem();
}
-};
+});
-function QueryBuilder() {
- this._init();
-}
+const QueryBuilder = new Lang.Class({
+ Name: 'QueryBuilder',
-QueryBuilder.prototype = {
_init: function() {
},
@@ -262,4 +259,4 @@ QueryBuilder.prototype = {
return new Query(sparql);
}
-};
+});
diff --git a/src/searchbar.js b/src/searchbar.js
index 0a66eaa..1dd3ec5 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -45,11 +45,9 @@ const SearchCategoryStock = {
PRIVATE: 'private'
};
-function SearchCategory(params) {
- this._init(params);
-};
+const SearchCategory = new Lang.Class({
+ Name: 'SearchCategory',
-SearchCategory.prototype = {
_init: function(params) {
this.id = params.id;
this.name = params.name;
@@ -74,17 +72,14 @@ 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 +105,11 @@ SearchCategoryManager.prototype = {
this.setActiveItem(recent);
}
-};
+});
-function SearchType(params) {
- this._init(params);
-}
+const SearchType = new Lang.Class({
+ Name: 'SearchType',
-SearchType.prototype = {
_init: function(params) {
this.id = params.id;
this.name = params.name;
@@ -126,17 +119,14 @@ 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 +149,7 @@ SearchTypeManager.prototype = {
this.setActiveItemById('all');
}
-};
+});
const SearchMatchStock = {
ALL: 'all',
@@ -167,11 +157,9 @@ const SearchMatchStock = {
AUTHOR: 'author'
};
-function SearchMatch(params) {
- this._init(params);
-}
+const SearchMatch = new Lang.Class({
+ Name: 'SearchMatch',
-SearchMatch.prototype = {
_init: function(params) {
this.id = params.id;
this.name = params.name;
@@ -193,19 +181,16 @@ 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 +210,15 @@ 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();
-};
+const SearchController = new Lang.Class({
+ Name: 'SearchController',
-SearchController.prototype = {
_init: function() {
this._dropdownState = false;
this._string = '';
@@ -269,14 +252,12 @@ SearchController.prototype = {
getDropdownState: function() {
return this._dropdownState;
}
-};
+});
Signals.addSignalMethods(SearchController.prototype);
-function Dropdown() {
- this._init();
-}
+const Dropdown = new Lang.Class({
+ Name: 'Dropdown',
-Dropdown.prototype = {
_init: function() {
this._sourceView = new Manager.BaseView(Global.sourceManager);
this._typeView = new Manager.BaseView(Global.searchTypeManager);
@@ -341,13 +322,11 @@ Dropdown.prototype = {
},
onCompleteScope: this });
}
-};
+});
-function Searchbar() {
- this._init();
-}
+const Searchbar = new Lang.Class({
+ Name: 'Searchbar',
-Searchbar.prototype = {
_init: function() {
this._searchEventId = 0;
this._searchFocusId = 0;
@@ -616,4 +595,4 @@ Searchbar.prototype = {
},
onCompleteScope: this });
}
-};
+});
diff --git a/src/selections.js b/src/selections.js
index 326933a..387d98f 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -42,11 +42,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 = [];
@@ -96,7 +94,7 @@ FetchCollectionsJob.prototype = {
if (this._callback)
this._callback(this._collections);
}
-};
+});
// fetch the state of every collection applicable to the selected items
const OrganizeCollectionState = {
@@ -106,11 +104,9 @@ const OrganizeCollectionState = {
HIDDEN: 1 << 2
};
-function FetchCollectionStateForSelectionJob() {
- this._init();
-}
+const FetchCollectionStateForSelectionJob = new Lang.Class({
+ Name: 'FetchCollectionStateForSelectionJob',
-FetchCollectionStateForSelectionJob.prototype = {
_init: function() {
this._collectionsForItems = {};
this._runningJobs = 0;
@@ -193,14 +189,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;
},
@@ -221,14 +215,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;
@@ -275,14 +267,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;
@@ -315,7 +305,7 @@ CreateCollectionJob.prototype = {
this._callback(this._createdUrn);
}));
}
-};
+});
const OrganizeModelColumns = {
ID: 0,
@@ -323,11 +313,9 @@ const OrganizeModelColumns = {
STATE: 2
};
-function OrganizeCollectionModel() {
- this._init();
-}
+const OrganizeCollectionModel = new Lang.Class({
+ Name: 'OrganizeCollectionModel',
-OrganizeCollectionModel.prototype = {
_init: function() {
this.model = Gd.create_organize_store();
this._placeholderRef = null;
@@ -453,13 +441,11 @@ OrganizeCollectionModel.prototype = {
this._collRemovedId = 0;
}
}
-};
+});
-function OrganizeCollectionView() {
- this._init();
-}
+const OrganizeCollectionView = new Lang.Class({
+ Name: 'OrganizeCollectionView',
-OrganizeCollectionView.prototype = {
_init: function() {
this._choiceConfirmed = false;
@@ -604,17 +590,15 @@ OrganizeCollectionView.prototype = {
confirmedChoice: function() {
this._choiceConfirmed = true;
}
-};
+});
const OrganizeCollectionDialogResponse = {
ADD: 1
};
-function OrganizeCollectionDialog(toplevel) {
- this._init(toplevel);
-};
+const OrganizeCollectionDialog = new Lang.Class({
+ Name: 'OrganizeCollectionDialog',
-OrganizeCollectionDialog.prototype = {
_init: function(toplevel) {
this.widget = new Gtk.Dialog({ transient_for: toplevel,
modal: true,
@@ -658,13 +642,11 @@ OrganizeCollectionDialog.prototype = {
this.widget.show_all();
}
-};
+});
-function SelectionController() {
- this._init();
-};
+const SelectionController = new Lang.Class({
+ Name: 'SelectionController',
-SelectionController.prototype = {
_init: function() {
this._selection = [];
this._selectionMode = false;
@@ -723,14 +705,12 @@ SelectionController.prototype = {
getSelectionMode: function() {
return this._selectionMode;
}
-};
+});
Signals.addSignalMethods(SelectionController.prototype);
-function SelectionToolbar() {
- this._init();
-}
+const SelectionToolbar = new Lang.Class({
+ Name: 'SelectionToolbar',
-SelectionToolbar.prototype = {
_init: function() {
this._itemListeners = {};
this._insideRefresh = false;
@@ -994,4 +974,4 @@ SelectionToolbar.prototype = {
},
onCompleteScope: this });
}
-};
+});
diff --git a/src/shellSearchProvider.js b/src/shellSearchProvider.js
index 6ddcb05..818cb47 100644
--- a/src/shellSearchProvider.js
+++ b/src/shellSearchProvider.js
@@ -113,11 +113,9 @@ function _createGIcon(cursor) {
return gicon;
}
-function CreateCollectionIconJob(id) {
- this._init(id);
-}
+const CreateCollectionIconJob = new Lang.Class({
+ Name: 'CreateCollectionIconJob',
-CreateCollectionIconJob.prototype = {
_init: function(id) {
this._id = id;
this._itemIcons = [];
@@ -225,13 +223,11 @@ CreateCollectionIconJob.prototype = {
_returnPixbuf: function() {
this._callback(Gd.create_collection_icon(_SHELL_SEARCH_ICON_SIZE, this._itemIcons));
}
-};
+});
-function FetchMetasJob(ids) {
- this._init(ids);
-}
+const FetchMetasJob = new Lang.Class({
+ Name: 'FetchMetasJob',
-FetchMetasJob.prototype = {
_init: function(ids) {
this._ids = ids;
this._metas = [];
@@ -295,13 +291,11 @@ FetchMetasJob.prototype = {
}));
}));
}
-};
+});
-function FetchIdsJob(terms) {
- this._init(terms);
-}
+const FetchIdsJob = new Lang.Class({
+ Name: 'FetchIdsJob',
-FetchIdsJob.prototype = {
_init: function(terms) {
this._terms = terms;
this._ids = [];
@@ -347,13 +341,11 @@ FetchIdsJob.prototype = {
this._callback(this._ids);
}
}
-};
+});
-function ShellSearchProvider() {
- this._init();
-}
+const ShellSearchProvider = new Lang.Class({
+ Name: 'ShellSearchProvider',
-ShellSearchProvider.prototype = {
_init: function() {
Gio.DBus.own_name(Gio.BusType.SESSION,
SEARCH_PROVIDER_NAME,
@@ -519,7 +511,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..e7ae399 100644
--- a/src/sources.js
+++ b/src/sources.js
@@ -33,11 +33,9 @@ const SourceStock = {
LOCAL: 'local'
}
-function Source(params) {
- this._init(params);
-};
+const Source = new Lang.Class({
+ Name: 'Source',
-Source.prototype = {
_init: function(params) {
this.id = null;
this.name = null;
@@ -77,17 +75,14 @@ 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 +122,4 @@ SourceManager.prototype = {
this.processNewItems(newItems);
}
-};
+});
diff --git a/src/spinnerBox.js b/src/spinnerBox.js
index c813c02..d100483 100644
--- a/src/spinnerBox.js
+++ b/src/spinnerBox.js
@@ -30,11 +30,9 @@ const Mainloop = imports.mainloop;
const _SPINNER_SIZE = 128;
-function SpinnerBox() {
- this._init();
-}
+const SpinnerBox = new Lang.Class({
+ Name: 'SpinnerBox',
-SpinnerBox.prototype = {
_init: function() {
this._delayedMoveId = 0;
@@ -104,4 +102,4 @@ SpinnerBox.prototype = {
return false;
}));
}
-};
+});
diff --git a/src/trackerController.js b/src/trackerController.js
index 045122f..901dd0e 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -35,11 +35,9 @@ const QueryType = {
UPDATE_BLANK: 2
};
-function TrackerConnectionQueue() {
- this._init();
-}
+const TrackerConnectionQueue = new Lang.Class({
+ Name: 'TrackerConnectionQueue',
-TrackerConnectionQueue.prototype = {
_init: function() {
this._queue = [];
this._running = false;
@@ -101,18 +99,16 @@ TrackerConnectionQueue.prototype = {
this._running = false;
this._checkQueue();
}
-};
+});
const RefreshFlags = {
NONE: 0,
RESET_OFFSET: 1 << 0
};
-function TrackerController() {
- this._init();
-}
+const TrackerController = new Lang.Class({
+ Name: 'TrackerController',
-TrackerController.prototype = {
_init: function() {
this._currentQuery = null;
this._cancellable = new Gio.Cancellable();
@@ -270,5 +266,5 @@ TrackerController.prototype = {
this._refreshInternal(RefreshFlags.NONE);
}
-};
+});
Signals.addSignalMethods(TrackerController.prototype);
diff --git a/src/view.js b/src/view.js
index e5923a8..7d4652a 100644
--- a/src/view.js
+++ b/src/view.js
@@ -35,11 +35,9 @@ const TrackerUtils = imports.trackerUtils;
const WindowMode = imports.windowMode;
const Utils = imports.utils;
-function ContextMenu(urns) {
- this._init(urns);
-}
+const ContextMenu = new Lang.Class({
+ Name: 'ContextMenu',
-ContextMenu.prototype = {
_init: function(urns) {
let favCount = 0;
let apps = [];
@@ -103,13 +101,11 @@ ContextMenu.prototype = {
this.widget.show_all();
}
-};
+});
-function View() {
- this._init();
-}
+const View = new Lang.Class({
+ Name: 'View',
-View.prototype = {
_init: function() {
this.widget = new Gd.MainView();
@@ -296,4 +292,4 @@ View.prototype = {
this._treeModel);
Global.selectionController.setSelection(selectedURNs);
}
-};
+});
diff --git a/src/windowMode.js b/src/windowMode.js
index b489163..d1d4992 100644
--- a/src/windowMode.js
+++ b/src/windowMode.js
@@ -19,6 +19,7 @@
*
*/
+const Lang = imports.lang;
const Signals = imports.signals;
const WindowMode = {
@@ -27,11 +28,9 @@ const WindowMode = {
PREVIEW: 2
};
-function ModeController() {
- this._init();
-};
+const ModeController = new Lang.Class({
+ Name: 'ModeController',
-ModeController.prototype = {
_init: function() {
this._mode = WindowMode.NONE;
this._fullscreen = false;
@@ -89,5 +88,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]