mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
toggle button label on activate
This commit is contained in:
parent
7a2da3cd58
commit
864c5108ac
1 changed files with 14 additions and 2 deletions
|
|
@ -7,7 +7,7 @@ use gtk::{
|
|||
// Defaults
|
||||
|
||||
const CSS_CLASSES: [&str; 1] = ["suggested-action"];
|
||||
const LABEL: &str = "Choose location..";
|
||||
const LABEL: (&str, &str) = ("Choose location..", "Awaiting for choose..");
|
||||
const MARGIN: i32 = 16;
|
||||
|
||||
/// Choose destination [File](https://docs.gtk.org/gio/iface.File.html)
|
||||
|
|
@ -24,11 +24,23 @@ impl Choose {
|
|||
let button = Button::builder()
|
||||
.css_classes(CSS_CLASSES)
|
||||
.halign(Align::Center)
|
||||
.label(LABEL)
|
||||
.label(if is_activate_on_release {
|
||||
LABEL.1
|
||||
} else {
|
||||
LABEL.0
|
||||
})
|
||||
.margin_top(MARGIN)
|
||||
.sensitive(!is_activate_on_release)
|
||||
.build();
|
||||
|
||||
button.connect_sensitive_notify(|this| {
|
||||
if this.is_sensitive() {
|
||||
this.set_label(LABEL.0)
|
||||
} else {
|
||||
this.set_label(LABEL.1)
|
||||
}
|
||||
});
|
||||
|
||||
if is_activate_on_release {
|
||||
button.connect_realize(|this| {
|
||||
this.activate();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue