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:
parent
183ca402d4
commit
ba5ec8015d
4 changed files with 40 additions and 10 deletions
|
@ -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| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue