mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
delegate cancellable features to client api
This commit is contained in:
parent
609cdf8512
commit
c693e5d88e
@ -23,12 +23,12 @@ use crate::Profile;
|
||||
use gtk::{
|
||||
gdk::Texture,
|
||||
gdk_pixbuf::Pixbuf,
|
||||
gio::{Cancellable, SocketClientEvent},
|
||||
gio::SocketClientEvent,
|
||||
glib::{
|
||||
gformat, GString, Priority, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags,
|
||||
UriHideFlags,
|
||||
},
|
||||
prelude::{CancellableExt, EditableExt, SocketClientExt},
|
||||
prelude::{EditableExt, SocketClientExt},
|
||||
};
|
||||
use sqlite::Transaction;
|
||||
use std::{rc::Rc, time::Duration};
|
||||
@ -380,19 +380,8 @@ impl Page {
|
||||
|
||||
// @TODO move outside
|
||||
fn load_gemini(&self, uri: Uri, is_history: bool) {
|
||||
// Cancel previous client operations
|
||||
{
|
||||
let cancellable = self.client.cancellable.take();
|
||||
if !cancellable.is_cancelled() {
|
||||
cancellable.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
// Init new Cancellable
|
||||
let cancellable = Cancellable::new();
|
||||
self.client.cancellable.replace(cancellable.clone());
|
||||
|
||||
// Init shared clones
|
||||
let cancellable = self.client.cancellable();
|
||||
let update = self.browser_action.update.clone();
|
||||
let tab_action = self.tab_action.clone();
|
||||
let navigation = self.navigation.clone();
|
||||
|
@ -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…
x
Reference in New Issue
Block a user