From 09ed33f7796e38094a688ab710e07639a030c52f Mon Sep 17 00:00:00 2001 From: thorou Date: Thu, 20 Jun 2024 22:11:21 +0200 Subject: [PATCH] Fix fltk frontend colors --- config.yml | 7 ----- gravel-frontend-fltk/src/config.rs | 50 ++---------------------------- 2 files changed, 2 insertions(+), 55 deletions(-) diff --git a/config.yml b/config.yml index 1561ed0..0d48bc4 100644 --- a/config.yml +++ b/config.yml @@ -76,13 +76,6 @@ frontend: # ## Google has a color picker if you search for, well, "color picker". # colors: # background: 0x202020 - # accent: 0xbf6c0d - # text: 0xffffff - # - # ## Alternative representation which is more customizable. - # ## Chose *either* block, not both. - # # colors: - # background: 0x202020 # query_text: 0xffffff # query_cursor: 0xbf6c0d # query_highlight: 0xbf6c0d diff --git a/gravel-frontend-fltk/src/config.rs b/gravel-frontend-fltk/src/config.rs index 84201c0..3d9354f 100644 --- a/gravel-frontend-fltk/src/config.rs +++ b/gravel-frontend-fltk/src/config.rs @@ -53,13 +53,12 @@ pub struct Layout { #[derive(Deserialize, Debug)] pub struct Config { pub layout: Layout, - #[serde(deserialize_with = "deserialize::colors")] - pub colors: DetailedColors, + pub colors: Colors, pub behaviour: Behaviour, } #[derive(Deserialize, Debug)] -pub struct DetailedColors { +pub struct Colors { #[serde(deserialize_with = "deserialize::color")] pub background: Color, #[serde(deserialize_with = "deserialize::color")] @@ -86,51 +85,6 @@ pub mod deserialize { u32::deserialize(de).map(Color::from_hex) } - pub fn colors<'de, D: Deserializer<'de>>(de: D) -> Result { - ColorVariants::deserialize(de).map(Into::into) - } - - #[derive(Deserialize, Debug)] - #[serde(untagged)] - pub enum ColorVariants { - SimpleColors(SimpleColors), - DetailedColors(super::DetailedColors), - } - - #[derive(Deserialize, Debug)] - pub struct SimpleColors { - #[serde(deserialize_with = "color")] - pub background: Color, - #[serde(deserialize_with = "color")] - pub accent: Color, - #[serde(deserialize_with = "color")] - pub text: Color, - } - - impl From for super::DetailedColors { - fn from(val: ColorVariants) -> Self { - match val { - ColorVariants::SimpleColors(colors) => colors.into(), - ColorVariants::DetailedColors(colors) => colors, - } - } - } - - impl From for super::DetailedColors { - fn from(val: SimpleColors) -> Self { - super::DetailedColors { - background: val.background, - query_text: val.text, - query_cursor: val.accent, - query_highlight: val.accent, - hit_title: val.text, - hit_subtitle: val.text, - hit_highlight: val.accent, - scrollbar: val.accent, - } - } - } - #[derive(Deserialize, Debug)] pub struct Layout { pub scale: f32,