[gnome-maps/wip/mlundblad/night-mode: 5/11] 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: 5/11] application: Add action for toggling night mode
- Date: Thu, 11 Jun 2020 21:09:06 +0000 (UTC)
commit 75f0e9489ad0c354c64b10adaa16d03522e3c0e5
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 | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/src/application.js b/src/application.js
index ab2252e6..0cd91640 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,11 +249,22 @@ 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']
}
- });
+ }, 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');
Gtk.IconTheme.get_default().append_search_path(GLib.build_filenamev([pkg.pkgdatadir,
'icons']));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]