mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 10:41:03 +02:00
feat(upower): icon size option
Adds missing `icon_size` config option to upower module.
This commit is contained in:
parent
e6a70f7663
commit
c3e9654cd3
2 changed files with 12 additions and 4 deletions
|
@ -9,9 +9,10 @@ Displays system power information such as the battery percentage, and estimated
|
||||||
|
|
||||||
> Type: `upower`
|
> Type: `upower`
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|----------|----------|-----------------|---------------------------------------------------|
|
|-------------|-----------|-----------------|---------------------------------------------------|
|
||||||
| `format` | `string` | `{percentage}%` | Format string to use for the widget button label. |
|
| `format` | `string` | `{percentage}%` | Format string to use for the widget button label. |
|
||||||
|
| `icon_size` | `integer` | `24` | Size to render icon at. |
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>JSON</summary>
|
<summary>JSON</summary>
|
||||||
|
|
|
@ -24,6 +24,9 @@ pub struct UpowerModule {
|
||||||
#[serde(default = "default_format")]
|
#[serde(default = "default_format")]
|
||||||
format: String,
|
format: String,
|
||||||
|
|
||||||
|
#[serde(default = "default_icon_size")]
|
||||||
|
icon_size: i32,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub common: Option<CommonConfig>,
|
pub common: Option<CommonConfig>,
|
||||||
}
|
}
|
||||||
|
@ -32,6 +35,10 @@ fn default_format() -> String {
|
||||||
String::from("{percentage}%")
|
String::from("{percentage}%")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fn default_icon_size() -> i32 {
|
||||||
|
24
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct UpowerProperties {
|
pub struct UpowerProperties {
|
||||||
percentage: f64,
|
percentage: f64,
|
||||||
|
@ -180,7 +187,7 @@ impl Module<gtk::Button> for UpowerModule {
|
||||||
.attach(None, move |properties: UpowerProperties| {
|
.attach(None, move |properties: UpowerProperties| {
|
||||||
let format = format.replace("{percentage}", &properties.percentage.to_string());
|
let format = format.replace("{percentage}", &properties.percentage.to_string());
|
||||||
let icon_name = String::from("icon:") + &properties.icon_name;
|
let icon_name = String::from("icon:") + &properties.icon_name;
|
||||||
ImageProvider::parse(&icon_name, &icon_theme, 24)
|
ImageProvider::parse(&icon_name, &icon_theme, self.icon_size)
|
||||||
.map(|provider| provider.load_into_image(icon.clone()));
|
.map(|provider| provider.load_into_image(icon.clone()));
|
||||||
label.set_markup(format.as_ref());
|
label.set_markup(format.as_ref());
|
||||||
Continue(true)
|
Continue(true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue