1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 18:51:04 +02:00

fix(upower): icon outside button

This moves the upower battery icon to inside the button,
moving it before the label for consistency.
This commit is contained in:
Jake Stanger 2023-05-26 18:58:30 +01:00
parent b9740cba8f
commit a6b686624b
2 changed files with 17 additions and 16 deletions

View file

@ -70,13 +70,14 @@ end:
## Styling ## Styling
| Selector | Description | | Selector | Description |
|---------------------------------|-----------------------------| |---------------------------------|--------------------------------|
| `.upower` | Upower widget container. | | `.upower` | Upower widget container. |
| `.upower .icon` | Upower widget battery icon. | | `.upower .button` | Upower widget button. |
| `.upower .button` | Upower widget button. | | `.upower .button .contents` | Upower widget button contents. |
| `.upower .button .label` | Upower widget button label. | | `.upower .button .icon` | Upower widget battery icon. |
| `.popup-upower` | Upower popup box. | | `.upower .button .label` | Upower widget button label. |
| `.popup-upower .upower-details` | Label inside the popup. | | `.popup-upower` | Upower popup box. |
| `.popup-upower .upower-details` | Label inside the popup. |
For more information on styling, please see the [styling guide](styling-guide). For more information on styling, please see the [styling guide](styling-guide).

View file

@ -41,7 +41,7 @@ pub struct UpowerProperties {
time_to_empty: i64, time_to_empty: i64,
} }
impl Module<gtk::Box> for UpowerModule { impl Module<gtk::Button> for UpowerModule {
type SendMessage = UpowerProperties; type SendMessage = UpowerProperties;
type ReceiveMessage = (); type ReceiveMessage = ();
@ -143,7 +143,7 @@ impl Module<gtk::Box> for UpowerModule {
self, self,
context: WidgetContext<Self::SendMessage, Self::ReceiveMessage>, context: WidgetContext<Self::SendMessage, Self::ReceiveMessage>,
info: &ModuleInfo, info: &ModuleInfo,
) -> Result<ModuleWidget<gtk::Box>> { ) -> Result<ModuleWidget<Button>> {
let icon_theme = info.icon_theme.clone(); let icon_theme = info.icon_theme.clone();
let icon = gtk::Image::new(); let icon = gtk::Image::new();
add_class(&icon, "icon"); add_class(&icon, "icon");
@ -154,15 +154,15 @@ impl Module<gtk::Box> for UpowerModule {
.build(); .build();
add_class(&label, "label"); add_class(&label, "label");
let container = gtk::Box::new(Orientation::Horizontal, 0); let container = gtk::Box::new(Orientation::Horizontal, 5);
add_class(&container, "upower"); add_class(&container, "contents");
let button = Button::new(); let button = Button::new();
add_class(&button, "button"); add_class(&button, "button");
button.add(&label);
container.add(&button);
container.add(&icon); container.add(&icon);
container.add(&label);
button.add(&container);
let orientation = info.bar_position.get_orientation(); let orientation = info.bar_position.get_orientation();
button.connect_clicked(move |button| { button.connect_clicked(move |button| {
@ -189,7 +189,7 @@ impl Module<gtk::Box> for UpowerModule {
let popup = self.into_popup(context.controller_tx, context.popup_rx, info); let popup = self.into_popup(context.controller_tx, context.popup_rx, info);
Ok(ModuleWidget { Ok(ModuleWidget {
widget: container, widget: button,
popup, popup,
}) })
} }