chore: remove build-tools dependency

chore: restructure
This commit is contained in:
Ilya Zlobintsev 2023-11-18 00:11:10 +02:00
parent 7d5a946e6e
commit 08f83babfb
6 changed files with 16 additions and 27 deletions

7
Cargo.lock generated
View File

@ -904,12 +904,6 @@ dependencies = [
"thiserror",
]
[[package]]
name = "glib-build-tools"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3431c56f463443cba9bc3600248bc6d680cb614c2ee1cdd39dab5415bd12ac5c"
[[package]]
name = "glib-macros"
version = "0.18.2"
@ -1206,7 +1200,6 @@ name = "lact-gui"
version = "0.4.6"
dependencies = [
"anyhow",
"glib-build-tools",
"gtk4",
"lact-client",
"lact-daemon",

View File

@ -16,8 +16,5 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
anyhow = "1.0"
[build-dependencies]
glib-build-tools = "0.18.0"
[dev-dependencies]
pretty_assertions = "1.4.0"

View File

@ -1,5 +1,4 @@
mod apply_revealer;
mod gpu_stats_section;
mod header;
mod info_row;
mod page_section;

View File

@ -1,5 +1,5 @@
use super::page_section::PageSection;
use gtk::glib::{self, subclass::types::ObjectSubclassIsExt, Object};
use crate::app::page_section::PageSection;
use gtk::glib::{self, Object};
use lact_client::schema::{DeviceStats, PowerStats};
glib::wrapper! {
@ -14,16 +14,14 @@ impl GpuStatsSection {
}
pub fn set_stats(&self, stats: &DeviceStats) {
let imp = self.imp();
let vram_usage =
if let (Some(used_vram), Some(total_vram)) = (stats.vram.used, stats.vram.total) {
used_vram as f64 / total_vram as f64
} else {
0.0
};
imp.vram_usage_bar.set_value(vram_usage);
imp.vram_usage_label.set_text(&format!(
self.set_vram_usage(vram_usage);
self.set_vram_usage_text(format!(
"{}/{} MiB",
stats.vram.used.unwrap_or(0) / 1024 / 1024,
stats.vram.total.unwrap_or(0) / 1024 / 1024,
@ -80,19 +78,14 @@ mod imp {
prelude::*,
widget::{CompositeTemplateClass, WidgetImpl},
},
CompositeTemplate, Label, LevelBar, TemplateChild,
CompositeTemplate,
};
use std::cell::RefCell;
#[derive(CompositeTemplate, Default, Properties)]
#[properties(wrapper_type = super::GpuStatsSection)]
#[template(file = "ui/gpu_stats_section.blp")]
#[template(file = "ui/oc_page/gpu_stats_section.blp")]
pub struct GpuStatsSection {
#[template_child]
pub vram_usage_label: TemplateChild<Label>,
#[template_child]
pub vram_usage_bar: TemplateChild<LevelBar>,
#[property(get, set)]
core_clock: RefCell<String>,
#[property(get, set)]
@ -105,6 +98,10 @@ mod imp {
gpu_usage: RefCell<String>,
#[property(get, set)]
power_usage: RefCell<String>,
#[property(get, set)]
vram_usage: RefCell<f64>,
#[property(get, set)]
vram_usage_text: RefCell<String>,
}
#[glib::object_subclass]

View File

@ -1,10 +1,11 @@
mod clocks_frame;
mod gpu_stats_section;
mod oc_adjustment;
mod performance_frame;
mod power_cap_frame;
use crate::app::gpu_stats_section::GpuStatsSection;
use clocks_frame::ClocksFrame;
use gpu_stats_section::GpuStatsSection;
use gtk::prelude::*;
use gtk::*;
use lact_client::schema::{

View File

@ -15,12 +15,14 @@ template $GpuStatsSection: $PageSection {
Overlay {
LevelBar vram_usage_bar {
hexpand: true;
value: 0.0;
value: bind template.vram-usage;
orientation: horizontal;
}
[overlay]
Label vram_usage_label {}
Label vram_usage_label {
label: bind template.vram-usage-text;
}
}
}