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

refactor(custom): reduce a lot of repeated code

This commit is contained in:
Jake Stanger 2023-04-10 13:51:07 +01:00
parent a9d1233909
commit 3613aef5c5
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
8 changed files with 85 additions and 97 deletions

View file

@ -1,6 +1,7 @@
use super::{CustomWidget, CustomWidgetContext, ExecEvent};
use crate::dynamic_string::DynamicString;
use crate::popup::Popup;
use crate::try_send;
use crate::{build, try_send};
use gtk::prelude::*;
use gtk::{Button, Label};
use serde::Deserialize;
@ -17,13 +18,7 @@ impl CustomWidget for ButtonWidget {
type Widget = Button;
fn into_widget(self, context: CustomWidgetContext) -> Self::Widget {
let mut builder = Button::builder();
if let Some(name) = self.name {
builder = builder.name(name);
}
let button = builder.build();
let button = build!(self, Self::Widget);
if let Some(text) = self.label {
let label = Label::new(None);