Files
driftwood/src/ui/widgets.rs

25 lines
764 B
Rust

use gtk::prelude::*;
/// Create a status badge pill label with the given text and style class.
/// Style classes: "success", "warning", "error", "info", "neutral"
pub fn status_badge(text: &str, style_class: &str) -> gtk::Label {
let label = gtk::Label::new(Some(text));
label.add_css_class("status-badge");
label.add_css_class(style_class);
label
}
/// Create a badge showing integration status.
pub fn integration_badge(integrated: bool) -> gtk::Label {
if integrated {
status_badge("Integrated", "success")
} else {
status_badge("Not integrated", "neutral")
}
}
/// Format bytes into a human-readable string.
pub fn format_size(bytes: i64) -> String {
humansize::format_size(bytes as u64, humansize::BINARY)
}