mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
delegate cancellable features to client api
This commit is contained in:
parent
609cdf8512
commit
c693e5d88e
2 changed files with 19 additions and 15 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use gtk::gio::Cancellable;
|
||||
use gtk::{gio::Cancellable, prelude::CancellableExt};
|
||||
use std::cell::RefCell;
|
||||
|
||||
/// Multi-client holder for single `Page` object
|
||||
|
|
@ -25,4 +25,19 @@ impl Client {
|
|||
gemini: gemini::Client::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get new [Cancellable](https://docs.gtk.org/gio/class.Cancellable.html) by cancel previous one
|
||||
pub fn cancellable(&self) -> Cancellable {
|
||||
// Init new Cancellable
|
||||
let cancellable = Cancellable::new();
|
||||
|
||||
// Cancel previous client operations
|
||||
let previous = self.cancellable.replace(cancellable.clone());
|
||||
if !previous.is_cancelled() {
|
||||
previous.cancel();
|
||||
}
|
||||
|
||||
// Done
|
||||
cancellable
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue