Set dark theme at application startup based on settings.

This commit is contained in:
Rowan Lewis 2018-03-17 23:46:37 +01:00
parent afdedc7575
commit 34536f4e21
2 changed files with 9 additions and 6 deletions

View File

@ -4,6 +4,7 @@ use gio::{ApplicationExt, ApplicationExtManual, ApplicationFlags, Settings, Sett
use glib;
use gtk;
use gtk::prelude::*;
use gtk::SettingsExt as GtkSettingsExt;
use hammond_data::{Podcast, Source};
@ -99,10 +100,18 @@ impl App {
}
fn setup_timed_callbacks(&self) {
self.setup_dark_theme();
self.setup_refresh_on_startup();
self.setup_auto_refresh();
}
fn setup_dark_theme(&self) {
let settings = gtk::Settings::get_default().unwrap();
let enabled = self.settings.get_boolean("dark-theme");
settings.set_property_gtk_application_prefer_dark_theme(enabled);
}
fn setup_refresh_on_startup(&self) {
// Update the feeds right after the Application is initialized.
if self.settings.get_boolean("refresh-on-startup") {

View File

@ -89,11 +89,5 @@ fn main() {
600,
);
// This set's the app to dark mode.
// It wiil be in the user's preference later.
// Uncomment it to run with the dark theme variant.
// let settings = gtk::Settings::get_default().unwrap();
// settings.set_property_gtk_application_prefer_dark_theme(true);
App::new().run();
}