1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 14:51:04 +02:00

feat(label): add truncate to module and custom widget

This commit is contained in:
Jake Stanger 2025-02-21 21:11:41 +00:00
parent 183ca402d4
commit ba5ec8015d
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
4 changed files with 40 additions and 10 deletions

View file

@ -4,7 +4,7 @@ use serde::Deserialize;
use super::{CustomWidget, CustomWidgetContext};
use crate::build;
use crate::config::{ModuleJustification, ModuleOrientation};
use crate::config::{ModuleJustification, ModuleOrientation, TruncateMode};
use crate::dynamic_value::dynamic_string;
use crate::gtk_helpers::IronbarLabelExt;
@ -44,6 +44,11 @@ pub struct LabelWidget {
/// **Default**: `left`
#[serde(default)]
justify: ModuleJustification,
/// See [truncate options](module-level-options#truncate-mode).
///
/// **Default**: `null`
truncate: Option<TruncateMode>,
}
impl CustomWidget for LabelWidget {
@ -56,6 +61,10 @@ impl CustomWidget for LabelWidget {
label.set_justify(self.justify.into());
label.set_use_markup(true);
if let Some(truncate) = self.truncate {
label.truncate(truncate);
}
{
let label = label.clone();
dynamic_string(&self.label, move |string| {