[gnome-maps/wip/mlundblad/night-mode: 2/3] application: Add action for toggling night mode
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/night-mode: 2/3] application: Add action for toggling night mode
- Date: Thu, 4 Jun 2020 21:03:43 +0000 (UTC)
commit 7228fee38540aecf082cee923833fa7bdb06cbb8
Author: Marcus Lundblad <ml update uu se>
Date: Tue Jun 2 22:35:06 2020 +0200
application: Add action for toggling night mode
src/application.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/src/application.js b/src/application.js
index ab2252e6..4acef4d4 100644
--- a/src/application.js
+++ b/src/application.js
@@ -225,6 +225,12 @@ 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();
@@ -243,12 +249,23 @@ 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: ['<Primary>Q']
}
});
+ // set dark theme when night-mode is enabled
+ let gtkSettings = Gtk.Settings.get_default();
+
+ gtkSettings.gtk_application_prefer_dark_theme =
+ settings.get('night-mode');
+
Gtk.IconTheme.get_default().append_search_path(GLib.build_filenamev([pkg.pkgdatadir,
'icons']));
this._initPlaceStore();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]