mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
toggle button label on activate
This commit is contained in:
parent
7a2da3cd58
commit
864c5108ac
@ -7,7 +7,7 @@ use gtk::{
|
|||||||
// Defaults
|
// Defaults
|
||||||
|
|
||||||
const CSS_CLASSES: [&str; 1] = ["suggested-action"];
|
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;
|
const MARGIN: i32 = 16;
|
||||||
|
|
||||||
/// Choose destination [File](https://docs.gtk.org/gio/iface.File.html)
|
/// Choose destination [File](https://docs.gtk.org/gio/iface.File.html)
|
||||||
@ -24,11 +24,23 @@ impl Choose {
|
|||||||
let button = Button::builder()
|
let button = Button::builder()
|
||||||
.css_classes(CSS_CLASSES)
|
.css_classes(CSS_CLASSES)
|
||||||
.halign(Align::Center)
|
.halign(Align::Center)
|
||||||
.label(LABEL)
|
.label(if is_activate_on_release {
|
||||||
|
LABEL.1
|
||||||
|
} else {
|
||||||
|
LABEL.0
|
||||||
|
})
|
||||||
.margin_top(MARGIN)
|
.margin_top(MARGIN)
|
||||||
.sensitive(!is_activate_on_release)
|
.sensitive(!is_activate_on_release)
|
||||||
.build();
|
.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 {
|
if is_activate_on_release {
|
||||||
button.connect_realize(|this| {
|
button.connect_realize(|this| {
|
||||||
this.activate();
|
this.activate();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user