mirror of
https://github.com/elkowar/eww.git
synced 2024-09-11 19:57:16 +03:00
* feat: add a checked property on checkbox. Close #693. * chore: update CHANGELOG.md --------- Co-authored-by: ElKowar <5300871+elkowar@users.noreply.github.com>
This commit is contained in:
parent
5fdaa4e03f
commit
ebe5f349d1
@ -11,6 +11,7 @@ All notable changes to eww will be listed here, starting at changes since versio
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
- Add `systray` widget (By: ralismark)
|
- Add `systray` widget (By: ralismark)
|
||||||
|
- Add `:checked` property to checkbox (By: levnikmyskin)
|
||||||
|
|
||||||
## [0.5.0] (17.02.2024)
|
## [0.5.0] (17.02.2024)
|
||||||
|
|
||||||
|
@ -345,10 +345,12 @@ const WIDGET_NAME_CHECKBOX: &str = "checkbox";
|
|||||||
fn build_gtk_checkbox(bargs: &mut BuilderArgs) -> Result<gtk::CheckButton> {
|
fn build_gtk_checkbox(bargs: &mut BuilderArgs) -> Result<gtk::CheckButton> {
|
||||||
let gtk_widget = gtk::CheckButton::new();
|
let gtk_widget = gtk::CheckButton::new();
|
||||||
def_widget!(bargs, _g, gtk_widget, {
|
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 timeout - timeout of the command. Default: "200ms"
|
||||||
// @prop onchecked - action (command) to be executed when checked by the user
|
// @prop onchecked - action (command) to be executed when checked by the user
|
||||||
// @prop onunchecked - similar to onchecked but when the widget is unchecked
|
// @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| {
|
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]);
|
run_command(timeout, if gtk_widget.is_active() { &onchecked } else { &onunchecked }, &[] as &[&str]);
|
||||||
}));
|
}));
|
||||||
|
Loading…
Reference in New Issue
Block a user