mirror of
https://github.com/JakeStanger/ironbar.git
synced 2024-11-30 05:24:20 +03:00
Merge pull request #159 from JakeStanger/fix/upower-icon
Upower icon fixes
This commit is contained in:
commit
e6a70f7663
@ -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).
|
||||||
|
@ -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| {
|
||||||
@ -180,7 +180,7 @@ impl Module<gtk::Box> 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, 32)
|
ImageProvider::parse(&icon_name, &icon_theme, 24)
|
||||||
.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)
|
||||||
@ -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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user