diff --git a/docs/modules/Custom.md b/docs/modules/Custom.md index f7d2510..d93d7c7 100644 --- a/docs/modules/Custom.md +++ b/docs/modules/Custom.md @@ -54,11 +54,16 @@ A text label. Pango markup is supported. > Type `label` -| Name | Type | Default | Description | -|---------------|------------------------------------------------------------|----------------|----------------------------------------------------------------------| -| `label` | [Dynamic String](dynamic-values#dynamic-string) | `null` | Widget text label. Pango markup and embedded scripts are supported. | -| `orientation` | `'horizontal'` or `'vertical'` (shorthand: `'h'` or `'v'`) | `'horizontal'` | Orientation of the label text. | -| `justify` | `'left'`, `'right'`, `'center'`, or `'fill'` | `'left'` | Justification (alignment) of the label text. | +| Name | Type | Default | Description | +|-----------------------|------------------------------------------------------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| +| `label` | [Dynamic String](dynamic-values#dynamic-string) | `null` | Widget text label. Pango markup and embedded scripts are supported. | +| `orientation` | `'horizontal'` or `'vertical'` (shorthand: `'h'` or `'v'`) | `'horizontal'` | Orientation of the label text. | +| `justify` | `'left'`, `'right'`, `'center'`, or `'fill'` | `'left'` | Justification (alignment) of the label text. | +| `truncate` | `'start'` or `'middle'` or `'end'` or `off` or `Map` | `off` | The location of the ellipses and where to truncate text from. Leave null to avoid truncating. Use the long-hand `Map` version if specifying a length. | +| `truncate.mode` | `'start'` or `'middle'` or `'end'` or `off` | `off` | The location of the ellipses and where to truncate text from. Leave null to avoid truncating. | +| `truncate.length` | `integer` | `null` | The fixed width (in chars) of the widget. Leave blank to let GTK automatically handle. | +| `truncate.max_length` | `integer` | `null` | The maximum number of characters before truncating. Leave blank to let GTK automatically handle. | + #### Button diff --git a/docs/modules/Label.md b/docs/modules/Label.md index c203554..206614a 100644 --- a/docs/modules/Label.md +++ b/docs/modules/Label.md @@ -7,9 +7,14 @@ For more advanced use-cases, use [custom](custom). > Type: `label` -| Name | Type | Default | Description | -|---------|-------------------------------------------------|---------|------------------------| -| `label` | [Dynamic String](dynamic-values#dynamic-string) | `null` | Text to show on label. | +| Name | Type | Default | Description | +|-----------------------|------------------------------------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------| +| `label` | [Dynamic String](dynamic-values#dynamic-string) | `null` | Text to show on label. | +| `truncate` | `'start'` or `'middle'` or `'end'` or `off` or `Map` | `off` | The location of the ellipses and where to truncate text from. Leave null to avoid truncating. Use the long-hand `Map` version if specifying a length. | +| `truncate.mode` | `'start'` or `'middle'` or `'end'` or `off` | `off` | The location of the ellipses and where to truncate text from. Leave null to avoid truncating. | +| `truncate.length` | `integer` | `null` | The fixed width (in chars) of the widget. Leave blank to let GTK automatically handle. | +| `truncate.max_length` | `integer` | `null` | The maximum number of characters before truncating. Leave blank to let GTK automatically handle. | +
JSON diff --git a/docs/modules/Launcher.md b/docs/modules/Launcher.md index 2c93432..3d6dfa8 100644 --- a/docs/modules/Launcher.md +++ b/docs/modules/Launcher.md @@ -13,22 +13,23 @@ Optionally displays a launchable set of favourites. > Type: `launcher` -| | Type | Default | Description | -|-----------------------------|---------------------------------------------|----------|--------------------------------------------------------------------------------------------------------------------------| -| `favorites` | `string[]` | `[]` | List of app IDs (or classes) to always show at the start of the launcher. | -| `show_names` | `boolean` | `false` | Whether to show app names on the button label. Names will still show on tooltips when set to false. | -| `show_icons` | `boolean` | `true` | Whether to show app icons on the button. | -| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). | -| `reversed` | `boolean` | `false` | Whether to reverse the order of favorites/items | -| `minimize_focused` | `boolean` | `true` | Whether to minimize a focused window when its icon is clicked. Only minimizes single windows. | -| `truncate.mode` | `'start'` or `'middle'` or `'end'` or `off` | `end` | The location of the ellipses and where to truncate text from. Applies to application names when `show_names` is enabled. | -| `truncate.length` | `integer` | `null` | The fixed width (in chars) of the widget. Leave blank to let GTK automatically handle. | -| `truncate.max_length` | `integer` | `null` | The maximum number of characters before truncating. Leave blank to let GTK automatically handle. | -| `truncate_popup.mode` | `'start'` or `'middle'` or `'end'` or `off` | `middle` | The location of the ellipses and where to truncate text from. Applies to window names within a group popup. | -| `truncate_popup.length` | `integer` | `null` | The fixed width (in chars) of the widget. Leave blank to let GTK automatically handle. | -| `truncate_popup.max_length` | `integer` | `25` | The maximum number of characters before truncating. Leave blank to let GTK automatically handle. | - - +| | Type | Default | Description | +|-----------------------------|---------------------------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| +| `favorites` | `string[]` | `[]` | List of app IDs (or classes) to always show at the start of the launcher. | +| `show_names` | `boolean` | `false` | Whether to show app names on the button label. Names will still show on tooltips when set to false. | +| `show_icons` | `boolean` | `true` | Whether to show app icons on the button. | +| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). | +| `reversed` | `boolean` | `false` | Whether to reverse the order of favorites/items | +| `minimize_focused` | `boolean` | `true` | Whether to minimize a focused window when its icon is clicked. Only minimizes single windows. | +| `truncate.mode` | `'start'` or `'middle'` or `'end'` or `off` | `end` | Location of the ellipses and where to truncate text from. Applies to application names when `show_names` is enabled. | +| `truncate.length` | `integer` | `null` | Fixed width (in chars) of the widget. Leave blank to let GTK automatically handle. | +| `truncate.max_length` | `integer` | `null` | Maximum number of characters before truncating. Leave blank to let GTK automatically handle. | +| `truncate_popup.mode` | `'start'` or `'middle'` or `'end'` or `off` | `middle` | Location of the ellipses and where to truncate text from. Applies to window names within a group popup. | +| `truncate_popup.length` | `integer` | `null` | Fixed width (in chars) of the widget. Leave blank to let GTK automatically handle. | +| `truncate_popup.max_length` | `integer` | `25` | Maximum number of characters before truncating. Leave blank to let GTK automatically handle. | +| `page_size` | `integer` | `1000` | Number of items to show on a page. When the number of items is reached, controls appear which can be used to move forward/back through the list of items. | +| `icons.page_back` | `string` or [image](images) | `󰅁` | Icon to show for page back button. | +| `icons.page_forward` | `string` or [image](images) | `󰅂` | Icon to show for page forward button. |
JSON @@ -104,14 +105,17 @@ start: ## Styling -| Selector | Description | -|-------------------------------|--------------------------| -| `.launcher` | Launcher widget box | -| `.launcher .item` | App button | -| `.launcher .item.open` | App button (open app) | -| `.launcher .item.focused` | App button (focused app) | -| `.launcher .item.urgent` | App button (urgent app) | -| `.popup-launcher` | Popup container | -| `.popup-launcher .popup-item` | Window button in popup | +| Selector | Description | +|--------------------------------------|---------------------------| +| `.launcher` | Launcher widget box | +| `.launcher .item` | App button | +| `.launcher .item.open` | App button (open app) | +| `.launcher .item.focused` | App button (focused app) | +| `.launcher .item.urgent` | App button (urgent app) | +| `.launcher .pagination` | Pagination controls box | +| `.launcher .pagination .btn-back` | Pagination back button | +| `.launcher .pagination .btn-forward` | Pagination forward button | +| `.popup-launcher` | Popup container | +| `.popup-launcher .popup-item` | Window button in popup | For more information on styling, please see the [styling guide](styling-guide). diff --git a/src/modules/custom/label.rs b/src/modules/custom/label.rs index 8903789..26a1ad5 100644 --- a/src/modules/custom/label.rs +++ b/src/modules/custom/label.rs @@ -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, } 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| { diff --git a/src/modules/label.rs b/src/modules/label.rs index ccb783f..6aa440e 100644 --- a/src/modules/label.rs +++ b/src/modules/label.rs @@ -1,4 +1,4 @@ -use crate::config::CommonConfig; +use crate::config::{CommonConfig, TruncateMode}; use crate::dynamic_value::dynamic_string; use crate::gtk_helpers::IronbarLabelExt; use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext}; @@ -17,6 +17,12 @@ pub struct LabelModule { /// **Required** label: String, + // -- Common -- + /// See [truncate options](module-level-options#truncate-mode). + /// + /// **Default**: `null` + truncate: Option, + /// See [common options](module-level-options#common-options). #[serde(flatten)] pub common: Option, @@ -26,6 +32,7 @@ impl LabelModule { pub(crate) fn new(label: String) -> Self { Self { label, + truncate: None, common: Some(CommonConfig::default()), } } @@ -58,6 +65,10 @@ impl Module