mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-02 14:18:49 +00:00
feat: debug view log blends in with headerbar and follows system color preference
This commit is contained in:
parent
067d022df4
commit
6b567fac5b
2 changed files with 33 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
||||||
.padded {
|
.padded {
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sourceview-transparent-bg, .sourceview-transparent-bg * {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ pub enum DebugViewMsg {
|
||||||
FilterLog(SearchDirection),
|
FilterLog(SearchDirection),
|
||||||
LogLevelChanged(LogLevel),
|
LogLevelChanged(LogLevel),
|
||||||
XRServiceActiveChanged(bool),
|
XRServiceActiveChanged(bool),
|
||||||
|
SetColorScheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracker::track]
|
#[tracker::track]
|
||||||
|
@ -120,6 +121,7 @@ impl SimpleComponent for DebugView {
|
||||||
add_css_class: "undershoot-top",
|
add_css_class: "undershoot-top",
|
||||||
#[name(textview)]
|
#[name(textview)]
|
||||||
sourceview5::View {
|
sourceview5::View {
|
||||||
|
add_css_class: "sourceview-transparent-bg",
|
||||||
set_margin_start: 1,
|
set_margin_start: 1,
|
||||||
set_hexpand: true,
|
set_hexpand: true,
|
||||||
set_vexpand: true,
|
set_vexpand: true,
|
||||||
|
@ -221,6 +223,9 @@ impl SimpleComponent for DebugView {
|
||||||
Self::Input::ClearLog => {
|
Self::Input::ClearLog => {
|
||||||
self.textbuf.set_text("");
|
self.textbuf.set_text("");
|
||||||
}
|
}
|
||||||
|
Self::Input::SetColorScheme => {
|
||||||
|
Self::set_color_scheme(&self.textbuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,11 +238,6 @@ impl SimpleComponent for DebugView {
|
||||||
.highlight_syntax(false)
|
.highlight_syntax(false)
|
||||||
.enable_undo(false)
|
.enable_undo(false)
|
||||||
.build();
|
.build();
|
||||||
if let Some(scheme) = &sourceview5::StyleSchemeManager::new().scheme("Adwaita-dark") {
|
|
||||||
textbuf.set_style_scheme(Some(scheme));
|
|
||||||
} else {
|
|
||||||
println!("gtksourceview style scheme not found")
|
|
||||||
}
|
|
||||||
let search_settings = sourceview5::SearchSettings::builder()
|
let search_settings = sourceview5::SearchSettings::builder()
|
||||||
.wrap_around(true)
|
.wrap_around(true)
|
||||||
.case_sensitive(false)
|
.case_sensitive(false)
|
||||||
|
@ -271,6 +271,14 @@ impl SimpleComponent for DebugView {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
withclones![sender];
|
||||||
|
adw::StyleManager::default().connect_dark_notify(move |_| {
|
||||||
|
sender.input(Self::Input::SetColorScheme);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Self::set_color_scheme(&textbuf);
|
||||||
|
|
||||||
let mut model = Self {
|
let mut model = Self {
|
||||||
xrservice_active: false,
|
xrservice_active: false,
|
||||||
tracker: 0,
|
tracker: 0,
|
||||||
|
@ -296,3 +304,19 @@ impl SimpleComponent for DebugView {
|
||||||
ComponentParts { model, widgets }
|
ComponentParts { model, widgets }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DebugView {
|
||||||
|
fn set_color_scheme(textbuf: &sourceview5::Buffer) {
|
||||||
|
let sourceview_scheme_name = if adw::StyleManager::default().is_dark() {
|
||||||
|
"Adwaita-dark"
|
||||||
|
} else {
|
||||||
|
"Adwaita"
|
||||||
|
};
|
||||||
|
if let Some(scheme) = &sourceview5::StyleSchemeManager::new().scheme(sourceview_scheme_name)
|
||||||
|
{
|
||||||
|
textbuf.set_style_scheme(Some(scheme));
|
||||||
|
} else {
|
||||||
|
println!("gtksourceview style scheme not found")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue