Introduce option to prefer dark GTK theme

This commit is contained in:
Christopher Lübbemeier 2017-12-05 13:38:31 +01:00
parent 3b4964c1a0
commit ef2e491b38

View File

@ -6,7 +6,7 @@ use std::sync::Arc;
use gtk; use gtk;
use gtk_sys; use gtk_sys;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::{ApplicationWindow, HeaderBar, ToolButton, Image, AboutDialog}; use gtk::{ApplicationWindow, HeaderBar, ToolButton, Image, AboutDialog, SettingsExt};
use gio::prelude::*; use gio::prelude::*;
use gio::{Menu, MenuExt, MenuItem, MenuItemExt, SimpleAction}; use gio::{Menu, MenuExt, MenuItem, MenuItemExt, SimpleAction};
@ -105,6 +105,15 @@ impl Ui {
comps.window = Some(ApplicationWindow::new(app)); comps.window = Some(ApplicationWindow::new(app));
let window = comps.window.as_ref().unwrap(); let window = comps.window.as_ref().unwrap();
let prefer_dark_theme = env::var("NVIM_GTK_PREFER_DARK_THEME")
.map(|opt| opt.trim() == "1")
.unwrap_or(false);
if prefer_dark_theme {
if let Some(settings) = window.get_settings() {
settings.set_property_gtk_application_prefer_dark_theme(true);
}
}
// Client side decorations including the toolbar are disabled via NVIM_GTK_NO_HEADERBAR=1 // Client side decorations including the toolbar are disabled via NVIM_GTK_NO_HEADERBAR=1
let use_header_bar = env::var("NVIM_GTK_NO_HEADERBAR") let use_header_bar = env::var("NVIM_GTK_NO_HEADERBAR")
.map(|opt| opt.trim() != "1") .map(|opt| opt.trim() != "1")