[gnome-maps/wip/mlundblad/es6] WIP: Use ES6 classes with GObject extensions



commit cb9a780b81bb84f4a961ed15b7ee5ce9a4fa2ad9
Author: Marcus Lundblad <ml update uu se>
Date:   Mon Nov 20 21:27:49 2017 +0100

    WIP: Use ES6 classes with GObject extensions

 src/accountListBox.js              |   26 +++----
 src/application.js                 |   88 ++++++++++++-------------
 src/busyMarker.js                  |    8 +--
 src/checkIn.js                     |   55 +++++++--------
 src/checkInDialog.js               |   58 ++++++++--------
 src/contactPlace.js                |   16 ++---
 src/contextMenu.js                 |   48 +++++++-------
 src/exportViewDialog.js            |   40 +++++------
 src/facebookBackend.js             |   52 +++++++--------
 src/favoritesPopover.js            |   20 +++---
 src/foursquareBackend.js           |   51 +++++++-------
 src/foursquareGoaAuthorizer.js     |   29 ++++-----
 src/geoJSONShapeLayer.js           |   24 ++++---
 src/geoJSONSource.js               |   78 +++++++++++-----------
 src/geoJSONStyle.js                |   13 ++--
 src/geoclue.js                     |   26 ++++----
 src/geocodeService.js              |   15 ++---
 src/gpxShapeLayer.js               |   18 +++--
 src/graphHopper.js                 |   47 ++++++-------
 src/http.js                        |   16 ++---
 src/instructionRow.js              |   13 ++--
 src/kmlShapeLayer.js               |   19 +++---
 src/layersPopover.js               |   36 +++++-----
 src/location.js                    |   17 ++---
 src/locationServiceNotification.js |   11 ++--
 src/longPrintLayout.js             |   17 ++---
 src/mainWindow.js                  |  129 +++++++++++++++++------------------
 src/mapBubble.js                   |   37 +++++------
 src/mapMarker.js                   |   94 +++++++++++++-------------
 src/serviceBackend.js              |   44 ++++++------
 src/shapeLayer.js                  |   38 +++++-----
 31 files changed, 565 insertions(+), 618 deletions(-)
---
diff --git a/src/accountListBox.js b/src/accountListBox.js
index e45a21e..e829535 100644
--- a/src/accountListBox.js
+++ b/src/accountListBox.js
@@ -21,25 +21,23 @@
 
 const Gio = imports.gi.Gio;
 const Goa = imports.gi.Goa;
+const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 
 const Application = imports.application;
 
-var AccountRow = new Lang.Class({
-    Name: 'AccountRow',
-    Extends: Gtk.ListBoxRow,
+var AccountRow = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/account-row.ui',
     InternalChildren: [ 'providerLabel',
                         'identityLabel',
                         'providerImage',
                         'attentionNeededImage' ],
-
-    _init: function(params) {
+}, class AccountRow extends Gtk.ListBoxRow {
+    _init(params) {
         this.account = params.account;
         delete params.account;
 
-        this.parent(params);
+        super._init(params);
 
         let account = this.account.get_account();
 
@@ -50,16 +48,14 @@ var AccountRow = new Lang.Class({
     }
 });
 
-var AccountListBox = new Lang.Class({
-    Name: 'AccountListBox',
-    Extends: Gtk.ListBox,
+var AccountListBox = GObject.registerClass({
     Signals: {
         'account-selected': { param_types: [Goa.Object] }
     },
-
-    _init: function(params) {
+}, class AccountListBox extends Gtk.ListBox {
+    _init(params) {
         params.activate_on_single_click = true;
-        this.parent(params);
+        super._init(params);
 
         Application.checkInManager.connect('accounts-refreshed', () => { this.refresh(); });
 
@@ -67,9 +63,9 @@ var AccountListBox = new Lang.Class({
                      (list, row) => { this.emit('account-selected', row.account); });
 
         this.refresh();
-    },
+    }
 
-    refresh: function() {
+    refresh() {
         let accounts = Application.checkInManager.accounts;
 
         this.forall(function(row) {
diff --git a/src/application.js b/src/application.js
index c155ba3..6e2fb9f 100644
--- a/src/application.js
+++ b/src/application.js
@@ -25,7 +25,6 @@ const GObject = imports.gi.GObject;
 const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
 const GtkClutter = imports.gi.GtkClutter;
-const Lang = imports.lang;
 const WebKit2 = imports.gi.WebKit2;
 
 const CheckIn = imports.checkIn;
@@ -62,9 +61,7 @@ var routeQuery = null;
 const _ensuredTypes = [WebKit2.WebView,
                        OSMTypeSearchEntry.OSMTypeSearchEntry];
 
-var Application = new Lang.Class({
-    Name: 'Application',
-    Extends: Gtk.Application,
+var Application = GObject.registerClass({
     Properties: {
         'connected': GObject.ParamSpec.boolean('connected',
                                                '',
@@ -72,24 +69,25 @@ var Application = new Lang.Class({
                                                GObject.ParamFlags.READABLE |
                                                GObject.ParamFlags.WRITABLE)
     },
+}, class Application extends Gtk.Application {
 
     set connected(p) {
         this._connected = p;
         this.notify('connected');
-    },
+    }
 
     get connected() {
         return this._connected;
-    },
+    }
 
-    _init: function() {
+    _init() {
         /* Translators: This is the program name. */
         GLib.set_application_name(_("Maps"));
 
         /* Needed to be able to use in UI files */
         _ensuredTypes.forEach((type) => { GObject.type_ensure(type); });
 
-        this.parent({ application_id: 'org.gnome.Maps',
+        super._init({ application_id: 'org.gnome.Maps',
                       flags: Gio.ApplicationFlags.HANDLES_OPEN });
         this._connected = false;
 
@@ -118,13 +116,13 @@ var Application = new Lang.Class({
 
             return -1;
         });
-    },
+    }
 
-    _checkNetwork: function() {
+    _checkNetwork() {
         this.connected = networkMonitor.connectivity === Gio.NetworkConnectivity.FULL;
-    },
+    }
 
-    _showContact: function(id) {
+    _showContact(id) {
         contactStore.lookup(id, (contact) => {
             this._mainWindow.markBusy();
             if (!contact) {
@@ -136,9 +134,9 @@ var Application = new Lang.Class({
                 this._mainWindow.mapView.showContact(contact);
             });
         });
-    },
+    }
 
-    _onShowContactActivate: function(action, parameter) {
+    _onShowContactActivate(action, parameter) {
         this._createWindow();
         this._checkNetwork();
         this._mainWindow.present();
@@ -153,20 +151,20 @@ var Application = new Lang.Class({
                     this._showContact(id);
             });
         }
-    },
+    }
 
-    _onQuitActivate: function() {
+    _onQuitActivate() {
         this._mainWindow.destroy();
-    },
+    }
 
-    _onOsmAccountSetupActivate: function() {
+    _onOsmAccountSetupActivate() {
         let dialog = osmEdit.createAccountDialog(this._mainWindow, false);
 
         dialog.show();
         dialog.connect('response', () => { dialog.destroy(); });
-    },
+    }
 
-    _addContacts: function() {
+    _addContacts() {
         contactStore.get_contacts().forEach((contact) => {
             contact.geocode(function() {
                 contact.get_places().forEach((p) => {
@@ -180,9 +178,9 @@ var Application = new Lang.Class({
                 });
             });
         });
-    },
+    }
 
-    _initPlaceStore: function() {
+    _initPlaceStore() {
         placeStore = new PlaceStore.PlaceStore({
             recentPlacesLimit: settings.get('recent-places-limit'),
             recentRoutesLimit: settings.get('recent-routes-limit')
@@ -202,18 +200,18 @@ var Application = new Lang.Class({
                     this._addContacts();
             });
         }
-    },
+    }
 
-    _initAppMenu: function() {
+    _initAppMenu() {
         let builder = new Gtk.Builder();
         builder.add_from_resource('/org/gnome/Maps/ui/app-menu.ui');
 
         let menu = builder.get_object('app-menu');
         this.set_app_menu(menu);
-    },
+    }
 
-    vfunc_startup: function() {
-        this.parent();
+    vfunc_startup() {
+        super.vfunc_startup();
 
         GtkClutter.init(null);
 
@@ -237,9 +235,9 @@ var Application = new Lang.Class({
                                                                              'icons']));
         this._initPlaceStore();
         this._initAppMenu();
-    },
+    }
 
-    _initServices: function() {
+    _initServices() {
         settings         = Settings.getSettings('org.gnome.Maps');
         routeQuery       = new RouteQuery.RouteQuery();
         routingDelegator = new RoutingDelegator.RoutingDelegator({ query: routeQuery });
@@ -252,9 +250,9 @@ var Application = new Lang.Class({
         contactStore = new Maps.ContactStore();
         contactStore.load();
         osmEdit = new OSMEdit.OSMEdit();
-    },
+    }
 
-    _createWindow: function() {
+    _createWindow() {
         if (this._mainWindow)
             return;
 
@@ -268,24 +266,24 @@ var Application = new Lang.Class({
                 log('* focus widget: %s'.format(widget));
             });
         }
-    },
+    }
 
-    vfunc_dbus_register: function(connection, path) {
-        this.parent(connection, path);
+    vfunc_dbus_register(connection, path) {
+        super.vfunc_dbus_register(connection, path);
         return true;
-    },
+    }
 
-    vfunc_dbus_unregister: function(connection, path) {
-        this.parent(connection, path);
-    },
+    vfunc_dbus_unregister(connection, path) {
+        super.vfunc_dbus_register(connection, path);
+    }
 
-    vfunc_activate: function() {
+    vfunc_activate() {
         this._createWindow();
         this._checkNetwork();
         this._mainWindow.present();
-    },
+    }
 
-    _openInternal: function(files) {
+    _openInternal(files) {
         if (!this._mainWindow || !this._mainWindow.mapView.view.realized)
             return;
 
@@ -298,9 +296,9 @@ var Application = new Lang.Class({
         } else {
             this._mainWindow.mapView.openShapeLayers(files);
         }
-    },
+    }
 
-    vfunc_open: function(files) {
+    vfunc_open(files) {
         normalStartup = false;
         this.activate();
 
@@ -310,9 +308,9 @@ var Application = new Lang.Class({
         else
             mapView.view.connect('notify::realized',
                                  this._openInternal.bind(this, files));
-    },
+    }
 
-    _onWindowDestroy: function(window) {
+    _onWindowDestroy(window) {
         this._mainWindow = null;
     }
 });
diff --git a/src/busyMarker.js b/src/busyMarker.js
index b53962d..3f99c3d 100644
--- a/src/busyMarker.js
+++ b/src/busyMarker.js
@@ -18,10 +18,8 @@
  */
 
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
-var BusyMarker = new Lang.Class({
-    Name: 'BusyMarker',
-    Extends: Gtk.Frame,
+var BusyMarker = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/busy-marker.ui'
-});
+}, class BusyMarker extends Gtk.Frame {});
diff --git a/src/checkIn.js b/src/checkIn.js
index d75d492..e314da7 100644
--- a/src/checkIn.js
+++ b/src/checkIn.js
@@ -22,15 +22,12 @@
 const GObject = imports.gi.GObject;
 const Goa = imports.gi.Goa;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 
 const CheckInDialog = imports.checkInDialog;
 const FacebookBackend = imports.facebookBackend;
 const FoursquareBackend = imports.foursquareBackend;
 
-var CheckInManager = new Lang.Class({
-    Name: 'CheckInManager',
-    Extends: GObject.Object,
+var CheckInManager = GObject.registerClass({
     Signals: {
         'accounts-refreshed': { }
     },
@@ -39,10 +36,10 @@ var CheckInManager = new Lang.Class({
                                                 '',
                                                 '',
                                                 GObject.ParamFlags.READABLE)
-    },
-
-    _init: function() {
-        this.parent();
+    }
+}, class CheckInManager extends GObject.Object {
+    _init() {
+        super._init();
 
         try {
             this._goaClient = Goa.Client.new_sync(null);
@@ -66,17 +63,17 @@ var CheckInManager = new Lang.Class({
         }
 
         this._refreshGoaAccounts();
-    },
+    }
 
-    _initBackends: function() {
+    _initBackends() {
         let facebookBackend = new FacebookBackend.FacebookBackend();
         this._backends[facebookBackend.name] = facebookBackend;
 
         let foursquareBackend = new FoursquareBackend.FoursquareBackend();
         this._backends[foursquareBackend.name] = foursquareBackend;
-    },
+    }
 
-    _refreshGoaAccounts: function() {
+    _refreshGoaAccounts() {
         if (!this._goaClient)
             return;
         let accounts = this._goaClient.get_accounts();
@@ -99,39 +96,39 @@ var CheckInManager = new Lang.Class({
 
         this.emit('accounts-refreshed');
         this.notify('hasCheckIn');
-    },
+    }
 
     get client() {
         return this._goaClient;
-    },
+    }
 
     get accounts() {
         return this._accounts;
-    },
+    }
 
     get hasCheckIn() {
         return this._accounts.length > 0;
-    },
+    }
 
-    _getAuthorizer: function(account) {
+    _getAuthorizer(account) {
         return this._authorizers[account.get_account().id];
-    },
+    }
 
-    _getBackend: function(account) {
+    _getBackend(account) {
         return this._backends[account.get_account().provider_type];
-    },
+    }
 
-    performCheckIn: function(account, checkIn, callback, cancellable) {
+    performCheckIn(account, checkIn, callback, cancellable) {
         this._getBackend(account)
             .performCheckIn(this._getAuthorizer(account), checkIn, callback, cancellable);
-    },
+    }
 
-    findPlaces: function(account, latitude, longitude, distance, callback, cancellable) {
+    findPlaces(account, latitude, longitude, distance, callback, cancellable) {
         this._getBackend(account)
             .findPlaces(this._getAuthorizer(account), latitude, longitude, distance, callback, cancellable);
-    },
+    }
 
-    showCheckInDialog: function(parentWindow, place, matchPlace) {
+    showCheckInDialog(parentWindow, place, matchPlace) {
         let dialog = new CheckInDialog.CheckInDialog({ transient_for: parentWindow,
                                                        matchPlace: matchPlace,
                                                        place: place });
@@ -170,14 +167,12 @@ var CheckInManager = new Lang.Class({
     }
 });
 
-var CheckIn = new Lang.Class({
-    Name: 'CheckIn',
-
-    _init: function() {
+var CheckIn = class {
+    _init() {
         this.message = null;
         this.place = null;
         this.privacy = null;
         this.broadcastFacebook = false;
         this.broadcastTwitter = false;
     }
-});
+};
diff --git a/src/checkInDialog.js b/src/checkInDialog.js
index 66dd6e9..371465b 100644
--- a/src/checkInDialog.js
+++ b/src/checkInDialog.js
@@ -20,8 +20,8 @@
  */
 
 const Gio = imports.gi.Gio;
+const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const AccountListBox = imports.accountListBox;
@@ -39,9 +39,7 @@ var Response = {
     FAILURE_CHECKIN_DISABLED: 5
 };
 
-var CheckInDialog = new Lang.Class({
-    Name: 'CheckInDialog',
-    Extends: Gtk.Dialog,
+var CheckInDialog = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/check-in-dialog.ui',
     InternalChildren: [ 'cancelButton',
                         'okButton',
@@ -59,8 +57,8 @@ var CheckInDialog = new Lang.Class({
                         'foursquareOptionsPrivacyComboBox',
                         'foursquareOptionsBroadcastFacebookCheckButton',
                         'foursquareOptionsBroadcastTwitterCheckButton' ],
-
-    _init: function(params) {
+}, class CheckInDialog extends Gtk.Dialog {
+    _init(params) {
         this._place = params.place;
         delete params.place;
 
@@ -70,7 +68,7 @@ var CheckInDialog = new Lang.Class({
         // This is a construct-only property and cannot be set by GtkBuilder
         params.use_header_bar = true;
 
-        this.parent(params);
+        super._init(params);
 
         this._account = null;
         this._checkIn = new CheckIn.CheckIn();
@@ -86,16 +84,16 @@ var CheckInDialog = new Lang.Class({
 
         this._initHeaderBar();
         this._initWidgets();
-    },
+    }
 
-    _initHeaderBar: function() {
+    _initHeaderBar() {
         this._cancelButton.connect('clicked',
                                    () => { this._cancellable.cancel(); });
 
         this._okButton.connect('clicked', () => { this._startCheckInStep(); });
-    },
+    }
 
-    _initWidgets: function() {
+    _initWidgets() {
         // Limitations in Gjs means we can't do this in UI files yet
         this._accountListBox = new AccountListBox.AccountListBox({ visible: true });
         this._accountFrame.add(this._accountListBox);
@@ -128,14 +126,14 @@ var CheckInDialog = new Lang.Class({
             this._checkIn.place = place;
             this._startMessageStep();
         });
-    },
+    }
 
-    vfunc_show: function() {
+    vfunc_show() {
         this._startup();
-        this.parent();
-    },
+        super.vfunc_show();
+    }
 
-    _startup: function() {
+    _startup() {
         let accounts = Application.checkInManager.accounts;
 
         if (accounts.length > 1)
@@ -148,9 +146,9 @@ var CheckInDialog = new Lang.Class({
                 this.response(Response.FAILURE_CHECKIN_DISABLED);
             });
         }
-    },
+    }
 
-    _onAccountRefreshed: function() {
+    _onAccountRefreshed() {
         let accounts = Application.checkInManager.accounts;
 
         if (!Application.checkInManager.hasCheckIn)
@@ -163,14 +161,14 @@ var CheckInDialog = new Lang.Class({
 
             this.response(Response.FAILURE_ACCOUNT_DISABLED);
         }
-    },
+    }
 
-    _startAccountStep: function() {
+    _startAccountStep() {
         this.set_title(_("Select an account"));
         this._stack.set_visible_child_name('account');
-    },
+    }
 
-    _startPlaceStep: function() {
+    _startPlaceStep() {
         this.set_title(_("Loading"));
         this._stack.set_visible_child_name('loading');
 
@@ -180,9 +178,9 @@ var CheckInDialog = new Lang.Class({
                                               100,
                                               this._onFindPlacesFinished.bind(this),
                                               this._cancellable);
-    },
+    }
 
-    _onFindPlacesFinished: function(account, places, error) {
+    _onFindPlacesFinished(account, places, error) {
         if (!error) {
             if (places.length === 0) {
                 this.response(Response.FAILURE_NO_PLACES);
@@ -212,9 +210,9 @@ var CheckInDialog = new Lang.Class({
             this.error = error;
             this.response(Response.FAILURE_GET_PLACES);
         }
-    },
+    }
 
-    _startMessageStep: function() {
+    _startMessageStep() {
         /* Translators: %s is the name of the place to check in.
          */
         this.set_title(_("Check in to %s").format(this._checkIn.place.name));
@@ -240,9 +238,9 @@ var CheckInDialog = new Lang.Class({
                 optionsGrids[provider].show();
             else
                 optionsGrids[provider].hide();
-    },
+    }
 
-    _startCheckInStep: function() {
+    _startCheckInStep() {
         this.set_title(_("Loading"));
         this._stack.set_visible_child_name('loading');
 
@@ -268,9 +266,9 @@ var CheckInDialog = new Lang.Class({
                                                   this._checkIn,
                                                   this._onPerformCheckInFinished.bind(this),
                                                   this._cancellable);
-    },
+    }
 
-    _onPerformCheckInFinished: function (account, data, error) {
+    _onPerformCheckInFinished(account, data, error) {
         if (!error)
             this.response(Response.SUCCESS);
         else {
diff --git a/src/contactPlace.js b/src/contactPlace.js
index b2d8876..961ea29 100644
--- a/src/contactPlace.js
+++ b/src/contactPlace.js
@@ -19,25 +19,23 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 const Place = imports.place;
 
-var ContactPlace = new Lang.Class({
-    Name: 'ContactPlace',
-    Extends: Place.Place,
-
-    _init: function(params) {
+var ContactPlace = GObject.registerClass({},
+class ContactPlace extends Place.Place {
+    _init(params) {
         this._contact = params.contact;
         delete params.contact;
 
         params.store = false;
-        this.parent(params);
-    },
+        super._init(params);
+    }
 
     get icon() {
         return this._contact.icon;
-    },
+    }
 
     get uniqueID() {
         return [this.name,
diff --git a/src/contextMenu.js b/src/contextMenu.js
index c80b42b..d604991 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -22,12 +22,12 @@
 const Champlain = imports.gi.Champlain;
 const Gdk = imports.gi.Gdk;
 const Geocode = imports.gi.GeocodeGlib;
+const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
 const Mainloop = imports.mainloop;
 
 const Application = imports.application;
 const ExportViewDialog = imports.exportViewDialog;
-const Lang = imports.lang;
 const Location = imports.location;
 const OSMAccountDialog = imports.osmAccountDialog;
 const OSMEdit = imports.osmEdit;
@@ -36,24 +36,22 @@ const Place = imports.place;
 const Utils = imports.utils;
 const ZoomInNotification = imports.zoomInNotification;
 
-var ContextMenu = new Lang.Class({
-    Name: 'ContextMenu',
-    Extends: Gtk.Menu,
+var ContextMenu = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/context-menu.ui',
     InternalChildren: [ 'whatsHereItem',
                         'geoURIItem',
                         'exportItem',
                         'addOSMLocationItem',
                         'routeItem' ],
-
-    _init: function(params) {
+}, class ContextMenu extends Gtk.Menu {
+    _init(params) {
         this._mapView = params.mapView;
         delete params.mapView;
 
         this._mainWindow = params.mainWindow;
         delete params.mainWindow;
 
-        this.parent(params);
+        super._init(params);
 
         this._mapView.connect('button-release-event',
                               this._onButtonReleaseEvent.bind(this));
@@ -72,9 +70,9 @@ var ContextMenu = new Lang.Class({
                                        this._routingUpdate.bind(this));
         this._routeItem.visible = false;
         this._routingUpdate();
-    },
+    }
 
-    _onButtonReleaseEvent: function(widget, event) {
+    _onButtonReleaseEvent(widget, event) {
         let [, button] = event.get_button();
         let [, x, y] = event.get_coords();
         this._longitude = this._mapView.view.x_to_longitude(x);
@@ -84,9 +82,9 @@ var ContextMenu = new Lang.Class({
             // Need idle to avoid Clutter dead-lock on re-entrance
             Mainloop.idle_add(() => { this.popup_at_pointer(event); });
         }
-    },
+    }
 
-    _routingUpdate: function() {
+    _routingUpdate() {
         let query = Application.routeQuery;
 
         if (query.points.length === 0)
@@ -100,9 +98,9 @@ var ContextMenu = new Lang.Class({
         } else {
             this._routeItem.label = _("Route to here");
         }
-    },
+    }
 
-    _onRouteActivated: function() {
+    _onRouteActivated() {
         let query = Application.routeQuery;
         let location = new Location.Location({ latitude: this._latitude,
                                                longitude: this._longitude,
@@ -116,9 +114,9 @@ var ContextMenu = new Lang.Class({
         } else {
             query.points[query.points.length - 1].place = place;
         }
-    },
+    }
 
-    _onWhatsHereActivated: function() {
+    _onWhatsHereActivated() {
         let location = new Location.Location({ latitude: this._latitude,
                                                longitude: this._longitude,
                                                accuracy: 0 });
@@ -131,9 +129,9 @@ var ContextMenu = new Lang.Class({
                 Application.notificationManager.showMessage(msg);
             }
         });
-    },
+    }
 
-    _onGeoURIActivated: function() {
+    _onGeoURIActivated() {
         let location = new Location.Location({ latitude: this._latitude,
                                                longitude: this._longitude,
                                                accuracy: 0 });
@@ -142,9 +140,9 @@ var ContextMenu = new Lang.Class({
         let uri = location.to_uri(Geocode.LocationURIScheme.GEO);
 
         clipboard.set_text(uri, uri.length);
-    },
+    }
 
-    _onAddOSMLocationActivated: function() {
+    _onAddOSMLocationActivated() {
         let osmEdit = Application.osmEdit;
         /* if the user is not alread signed in, show the account dialog */
         if (!osmEdit.isSignedIn) {
@@ -161,9 +159,9 @@ var ContextMenu = new Lang.Class({
         }
 
         this._addOSMLocation();
-    },
+    }
 
-    _addOSMLocation: function() {
+    _addOSMLocation() {
         let osmEdit = Application.osmEdit;
 
         if (this._mapView.view.get_zoom_level() < OSMEdit.MIN_ADD_LOCATION_ZOOM_LEVEL) {
@@ -187,9 +185,9 @@ var ContextMenu = new Lang.Class({
                     _("Location was added to the map, note that it may take a while before it shows on the 
map and in search results."));
             }
         });
-    },
+    }
 
-    _activateExport: function() {
+    _activateExport() {
         let view = this._mapView.view;
         let surface = view.to_surface(true);
         let bbox = view.get_bounding_box();
@@ -206,9 +204,9 @@ var ContextMenu = new Lang.Class({
 
         dialog.connect('response', () => { dialog.destroy(); });
         dialog.show_all();
-    },
+    }
 
-    _onExportActivated: function() {
+    _onExportActivated() {
         if (this._mapView.view.state === Champlain.State.DONE) {
             this._activateExport();
         } else {
diff --git a/src/exportViewDialog.js b/src/exportViewDialog.js
index c946563..55295dc 100644
--- a/src/exportViewDialog.js
+++ b/src/exportViewDialog.js
@@ -21,8 +21,8 @@ const Cairo = imports.cairo;
 const Gdk = imports.gi.Gdk;
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
+const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 
 const Utils = imports.utils;
 
@@ -33,9 +33,7 @@ var Response = {
 
 const _PREVIEW_WIDTH = 150;
 
-var ExportViewDialog = new Lang.Class({
-    Name: 'ExportViewDialog',
-    Extends: Gtk.Dialog,
+var ExportViewDialog = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/export-view-dialog.ui',
     InternalChildren: [ 'exportButton',
                         'cancelButton',
@@ -43,8 +41,8 @@ var ExportViewDialog = new Lang.Class({
                         'fileChooserButton',
                         'previewArea',
                         'layersCheckButton' ],
-
-    _init: function(params) {
+}, class ExportViewDialog extends Gtk.Dialog {
+    _init(params) {
         this._surface = params.surface;
         delete params.surface;
 
@@ -58,7 +56,7 @@ var ExportViewDialog = new Lang.Class({
         delete params.mapView;
 
         params.use_header_bar = true;
-        this.parent(params);
+        super._init(params);
 
         this._cancelButton.connect('clicked', () => { this.response(Response.CANCEL); });
         this._exportButton.connect('clicked', () => { this._exportView(); });
@@ -74,18 +72,18 @@ var ExportViewDialog = new Lang.Class({
         this._filenameEntry.text = this._fileName = this._getName();
         this._fileChooserButton.set_current_folder(this._folder);
         this._setupPreviewArea();
-    },
+    }
 
-    _getName: function() {
+    _getName() {
         /* Translators: This is a format string for a PNG filename for an
          * exported image with coordinates. The .png extension should be kept
          * intact in the translated string.
          */
         return _("Maps at %f, %f.png").format(this._latitude.toFixed(2),
                                               this._longitude.toFixed(2));
-    },
+    }
 
-    _setupPreviewArea: function() {
+    _setupPreviewArea() {
         let [surfaceWidth, surfaceHeight] = this._mapView.view.get_size();
 
         let width = _PREVIEW_WIDTH;
@@ -95,9 +93,9 @@ var ExportViewDialog = new Lang.Class({
         this._previewArea.set_size_request(width, height);
         this._previewArea.connect('draw',
                                   (w, cr) => { this._drawPreview(w, cr); });
-    },
+    }
 
-    _drawPreview: function(widget, cr) {
+    _drawPreview(widget, cr) {
         cr.setOperator(Cairo.Operator.CLEAR);
         cr.paint();
         cr.setOperator(Cairo.Operator.OVER);
@@ -105,9 +103,9 @@ var ExportViewDialog = new Lang.Class({
         cr.scale(this._scaleFactor, this._scaleFactor);
         cr.setSourceSurface(this._surface, 0, 0);
         cr.paint();
-    },
+    }
 
-    _onFileNameChanged: function() {
+    _onFileNameChanged() {
         let name = GLib.filename_from_utf8(this._filenameEntry.text, -1)[0];
         name = name.toString();
         if (!name) {
@@ -122,9 +120,9 @@ var ExportViewDialog = new Lang.Class({
         } catch(e) {
             this._exportButton.sensitive = false;
         }
-    },
+    }
 
-    _onFolderChanged: function() {
+    _onFolderChanged() {
         let folder = this._fileChooserButton.get_filename();
 
         if (!GLib.file_test(folder, GLib.FileTest.IS_DIR)) {
@@ -138,9 +136,9 @@ var ExportViewDialog = new Lang.Class({
 
         this._exportButton.sensitive = true;
         this._folder = folder;
-    },
+    }
 
-    _exportView: function() {
+    _exportView() {
         let [width, height] = this._mapView.view.get_size();
         let pixbuf = Gdk.pixbuf_get_from_surface(this._surface, 0, 0, width, height);
         let path = GLib.build_filenamev([this._folder, this._fileName]);
@@ -174,9 +172,9 @@ var ExportViewDialog = new Lang.Class({
             dialog.connect('response', () => { dialog.destroy(); });
             dialog.show_all();
         }
-    },
+    }
 
-    _includeLayersChanged: function() {
+    _includeLayersChanged() {
         let includeLayers = this._layersCheckButton.get_active();
 
         this._surface = this._mapView.view.to_surface(includeLayers);
diff --git a/src/facebookBackend.js b/src/facebookBackend.js
index c01306f..9bf0f7d 100644
--- a/src/facebookBackend.js
+++ b/src/facebookBackend.js
@@ -20,43 +20,41 @@
  */
 
 const GFBGraph = imports.gi.GFBGraph;
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 const ServiceBackend = imports.serviceBackend;
 const SocialPlace = imports.socialPlace;
 
 const _PLACE_LINK_FORMAT = 'https://www.facebook.com/%s';
 
-var FacebookBackend = new Lang.Class({
-    Name: 'SocialServiceFacebookBackend',
-    Extends: ServiceBackend.ServiceBackend,
-
+var FacebookBackend = GObject.registerClass({},
+class FacebookBackend extends ServiceBackend.ServiceBackend {
     get name() {
         return 'facebook';
-    },
+    }
 
-    createRestCall: function(authorizer) {
+    createRestCall(authorizer) {
         return GFBGraph.new_rest_call(authorizer);
-    },
+    }
 
-    refreshAuthorization: function(authorizer, cancellable) {
+    refreshAuthorization(authorizer, cancellable) {
         return authorizer.refresh_authorization(cancellable);
-    },
+    }
 
-    getAuthorizerAccount: function(authorizer) {
+    getAuthorizerAccount(authorizer) {
         return authorizer.goa_object;
-    },
+    }
 
-    createAuthorizer: function(account) {
+    createAuthorizer(account) {
         return new GFBGraph.GoaAuthorizer({ goa_object: account });
-    },
+    }
 
-    isTokenInvalid: function(restCall, data) {
+    isTokenInvalid(restCall, data) {
         return data.error &&
                (data.error.code === 2500 || data.error.code === 104 || data.error.code === 190);
-    },
+    }
 
-    isInvalidCall: function(restCall, data) {
+    isInvalidCall(restCall, data) {
         if (!data) {
             return true;
         } else if (data.error) {
@@ -64,21 +62,21 @@ var FacebookBackend = new Lang.Class({
         } else {
             return false;
         }
-    },
+    }
 
-    getCallResultCode: function(restCall, data) {
+    getCallResultCode(restCall, data) {
         return data ?
             (data.error ? data.error.code : null) :
             restCall.get_status_code();
-    },
+    }
 
-    getCallResultMessage: function(restCall, data) {
+    getCallResultMessage(restCall, data) {
         return data ?
             (data.error ? data.error.message : null) :
             restCall.get_status_message();
-    },
+    }
 
-    _realPerformCheckIn: function(authorizer, checkIn, callback, cancellable) {
+    _realPerformCheckIn(authorizer, checkIn, callback, cancellable) {
         this.callAsync(authorizer,
                        'POST',
                        'me/feed',
@@ -89,9 +87,9 @@ var FacebookBackend = new Lang.Class({
                        },
                        callback,
                        cancellable);
-    },
+    }
 
-    _realFindPlaces: function(authorizer, latitude, longitude, distance, callback, cancellable) {
+    _realFindPlaces(authorizer, latitude, longitude, distance, callback, cancellable) {
         this.callAsync(authorizer,
                        'GET',
                        'search',
@@ -102,9 +100,9 @@ var FacebookBackend = new Lang.Class({
                        },
                        callback,
                        cancellable);
-    },
+    }
 
-    createPlaces: function(rawData) {
+    createPlaces(rawData) {
         return rawData.data.map(function(place) {
             let link = _PLACE_LINK_FORMAT.format(place.id);
 
diff --git a/src/favoritesPopover.js b/src/favoritesPopover.js
index e6a5a0d..34e4ad2 100644
--- a/src/favoritesPopover.js
+++ b/src/favoritesPopover.js
@@ -20,7 +20,6 @@
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 
 const Application = imports.application;
 const PlaceListRow = imports.placeListRow;
@@ -28,9 +27,7 @@ const PlaceStore = imports.placeStore;
 
 const _N_VISIBLE = 6;
 
-var FavoritesPopover = new Lang.Class({
-    Name: 'FavoritesPopover',
-    Extends: Gtk.Popover,
+var FavoritesPopover = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/favorites-popover.ui',
     InternalChildren: [ 'mainGrid',
                         'revealer',
@@ -44,16 +41,17 @@ var FavoritesPopover = new Lang.Class({
                                         GObject.ParamFlags.READABLE |
                                         GObject.ParamFlags.WRITABLE,
                                         0, GLib.MAXINT32, 0)
-    },
+    }
+}, class FavoritesPopover extends Gtk.Popover {
 
-    _init: function(params) {
+    _init(params) {
         params = params || { };
 
         this._mapView = params.mapView;
         delete params.mapView;
 
         params.transitions_enabled = false;
-        this.parent(params);
+        super._init(params);
 
         this._rows = 0;
 
@@ -92,20 +90,20 @@ var FavoritesPopover = new Lang.Class({
         });
 
         this._updateList();
-    },
+    }
 
     set rows(rows) {
         if (rows !== this._rows) {
             this._rows = rows;
             this.notify('rows');
         }
-    },
+    }
 
     get rows() {
         return this._rows;
-    },
+    }
 
-    _updateList: function() {
+    _updateList() {
         this._list.forall((row) => { row.destroy(); });
 
         let rows = 0;
diff --git a/src/foursquareBackend.js b/src/foursquareBackend.js
index 014c9da..b3c0015 100644
--- a/src/foursquareBackend.js
+++ b/src/foursquareBackend.js
@@ -19,7 +19,7 @@
  * Author: Damián Nohales <damiannohales gmail com>
  */
 
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 const FoursquareGoaAuthorizer = imports.foursquareGoaAuthorizer;
 const ServiceBackend = imports.serviceBackend;
@@ -27,47 +27,46 @@ const SocialPlace = imports.socialPlace;
 
 const _PLACE_LINK_FORMAT = 'https://foursquare.com/v/foursquare-hq/%s';
 
-var FoursquareBackend = new Lang.Class({
-    Name: 'SocialServiceFoursquareBackend',
-    Extends: ServiceBackend.ServiceBackend,
+var FoursquareBackend = GObject.registerClass({},
+class SocialServiceFoursquareBackend extends ServiceBackend.ServiceBackend {
 
     get name() {
         return 'foursquare';
-    },
+    }
 
-    createRestCall: function(authorizer) {
+    createRestCall(authorizer) {
         return FoursquareGoaAuthorizer.newRestCall(authorizer);
-    },
+    }
 
-    refreshAuthorization: function(authorizer, cancellable) {
+    refreshAuthorization(authorizer, cancellable) {
         return authorizer.refreshAuthorization(cancellable);
-    },
+    }
 
-    getAuthorizerAccount: function(authorizer) {
+    getAuthorizerAccount(authorizer) {
         return authorizer.goaObject;
-    },
+    }
 
-    createAuthorizer: function(account) {
+    createAuthorizer(account) {
         return new FoursquareGoaAuthorizer.FoursquareGoaAuthorizer({ goaObject: account });
-    },
+    }
 
-    isTokenInvalid: function(restCall, data) {
+    isTokenInvalid(restCall, data) {
         return data.meta.code === 401 || data.meta.code === 403;
-    },
+    }
 
-    isInvalidCall: function(restCall, data) {
+    isInvalidCall(restCall, data) {
         return !data || data.meta.code !== 200;
-    },
+    }
 
-    getCallResultCode: function(restCall, data) {
+    getCallResultCode(restCall, data) {
         return data ? data.meta.code : restCall.get_status_code();
-    },
+    }
 
-    getCallResultMessage: function(restCall, data) {
+    getCallResultMessage(restCall, data) {
         return data ? data.meta.errorDetail : restCall.get_status_message();
-    },
+    }
 
-    _realPerformCheckIn: function(authorizer, checkIn, callback, cancellable) {
+    _realPerformCheckIn(authorizer, checkIn, callback, cancellable) {
         let broadcast = checkIn.privacy;
 
         if (checkIn.broadcastFacebook)
@@ -86,9 +85,9 @@ var FoursquareBackend = new Lang.Class({
                        },
                        callback,
                        cancellable);
-    },
+    }
 
-    _realFindPlaces: function(authorizer, latitude, longitude, distance, callback, cancellable) {
+    _realFindPlaces(authorizer, latitude, longitude, distance, callback, cancellable) {
         this.callAsync(authorizer,
                        'GET',
                        'venues/search',
@@ -99,9 +98,9 @@ var FoursquareBackend = new Lang.Class({
                        },
                        callback,
                        cancellable);
-    },
+    }
 
-    createPlaces: function(rawData) {
+    createPlaces(rawData) {
         return rawData.response.venues.map(function(place) {
             let link = _PLACE_LINK_FORMAT.format(place.id);
 
diff --git a/src/foursquareGoaAuthorizer.js b/src/foursquareGoaAuthorizer.js
index ba7538e..71005b7 100644
--- a/src/foursquareGoaAuthorizer.js
+++ b/src/foursquareGoaAuthorizer.js
@@ -20,32 +20,29 @@
  */
 
 const Rest = imports.gi.Rest;
-const Lang = imports.lang;
 
 const _FOURSQUARE_API_VERSION = '20140226';
 
-var FoursquareGoaAuthorizer = new Lang.Class({
-    Name: 'FoursquareGoaAuthorizer',
-
-    _init: function(params) {
+var FoursquareGoaAuthorizer = class FoursquareGoaAuthorizer {
+    _init(params) {
         if (!params.goaObject) {
             logError('FoursquareGoaAuthorizer requires goaObject parameter');
             return;
         }
 
         this.goaObject = params.goaObject;
-    },
+    }
 
     get goaObject() {
         return this._goaObject;
-    },
+    }
 
     set goaObject(object) {
         this._goaObject = object;
         this._accessToken = null;
-    },
+    }
 
-    _refreshAccessToken: function(cancellable) {
+    _refreshAccessToken(cancellable) {
         if (this._accessToken)
             return true;
 
@@ -57,21 +54,21 @@ var FoursquareGoaAuthorizer = new Lang.Class({
         }
 
         return false;
-    },
+    }
 
-    processCall: function(restCall) {
+    processCall(restCall) {
         this._refreshAccessToken(null);
         restCall.add_param('oauth_token', this._accessToken);
         restCall.add_param('v', _FOURSQUARE_API_VERSION);
-    },
+    }
 
-    processMessage: function(soupMessage) {
+    processMessage(soupMessage) {
         this._refreshAccessToken(null);
         let uri = soupMessage.get_uri();
         uri.set_query(uri, 'oauth_token' + this._accessToken + '&v=' + _FOURSQUARE_API_VERSION);
-    },
+    }
 
-    refreshAuthorization: function(cancellable) {
+    refreshAuthorization(cancellable) {
         let ensureCredentialsResult = this.goaObject.get_account().call_ensure_credentials_sync(cancellable);
         if (ensureCredentialsResult[0]) {
             this._accessToken = null;
@@ -80,7 +77,7 @@ var FoursquareGoaAuthorizer = new Lang.Class({
 
         return false;
     }
-});
+};
 
 function newRestCall(authorizer)
 {
diff --git a/src/geoJSONShapeLayer.js b/src/geoJSONShapeLayer.js
index 422f6d3..1849fc9 100644
--- a/src/geoJSONShapeLayer.js
+++ b/src/geoJSONShapeLayer.js
@@ -17,34 +17,33 @@
  * Author: Hashem Nasarat <hashem riseup net>
  */
 
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 const GeoJSONSource = imports.geoJSONSource;
 const ShapeLayer = imports.shapeLayer;
 
-var GeoJSONShapeLayer = new Lang.Class({
-    Name: 'GeoJSONShapeLayer',
-    Extends: ShapeLayer.ShapeLayer,
+var GeoJSONShapeLayer = GObject.registerClass({},
+class GeoJSONShapeLayer extends ShapeLayer.ShapeLayer {
 
-    _init: function(params) {
-        this.parent(params);
+    _init(params) {
+        super._init(params);
 
         this._mapSource = new GeoJSONSource.GeoJSONSource({
             mapView: this._mapView,
             markerLayer: this._markerLayer
         });
-    },
+    }
 
-    getName: function() {
+    getName() {
         /* Special Case since this file extension contains 2 periods */
         let suffix = '.geo.json';
         if (this.filename.endsWith(suffix))
             return this.filename.replace(new RegExp(suffix + '$'), '');
         else
-            return this.parent();
-    },
+            return super.getName();
+    }
 
-    _parseContent: function() {
+    _parseContent() {
         this._mapSource.parse(JSON.parse(this._fileContents));
     }
 });
@@ -53,3 +52,6 @@ GeoJSONShapeLayer.mimeTypes = ['application/vnd.geo+json',
                                'application/geo+json',
                                'application/json'];
 GeoJSONShapeLayer.displayName = 'GeoJSON';
+GeoJSONShapeLayer.createInstance = function(params) {
+    return new GeoJSONShapeLayer(params);
+};
diff --git a/src/geoJSONSource.js b/src/geoJSONSource.js
index 0eef485..4624796 100644
--- a/src/geoJSONSource.js
+++ b/src/geoJSONSource.js
@@ -21,7 +21,7 @@
 const Cairo = imports.cairo;
 const Champlain = imports.gi.Champlain;
 const Clutter = imports.gi.Clutter;
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 const Mainloop = imports.mainloop;
 
 const Geojsonvt = imports.geojsonvt.geojsonvt;
@@ -39,42 +39,42 @@ const TileFeature = { POINT: 1,
                       LINESTRING: 2,
                       POLYGON: 3 };
 
-var GeoJSONSource = new Lang.Class({
-    Name: 'GeoJSONSource',
-    Extends: Champlain.TileSource,
+var GeoJSONSource = GObject.registerClass({},
+class GeoJSONSource extends Champlain.TileSource {
 
-    _init: function(params) {
-        this.parent();
+    _init(params) {
+        super._init();
 
         this._mapView = params.mapView;
         this._markerLayer = params.markerLayer;
         this._bbox = new Champlain.BoundingBox();
-    },
+    }
 
     get bbox() {
         return this._bbox;
-    },
-    vfunc_get_tile_size: function() {
+    }
+
+    vfunc_get_tile_size() {
         return TILE_SIZE;
-    },
+    }
 
-    vfunc_get_max_zoom_level: function() {
+    vfunc_get_max_zoom_level() {
         return 20;
-    },
+    }
 
-    vfunc_get_min_zoom_level: function() {
+    vfunc_get_min_zoom_level() {
         return 0;
-    },
+    }
 
-    vfunc_get_id: function() {
+    vfunc_get_id() {
         return 'GeoJSONSource';
-    },
+    }
 
-    vfunc_get_name: function() {
+    vfunc_get_name() {
         return 'GeoJSONSource';
-    },
+    }
 
-    vfunc_fill_tile: function(tile) {
+    vfunc_fill_tile(tile) {
         if (tile.get_state() === Champlain.State.DONE)
             return;
 
@@ -87,40 +87,40 @@ var GeoJSONSource = new Lang.Class({
         });
 
         Mainloop.idle_add(() => { this._renderTile(tile); });
-    },
+    }
 
-    _validate: function([lon, lat]) {
+    _validate([lon, lat]) {
         if ((-180 <= lon && lon <= 180) &&
             (-90  <= lat && lat <= 90)) {
             return;
         }
 
         throw new Error(_("invalid coordinate"));
-    },
+    }
 
-    _compose: function(coordinates) {
+    _compose(coordinates) {
         coordinates.forEach((coordinate) => {
             this._validate(coordinate);
             this._bbox.extend(coordinate[1], coordinate[0]);
         });
-    },
+    }
 
-    _clampBBox: function() {
+    _clampBBox() {
         this._bbox.top = Math.min(this._bbox.top, MapView.MAX_LATITUDE);
         this._bbox.left = Math.max(this._bbox.left, MapView.MIN_LONGITUDE);
         this._bbox.bottom = Math.max(this._bbox.bottom, MapView.MIN_LATITUDE);
         this._bbox.right = Math.min(this._bbox.right, MapView.MAX_LONGITUDE);
-    },
+    }
 
-    _parseLineString: function(coordinates) {
+    _parseLineString(coordinates) {
         this._compose(coordinates);
-    },
+    }
 
-    _parsePolygon: function(coordinates) {
+    _parsePolygon(coordinates) {
         coordinates.forEach((coordinate) => { this._compose(coordinate); });
-    },
+    }
 
-    _parsePoint: function(coordinates, properties) {
+    _parsePoint(coordinates, properties) {
         let name = null;
         if (properties)
             name = properties.name;
@@ -140,9 +140,9 @@ var GeoJSONSource = new Lang.Class({
         let placeMarker = new PlaceMarker.PlaceMarker({ place: place,
                                                         mapView: this._mapView });
         this._markerLayer.add_marker(placeMarker);
-    },
+    }
 
-    _parseGeometry: function(geometry, properties) {
+    _parseGeometry(geometry, properties) {
         if(!geometry)
             throw new Error(_("parse error"));
 
@@ -180,9 +180,9 @@ var GeoJSONSource = new Lang.Class({
         default:
             throw new Error(_("unknown geometry"));
         }
-    },
+    }
 
-    _parseInternal: function(root) {
+    _parseInternal(root) {
         if (!root || !root.type)
             throw new Error(_("parse error"));
 
@@ -207,16 +207,16 @@ var GeoJSONSource = new Lang.Class({
         default:
             this._parseGeometry(root);
         }
-    },
+    }
 
-    parse: function(json) {
+    parse(json) {
         this._parseInternal(json);
         this._tileIndex = Geojsonvt.geojsonvt(json, { extent: TILE_SIZE,
                                                       maxZoom: 20 });
         this._clampBBox();
-    },
+    }
 
-    _renderTile: function(tile) {
+    _renderTile(tile) {
         let tileJSON = this._tileIndex.getTile(tile.zoom_level, tile.x, tile.y);
         let content = new Clutter.Canvas({ width: TILE_SIZE,
                                            height: TILE_SIZE });
diff --git a/src/geoJSONStyle.js b/src/geoJSONStyle.js
index fce56bb..b4ea97b 100644
--- a/src/geoJSONStyle.js
+++ b/src/geoJSONStyle.js
@@ -18,12 +18,9 @@
  * Author: Alaf Azam <alafazam gmail com>
  */
 
-const Lang = imports.lang;
+var GeoJSONStyle = class GeoJSONStyle {
 
-var GeoJSONStyle = new Lang.Class({
-    Name: 'GeoJSONStyle',
-
-    _init: function(params) {
+    constructor(params) {
 
         if (params.lineWidth || params.lineWidth === 0)
             this.lineWidth = params.lineWidth;
@@ -46,9 +43,9 @@ var GeoJSONStyle = new Lang.Class({
         this.fillColor =  this._hexToColor(params.fillColor) || { red: 0.37,
                                                                   green: 0.62,
                                                                   blue: 0.87 };
-    },
+    }
 
-    _hexToColor: function(colorString) {
+    _hexToColor(colorString) {
         let color = null;
         
         if (!colorString)
@@ -80,7 +77,7 @@ var GeoJSONStyle = new Lang.Class({
 
         return color;
     }
-});
+};
 
 GeoJSONStyle.parseSimpleStyle = function(tags) {
     return  new GeoJSONStyle({ alpha: tags['stroke-opacity'],
diff --git a/src/geoclue.js b/src/geoclue.js
index 66f847b..19d2224 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -22,7 +22,6 @@
 const GObject = imports.gi.GObject;
 const GClue = imports.gi.Geoclue;
 const Gio = imports.gi.Gio;
-const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const Place = imports.place;
@@ -37,9 +36,7 @@ var State = {
     FAILED: 3
 };
 
-var Geoclue = new Lang.Class({
-    Name: 'Geoclue',
-    Extends: GObject.Object,
+var Geoclue = GObject.registerClass({
     Signals: {
         'location-changed': { }
     },
@@ -53,25 +50,26 @@ var Geoclue = new Lang.Class({
                                        State.FAILED,
                                        State.INITIAL)
     },
+}, class Geoclue extends GObject.Object {
 
     set state(s) {
         this._state = s;
         this.notify('state');
-    },
+    }
 
     get state() {
         return this._state;
-    },
+    }
 
-    _init: function() {
-        this.parent();
+    _init() {
+        super._init();
         this.place = null;
         this._state = State.INITIAL;
 
         this.start(null);
-    },
+    }
 
-    start: function(callback) {
+    start(callback) {
         let id = 'org.gnome.Maps';
         let level = GClue.AccuracyLevel.EXACT;
 
@@ -101,9 +99,9 @@ var Geoclue = new Lang.Class({
             if (callback)
                 callback(true);
         });
-    },
+    }
 
-    _onLocationNotify: function(simple) {
+    _onLocationNotify(simple) {
         let geoclueLocation = simple.get_location();
         let location = new Location.Location({
             latitude: geoclueLocation.latitude,
@@ -113,9 +111,9 @@ var Geoclue = new Lang.Class({
             description: geoclueLocation.description
         });
         this._updateLocation(location);
-    },
+    }
 
-    _updateLocation: function(location) {
+    _updateLocation(location) {
         if (!this.place)
             this.place = new Place.Place({ name: _("Current location") });
 
diff --git a/src/geocodeService.js b/src/geocodeService.js
index 8c90cfb..441925a 100644
--- a/src/geocodeService.js
+++ b/src/geocodeService.js
@@ -22,18 +22,13 @@
  */
 
 const Geocode = imports.gi.GeocodeGlib;
-const Lang = imports.lang;
 
 const Application = imports.application;
 const Place = imports.place;
 const Utils = imports.utils;
 
-var GeocodeService = new Lang.Class({
-    Name: 'GeocodeService',
-
-    _init: function() { },
-
-    search: function(string, bbox, cancellable, callback) {
+var GeocodeService = class GeocodeService {
+    search(string, bbox, cancellable, callback) {
         let answerCount = Application.settings.get('max-search-results');
         let forward     = Geocode.Forward.new_for_string(string);
 
@@ -60,9 +55,9 @@ var GeocodeService = new Lang.Class({
                 callback(null);
             }
         });
-    },
+    }
 
-    reverse: function(location, cancellable, callback) {
+    reverse(location, cancellable, callback) {
         let reverse = Geocode.Reverse.new_for_location(location);
 
         Application.application.mark_busy();
@@ -80,4 +75,4 @@ var GeocodeService = new Lang.Class({
             }
         });
     }
-});
+};
diff --git a/src/gpxShapeLayer.js b/src/gpxShapeLayer.js
index f3b6e87..c6491fc 100644
--- a/src/gpxShapeLayer.js
+++ b/src/gpxShapeLayer.js
@@ -17,27 +17,26 @@
  * Author: Hashem Nasarat <hashem riseup net>
  */
 
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 const GeoJSONSource = imports.geoJSONSource;
 const ShapeLayer = imports.shapeLayer;
 const Togeojson = imports.togeojson.togeojson;
 const Domparser = imports.xmldom.domparser;
 
-var GpxShapeLayer = new Lang.Class({
-    Name: 'GpxShapeLayer',
-    Extends: ShapeLayer.ShapeLayer,
+var GpxShapeLayer = GObject.registerClass({},
+class GpxShapeLayer extends ShapeLayer.ShapeLayer {
 
-    _init: function(params) {
-        this.parent(params);
+    constructor(params) {
+        super.construct(params);
 
         this._mapSource = new GeoJSONSource.GeoJSONSource({
             mapView: this._mapView,
             markerLayer: this._markerLayer
         });
-    },
+    }
 
-    _parseContent: function() {
+    _parseContent() {
         let s = this._fileContents.toString();
         let parser = new Domparser.DOMParser();
         let json = Togeojson.toGeoJSON.gpx(parser.parseFromString(s));
@@ -47,3 +46,6 @@ var GpxShapeLayer = new Lang.Class({
 
 GpxShapeLayer.mimeTypes = ['application/gpx+xml' ];
 GpxShapeLayer.displayName = 'GPX';
+GpxShapeLayer.createInstance = function(params) {
+    return new GpxShapeLayer(params);
+};
diff --git a/src/graphHopper.js b/src/graphHopper.js
index bd1281d..b1cb5c1 100644
--- a/src/graphHopper.js
+++ b/src/graphHopper.js
@@ -21,7 +21,6 @@
 
 const Champlain = imports.gi.Champlain;
 const GLib = imports.gi.GLib;
-const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Soup = imports.gi.Soup;
 
@@ -32,14 +31,13 @@ const Route = imports.route;
 const RouteQuery = imports.routeQuery;
 const Utils = imports.utils;
 
-var GraphHopper = new Lang.Class({
-    Name: 'GraphHopper',
+var GraphHopper = class GraphHopper {
 
     get route() {
         return this._route;
-    },
+    }
 
-    _init: function(params) {
+    constructor(params) {
         this._session = new Soup.Session({ user_agent : 'gnome-maps/' + pkg.version });
         this._key     = "VCIHrHj0pDKb8INLpT4s5hVadNmJ1Q3vi0J4nJYP";
         this._baseURL = "https://graphhopper.com/api/1/route?";;
@@ -48,10 +46,9 @@ var GraphHopper = new Lang.Class({
         this.storedRoute = null;
         this._query = params.query;
         delete params.query;
-        this.parent(params);
-    },
+    }
 
-    _updateFromStored: function() {
+    _updateFromStored() {
         Mainloop.idle_add(() => {
             if (!this.storedRoute)
                 return;
@@ -63,9 +60,9 @@ var GraphHopper = new Lang.Class({
                                 bbox: this.storedRoute.bbox });
             this.storedRoute = null;
         });
-    },
+    }
 
-    _queryGraphHopper: function(points, transportationType, callback) {
+    _queryGraphHopper(points, transportationType, callback) {
         let url = this._buildURL(points, transportationType);
         let msg = Soup.Message.new('GET', url);
         this._session.queue_message(msg, (session, message) => {
@@ -79,9 +76,9 @@ var GraphHopper = new Lang.Class({
                 callback(null, e);
             }
         });
-    },
+    }
 
-    fetchRoute: function(points, transportationType) {
+    fetchRoute(points, transportationType) {
         if (this.storedRoute) {
             this._updateFromStored();
             return;
@@ -109,9 +106,9 @@ var GraphHopper = new Lang.Class({
                 }
             }
         });
-    },
+    }
 
-    fetchRouteAsync: function(points, transportationType, callback) {
+    fetchRouteAsync(points, transportationType, callback) {
         this._queryGraphHopper(points, transportationType,
                                (result, exception) => {
             if (result) {
@@ -121,9 +118,9 @@ var GraphHopper = new Lang.Class({
                 callback(null, exception);
             }
         });
-    },
+    }
 
-    _buildURL: function(points, transportation) {
+    _buildURL(points, transportation) {
         let locations = points.map(function(point) {
             return [point.place.location.latitude, point.place.location.longitude].join(',');
         });
@@ -138,9 +135,9 @@ var GraphHopper = new Lang.Class({
         let url = this._baseURL + query.toString();
         Utils.debug("Sending route request to: " + url);
         return url;
-    },
+    }
 
-    _parseMessage: function({ status_code, response_body, uri }) {
+    _parseMessage({ status_code, response_body, uri }) {
         if (status_code === 500) {
             log("Internal server error.\n"
                 + "This is most likely a bug in GraphHopper");
@@ -166,9 +163,9 @@ var GraphHopper = new Lang.Class({
         }
 
         return result;
-    },
+    }
 
-    _createRoute: function(route) {
+    _createRoute(route) {
         let path       = EPAF.decode(route.points);
         let turnPoints = this._createTurnPoints(path, route.instructions);
         let bbox       = new Champlain.BoundingBox();
@@ -182,9 +179,9 @@ var GraphHopper = new Lang.Class({
                  distance:   route.distance,
                  time:       route.time,
                  bbox:       bbox };
-    },
+    }
 
-    _createTurnPoints: function(path, instructions) {
+    _createTurnPoints(path, instructions) {
         let via = 0;
         let startPoint = new Route.TurnPoint({
             coordinate:  path[0],
@@ -212,9 +209,9 @@ var GraphHopper = new Lang.Class({
             });
         });
         return [startPoint].concat(rest);
-    },
+    }
 
-    _createTurnPointType: function(sign) {
+    _createTurnPointType(sign) {
         let type = sign + 3;
         let min  = Route.TurnPointType.SHARP_LEFT;
         let max  = Route.TurnPointType.ROUNDABOUT;
@@ -223,4 +220,4 @@ var GraphHopper = new Lang.Class({
         else
             return undefined;
     }
-});
+};
diff --git a/src/http.js b/src/http.js
index 482e3aa..1089ff0 100644
--- a/src/http.js
+++ b/src/http.js
@@ -19,7 +19,6 @@
  * Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
  */
 
-const Lang = imports.lang;
 const Soup = imports.gi.Soup;
 
 function encode(data) {
@@ -29,18 +28,17 @@ function encode(data) {
     return Soup.URI.encode(data.toString(), null);
 }
 
-var Query = new Lang.Class({
-    Name: 'Query',
+var Query = class Query {
 
-    _init: function(obj) {
+    constructor(obj) {
         this._query = {};
         for(let key in obj) {
             this.add(key, obj[key]);
         }
-    },
+    }
 
     // a value === null represents an empty value
-    add: function(key, value) {
+    add(key, value) {
         // Initialize query field if it isn't already
         let queryValue = this._query[key];
         if(!Array.isArray(queryValue))
@@ -50,9 +48,9 @@ var Query = new Lang.Class({
             this._query[key] = this._query[key].concat(value);
         else
             this._query[key].push(value);
-    },
+    }
 
-    toString: function() {
+    toString() {
         let vars = [];
         for(let key in this._query) {
             let values = this._query[key];
@@ -67,4 +65,4 @@ var Query = new Lang.Class({
         }
         return vars.join('&');
     }
-});
+};
diff --git a/src/instructionRow.js b/src/instructionRow.js
index 644e13f..f8f4cdc 100644
--- a/src/instructionRow.js
+++ b/src/instructionRow.js
@@ -20,19 +20,18 @@
  *         Mattias Bengtsson <mattias jc bengtsson gmail com>
  */
 
+const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 const Utils = imports.utils;
 
-var InstructionRow = new Lang.Class({
-    Name: "InstructionRow",
-    Extends: Gtk.ListBoxRow,
+var InstructionRow = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/instruction-row.ui',
     InternalChildren: [ 'directionImage',
                         'instructionLabel',
-                        'distanceLabel' ],
+                        'distanceLabel' ]
+}, class InstructionRow extends Gtk.ListBoxRow {
 
-    _init: function(params) {
+    _init(params) {
         this.turnPoint = params.turnPoint;
         delete params.turnPoint;
 
@@ -42,7 +41,7 @@ var InstructionRow = new Lang.Class({
         let lines = params.lines;
         delete params.lines;
 
-        this.parent(params);
+        super._init(params);
 
         if (lines)
             this._instructionLabel.lines = lines;
diff --git a/src/kmlShapeLayer.js b/src/kmlShapeLayer.js
index 3de9985..a721358 100644
--- a/src/kmlShapeLayer.js
+++ b/src/kmlShapeLayer.js
@@ -17,27 +17,25 @@
  * Author: Hashem Nasarat <hashem riseup net>
  */
 
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 const GeoJSONSource = imports.geoJSONSource;
 const ShapeLayer = imports.shapeLayer;
 const Togeojson = imports.togeojson.togeojson;
 const Domparser = imports.xmldom.domparser;
 
-var KmlShapeLayer = new Lang.Class({
-    Name: 'KmlShapeLayer',
-    Extends: ShapeLayer.ShapeLayer,
-
-    _init: function(params) {
-        this.parent(params);
+var KmlShapeLayer = GObject.registerClass({},
+class KmlShapeLayer extends ShapeLayer.ShapeLayer {
+    _init(params) {
+        super._init(params);
 
         this._mapSource = new GeoJSONSource.GeoJSONSource({
             mapView: this._mapView,
             markerLayer: this._markerLayer
         });
-    },
+    }
 
-    _parseContent: function() {
+    _parseContent() {
         let s = this._fileContents.toString();
         let parser = new Domparser.DOMParser();
         let json = Togeojson.toGeoJSON.kml(parser.parseFromString(s));
@@ -47,3 +45,6 @@ var KmlShapeLayer = new Lang.Class({
 
 KmlShapeLayer.mimeTypes = ['application/vnd.google-earth.kml+xml'];
 KmlShapeLayer.displayName = 'KML';
+KmlShapeLayer.createInstance = function(params) {
+    return new KmlShapeLayer(params);
+};
diff --git a/src/layersPopover.js b/src/layersPopover.js
index 8d32a5b..3c9abdb 100644
--- a/src/layersPopover.js
+++ b/src/layersPopover.js
@@ -17,25 +17,24 @@
  * Author: Dario Di Nucci <linkin88mail gmail com>
  */
 
+const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 
 const MapView = imports.mapView;
 const ShapeLayer = imports.shapeLayer;
 const Utils = imports.utils;
 
-var ShapeLayerRow = new Lang.Class({
-    Name: 'ShapeLayerRow',
-    Extends: Gtk.ListBoxRow,
+var ShapeLayerRow = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/shape-layer-row.ui',
     Children: ['closeButton'],
-    InternalChildren: ['layerLabel', 'visibleButton'],
+    InternalChildren: ['layerLabel', 'visibleButton']
+}, class ShapeLayerRow extends Gtk.ListBoxRow {
 
-    _init: function(params) {
+    _init(params) {
         this.shapeLayer = params.shapeLayer;
         delete params.shapeLayer;
 
-        this.parent(params);
+        super._init(params);
 
         this._layerLabel.label = this.shapeLayer.getName();
         this._layerLabel.tooltip_text = this.shapeLayer.file.get_parse_name();
@@ -52,20 +51,19 @@ var ShapeLayerRow = new Lang.Class({
     }
 });
 
-var LayersPopover = new Lang.Class({
-    Name: 'LayersPopover',
-    Extends: Gtk.Popover,
+var LayersPopover = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/layers-popover.ui',
     InternalChildren: [ 'streetLayerButton',
                         'aerialLayerButton',
                         'layersListBox',
-                        'loadLayerButton' ],
+                        'loadLayerButton' ]
+}, class LayersPopover extends Gtk.Popover {
 
-    _init: function(params) {
+    _init(params) {
         this._mapView = params.mapView;
         delete params.mapView;
 
-        this.parent({ width_request: 200,
+        super._init({ width_request: 200,
                       no_show_all: true,
                       transitions_enabled: false,
                       visible: false });
@@ -92,22 +90,22 @@ var LayersPopover = new Lang.Class({
         this._aerialLayerButton.connect('clicked', () => {
             this._mapView.setMapType(MapView.MapType.AERIAL);
         });
-    },
+    }
 
-    setMapType: function(mapType) {
+    setMapType(mapType) {
         if (mapType === MapView.MapType.STREET)
             this._streetLayerButton.active = true;
         else if (mapType === MapView.MapType.AERIAL)
             this._aerialLayerButton.active = true;
-    },
+    }
 
-    _onRemoveClicked: function(row) {
+    _onRemoveClicked(row) {
         this._mapView.removeShapeLayer(row.shapeLayer);
         if (this._layersListBox.get_children().length <= 0)
             this._layersListBox.hide();
-    },
+    }
 
-    _listBoxCreateWidget: function(shapeLayer) {
+    _listBoxCreateWidget(shapeLayer) {
         let row = new ShapeLayerRow({ shapeLayer: shapeLayer });
         row.closeButton.connect('clicked',
                                 () => { this._onRemoveClicked(row); });
diff --git a/src/location.js b/src/location.js
index d4ec63a..f416826 100644
--- a/src/location.js
+++ b/src/location.js
@@ -22,25 +22,24 @@
  */
 
 const Geocode = imports.gi.GeocodeGlib;
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 /* Adds heading to Geocode.Location */
-var Location = new Lang.Class({
-    Name: 'Location',
-    Extends: Geocode.Location,
+var Location = GObject.registerClass({},
+class Location extends Geocode.Location {
 
-    _init: function(params) {
+    _init(params) {
         this._heading = params.heading;
         delete params.heading;
 
-        this.parent(params);
-    },
+        super._init(params);
+    }
 
     get heading() {
         return this._heading;
-    },
+    }
 
     set heading(v) {
         this._heading = v;
-    },
+    }
 });
diff --git a/src/locationServiceNotification.js b/src/locationServiceNotification.js
index 9cf6219..bbe17e6 100644
--- a/src/locationServiceNotification.js
+++ b/src/locationServiceNotification.js
@@ -21,7 +21,7 @@
 
 const Gdk = imports.gi.Gdk;
 const Gio = imports.gi.Gio;
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 const Application = imports.application;
 const Geoclue = imports.geoclue;
@@ -30,12 +30,11 @@ const Utils = imports.utils;
 
 const _PRIVACY_PANEL = 'gnome-privacy-panel.desktop';
 
-var LocationServiceNotification = new Lang.Class({
-    Name: 'LocationServiceNotification',
-    Extends: Notification.Notification,
+var LocationServiceNotification = GObject.registerClass({},
+class LocationServiceNotification extends Notification.Notification {
 
-    _init: function() {
-        this.parent();
+    _init() {
+        super._init();
 
         let ui = Utils.getUIObject('location-service-notification',
                                    [ 'button', 'grid' ]);
diff --git a/src/longPrintLayout.js b/src/longPrintLayout.js
index 956a76e..8439761 100644
--- a/src/longPrintLayout.js
+++ b/src/longPrintLayout.js
@@ -17,7 +17,7 @@
  * Author: Amisha Singla <amishas157 gmail com>
  */
 
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 const PrintLayout = imports.printLayout;
 const Route = imports.route;
@@ -37,11 +37,10 @@ const _MiniMapView = {
     ZOOM_LEVEL: 18
 };
 
-var LongPrintLayout = new Lang.Class({
-    Name: 'LongPrintLayout',
-    Extends: PrintLayout.PrintLayout,
+var LongPrintLayout = GObject.registerClass({},
+class LongPrintLayout extends PrintLayout.PrintLayout {
 
-    _init: function(params) {
+    _init(params) {
         this._route = params.route;
         delete params.route;
 
@@ -55,11 +54,11 @@ var LongPrintLayout = new Lang.Class({
         });
         params.totalSurfaces = totalSurfaces;
 
-        this.parent(params);
-    },
+        super._init(params);
+    }
 
-    render: function() {
-        this.parent();
+    render() {
+        super.render();
 
         let instructionWidth = _Instruction.SCALE_X * this._pageWidth;
         let instructionHeight = _Instruction.SCALE_Y * this._pageHeight;
diff --git a/src/mainWindow.js b/src/mainWindow.js
index b2bee4a..bf103cb 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -25,7 +25,6 @@ const GObject = imports.gi.GObject;
 const Gdk = imports.gi.Gdk;
 const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const Application = imports.application;
@@ -48,13 +47,12 @@ const _CONFIGURE_ID_TIMEOUT = 100; // msecs
 const _WINDOW_MIN_WIDTH = 600;
 const _WINDOW_MIN_HEIGHT = 500;
 
-var ShapeLayerFileChooser = new Lang.Class({
-    Name: 'ShapeLayerFileChooser',
-    Extends: Gtk.FileChooserNative,
-    Template: 'resource:///org/gnome/Maps/ui/shape-layer-file-chooser.ui',
+var ShapeLayerFileChooser = GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/shape-layer-file-chooser.ui'
+}, class ShapeLayerFileChooser extends Gtk.FileChooserNative {
 
-    _init: function(params) {
-        this.parent(params);
+    _init(params) {
+        super._init(params);
         let allFilter = new Gtk.FileFilter();
         allFilter.set_name(_("All Layer Files"));
         this.add_filter(allFilter);
@@ -73,9 +71,7 @@ var ShapeLayerFileChooser = new Lang.Class({
     }
 });
 
-var MainWindow = new Lang.Class({
-    Name: 'MainWindow',
-    Extends: Gtk.ApplicationWindow,
+var MainWindow = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/main-window.ui',
     InternalChildren: [ 'headerBar',
                         'grid',
@@ -87,17 +83,18 @@ var MainWindow = new Lang.Class({
                         'favoritesButton',
                         'printRouteButton',
                         'zoomInButton',
-                        'zoomOutButton' ],
+                        'zoomOutButton' ]
+}, class MainWindow extends Gtk.ApplicationWindow {
 
     get mapView() {
         return this._mapView;
-    },
+    }
 
-    _init: function(params) {
+    _init(params) {
         this._overlay = params.overlay;
         delete params.overlay;
 
-        this.parent(params);
+        super._init(params);
 
         this._configureId = 0;
 
@@ -135,9 +132,9 @@ var MainWindow = new Lang.Class({
         this._grid.attach(this._sidebar, 1, 0, 1, 1);
 
         this._grid.show_all();
-    },
+    }
 
-    _createPlaceEntry: function() {
+    _createPlaceEntry() {
         let placeEntry = new PlaceEntry.PlaceEntry({ mapView: this._mapView,
                                                      visible: true,
                                                      margin_start: 35,
@@ -156,9 +153,9 @@ var MainWindow = new Lang.Class({
         popover.connect('selected', () => { this._mapView.grab_focus(); });
         this._mapView.view.connect('button-press-event', () => { popover.hide(); });
         return placeEntry;
-    },
+    }
 
-    _createSidebar: function() {
+    _createSidebar() {
         let sidebar = new Sidebar.Sidebar(this._mapView);
 
         Application.routeQuery.connect('notify', () => { this._setRevealSidebar(true); });
@@ -169,9 +166,9 @@ var MainWindow = new Lang.Class({
                                        sidebar, 'visible',
                                        GObject.BindingFlags.DEFAULT);
         return sidebar;
-    },
+    }
 
-    _initDND: function() {
+    _initDND() {
         this.drag_dest_set(Gtk.DestDefaults.DROP, null, 0);
         this.drag_dest_add_uri_targets();
 
@@ -187,9 +184,9 @@ var MainWindow = new Lang.Class({
             else
                 Gtk.drag_finish(ctx, false, false, time);
         });
-    },
+    }
 
-    _initActions: function() {
+    _initActions() {
         Utils.addActions(this, {
             'close': {
                 onActivate: this.close.bind(this)
@@ -243,9 +240,9 @@ var MainWindow = new Lang.Class({
                 onActivate: this._onOpenShapeLayer.bind(this)
             }
         });
-    },
+    }
 
-    _initSignals: function() {
+    _initSignals() {
         this.connect('delete-event', this._quit.bind(this));
         this.connect('configure-event',
                      this._onConfigureEvent.bind(this));
@@ -305,9 +302,9 @@ var MainWindow = new Lang.Class({
                                    this._updateZoomButtonsSensitivity.bind(this));
         this._mapView.view.connect('notify::min-zoom-level',
                                    this._updateZoomButtonsSensitivity.bind(this));
-    },
+    }
 
-    _updateZoomButtonsSensitivity: function() {
+    _updateZoomButtonsSensitivity() {
         let zoomLevel = this._mapView.view.zoom_level;
         let maxZoomLevel = this._mapView.view.max_zoom_level;
         let minZoomLevel = this._mapView.view.min_zoom_level;
@@ -321,17 +318,17 @@ var MainWindow = new Lang.Class({
             this._zoomOutButton.set_sensitive(false);
         else
             this._zoomOutButton.set_sensitive(true);
-    },
+    }
 
-    _updateLocationSensitivity: function() {
+    _updateLocationSensitivity() {
         let sensitive = (Application.geoclue.state !== Geoclue.State.INITIAL &&
                          (this.application.connected ||
                           this.application.local_tile_path));
 
         this._gotoUserLocationButton.sensitive = sensitive;
-    },
+    }
 
-    _initHeaderbar: function() {
+    _initHeaderbar() {
         this._placeEntry = this._createPlaceEntry();
         this._headerBar.custom_title = this._placeEntry;
 
@@ -357,9 +354,9 @@ var MainWindow = new Lang.Class({
             this._placeEntry.sensitive = app.connected;
             this._printRouteButton.sensitive = app.connected;
         });
-    },
+    }
 
-    _saveWindowGeometry: function() {
+    _saveWindowGeometry() {
         let window = this.get_window();
         let state = window.get_state();
 
@@ -372,9 +369,9 @@ var MainWindow = new Lang.Class({
 
         let position = this.get_position();
         Application.settings.set('window-position', position);
-    },
+    }
 
-    _restoreWindowGeometry: function() {
+    _restoreWindowGeometry() {
         let size = Application.settings.get('window-size');
         if (size.length === 2) {
             let [width, height] = size;
@@ -390,9 +387,9 @@ var MainWindow = new Lang.Class({
 
         if (Application.settings.get('window-maximized'))
             this.maximize();
-    },
+    }
 
-    _onConfigureEvent: function(widget, event) {
+    _onConfigureEvent(widget, event) {
         if (this._configureId !== 0) {
             Mainloop.source_remove(this._configureId);
             this._configureId = 0;
@@ -403,9 +400,9 @@ var MainWindow = new Lang.Class({
             this._configureId = 0;
             return false;
         });
-    },
+    }
 
-    _onWindowStateEvent: function(widget, event) {
+    _onWindowStateEvent(widget, event) {
         let window = widget.get_window();
         let state = window.get_state();
 
@@ -414,9 +411,9 @@ var MainWindow = new Lang.Class({
 
         let maximized = (state & Gdk.WindowState.MAXIMIZED);
         Application.settings.set('window-maximized', maximized);
-    },
+    }
 
-    _quit: function() {
+    _quit() {
         // remove configure event handler if still there
         if (this._configureId !== 0) {
             Mainloop.source_remove(this._configureId);
@@ -427,18 +424,18 @@ var MainWindow = new Lang.Class({
         this._saveWindowGeometry();
 
         return false;
-    },
+    }
 
-    _getLocationServiceNotification: function() {
+    _getLocationServiceNotification() {
         if (!this._locationServiceNotification) {
             this._locationServiceNotification =
                 new LocationServiceNotification.LocationServiceNotification();
         }
 
         return this._locationServiceNotification;
-    },
+    }
 
-    _onGotoUserLocationActivate: function() {
+    _onGotoUserLocationActivate() {
         let message;
 
         if (Application.geoclue.state === Geoclue.State.ON) {
@@ -463,42 +460,42 @@ var MainWindow = new Lang.Class({
                 break;
             }
         });
-    },
+    }
 
-    _printRouteActivate: function() {
+    _printRouteActivate() {
         if (this._mapView.routeShowing) {
             let operation = new PrintOperation.PrintOperation({ mainWindow: this });
         }
-    },
+    }
 
-    _onMapTypeMenuActivate: function(action) {
+    _onMapTypeMenuActivate(action) {
         let state = action.get_state().get_boolean();
         action.set_state(GLib.Variant.new('b', !state));
-    },
+    }
 
-    _onStreetViewActivate: function() {
+    _onStreetViewActivate() {
         this._mapView.setMapType(MapView.MapType.STREET);
         this.layersPopover.setMapType(MapView.MapType.STREET);
-    },
+    }
 
-    _onAerialViewActivate: function() {
+    _onAerialViewActivate() {
         this._mapView.setMapType(MapView.MapType.AERIAL);
         this.layersPopover.setMapType(MapView.MapType.AERIAL);
-    },
+    }
 
-    _onToggleSidebarChangeState: function(action, variant) {
+    _onToggleSidebarChangeState(action, variant) {
         action.set_state(variant);
 
         let reveal = variant.get_boolean();
         this._sidebar.set_reveal_child(reveal);
-    },
+    }
 
-    _setRevealSidebar: function(value) {
+    _setRevealSidebar(value) {
         let action = this.lookup_action('toggle-sidebar');
         action.change_state(GLib.Variant.new_boolean(value));
-    },
+    }
 
-    _onAboutActivate: function() {
+    _onAboutActivate() {
         let aboutDialog = new Gtk.AboutDialog({
             artists: [ 'Jakub Steiner <jimmac gmail com>',
                        'Andreas Nilsson <nisses mail home se>' ],
@@ -535,9 +532,9 @@ var MainWindow = new Lang.Class({
 
         aboutDialog.show();
         aboutDialog.connect('response', () => { aboutDialog.destroy(); });
-    },
+    }
 
-    _getAttribution: function() {
+    _getAttribution() {
         let tileProviderInfo = Service.getService().tileProviderInfo;
         let attribution = _("Map data by %s and contributors").format('<a 
href="https://www.openstreetmap.org";>OpenStreetMap</a>');
 
@@ -559,9 +556,9 @@ var MainWindow = new Lang.Class({
         }
 
         return attribution;
-    },
+    }
 
-    _onOpenShapeLayer: function() {
+    _onOpenShapeLayer() {
         let fileChooser = new ShapeLayerFileChooser({
             transient_for: this,
         });
@@ -574,9 +571,9 @@ var MainWindow = new Lang.Class({
             fileChooser.destroy();
         });
         fileChooser.show();
-    },
+    }
 
-    markBusy: function() {
+    markBusy() {
         if (this._busySignalId !== 0)
             return;
 
@@ -584,9 +581,9 @@ var MainWindow = new Lang.Class({
 
         let stage = this._mapView.view.get_stage();
         this._busySignalId = stage.connect('captured-event', () => { return true; });
-    },
+    }
 
-    unmarkBusy: function() {
+    unmarkBusy() {
         this._busy.hide();
 
         let stage = this._mapView.view.get_stage();
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 130d721..2ca2aa9 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -23,7 +23,6 @@ const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const Application = imports.application;
@@ -40,12 +39,10 @@ var Button = {
     CHECK_IN: 16
 };
 
-var MapBubble = new Lang.Class({
-    Name: "MapBubble",
-    Extends: Gtk.Popover,
-    Abstract: true,
+var MapBubble = GObject.registerClass({ Abstract: true },
+class MapBubble extends Gtk.Popover {
 
-    _init: function(params) {
+    _init(params) {
         this._place = params.place;
         delete params.place;
 
@@ -67,7 +64,7 @@ var MapBubble = new Lang.Class({
 
         params.modal = false;
 
-        this.parent(params);
+        super._init(params);
         let ui = Utils.getUIObject('map-bubble', [ 'bubble-main-grid',
                                                    'bubble-image',
                                                    'bubble-thumbnail',
@@ -98,29 +95,29 @@ var MapBubble = new Lang.Class({
         }
 
         this.add(ui.bubbleMainGrid);
-    },
+    }
 
     get image() {
         return this._image;
-    },
+    }
 
     get thumbnail() {
         return this._thumbnail;
-    },
+    }
 
     get iconStack() {
         return this._iconStack;
-    },
+    }
 
     get place() {
         return this._place;
-    },
+    }
 
     get content() {
         return this._content;
-    },
+    }
 
-    _initFavoriteButton: function(button, image) {
+    _initFavoriteButton(button, image) {
         let placeStore = Application.placeStore;
         button.visible = true;
 
@@ -143,9 +140,9 @@ var MapBubble = new Lang.Class({
                                     PlaceStore.PlaceType.FAVORITE);
             }
         });
-    },
+    }
 
-    _initSendToButton: function(button) {
+    _initSendToButton(button) {
         let dialog = new SendToDialog.SendToDialog({ transient_for: this.get_toplevel(),
                                                      modal: true,
                                                      mapView: this._mapView,
@@ -160,9 +157,9 @@ var MapBubble = new Lang.Class({
             });
             dialog.show_all();
         });
-    },
+    }
 
-    _initRouteButton: function(button, routeFrom) {
+    _initRouteButton(button, routeFrom) {
         let query = Application.routeQuery;
         let from = query.points[0];
         let to = query.points[query.points.length - 1];
@@ -183,9 +180,9 @@ var MapBubble = new Lang.Class({
             this.destroy();
             query.thaw_notify();
         });
-    },
+    }
 
-    _initCheckInButton: function(button, matchPlace) {
+    _initCheckInButton(button, matchPlace) {
         Application.checkInManager.bind_property('hasCheckIn',
                                                  button, 'visible',
                                                  GObject.BindingFlags.DEFAULT |
diff --git a/src/mapMarker.js b/src/mapMarker.js
index 28a40bf..67685db 100644
--- a/src/mapMarker.js
+++ b/src/mapMarker.js
@@ -25,15 +25,12 @@ const Clutter = imports.gi.Clutter;
 const Gdk = imports.gi.Gdk;
 const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const MapWalker = imports.mapWalker;
 const Utils = imports.utils;
 
-var MapMarker = new Lang.Class({
-    Name: 'MapMarker',
-    Extends: Champlain.Marker,
+var MapMarker = GObject.registerClass({
     Implements: [Champlain.Exportable],
     Abstract: true,
     Signals: {
@@ -42,9 +39,10 @@ var MapMarker = new Lang.Class({
     Properties: {
         'surface': GObject.ParamSpec.override('surface',
                                               Champlain.Exportable)
-    },
+    }
+}, class MapMarker extends Champlain.Marker {
 
-    _init: function(params) {
+    _init(params) {
         this._place = params.place;
         delete params.place;
 
@@ -55,7 +53,7 @@ var MapMarker = new Lang.Class({
         params.longitude = this.place.location.longitude;
         params.selectable = true;
 
-        this.parent(params);
+        super._init(params);
 
         this.connect('notify::size', this._translateMarkerPosition.bind(this));
         if (this._mapView) {
@@ -76,25 +74,25 @@ var MapMarker = new Lang.Class({
             this._view.connect('notify::longitude', this._onViewUpdated.bind(this));
             this._view.connect('notify::zoom-level', this._onViewUpdated.bind(this));
         }
-    },
+    }
 
     get surface() {
         return this._surface;
-    },
+    }
 
     set surface(v) {
         this._surface = v;
-    },
+    }
 
-    vfunc_get_surface: function() {
+    vfunc_get_surface() {
         return this._surface;
-    },
+    }
 
-    vfunc_set_surface: function(surface) {
+    vfunc_set_surface(surface) {
         this._surface = surface;
-    },
+    }
 
-    _actorFromIconName: function(name, size, color) {
+    _actorFromIconName(name, size, color) {
         try {
             let theme = Gtk.IconTheme.get_default();
             let pixbuf;
@@ -130,9 +128,9 @@ var MapMarker = new Lang.Class({
             Utils.debug('Failed to load image: %s'.format(e.message));
             return null;
         }
-    },
+    }
 
-    _onButtonPress: function(marker, event) {
+    _onButtonPress(marker, event) {
         // Zoom in on marker on double-click
         if (event.get_click_count() > 1) {
             if (this._view.zoom_level < this._view.max_zoom_level) {
@@ -140,11 +138,11 @@ var MapMarker = new Lang.Class({
                 this._view.center_on(this.latitude, this.longitude);
             }
         }
-    },
+    }
 
-    _translateMarkerPosition: function() {
+    _translateMarkerPosition() {
         this.set_translation(-this.anchor.x, -this.anchor.y, 0);
-    },
+    }
 
     /**
      * Returns: The anchor point for the marker icon, relative to the
@@ -152,29 +150,29 @@ var MapMarker = new Lang.Class({
      */
     get anchor() {
         return { x: 0, y: 0 };
-    },
+    }
 
     get bubbleSpacing() {
         return 0;
-    },
+    }
 
     get place() {
         return this._place;
-    },
+    }
 
     get bubble() {
         if (this._bubble === undefined)
             this._bubble = this._createBubble();
 
         return this._bubble;
-    },
+    }
 
-    _createBubble: function() {
+    _createBubble() {
         // Markers has no associated bubble by default
         return null;
-    },
+    }
 
-    _positionBubble: function(bubble) {
+    _positionBubble(bubble) {
         let [tx, ty, tz] = this.get_translation();
         let x = this._view.longitude_to_x(this.longitude);
         let y = this._view.latitude_to_y(this.latitude);
@@ -200,9 +198,9 @@ var MapMarker = new Lang.Class({
         // Avoid bubble to cover header bar if the marker is close to the top map edge
         else if (pos.y - bubbleSize.height <= 0)
             bubble.position = Gtk.PositionType.BOTTOM;
-    },
+    }
 
-    _hideBubbleOn: function(signal, duration) {
+    _hideBubbleOn(signal, duration) {
         let sourceId = null;
         let signalId = this._view.connect(signal, () => {
             if (sourceId)
@@ -236,9 +234,9 @@ var MapMarker = new Lang.Class({
                 this._view.disconnect(signalId);
             }
         });
-    },
+    }
 
-    _initBubbleSignals: function() {
+    _initBubbleSignals() {
         this._hideBubbleOn('notify::zoom-level', 500);
         this._hideBubbleOn('notify::size');
 
@@ -278,9 +276,9 @@ var MapMarker = new Lang.Class({
             this._bubble.destroy();
             delete this._bubble;
         });
-    },
+    }
 
-    _isInsideView: function() {
+    _isInsideView() {
         let [tx, ty, tz] = this.get_translation();
         let x = this._view.longitude_to_x(this.longitude);
         let y = this._view.latitude_to_y(this.latitude);
@@ -288,53 +286,53 @@ var MapMarker = new Lang.Class({
 
         return x + tx + this.width > 0 && x + tx < mapSize.width &&
                y + ty + this.height > 0 && y + ty < mapSize.height;
-    },
+    }
 
-    _onViewUpdated: function() {
+    _onViewUpdated() {
         if (this.bubble) {
             if (this._isInsideView())
                 this._positionBubble(this.bubble);
             else
                 this.bubble.hide();
         }
-    },
+    }
 
-    showBubble: function() {
+    showBubble() {
         if (this.bubble && !this.bubble.visible && this._isInsideView()) {
             this._initBubbleSignals();
             this.bubble.show();
             this._positionBubble(this.bubble);
         }
-    },
+    }
 
-    hideBubble: function() {
+    hideBubble() {
         if (this._bubble)
             this._bubble.hide();
-    },
+    }
 
     get walker() {
         if (this._walker === undefined)
             this._walker = new MapWalker.MapWalker(this.place, this._mapView);
 
         return this._walker;
-    },
+    }
 
-    zoomToFit: function() {
+    zoomToFit() {
         this.walker.zoomToFit();
-    },
+    }
 
-    goTo: function(animate) {
+    goTo(animate) {
         Utils.once(this.walker, 'gone-to', () => { this.emit('gone-to'); });
         this.walker.goTo(animate);
-    },
+    }
 
-    goToAndSelect: function(animate) {
+    goToAndSelect(animate) {
         Utils.once(this, 'gone-to', () => { this.selected = true; });
 
         this.goTo(animate);
-    },
+    }
 
-    _onMarkerSelected: function() {
+    _onMarkerSelected() {
         if (this.selected)
             this.showBubble();
         else
diff --git a/src/serviceBackend.js b/src/serviceBackend.js
index bbe7165..edcfdeb 100644
--- a/src/serviceBackend.js
+++ b/src/serviceBackend.js
@@ -19,42 +19,42 @@
  * Author: Damián Nohales <damiannohales gmail com>
  */
 
-const Lang = imports.lang;
+const GObject = imports.gi.GObject;
 
 const Utils = imports.utils;
 
-var ServiceBackend = new Lang.Class({
-    Name: 'SocialServiceServiceBackend',
-    Abstract: true,
+var ServiceBackend = GObject.registerClass({
+    Abstract: true
+}, class ServiceBackend extends GObject.Object {
 
     //Abstract
-    get name() { },
+    get name() { }
 
     //Abstract
-    createRestCall: function(authorizer) { },
+    createRestCall(authorizer) { }
 
     //Abstract
-    refreshAuthorization: function(authorizer, cancellable) { },
+    refreshAuthorization(authorizer, cancellable) { }
 
     //Abstract
-    getAuthorizerAccount: function(authorizer) { },
+    getAuthorizerAccount(authorizer) { }
 
     //Abstract
-    createAuthorizer: function(account) { },
+    createAuthorizer(account) { }
 
     //Abstract
-    isTokenInvalid: function(restCall, parsedPayload) { },
+    isTokenInvalid(restCall, parsedPayload) { }
 
     //Abstract
-    isInvalidCall: function(restCall, parsedPayload) { },
+    isInvalidCall(restCall, parsedPayload) { }
 
     //Abstract
-    getCallResultCode: function(restCall, parsedPayload) { },
+    getCallResultCode(restCall, parsedPayload) { }
 
     //Abstract
-    getCallResultMessage: function(restCall, parsedPayload) { },
+    getCallResultMessage(restCall, parsedPayload) { }
 
-    callAsync: function(authorizer, method, func, params, callback, cancellable, mustRefreshToken) {
+    callAsync(authorizer, method, func, params, callback, cancellable, mustRefreshToken) {
         mustRefreshToken = mustRefreshToken || true;
         cancellable = cancellable || null;
 
@@ -94,17 +94,17 @@ var ServiceBackend = new Lang.Class({
             else
                 callback(account, data, null);
         });
-    },
+    }
 
-    performCheckIn: function(authorizer, checkIn, callback, cancellable) {
+    performCheckIn(authorizer, checkIn, callback, cancellable) {
         callback = callback || function() {};
         this._realPerformCheckIn(authorizer, checkIn, callback, cancellable);
-    },
+    }
 
     //Abstract
-    _realPerformCheckIn: function(authorizer, checkIn, callback, cancellable) { },
+    _realPerformCheckIn(authorizer, checkIn, callback, cancellable) { }
 
-    findPlaces: function(authorizer, latitude, longitude, distance, callback, cancellable) {
+    findPlaces(authorizer, latitude, longitude, distance, callback, cancellable) {
         callback = callback || function() {};
         this._realFindPlaces(authorizer,
                              latitude,
@@ -117,11 +117,11 @@ var ServiceBackend = new Lang.Class({
                                      callback(account, [], error);
                              },
                              cancellable);
-    },
+    }
 
     //Abstract
-    _realFindPlaces: function(authorizer, latitude, longitude, distance, callback, cancellable) { },
+    _realFindPlaces(authorizer, latitude, longitude, distance, callback, cancellable) { }
 
     //Abstract
-    createPlaces: function(rawData) { }
+    createPlaces(rawData) { }
 });
diff --git a/src/shapeLayer.js b/src/shapeLayer.js
index 9dd5107..dccc789 100644
--- a/src/shapeLayer.js
+++ b/src/shapeLayer.js
@@ -22,26 +22,26 @@ const Gio = imports.gi.Gio;
 const GObject = imports.gi.GObject;
 const Lang = imports.lang;
 
+const GeoJSONShapeLayer = imports.geoJSONShapeLayer;
+
 var SUPPORTED_TYPES = [];
 
 function newFromFile(file, mapView) {
     let contentType = Gio.content_type_guess(file.get_uri(), null)[0];
     for (let layerClass of SUPPORTED_TYPES) {
         if (layerClass.mimeTypes.indexOf(contentType) > -1) {
-            return new layerClass({ file: file, mapView: mapView });
+            return layerClass.createInstance({ file: file, mapView: mapView });
         }
     }
     return null;
 }
 
-var ShapeLayer = new Lang.Class({
-    Name: 'ShapeLayer',
-    Extends: GObject.Object,
-    Abstract: true,
-
-    _init: function(params) {
-        this.parent();
+var ShapeLayer = GObject.registerClass({
+    Abstract: true
+}, class ShapeLayer extends GObject.Object {
 
+    _init(params) {
+        super._init();
         this._visible = true;
         this._mapView = params.mapView;
         this.file = params.file;
@@ -56,15 +56,15 @@ var ShapeLayer = new Lang.Class({
             selection_mode: Champlain.SelectionMode.SINGLE
         });
         this._mapSource = null;
-    },
+    }
 
     get bbox() {
         return this._mapSource.bbox;
-    },
+    }
 
     get visible() {
         return this._visible;
-    },
+    }
 
     set visible(v) {
         if (v && !this._visible) {
@@ -75,17 +75,17 @@ var ShapeLayer = new Lang.Class({
             this._markerLayer.hide_all_markers();
         }
         this._visible = v;
-    },
+    }
 
-    getName: function() {
+    getName() {
         /*
          * Remove file extension and use that in lieu of a fileformat-specific
          * display name.
          */
         return this.filename.replace(/\.[^\.]+$/, '');
-    },
+    }
 
-    load: function() {
+    load() {
         let [status, buffer] = this.file.load_contents(null);
         this._fileContents = buffer;
         if (!status)
@@ -93,14 +93,14 @@ var ShapeLayer = new Lang.Class({
         this._parseContent();
         this._mapView.view.add_layer(this._markerLayer);
         this._mapView.view.add_overlay_source(this._mapSource, 255);
-    },
+    }
 
 
-    _parseContent: function() {
+    _parseContent() {
         /* Unimplemented */
-    },
+    }
 
-    unload: function() {
+    unload() {
         this._mapView.view.remove_layer(this._markerLayer);
         this._mapView.view.remove_overlay_source(this._mapSource);
     }



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