diff --git a/CHANGELOG.md b/CHANGELOG.md index d9006315..60b557eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to eww will be listed here, starting at changes since versio ### Features - Add `systray` widget (By: ralismark) +- Add `:checked` property to checkbox (By: levnikmyskin) ## [0.5.0] (17.02.2024) diff --git a/crates/eww/src/widgets/widget_definitions.rs b/crates/eww/src/widgets/widget_definitions.rs index 4c9466cf..16aae7d0 100644 --- a/crates/eww/src/widgets/widget_definitions.rs +++ b/crates/eww/src/widgets/widget_definitions.rs @@ -345,10 +345,12 @@ const WIDGET_NAME_CHECKBOX: &str = "checkbox"; fn build_gtk_checkbox(bargs: &mut BuilderArgs) -> Result { let gtk_widget = gtk::CheckButton::new(); def_widget!(bargs, _g, gtk_widget, { + // @prop checked - whether the checkbox is toggled or not when created // @prop timeout - timeout of the command. Default: "200ms" // @prop onchecked - action (command) to be executed when checked by the user // @prop onunchecked - similar to onchecked but when the widget is unchecked - prop(timeout: as_duration = Duration::from_millis(200), onchecked: as_string = "", onunchecked: as_string = "") { + prop(checked: as_bool = false, timeout: as_duration = Duration::from_millis(200), onchecked: as_string = "", onunchecked: as_string = "") { + gtk_widget.set_active(checked); connect_signal_handler!(gtk_widget, gtk_widget.connect_toggled(move |gtk_widget| { run_command(timeout, if gtk_widget.is_active() { &onchecked } else { &onunchecked }, &[] as &[&str]); }));