mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
move connect_changed to entry constructor
This commit is contained in:
parent
bf290a9648
commit
81a8e32dc2
2 changed files with 11 additions and 9 deletions
|
|
@ -8,7 +8,7 @@ use navigation::Navigation;
|
||||||
use tag::Tag;
|
use tag::Tag;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
prelude::{BoxExt, ButtonExt, CheckButtonExt, EditableExt, EntryExt, TextBufferExt, WidgetExt},
|
prelude::{BoxExt, ButtonExt, CheckButtonExt, EditableExt, TextBufferExt, WidgetExt},
|
||||||
Box, Button, Entry, Orientation, TextBuffer, TextIter, TextSearchFlags, TextTag,
|
Box, Button, Entry, Orientation, TextBuffer, TextIter, TextSearchFlags, TextTag,
|
||||||
};
|
};
|
||||||
use std::{cell::Cell, rc::Rc};
|
use std::{cell::Cell, rc::Rc};
|
||||||
|
|
@ -59,14 +59,7 @@ impl Find {
|
||||||
let match_case = match_case.clone();
|
let match_case = match_case.clone();
|
||||||
let matches = matches.clone();
|
let matches = matches.clone();
|
||||||
let text_buffer = text_buffer.clone();
|
let text_buffer = text_buffer.clone();
|
||||||
move |this| {
|
move |_| {
|
||||||
// toggle entry clear button
|
|
||||||
if this.text().is_empty() {
|
|
||||||
this.set_secondary_icon_name(None);
|
|
||||||
} else {
|
|
||||||
this.set_secondary_icon_name(Some("edit-clear-symbolic"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// do search
|
// do search
|
||||||
let result = find(
|
let result = find(
|
||||||
&text_buffer,
|
&text_buffer,
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,15 @@ pub fn new() -> Entry {
|
||||||
_ => todo!(), // unexpected
|
_ => todo!(), // unexpected
|
||||||
});
|
});
|
||||||
|
|
||||||
|
entry.connect_changed(|this| {
|
||||||
|
// toggle entry clear button
|
||||||
|
if this.text().is_empty() {
|
||||||
|
this.set_secondary_icon_name(None);
|
||||||
|
} else {
|
||||||
|
this.set_secondary_icon_name(Some("edit-clear-symbolic"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
entry
|
entry
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue