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:
parent
a9d1233909
commit
3613aef5c5
8 changed files with 85 additions and 97 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue