Commit a09e9570 authored by Mattias Bengtsson's avatar Mattias Bengtsson Committed by Jonas Danielsson

MainWindow: Use getter for mapView

This adds consistency to our coding style.

https://bugzilla.gnome.org/show_bug.cgi?id=740647
parent c7e6f397
...@@ -58,6 +58,10 @@ const MainWindow = new Lang.Class({ ...@@ -58,6 +58,10 @@ const MainWindow = new Lang.Class({
'layersButton', 'layersButton',
'favoritesButton' ], 'favoritesButton' ],
get mapView() {
return this._mapView;
},
_init: function(params) { _init: function(params) {
this._overlay = params.overlay; this._overlay = params.overlay;
delete params.overlay; delete params.overlay;
...@@ -66,18 +70,18 @@ const MainWindow = new Lang.Class({ ...@@ -66,18 +70,18 @@ const MainWindow = new Lang.Class({
this._configureId = 0; this._configureId = 0;
this.mapView = new MapView.MapView(); this._mapView = new MapView.MapView();
this._overlay.add(this.mapView); this._overlay.add(this._mapView);
this.mapView.gotoUserLocation(false); this._mapView.gotoUserLocation(false);
this._sidebar = this._createSidebar(); this._sidebar = this._createSidebar();
this._contextMenu = new ContextMenu.ContextMenu(this.mapView); this._contextMenu = new ContextMenu.ContextMenu(this._mapView);
this._layersButton.popover = new LayersPopover.LayersPopover(); this._layersButton.popover = new LayersPopover.LayersPopover();
this._favoritesButton.popover = new FavoritesPopover.FavoritesPopover({ mapView: this.mapView }); this._favoritesButton.popover = new FavoritesPopover.FavoritesPopover({ mapView: this._mapView });
this._overlay.add_overlay(new ZoomControl.ZoomControl(this.mapView)); this._overlay.add_overlay(new ZoomControl.ZoomControl(this._mapView));
this._mainStack.add(this._overlay); this._mainStack.add(this._overlay);
this._busy = new BusyMarker.BusyMarker(); this._busy = new BusyMarker.BusyMarker();
...@@ -96,7 +100,7 @@ const MainWindow = new Lang.Class({ ...@@ -96,7 +100,7 @@ const MainWindow = new Lang.Class({
}, },
_createPlaceEntry: function() { _createPlaceEntry: function() {
let placeEntry = new PlaceEntry.PlaceEntry({ mapView: this.mapView, let placeEntry = new PlaceEntry.PlaceEntry({ mapView: this._mapView,
visible: true, visible: true,
margin_start: 6, margin_start: 6,
margin_end: 6, margin_end: 6,
...@@ -105,24 +109,24 @@ const MainWindow = new Lang.Class({ ...@@ -105,24 +109,24 @@ const MainWindow = new Lang.Class({
}); });
placeEntry.connect('notify::place', (function() { placeEntry.connect('notify::place', (function() {
if (placeEntry.place) { if (placeEntry.place) {
this.mapView.showSearchResult(placeEntry.place); this._mapView.showSearchResult(placeEntry.place);
} }
}).bind(this)); }).bind(this));
let popover = placeEntry.popover; let popover = placeEntry.popover;
popover.connect('selected', popover.connect('selected',
this.mapView.grab_focus.bind(this.mapView)); this._mapView.grab_focus.bind(this._mapView));
this.mapView.view.connect('button-press-event', this._mapView.view.connect('button-press-event',
popover.hide.bind(popover)); popover.hide.bind(popover));
return placeEntry; return placeEntry;
}, },
_createSidebar: function() { _createSidebar: function() {
let sidebar = new Sidebar.Sidebar(this.mapView); let sidebar = new Sidebar.Sidebar(this._mapView);
Application.routeService.query.connect('notify', Application.routeService.query.connect('notify',
this._setRevealSidebar.bind(this, true)); this._setRevealSidebar.bind(this, true));
sidebar.bind_property('reveal-child', sidebar.bind_property('reveal-child',
this.mapView, 'routeVisible', this._mapView, 'routeVisible',
GObject.BindingFlags.BIDIRECTIONAL); GObject.BindingFlags.BIDIRECTIONAL);
this.application.bind_property('connected', this.application.bind_property('connected',
sidebar, 'visible', sidebar, 'visible',
...@@ -157,11 +161,11 @@ const MainWindow = new Lang.Class({ ...@@ -157,11 +161,11 @@ const MainWindow = new Lang.Class({
}, },
'zoom-in': { 'zoom-in': {
accels: ['<Primary>plus'], accels: ['<Primary>plus'],
onActivate: this.mapView.view.zoom_in.bind(this.mapView.view) onActivate: this._mapView.view.zoom_in.bind(this._mapView.view)
}, },
'zoom-out': { 'zoom-out': {
accels: ['<Primary>minus'], accels: ['<Primary>minus'],
onActivate: this.mapView.view.zoom_out.bind(this.mapView.view) onActivate: this._mapView.view.zoom_out.bind(this._mapView.view)
}, },
'find': { 'find': {
accels: ['<Primary>F'], accels: ['<Primary>F'],
...@@ -176,11 +180,11 @@ const MainWindow = new Lang.Class({ ...@@ -176,11 +180,11 @@ const MainWindow = new Lang.Class({
this._onConfigureEvent.bind(this)); this._onConfigureEvent.bind(this));
this.connect('window-state-event', this.connect('window-state-event',
this._onWindowStateEvent.bind(this)); this._onWindowStateEvent.bind(this));
this.mapView.view.connect('button-press-event', (function() { this._mapView.view.connect('button-press-event', (function() {
// Can not call something that will generate clutter events // Can not call something that will generate clutter events
// from a clutter event-handler. So use an idle. // from a clutter event-handler. So use an idle.
Mainloop.idle_add((function() { Mainloop.idle_add((function() {
this.mapView.grab_focus(); this._mapView.grab_focus();
}).bind(this)); }).bind(this));
}).bind(this)); }).bind(this));
...@@ -322,7 +326,7 @@ const MainWindow = new Lang.Class({ ...@@ -322,7 +326,7 @@ const MainWindow = new Lang.Class({
break; break;
default: default:
this.mapView.gotoUserLocation(true); this._mapView.gotoUserLocation(true);
break; break;
} }
}, },
...@@ -335,7 +339,7 @@ const MainWindow = new Lang.Class({ ...@@ -335,7 +339,7 @@ const MainWindow = new Lang.Class({
_onMapTypeActivate: function(action, value) { _onMapTypeActivate: function(action, value) {
action.set_state(value); action.set_state(value);
let [mapType, len] = value.get_string(); let [mapType, len] = value.get_string();
this.mapView.setMapType(MapView.MapType[mapType]); this._mapView.setMapType(MapView.MapType[mapType]);
}, },
_onToggleSidebarChangeState: function(action, variant) { _onToggleSidebarChangeState: function(action, variant) {
...@@ -384,7 +388,7 @@ const MainWindow = new Lang.Class({ ...@@ -384,7 +388,7 @@ const MainWindow = new Lang.Class({
this._busy.show(); this._busy.show();
let stage = this.mapView.view.get_stage(); let stage = this._mapView.view.get_stage();
this._busySignalId = stage.connect('captured-event', function() { this._busySignalId = stage.connect('captured-event', function() {
return true; return true;
}); });
...@@ -393,7 +397,7 @@ const MainWindow = new Lang.Class({ ...@@ -393,7 +397,7 @@ const MainWindow = new Lang.Class({
unmarkBusy: function() { unmarkBusy: function() {
this._busy.hide(); this._busy.hide();
let stage = this.mapView.view.get_stage(); let stage = this._mapView.view.get_stage();
stage.disconnect(this._busySignalId); stage.disconnect(this._busySignalId);
this._busySignalId = 0; this._busySignalId = 0;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment