mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 23:01:04 +02:00
feat(launcher): truncate
and truncate_popup
config options
This commit is contained in:
parent
8b05ed526d
commit
da13b9d500
5 changed files with 123 additions and 62 deletions
|
@ -44,7 +44,7 @@ use std::collections::HashMap;
|
|||
use schemars::JsonSchema;
|
||||
|
||||
pub use self::common::{CommonConfig, ModuleOrientation, TransitionType};
|
||||
pub use self::truncate::TruncateMode;
|
||||
pub use self::truncate::{EllipsizeMode, TruncateMode};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
use gtk::pango::EllipsizeMode as GtkEllipsizeMode;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Copy)]
|
||||
#[derive(Debug, Deserialize, Clone, Copy, Default)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum EllipsizeMode {
|
||||
None,
|
||||
Start,
|
||||
Middle,
|
||||
#[default]
|
||||
End,
|
||||
}
|
||||
|
||||
|
@ -28,6 +29,8 @@ impl From<EllipsizeMode> for GtkEllipsizeMode {
|
|||
///
|
||||
/// The option can be configured in one of two modes.
|
||||
///
|
||||
/// **Default**: `Auto (end)`
|
||||
///
|
||||
#[derive(Debug, Deserialize, Clone, Copy)]
|
||||
#[serde(untagged)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
|
@ -56,7 +59,7 @@ pub enum TruncateMode {
|
|||
///
|
||||
/// **Valid options**: `start`, `middle`, `end`
|
||||
/// <br>
|
||||
/// **Default**: `null`
|
||||
/// **Default**: `end`
|
||||
Auto(EllipsizeMode),
|
||||
|
||||
/// Length mode defines a fixed point at which to ellipsize.
|
||||
|
@ -100,6 +103,12 @@ pub enum TruncateMode {
|
|||
},
|
||||
}
|
||||
|
||||
impl Default for TruncateMode {
|
||||
fn default() -> Self {
|
||||
Self::Auto(EllipsizeMode::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl TruncateMode {
|
||||
pub const fn length(&self) -> Option<i32> {
|
||||
match self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue