mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 23:01:04 +02:00
Add truncate
option for volume
popup
This commit is contained in:
parent
4fad5a4d18
commit
f9ff267aa2
2 changed files with 28 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::channels::{AsyncSenderExt, BroadcastReceiverExt};
|
||||
use crate::clients::volume::{self, Event};
|
||||
use crate::config::{CommonConfig, LayoutConfig};
|
||||
use crate::config::{CommonConfig, LayoutConfig, TruncateMode};
|
||||
use crate::gtk_helpers::{IronbarGtkExt, IronbarLabelExt};
|
||||
use crate::modules::{
|
||||
Module, ModuleInfo, ModuleParts, ModulePopup, ModuleUpdateEvent, PopupButton, WidgetContext,
|
||||
|
@ -39,6 +39,11 @@ pub struct VolumeModule {
|
|||
icons: Icons,
|
||||
|
||||
// -- Common --
|
||||
/// See [truncate options](module-level-options#truncate-mode).
|
||||
///
|
||||
/// **Default**: `null`
|
||||
pub(crate) truncate: Option<TruncateMode>,
|
||||
|
||||
/// See [layout options](module-level-options#layout)
|
||||
#[serde(default, flatten)]
|
||||
layout: LayoutConfig,
|
||||
|
@ -403,6 +408,10 @@ impl Module<Button> for VolumeModule {
|
|||
let label = Label::new(Some(&info.name));
|
||||
label.add_class("title");
|
||||
|
||||
if let Some(truncate) = self.truncate {
|
||||
label.truncate(truncate);
|
||||
};
|
||||
|
||||
let slider = Scale::builder().sensitive(info.can_set_volume).build();
|
||||
slider.set_range(0.0, self.max_volume);
|
||||
slider.set_value(info.volume);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue