-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
library: Ported
Switch
to Rust (#561)
- Loading branch information
1 parent
c294ce8
commit 4a8ef07
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::workbench; | ||
use glib::clone; | ||
use gtk::glib; | ||
|
||
pub fn main() { | ||
let switch_on: gtk::Switch = workbench::builder().object("switch_on").unwrap(); | ||
let label_on: gtk::Label = workbench::builder().object("label_on").unwrap(); | ||
|
||
let switch_off: gtk::Switch = workbench::builder().object("switch_off").unwrap(); | ||
let label_off: gtk::Label = workbench::builder().object("label_off").unwrap(); | ||
|
||
switch_on.connect_active_notify(clone!(@weak switch_off => move |switch_on| { | ||
label_on.set_label(if switch_on.is_active() { "On" } else { "Off" }); | ||
switch_off.set_active(!switch_on.is_active()); | ||
})); | ||
|
||
switch_off.connect_active_notify(move |switch_off| { | ||
label_off.set_label(if switch_off.is_active() { "On" } else { "Off" }); | ||
switch_on.set_active(!switch_off.is_active()); | ||
}); | ||
} |