diff --git a/data/org.gnome.Maps.gschema.xml b/data/org.gnome.Maps.gschema.xml index cc32f780647c5e50f232948b50eb09cb80c3d7b9..f9239066320199d87cc58bdffd9693a0ecc3b04e 100644 --- a/data/org.gnome.Maps.gschema.xml +++ b/data/org.gnome.Maps.gschema.xml @@ -75,11 +75,6 @@ 'pedestrian' Last used transportation type for routing - - false - Night mode - Whether the application is in night mode. - false Use hybrid aerial tiles diff --git a/data/ui/main-window.ui b/data/ui/main-window.ui index a21db6aa6543624958a1e148453cd60f991740b9..c87b6321754666dcb06999c07aa05d107e8fec8a 100644 --- a/data/ui/main-window.ui +++ b/data/ui/main-window.ui @@ -3,10 +3,6 @@
- - app.night-mode - Night Mode - app.osm-account-setup Set up OpenStreetMap Account diff --git a/src/application.js b/src/application.js index 573bceeff532d5a4c6f5b0e3bf73989089551a11..32d309b0556ec216ef90f0ab254583ff5447b235 100644 --- a/src/application.js +++ b/src/application.js @@ -227,12 +227,6 @@ var Application = GObject.registerClass({ } } - _onNightModeChange(action) { - let state = action.get_state(); - let gtkSettings = Gtk.Settings.get_default(); - gtkSettings.gtk_application_prefer_dark_theme = state.get_boolean(); - } - vfunc_startup() { super.vfunc_startup(); @@ -252,22 +246,15 @@ var Application = GObject.registerClass({ 'osm-account-setup': { onActivate: this._onOsmAccountSetupActivate.bind(this) }, - 'night-mode': { - paramType: 'b', - onChangeState: this._onNightModeChange.bind(this), - setting: 'night-mode' - }, 'quit': { onActivate: () => this.quit(), accels: ['Q'] } }, settings); - // set dark theme when night-mode is enabled - let gtkSettings = Gtk.Settings.get_default(); - gtkSettings.gtk_application_prefer_dark_theme = - settings.get('night-mode'); + this._styleManager = Hdy.StyleManager.get_default(); + this._styleManager.set_color_scheme(Hdy.ColorScheme.PREFER_LIGHT); Gtk.IconTheme.get_default().append_search_path(GLib.build_filenamev([pkg.pkgdatadir, 'icons'])); diff --git a/src/layersPopover.js b/src/layersPopover.js index 70f2565778105f0b41e27584b0a363d82617777c..d421b71f86506e0315b279056d359f16d9eca8ab 100644 --- a/src/layersPopover.js +++ b/src/layersPopover.js @@ -21,6 +21,7 @@ const Champlain = imports.gi.Champlain; const GObject = imports.gi.GObject; const Gtk = imports.gi.Gtk; const Gdk = imports.gi.Gdk; +const Hdy = imports.gi.Handy; const Application = imports.application; const MapSource = imports.mapSource; @@ -144,8 +145,8 @@ var LayersPopover = GObject.registerClass({ this._setLayerPreviews.bind(this)); this._mapView.view.connect("notify::longitude", this._setLayerPreviews.bind(this)); - Application.settings.connect("changed::night-mode", - this._onNightModeChanged.bind(this)); + Hdy.StyleManager.get_default().connect("notify::dark", + this._onDarkChanged.bind(this)); Application.settings.connect("changed::hybrid-aerial", this._onHybridAerialChanged.bind(this)); @@ -160,9 +161,9 @@ var LayersPopover = GObject.registerClass({ }); } - _onNightModeChanged() { + _onDarkChanged() { if (Service.getService().tiles.streetDark && - Application.settings.get('night-mode')) { + Hdy.StyleManager.get_default().dark) { this._setLayerPreviewImage('streetDark', true); } else { this._setLayerPreviewImage('street', true); @@ -180,7 +181,7 @@ var LayersPopover = GObject.registerClass({ _setLayerPreviews() { if (Service.getService().tiles.streetDark && - Application.settings.get('night-mode')) { + Hdy.StyleManager.get_default().dark) { this._setLayerPreviewImage('streetDark'); } else { this._setLayerPreviewImage('street'); diff --git a/src/mainWindow.js b/src/mainWindow.js index 9abceb4602bee4d71d871d510fb07d1e5ff3643a..08446e361c6db031dd880a0a792f9b6536d432f0 100644 --- a/src/mainWindow.js +++ b/src/mainWindow.js @@ -86,7 +86,7 @@ var MainWindow = GObject.registerClass({ 'noNetworkView', 'actionBar', 'actionBarRevealer', - 'placeBarContainer' ] + 'placeBarContainer'] }, class MainWindow extends Gtk.ApplicationWindow { get mapView() { diff --git a/src/mapView.js b/src/mapView.js index 10e6d5a342a043b9ab699946f0d8eb6325433996..fef736c2848a410cd8579d34b3a4ba3261512f2a 100644 --- a/src/mapView.js +++ b/src/mapView.js @@ -26,6 +26,7 @@ const Geocode = imports.gi.GeocodeGlib; const Gio = imports.gi.Gio; const Gtk = imports.gi.Gtk; const GtkChamplain = imports.gi.GtkChamplain; +const Hdy = imports.gi.Handy; const Mainloop = imports.mainloop; const Application = imports.application; @@ -210,8 +211,8 @@ var MapView = GObject.registerClass({ // if dark tiles is available, setup handler to switch style if (Service.getService().tiles.streetDark) { - Application.settings.connect('changed::night-mode', - this._onNightModeChanged.bind(this)); + Hdy.StyleManager.get_default().connect('notify::dark', + this._onDarkChanged.bind(this)); } // if hybrid aerial tiles are available, setup handler to toggle @@ -272,11 +273,11 @@ var MapView = GObject.registerClass({ this._setBackgroundPatternIfNeeded(); } - _onNightModeChanged() { + _onDarkChanged() { if (this._mapType === MapType.STREET) { let overlay_sources = this.view.get_overlay_sources(); - if (Application.settings.get('night-mode')) + if (Hdy.StyleManager.get_default().dark) this.view.map_source = MapSource.createStreetDarkSource(); else this.view.map_source = MapSource.createStreetSource(); @@ -428,7 +429,7 @@ var MapView = GObject.registerClass({ } } else { if (tiles.streetDark && - Application.settings.get('night-mode')) { + Hdy.StyleManager.get_default().dark) { this.view.map_source = MapSource.createStreetDarkSource(); } else { this.view.map_source = MapSource.createStreetSource();