fix: set vte text color at startup

This commit is contained in:
Gabriele Musco 2024-01-07 14:10:45 +00:00
commit b954e20cf2

View file

@ -181,13 +181,7 @@ impl SimpleComponent for DebugView {
self.vte_terminal.feed("\x1bc".as_bytes()); self.vte_terminal.feed("\x1bc".as_bytes());
} }
Self::Input::SetColorScheme => { Self::Input::SetColorScheme => {
if adw::StyleManager::default().is_dark() { Self::set_color_scheme(&self.vte_terminal);
self.vte_terminal
.set_color_foreground(&gtk::gdk::RGBA::new(1.0, 1.0, 1.0, 1.0));
} else {
self.vte_terminal
.set_color_foreground(&gtk::gdk::RGBA::new(0.0, 0.0, 0.0, 1.0));
}
} }
} }
} }
@ -239,6 +233,7 @@ impl SimpleComponent for DebugView {
.build(); .build();
t.set_clear_background(false); t.set_clear_background(false);
t.search_set_wrap_around(true); t.search_set_wrap_around(true);
Self::set_color_scheme(&t);
t t
}, },
}; };
@ -274,3 +269,13 @@ impl SimpleComponent for DebugView {
ComponentParts { model, widgets } ComponentParts { model, widgets }
} }
} }
impl DebugView {
fn set_color_scheme(term: &Terminal) {
if adw::StyleManager::default().is_dark() {
term.set_color_foreground(&gtk::gdk::RGBA::new(1.0, 1.0, 1.0, 1.0));
} else {
term.set_color_foreground(&gtk::gdk::RGBA::new(0.0, 0.0, 0.0, 1.0));
}
}
}