logging: Try to improve common operations
This adds sugar for logging `Result`s with a handler, makes names evoke something closer to "logging" than "warning", tries to remove any redundant `Logging` where the module name will do, and introduces a type strictly for bad things happening.
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
/*! CSS data loading. */
|
||||
|
||||
use std::env;
|
||||
use ::logging;
|
||||
|
||||
use glib::object::ObjectExt;
|
||||
use logging::Warn;
|
||||
@ -94,15 +95,13 @@ fn get_theme_name(settings: >k::Settings) -> GtkTheme {
|
||||
None => GtkTheme {
|
||||
name: {
|
||||
settings.get_property("gtk-theme-name")
|
||||
// maybe TODO: is this worth a warning?
|
||||
.or_warn("No theme name")
|
||||
.or_print(logging::Problem::Surprise, "No theme name")
|
||||
.and_then(|value| value.get::<String>())
|
||||
.unwrap_or(DEFAULT_THEME_NAME.into())
|
||||
},
|
||||
variant: {
|
||||
settings.get_property("gtk-application-prefer-dark-theme")
|
||||
// maybe TODO: is this worth a warning?
|
||||
.or_warn("No settings key")
|
||||
.or_print(logging::Problem::Surprise, "No settings key")
|
||||
.and_then(|value| value.get::<bool>())
|
||||
.and_then(|dark_preferred| match dark_preferred {
|
||||
true => Some("dark".into()),
|
||||
|
||||
Reference in New Issue
Block a user