1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 14:51:04 +02:00

feat: fully implement orientation/justify options

Adds `orientation` and `justify` options to all modules and custom
widgets where it makes sense to do so.

Any modules without support document this. Widgets fully document the
options inline where present for now.

Resolves #296
This commit is contained in:
Jake Stanger 2025-03-22 19:19:47 +00:00
parent 0855039bce
commit c20feb77b7
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
29 changed files with 317 additions and 161 deletions

View file

@ -8,7 +8,7 @@ use zbus;
use zbus::fdo::PropertiesProxy;
use crate::clients::upower::BatteryState;
use crate::config::CommonConfig;
use crate::config::{CommonConfig, LayoutConfig};
use crate::gtk_helpers::{IronbarGtkExt, IronbarLabelExt};
use crate::image::ImageProvider;
use crate::modules::PopupButton;
@ -37,6 +37,11 @@ pub struct UpowerModule {
#[serde(default = "default_icon_size")]
icon_size: i32,
// -- Common --
/// See [layout options](module-level-options#layout)
#[serde(default, flatten)]
layout: LayoutConfig,
/// See [common options](module-level-options#common-options).
#[serde(flatten)]
pub common: Option<CommonConfig>,
@ -172,10 +177,13 @@ impl Module<Button> for UpowerModule {
let label = Label::builder()
.label(&self.format)
.use_markup(true)
.angle(self.layout.angle(info))
.justify(self.layout.justify.into())
.build();
label.add_class("label");
let container = gtk::Box::new(info.bar_position.orientation(), 5);
let container = gtk::Box::new(self.layout.orientation(info), 5);
container.add_class("contents");
let button = Button::new();