Commit 99256e1a authored by Marcus Lundblad's avatar Marcus Lundblad
Browse files

mapView: Don't set dark background pattern

As we currently don't have dark tiles available,
remove code setting a dark background, as it
involves dealing with Clutter, and would anyway
get removed when porting to GTK4 and libshumate.
parent f2215b60
Pipeline #393952 passed with stages
in 8 minutes and 37 seconds
......@@ -169,9 +169,6 @@ var MapView = GObject.registerClass({
Application.geoclue.connect('notify::state',
this._updateUserLocation.bind(this));
this._connectRouteSignals();
// set dark background if we start up in dark theme
this._setBackgroundPatternIfNeeded();
}
_initScale(view) {
......@@ -202,8 +199,6 @@ var MapView = GObject.registerClass({
view.horizontal_wrap = true;
view.connect('notify::latitude', this._onViewMoved.bind(this));
view.connect('notify::longitude',
() => this._setBackgroundPatternIfNeeded());
// switching map type will set view min-zoom-level from map source
view.connect('notify::min-zoom-level', () => {
if (view.min_zoom_level < MapMinZoom) {
......@@ -223,10 +218,6 @@ var MapView = GObject.registerClass({
this._onHybridAerialChanged.bind(this));
}
this._gtkSettings = Gtk.Settings.get_default();
this._gtkSettings.connect('notify::gtk-application-prefer-dark-theme',
this._onPreferDarkThemeChanged.bind(this));
Application.settings.connect('changed::show-scale',
this._onShowScaleChanged.bind(this));
......@@ -234,50 +225,6 @@ var MapView = GObject.registerClass({
return view;
}
/* handler to draw background for dark theme,
* these three functions should not be needed later with a native GTK
* widget (Shumate)
*/
_drawDarkBackground(canvas, cr, width, height) {
// set this arbitrarily to try to match the typical dark tile set
cr.setSourceRGB(0.2, 0.2, 0.2);
cr.rectangle(0, 0, width, height);
cr.fillPreserve();
return true;
}
_createDarkBackground() {
this._darkBackground = new Clutter.Canvas();
this._darkBackground.set_size(512, 512);
this._darkBackground.connect('draw',
this._drawDarkBackground.bind(this));
this._darkBackground.invalidate();
}
_isWrappingAround() {
let bbox = this.view.get_bounding_box();
return bbox.left > bbox.right;
}
_setBackgroundPatternIfNeeded() {
if (this._gtkSettings.gtk_application_prefer_dark_theme &&
!this._isWrappingAround()) {
if (!this._darkBackgroud)
this._createDarkBackground();
this.view.set_background_pattern(this._darkBackground);
this._customBackgroundSet = true;
} else if (this._customBackgroundSet) {
this.view.background_pattern = null;
this._customBackgroundSet = false;
}
}
_onPreferDarkThemeChanged() {
this._setBackgroundPatternIfNeeded();
}
_onDarkChanged() {
if (this._mapType === MapType.STREET) {
let overlay_sources = this.view.get_overlay_sources();
......
Supports Markdown
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