[gnome-maps] Use object destructuring in constructors
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] Use object destructuring in constructors
- Date: Thu, 6 Oct 2022 20:44:50 +0000 (UTC)
commit 03acf6f3b8c5c08f67c5989c746a8c9b4a3923f6
Author: James Westman <james jwestman net>
Date: Tue Oct 4 16:09:06 2022 -0500
Use object destructuring in constructors
data/ui/export-view-dialog.ui | 1 -
src/exportViewDialog.js | 31 ++++++++++---------------------
src/favoritesPopover.js | 5 +----
src/geoJSONSource.js | 7 +------
src/graphHopper.js | 4 ++--
src/headerBar.js | 5 +----
src/instructionRow.js | 11 +----------
src/layersPopover.js | 5 +----
src/location.js | 5 +----
src/locationServiceDialog.js | 6 ++----
src/longPrintLayout.js | 8 ++------
src/mainWindow.js | 1 +
src/mapBubble.js | 8 +-------
src/mapMarker.js | 19 +++++++------------
src/mapView.js | 10 ++--------
src/osmAccountDialog.js | 11 +++--------
src/osmEditDialog.js | 33 +++------------------------------
src/osmTypeListRow.js | 7 ++-----
src/osmTypePopover.js | 4 ++--
src/osmTypeSearchEntry.js | 4 ++--
src/placeBar.js | 8 +-------
src/placeButtons.js | 8 +-------
src/placeDialog.js | 11 ++---------
src/placeEntry.js | 15 +++------------
src/placeListRow.js | 14 +++-----------
src/placePopover.js | 7 ++-----
src/placeStore.js | 8 +-------
src/placeView.js | 14 +++-----------
src/printLayout.js | 14 +-------------
src/printOperation.js | 5 ++---
src/routeEntry.js | 15 +++------------
src/routeQuery.js | 4 ++--
src/routingDelegator.js | 4 ++--
src/searchPopover.js | 7 ++-----
src/sendToDialog.js | 11 ++---------
src/shortPrintLayout.js | 5 +----
src/storedRoute.js | 14 +-------------
src/transitArrivalMarker.js | 11 ++++-------
src/transitArrivalRow.js | 8 +-------
src/transitBoardMarker.js | 9 +++------
src/transitItineraryRow.js | 5 +----
src/transitLegRow.js | 11 +----------
src/transitPrintLayout.js | 13 +++++--------
src/transitRouteLabel.js | 7 +------
src/transitRouter.js | 4 ++--
src/transitStopRow.js | 8 +-------
src/transitWalkMarker.js | 18 ++++++------------
src/translations.js | 2 +-
src/turnPointMarker.js | 18 +++---------------
src/userLocationMarker.js | 14 ++++++--------
src/zoomInDialog.js | 15 +++------------
51 files changed, 115 insertions(+), 377 deletions(-)
---
diff --git a/data/ui/export-view-dialog.ui b/data/ui/export-view-dialog.ui
index c2824de1..69601863 100644
--- a/data/ui/export-view-dialog.ui
+++ b/data/ui/export-view-dialog.ui
@@ -2,7 +2,6 @@
<interface>
<requires lib="gtk" version="4.0"/>
<template class="Gjs_ExportViewDialog" parent="GtkDialog">
- <property name="use_header_bar">1</property>
<property name="resizable">0</property>
<property name="title" translatable="1">Export view</property>
<child internal-child="headerbar">
diff --git a/src/exportViewDialog.js b/src/exportViewDialog.js
index bd30c560..be060f52 100644
--- a/src/exportViewDialog.js
+++ b/src/exportViewDialog.js
@@ -37,27 +37,16 @@ export class ExportViewDialog extends Gtk.Dialog {
CANCEL: 1
};
- constructor(params) {
- let paintable = params.paintable;
- delete params.paintable;
-
- let latitude = params.latitude;
- delete params.latitude;
-
- let longitude = params.longitude;
- delete params.longitude;
-
- let mapView = params.mapView;
- delete params.mapView;
-
- let width = params.width;
- delete params.width;
-
- let height = params.height;
- delete params.height;
-
- params.use_header_bar = true;
- super(params);
+ constructor({
+ paintable,
+ latitude,
+ longitude,
+ mapView,
+ width,
+ height,
+ ...params
+ }) {
+ super({...params, use_header_bar: true});
this._paintable = paintable;
this._mapView = mapView;
diff --git a/src/favoritesPopover.js b/src/favoritesPopover.js
index 0e524fa9..39925aca 100644
--- a/src/favoritesPopover.js
+++ b/src/favoritesPopover.js
@@ -29,10 +29,7 @@ const _N_VISIBLE = 6;
export class FavoritesPopover extends Gtk.Popover {
- constructor(params) {
- let mapView = params.mapView;
- delete params.mapView;
-
+ constructor({mapView, ...params}) {
super(params);
this._mapView = mapView;
diff --git a/src/geoJSONSource.js b/src/geoJSONSource.js
index 29ea88d0..e6bfd430 100644
--- a/src/geoJSONSource.js
+++ b/src/geoJSONSource.js
@@ -42,12 +42,7 @@ const TileFeature = { POINT: 1,
export class GeoJSONSource extends GnomeMaps.SyncMapSource {
- constructor(params) {
- let mapView = params.mapView;
- delete params.mapView;
- let markerLayer = params.markerLayer;
- delete params.markerLayer;
-
+ constructor({mapView, markerLayer, ...params}) {
super(params);
this._mapView = mapView;
diff --git a/src/graphHopper.js b/src/graphHopper.js
index 78044465..aa1d0c71 100644
--- a/src/graphHopper.js
+++ b/src/graphHopper.js
@@ -58,14 +58,14 @@ export class GraphHopper {
return this._route;
}
- constructor(params) {
+ constructor({query}) {
this._session = new Soup.Session({ user_agent : 'gnome-maps/' + pkg.version });
this._key = "VCIHrHj0pDKb8INLpT4s5hVadNmJ1Q3vi0J4nJYP";
this._baseURL = "https://graphhopper.com/api/1/route?";
this._locale = GLib.get_language_names()[0];
this._route = new Route();
this.storedRoute = null;
- this._query = params.query;
+ this._query = query;
}
_updateFromStored() {
diff --git a/src/headerBar.js b/src/headerBar.js
index b023b81d..99ba043b 100644
--- a/src/headerBar.js
+++ b/src/headerBar.js
@@ -28,10 +28,7 @@ import {LayersPopover} from './layersPopover.js';
import {MapView} from './mapView.js';
export class HeaderBarLeft extends Gtk.Box {
- constructor(params) {
- let mapView = params.mapView;
- delete params.mapView;
-
+ constructor({mapView, ...params}) {
super(params);
this._layersPopover = new LayersPopover({ mapView: mapView });
diff --git a/src/instructionRow.js b/src/instructionRow.js
index 571a19d0..19d29558 100644
--- a/src/instructionRow.js
+++ b/src/instructionRow.js
@@ -26,16 +26,7 @@ import * as Utils from './utils.js';
export class InstructionRow extends Gtk.ListBoxRow {
- constructor(params) {
- let turnPoint = params.turnPoint;
- delete params.turnPoint;
-
- let hasColor = params.hasColor;
- delete params.hasColor;
-
- let lines = params.lines;
- delete params.lines;
-
+ constructor({turnPoint, hasColor, lines, ...params}) {
super(params);
this.turnPoint = turnPoint;
diff --git a/src/layersPopover.js b/src/layersPopover.js
index 522f41c8..905d90d6 100644
--- a/src/layersPopover.js
+++ b/src/layersPopover.js
@@ -35,10 +35,7 @@ const PREVIEW_HEIGHT = 80;
export class ShapeLayerRow extends Gtk.ListBoxRow {
- constructor(params) {
- let shapeLayer = params.shapeLayer;
- delete params.shapeLayer;
-
+ constructor({shapeLayer, ...params}) {
super(params);
this.shapeLayer = shapeLayer;
diff --git a/src/location.js b/src/location.js
index 1a0fe898..cd64ec40 100644
--- a/src/location.js
+++ b/src/location.js
@@ -27,10 +27,7 @@ import GObject from 'gi://GObject';
/* Adds heading to Geocode.Location */
export class Location extends Geocode.Location {
- constructor(params) {
- let heading = params.heading;
- delete params.heading;
-
+ constructor({heading, ...params}) {
super(params);
this._heading = heading;
}
diff --git a/src/locationServiceDialog.js b/src/locationServiceDialog.js
index 16798eb2..d9a75799 100644
--- a/src/locationServiceDialog.js
+++ b/src/locationServiceDialog.js
@@ -32,10 +32,8 @@ const _PRIVACY_PANEL = 'gnome-location-panel.desktop';
export class LocationServiceDialog extends Gtk.Dialog {
constructor(params) {
- /* This is a construct-only property and cannot be set by GtkBuilder */
- params.use_header_bar = true;
-
- super(params);
+ /* use_header_bar is a construct-only property and cannot be set by GtkBuilder */
+ super({...params, use_header_bar: true});
this._settingsButton.connect('clicked', () => this._onSettings());
this._cancelButton.connect('clicked', () => this._onCancel());
diff --git a/src/longPrintLayout.js b/src/longPrintLayout.js
index 21cf51d8..8cdb506f 100644
--- a/src/longPrintLayout.js
+++ b/src/longPrintLayout.js
@@ -40,10 +40,7 @@ const _MiniMapView = {
export class LongPrintLayout extends PrintLayout {
- constructor(params) {
- let route = params.route;
- delete params.route;
-
+ constructor({route, ...params}) {
/* (Header + 3 maps) + instructions */
let totalSurfaces = 4 + route.turnPoints.length;
@@ -52,9 +49,8 @@ export class LongPrintLayout extends PrintLayout {
if (turnPoint.type === TurnPoint.Type.VIA)
totalSurfaces++;
});
- params.totalSurfaces = totalSurfaces;
- super(params);
+ super({...params, totalSurfaces});
this._route = route;
}
diff --git a/src/mainWindow.js b/src/mainWindow.js
index a3489504..cf771082 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -57,6 +57,7 @@ class ShapeLayerFileChooser extends Gtk.FileChooserNative {
constructor(params) {
super(params);
+
let allFilter = new Gtk.FileFilter();
allFilter.set_name(_("All Layer Files"));
this.add_filter(allFilter);
diff --git a/src/mapBubble.js b/src/mapBubble.js
index cc74dd04..ea90b35e 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -42,13 +42,7 @@ const HEIGHT_MARGIN = 100;
export class MapBubble extends Gtk.Popover {
- constructor(params) {
- let place = params.place;
- delete params.place;
-
- let mapView = params.mapView;
- delete params.mapView;
-
+ constructor({place, mapView, ...params}) {
super(params);
let content = new PlaceView({ place, mapView, visible: true });
diff --git a/src/mapMarker.js b/src/mapMarker.js
index 3b5aaed8..7eeffded 100644
--- a/src/mapMarker.js
+++ b/src/mapMarker.js
@@ -34,18 +34,13 @@ import * as Utils from './utils.js';
export class MapMarker extends Shumate.Marker {
- constructor(params) {
- let place = params.place;
- delete params.place;
-
- let mapView = params.mapView;
- delete params.mapView;
-
- params.latitude = place.location.latitude;
- params.longitude = place.location.longitude;
- params.selectable = true;
-
- super(params);
+ constructor({place, mapView, ...params}) {
+ super({
+ ...params,
+ latitude: place.location.latitude,
+ longitude: place.location.longitude,
+ selectable: true,
+ });
this._place = place;
this._mapView = mapView;
diff --git a/src/mapView.js b/src/mapView.js
index 7b267501..be341e6d 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -127,13 +127,7 @@ export class MapView extends Gtk.Overlay {
return this._mapSource;
}
- constructor(params) {
- let mapTypeParam = params.mapType;
- delete params.mapType;
-
- let mainWindow = params.mainWindow;
- delete params.mainWindow;
-
+ constructor({mapType, mainWindow, ...params}) {
super(params);
this._mainWindow = mainWindow;
@@ -143,7 +137,7 @@ export class MapView extends Gtk.Overlay {
this.child = this.map;
this._initLicense();
- this.setMapType(mapTypeParam ?? this._getStoredMapType());
+ this.setMapType(mapType ?? this._getStoredMapType());
this._initScale();
this._initLayers();
diff --git a/src/osmAccountDialog.js b/src/osmAccountDialog.js
index 035a77d8..1e83835d 100644
--- a/src/osmAccountDialog.js
+++ b/src/osmAccountDialog.js
@@ -30,14 +30,9 @@ export class OSMAccountDialog extends Gtk.Dialog {
static Response = { SIGNED_IN: 0 };
- constructor(params) {
- /* This is a construct-only property and cannot be set by GtkBuilder */
- params.use_header_bar = true;
-
- let closeOnSignIn = params.closeOnSignIn;
- delete params.closeOnSignIn;
-
- super(params);
+ constructor({closeOnSignIn, ...params}) {
+ /* use_header_bar is a construct-only property and cannot be set by GtkBuilder */
+ super({...params, use_header_bar: true});
this._closeOnSignIn = closeOnSignIn;
this._signInButton.connect('clicked',
diff --git a/src/osmEditDialog.js b/src/osmEditDialog.js
index 787d9bc2..d93f1441 100644
--- a/src/osmEditDialog.js
+++ b/src/osmEditDialog.js
@@ -254,19 +254,7 @@ const OSM_FIELDS = [
export class OSMEditAddress extends Gtk.Grid {
- constructor(params) {
- let street = params.street;
- delete params.street;
-
- let number = params.number;
- delete params.number;
-
- let postCode = params.postCode;
- delete params.postCode;
-
- let city = params.city;
- delete params.city;
-
+ constructor({street, number, postCode, city, ...params}) {
super(params);
if (street)
@@ -300,23 +288,8 @@ export class OSMEditDialog extends Gtk.Dialog {
ERROR: 3
};
- constructor(params) {
- let place = params.place;
- delete params.place;
-
- let addLocation = params.addLocation;
- delete params.addLocation;
-
- let latitude = params.latitude;
- delete params.latitude;
-
- let longitude = params.longitude;
- delete params.longitude;
-
- /* This is a construct-only property and cannot be set by GtkBuilder */
- params.use_header_bar = true;
-
- super(params);
+ constructor({place, addLocation, latitude, longitude, ...params}) {
+ super({...params, use_header_bar: true});
/* I could not get this widget working from within the widget template
* this results in a segfault. The widget definition is left in-place,
diff --git a/src/osmTypeListRow.js b/src/osmTypeListRow.js
index 81940e0e..524b511f 100644
--- a/src/osmTypeListRow.js
+++ b/src/osmTypeListRow.js
@@ -24,11 +24,8 @@ import Gtk from 'gi://Gtk';
export class OSMTypeListRow extends Gtk.ListBoxRow {
- constructor(props) {
- let type = props.type;
- delete props.type;
-
- super(props);
+ constructor({type, ...params}) {
+ super(params);
this._type = type;
this._name.label = this._type.title;
diff --git a/src/osmTypePopover.js b/src/osmTypePopover.js
index b4026f98..ca7f0994 100644
--- a/src/osmTypePopover.js
+++ b/src/osmTypePopover.js
@@ -27,8 +27,8 @@ import {SearchPopover} from './searchPopover.js';
export class OSMTypePopover extends SearchPopover {
- constructor(props) {
- super(props);
+ constructor(params) {
+ super(params);
this._list.connect('row-activated', (list, row) => {
if (row)
diff --git a/src/osmTypeSearchEntry.js b/src/osmTypeSearchEntry.js
index fc14ec21..b51e2a90 100644
--- a/src/osmTypeSearchEntry.js
+++ b/src/osmTypeSearchEntry.js
@@ -30,8 +30,8 @@ const MAX_MATCHES = 10;
export class OSMTypeSearchEntry extends Gtk.SearchEntry {
- constructor(props) {
- super(props);
+ constructor(params) {
+ super(params);
this._popover = new OSMTypePopover({ entry: this });
this._popover.set_parent(this);
diff --git a/src/placeBar.js b/src/placeBar.js
index e119c7da..5ed5d255 100644
--- a/src/placeBar.js
+++ b/src/placeBar.js
@@ -32,13 +32,7 @@ import {PlaceView} from './placeView.js';
import * as Utils from './utils.js';
export class PlaceBar extends Gtk.Revealer {
- constructor(params) {
- let mapView = params.mapView;
- delete params.mapView;
-
- let mainWindow = params.mainWindow;
- delete params.mainWindow;
-
+ constructor({mapView, mainWindow, ...params}) {
super(params);
this._mapView = mapView;
diff --git a/src/placeButtons.js b/src/placeButtons.js
index e7c5ee60..c201b992 100644
--- a/src/placeButtons.js
+++ b/src/placeButtons.js
@@ -31,13 +31,7 @@ import {PlaceStore} from './placeStore.js';
import {SendToDialog} from './sendToDialog.js';
export class PlaceButtons extends Gtk.Box {
- constructor(params) {
- let place = params.place;
- delete params.place;
-
- let mapView = params.mapView;
- delete params.mapView;
-
+ constructor({place, mapView, ...params}) {
super(params);
this._mapView = mapView;
diff --git a/src/placeDialog.js b/src/placeDialog.js
index 7adabad5..33913f29 100644
--- a/src/placeDialog.js
+++ b/src/placeDialog.js
@@ -26,15 +26,8 @@ import {PlaceFormatter} from './placeFormatter.js';
import {PlaceView} from './placeView.js';
export class PlaceDialog extends Gtk.Dialog {
- constructor(params) {
- let place = params.place;
- delete params.place;
-
- let mapView = params.mapView;
- delete params.mapView;
-
- params.use_header_bar = true;
- super(params);
+ constructor({place, mapView, ...params}) {
+ super({...params, use_header_bar: true});
if (this.transient_for.maximized) {
this.maximize();
diff --git a/src/placeEntry.js b/src/placeEntry.js
index 96780502..971494ab 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -84,20 +84,11 @@ export class PlaceEntry extends Gtk.SearchEntry {
return this._popover;
}
- constructor(props) {
- let mapView = props.mapView;
- delete props.mapView;
-
- let maxChars = props.maxChars;
- delete props.maxChars;
-
- let matchRoute = props.matchRoute ?? false;
- delete props.matchRoute;
-
- super(props);
+ constructor({mapView, maxChars, matchRoute, ...params}) {
+ super(params);
this._mapView = mapView;
- this._matchRoute = matchRoute;
+ this._matchRoute = matchRoute ?? false;
this._filter = new Gtk.TreeModelFilter({ child_model: Application.placeStore });
this._filter.set_visible_func(this._completionVisibleFunc.bind(this));
diff --git a/src/placeListRow.js b/src/placeListRow.js
index 8bf708af..65069805 100644
--- a/src/placeListRow.js
+++ b/src/placeListRow.js
@@ -27,18 +27,10 @@ import * as Utils from './utils.js';
export class PlaceListRow extends Gtk.ListBoxRow {
- constructor(params) {
- let place = params.place;
- delete params.place;
-
- let searchString = params.searchString || '';
- delete params.searchString;
-
- let type = params.type;
- delete params.type;
-
+ constructor({place, searchString, type, ...params}) {
super(params);
- this.update(place, type, searchString);
+
+ this.update(place, type, searchString || '');
}
update(place, type, searchString) {
diff --git a/src/placePopover.js b/src/placePopover.js
index 9f967f41..fb66093e 100644
--- a/src/placePopover.js
+++ b/src/placePopover.js
@@ -29,11 +29,8 @@ const _PLACE_ICON_SIZE = 20;
export class PlacePopover extends SearchPopover {
- constructor(props) {
- let maxChars = props.maxChars;
- delete props.maxChars;
-
- super(props);
+ constructor({maxChars, ...params}) {
+ super(params);
this._maxChars = maxChars;
diff --git a/src/placeStore.js b/src/placeStore.js
index d95a6ce7..de73576f 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -51,13 +51,7 @@ export class PlaceStore extends Gtk.ListStore {
LANGUAGE: 5
}
- constructor(params) {
- let recentPlacesLimit = params.recentPlacesLimit;
- delete params.recentPlacesLimit;
-
- let recentRoutesLimit = params.recentRoutesLimit;
- delete params.recentRoutesLimit;
-
+ constructor({recentPlacesLimit, recentRoutesLimit, ...params}) {
super(params);
this._recentPlacesLimit = recentPlacesLimit;
diff --git a/src/placeView.js b/src/placeView.js
index ce76dcee..c8bcdc40 100644
--- a/src/placeView.js
+++ b/src/placeView.js
@@ -47,22 +47,14 @@ const LRM = '\u200E';
export class PlaceView extends Gtk.Box {
- constructor(params) {
- let place = params.place;
- delete params.place;
-
- let mapView = params.mapView;
- delete params.mapView;
-
- /* This mode is used in PlaceBar for inline current location details.
+ constructor({place, mapView, inlineMode, ...params}) {
+ /* inlineMode is used in PlaceBar for inline current location details.
It hides the title box and decreases the start margin on the rows. */
- let inlineMode = !!params.inlineMode;
- delete params.inlineMode;
super(params);
this._place = place;
- this._inlineMode = inlineMode;
+ this._inlineMode = !!inlineMode;
let ui = Utils.getUIObject('place-view', [ 'bubble-main-box',
'bubble-spinner',
diff --git a/src/printLayout.js b/src/printLayout.js
index c977b6c9..7322c8f7 100644
--- a/src/printLayout.js
+++ b/src/printLayout.js
@@ -57,19 +57,7 @@ const _MapView = {
export class PrintLayout extends GObject.Object {
- constructor(params) {
- let pageWidth = params.pageWidth;
- delete params.pageWidth;
-
- let pageHeight = params.pageHeight;
- delete params.pageHeight;
-
- let totalSurfaces = params.totalSurfaces;
- delete params.totalSurfaces;
-
- let mainWindow = params.mainWindow;
- delete params.mainWindow;
-
+ constructor({pageWidth, pageHeight, totalSurfaces, mainWindow, ...params}) {
super(params);
this._pageWidth = pageWidth;
diff --git a/src/printOperation.js b/src/printOperation.js
index 0979bbaf..b4c31eb3 100644
--- a/src/printOperation.js
+++ b/src/printOperation.js
@@ -33,9 +33,8 @@ const _SHORT_LAYOUT_MAX_DISTANCE = 3000;
export class PrintOperation {
- constructor(params) {
- this._mainWindow = params.mainWindow;
- delete params.mainWindow;
+ constructor({mainWindow}) {
+ this._mainWindow = mainWindow;
this._operation = new Gtk.PrintOperation({ embed_page_setup: true });
this._operation.connect('begin-print', this._beginPrint.bind(this));
diff --git a/src/routeEntry.js b/src/routeEntry.js
index 343109e9..0f97e3cd 100644
--- a/src/routeEntry.js
+++ b/src/routeEntry.js
@@ -37,21 +37,12 @@ export class RouteEntry extends Gtk.Grid {
VIA: 2
}
- constructor(params) {
- let type = params.type;
- delete params.type;
-
- let point = params.point ?? null;
- delete params.point;
-
- let mapView = params.mapView ?? null;
- delete params.mapView;
-
+ constructor({type, point, mapView, ...params}) {
super(params);
this._type = type;
- this._point = point;
- this._mapView = mapView;
+ this._point = point ?? null;
+ this._mapView = mapView ?? null;
this.entry = this._createEntry();
this._entryGrid.attach(this.entry, 0, 0, 1, 1);
diff --git a/src/routeQuery.js b/src/routeQuery.js
index 8be64c88..1e07f048 100644
--- a/src/routeQuery.js
+++ b/src/routeQuery.js
@@ -141,8 +141,8 @@ export class RouteQuery extends GObject.Object {
this.notify('points');
}
- constructor(args) {
- super(args);
+ constructor(params) {
+ super(params);
this._points = [];
this._time = null;
this._date = null;
diff --git a/src/routingDelegator.js b/src/routingDelegator.js
index 256a06b2..971c8c2a 100644
--- a/src/routingDelegator.js
+++ b/src/routingDelegator.js
@@ -27,8 +27,8 @@ const _FALLBACK_TRANSPORTATION = RouteQuery.Transportation.PEDESTRIAN;
export class RoutingDelegator {
- constructor(params) {
- this._query = params.query;
+ constructor({query}) {
+ this._query = query;
this._transitRouting = false;
this._graphHopper = new GraphHopper({ query: this._query });
diff --git a/src/searchPopover.js b/src/searchPopover.js
index 919eec3f..a830c8b1 100644
--- a/src/searchPopover.js
+++ b/src/searchPopover.js
@@ -28,11 +28,8 @@ import Gtk from 'gi://Gtk';
focus-taking internal widget to the spawning search entry widget */
export class SearchPopover extends Gtk.Popover {
- constructor(props) {
- let entry = props.entry;
- delete props.entry;
-
- super(props);
+ constructor({entry, ...params}) {
+ super(params);
this._entry = entry;
diff --git a/src/sendToDialog.js b/src/sendToDialog.js
index 549d2f54..f2665417 100644
--- a/src/sendToDialog.js
+++ b/src/sendToDialog.js
@@ -41,15 +41,8 @@ export class SendToDialog extends Gtk.Dialog {
CANCEL: 1
};
- constructor(params) {
- let place = params.place;
- delete params.place;
-
- let mapView = params.mapView;
- delete params.mapView;
-
- params.use_header_bar = true;
- super(params);
+ constructor({place, mapView, ...params}) {
+ super({...params, use_header_bar: true});
this._place = place;
this._location = this._place.location;
diff --git a/src/shortPrintLayout.js b/src/shortPrintLayout.js
index 5d09be12..fd9d17fe 100644
--- a/src/shortPrintLayout.js
+++ b/src/shortPrintLayout.js
@@ -29,10 +29,7 @@ const _Instruction = {
};
export class ShortPrintLayout extends PrintLayout {
- constructor(params) {
- let route = params.route;
- delete params.route;
-
+ constructor({route, ...params}) {
/* (Header + map) + instructions */
//let totalSurfaces = 2 + route.turnPoints.length;
// for now don't count the map surface, as we don't have that yet
diff --git a/src/storedRoute.js b/src/storedRoute.js
index 094657d0..1e0e0bf3 100644
--- a/src/storedRoute.js
+++ b/src/storedRoute.js
@@ -34,19 +34,7 @@ const _LRM = '\u200E';
export class StoredRoute extends Place {
- constructor(params) {
- let route = params.route;
- delete params.route;
-
- let transportation = params.transportation;
- delete params.transportation;
-
- let places = params.places;
- delete params.places;
-
- let geoclue = params.geoclue;
- delete params.geoclue;
-
+ constructor({route, transportation, places, geoclue, ...params}) {
super(params);
this._transportation = transportation;
diff --git a/src/transitArrivalMarker.js b/src/transitArrivalMarker.js
index 8a0c1560..9a972b97 100644
--- a/src/transitArrivalMarker.js
+++ b/src/transitArrivalMarker.js
@@ -30,16 +30,13 @@ import * as TransitPlan from './transitPlan.js';
export class TransitArrivalMarker extends MapMarker {
- constructor(params) {
- let lastPoint = params.leg.polyline[params.leg.polyline.length - 1];
+ constructor({leg, ...params}) {
+ let lastPoint = leg.polyline[leg.polyline.length - 1];
let location = new Location({ latitude: lastPoint.latitude,
longitude: lastPoint.longitude });
- let bgColor = params.leg.color ?? TransitPlan.DEFAULT_ROUTE_COLOR;
+ let bgColor = leg.color ?? TransitPlan.DEFAULT_ROUTE_COLOR;
- delete params.leg;
- params.place = new Place({ location: location });
-
- super(params);
+ super({...params, place: new Place({ location: location })});
let bgRed = Color.parseColor(bgColor, 0);
let bgGreen = Color.parseColor(bgColor, 1);
diff --git a/src/transitArrivalRow.js b/src/transitArrivalRow.js
index 05e00e13..7818199b 100644
--- a/src/transitArrivalRow.js
+++ b/src/transitArrivalRow.js
@@ -27,13 +27,7 @@ import * as Transit from './transit.js';
export class TransitArrivalRow extends Gtk.ListBoxRow {
- constructor(params) {
- let itinerary = params.itinerary;
- delete params.itinerary;
-
- let mapView = params.mapView;
- delete params.mapView;
-
+ constructor({itinerary, mapView, ...params}) {
super(params);
let lastLeg = itinerary.legs[itinerary.legs.length - 1];
diff --git a/src/transitBoardMarker.js b/src/transitBoardMarker.js
index 901499e0..7fafb7e8 100644
--- a/src/transitBoardMarker.js
+++ b/src/transitBoardMarker.js
@@ -41,15 +41,12 @@ const OUTLINE_LUMINANCE_THREASHHOLD = 0.9;
export class TransitBoardMarker extends MapMarker {
- constructor(params) {
- let firstPoint = params.leg.polyline[0];
+ constructor({leg, ...params}) {
+ let firstPoint = leg.polyline[0];
let location = new Location({ latitude: firstPoint.latitude,
longitude: firstPoint.longitude });
- let leg = params.leg;
- delete params.leg;
- params.place = new Place({ location: location });
- super(params);
+ super({...params, place: new Place({ location: location })});
this._image.pixel_size = MARKER_SIZE;
this._image.paintable = this._createPaintable(leg);
diff --git a/src/transitItineraryRow.js b/src/transitItineraryRow.js
index 9ae2594e..6fdb829b 100644
--- a/src/transitItineraryRow.js
+++ b/src/transitItineraryRow.js
@@ -29,10 +29,7 @@ const MAX_LEGS_SHOWN = 8;
export class TransitItineraryRow extends Gtk.ListBoxRow {
- constructor(params) {
- let itinerary = params.itinerary;
- delete params.itinerary;
-
+ constructor({itinerary, ...params}) {
super(params);
this._itinerary = itinerary;
diff --git a/src/transitLegRow.js b/src/transitLegRow.js
index b1e06db8..d1a16a43 100644
--- a/src/transitLegRow.js
+++ b/src/transitLegRow.js
@@ -37,16 +37,7 @@ const _ = gettext.gettext;
export class TransitLegRow extends Gtk.ListBoxRow {
- constructor(params) {
- let leg = params.leg;
- delete params.leg;
-
- let start = params.start;
- delete params.start;
-
- let mapView = params.mapView;
- delete params.mapView;
-
+ constructor({leg, start, mapView, ...params}) {
super(params);
this._leg = leg;
diff --git a/src/transitPrintLayout.js b/src/transitPrintLayout.js
index 07dffd72..4006df10 100644
--- a/src/transitPrintLayout.js
+++ b/src/transitPrintLayout.js
@@ -57,14 +57,11 @@ const OUTLINE_LUMINANCE_THREASHHOLD = 0.9;
export class TransitPrintLayout extends PrintLayout {
- constructor(params) {
- let itinerary = params.itinerary;
- delete params.itinerary;
-
- params.totalSurfaces =
- TransitPrintLayout._getNumberOfSurfaces(itinerary);
-
- super(params);
+ constructor({itinerary, ...params}) {
+ super({
+ ...params,
+ totalSurfaces: TransitPrintLayout._getNumberOfSurfaces(itinerary),
+ });
this._itinerary = itinerary;
}
diff --git a/src/transitRouteLabel.js b/src/transitRouteLabel.js
index 8de17047..680d18b0 100644
--- a/src/transitRouteLabel.js
+++ b/src/transitRouteLabel.js
@@ -44,12 +44,7 @@ const HIGH_CONTRAST_TEXT_COLOR = 'ffffff';
export class TransitRouteLabel extends Gtk.Label {
- constructor(params) {
- let leg = params.leg;
- let compact = params.compact;
-
- delete params.leg;
- delete params.compact;
+ constructor({leg, compact, ...params}) {
super(params);
this._setLabel(leg, compact);
diff --git a/src/transitRouter.js b/src/transitRouter.js
index 8eb1563d..05e6627b 100644
--- a/src/transitRouter.js
+++ b/src/transitRouter.js
@@ -40,9 +40,9 @@ import {Resrobot} from './transitplugins/resrobot.js';
* requests).
*/
export class TransitRouter {
- constructor(params) {
+ constructor({query}) {
this._plan = new Plan();
- this._query = params.query;
+ this._query = query;
this._providers = Service.getService().transitProviders;
this._providerCache = [];
this._language = Utils.getLanguage();
diff --git a/src/transitStopRow.js b/src/transitStopRow.js
index c607d963..bad8ebfa 100644
--- a/src/transitStopRow.js
+++ b/src/transitStopRow.js
@@ -28,13 +28,7 @@ const _ = gettext.gettext;
export class TransitStopRow extends Gtk.ListBoxRow {
- constructor(params) {
- let stop = params.stop;
- delete params.stop;
-
- let final = params.final;
- delete params.final;
-
+ constructor({stop, final, ...params}) {
super(params);
this.stop = stop;
diff --git a/src/transitWalkMarker.js b/src/transitWalkMarker.js
index b9da6ee2..30ad39e4 100644
--- a/src/transitWalkMarker.js
+++ b/src/transitWalkMarker.js
@@ -29,30 +29,24 @@ import {Place} from './place.js';
export class TransitWalkMarker extends MapMarker {
- constructor(params) {
+ constructor({leg, previousLeg, ...params}) {
/* if there is a preceding leg, put the marker at the end of that leg
* to avoid gaps, since we will "fill out" the walking leg path line
* since sometimes the walking route might not reach exactly to the
* transit stop's position
*/
let point;
- if (params.previousLeg)
- point = params.previousLeg.polyline[params.previousLeg.polyline.length - 1];
+ if (previousLeg)
+ point = previousLeg.polyline[previousLeg.polyline.length - 1];
else
- point = params.leg.polyline[0];
+ point = leg.polyline[0];
- let bgColor = params.leg.color ? params.leg.color :
- TransitPlan.DEFAULT_ROUTE_COLOR;
-
- delete params.leg;
- delete params.previousLeg;
+ let bgColor = leg.color ? leg.color : TransitPlan.DEFAULT_ROUTE_COLOR;
let location = new Location({ latitude: point.latitude,
longitude: point.longitude });
- params.place = new Place({ location: location });
-
- super(params);
+ super({...params, place: new Place({ location: location })});
let bgRed = Color.parseColor(bgColor, 0);
let bgGreen = Color.parseColor(bgColor, 1);
diff --git a/src/translations.js b/src/translations.js
index 6106c33d..3a82d301 100644
--- a/src/translations.js
+++ b/src/translations.js
@@ -284,7 +284,7 @@ function _translateOpeningHoursTime(string) {
export function translateReligion(string) {
switch(string) {
case 'animist': return _("Animism");
- case 'bahai': return_("Bahá'í");
+ case 'bahai': return _("Bahá'í");
case 'buddhist': return _("Buddhism");
case 'caodaism': return _("Caodaism");
case 'christian': return _("Christianity");
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index 6ac57791..a9252dc4 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -31,19 +31,7 @@ import * as Utils from './utils.js';
export class TurnPointMarker extends MapMarker {
- constructor(params) {
- let queryPoint = params.queryPoint;
- delete params.queryPoint;
-
- let turnPoint = params.turnPoint;
- delete params.turnPoint;
-
- let transitStop = params.transitStop;
- delete params.transitStop;
-
- let transitLeg = params.transitLeg;
- delete params.transitLeg;
-
+ constructor({queryPoint, turnPoint, transitStop, transitLeg, ...params}) {
let latitude;
let longitude;
@@ -55,11 +43,11 @@ export class TurnPointMarker extends MapMarker {
longitude = transitStop.coordinate[1];
}
- params.place =
+ let place =
new Place({ location: new Location({ latitude: latitude,
longitude: longitude }) });
- super(params);
+ super({...params, place: place});
this._queryPoint = queryPoint;
diff --git a/src/userLocationMarker.js b/src/userLocationMarker.js
index d4dbc192..173b296b 100644
--- a/src/userLocationMarker.js
+++ b/src/userLocationMarker.js
@@ -28,14 +28,12 @@ import {MapMarker} from './mapMarker.js';
export class AccuracyCircleMarker extends Shumate.Marker {
- constructor(params) {
- let place = params.place;
- delete params.place;
-
- params.latitude = place.location.latitude;
- params.longitude = place.location.longitude;
-
- super(params);
+ constructor({place, ...params}) {
+ super({
+ ...params,
+ latitude: place.location.latitude,
+ longitude: place.location.longitude,
+ });
this._place = place;
}
diff --git a/src/zoomInDialog.js b/src/zoomInDialog.js
index 89eb07d1..351d1fe8 100644
--- a/src/zoomInDialog.js
+++ b/src/zoomInDialog.js
@@ -27,18 +27,9 @@ import {OSMEdit} from './osmEdit.js';
export class ZoomInDialog extends Gtk.Dialog {
- constructor(params) {
- let latitude = params.latitude;
- delete params.latitude;
- let longitude = params.longitude;
- delete params.longitude;
- let map = params.map;
- delete params.map;
-
- /* This is a construct-only property and cannot be set by GtkBuilder */
- params.use_header_bar = true;
-
- super(params);
+ constructor({latitude, longitude, map, ...params}) {
+ /* use_header_bar is a construct-only property and cannot be set by GtkBuilder */
+ super({...params, use_header_bar: true});
this._latitude = latitude;
this._longitude = longitude;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]