|
|
|
@ -1,11 +1,14 @@
@@ -1,11 +1,14 @@
|
|
|
|
|
use gtk::{ |
|
|
|
|
gio::SimpleAction, |
|
|
|
|
glib::{GString, Uri, UriFlags}, |
|
|
|
|
glib::{timeout_add_local, ControlFlow, GString, Uri, UriFlags}, |
|
|
|
|
prelude::{ActionExt, EditableExt, EntryExt}, |
|
|
|
|
Entry, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
use std::sync::Arc; |
|
|
|
|
use std::{sync::Arc, time::Duration}; |
|
|
|
|
|
|
|
|
|
const PROGRESS_ANIMATION_STEP: f64 = 0.2; |
|
|
|
|
const PROGRESS_ANIMATION_TIME: u64 = 25; |
|
|
|
|
|
|
|
|
|
pub struct Request { |
|
|
|
|
widget: Entry, |
|
|
|
@ -15,6 +18,7 @@ impl Request {
@@ -15,6 +18,7 @@ impl Request {
|
|
|
|
|
// Construct
|
|
|
|
|
pub fn new( |
|
|
|
|
text: Option<GString>, |
|
|
|
|
// Actions
|
|
|
|
|
action_update: Arc<SimpleAction>, |
|
|
|
|
action_tab_page_reload: Arc<SimpleAction>, |
|
|
|
|
) -> Self { |
|
|
|
@ -45,8 +49,21 @@ impl Request {
@@ -45,8 +49,21 @@ impl Request {
|
|
|
|
|
|
|
|
|
|
// Actions
|
|
|
|
|
pub fn update(&self, progress_fraction: f64) { |
|
|
|
|
self.widget.set_progress_fraction(progress_fraction); |
|
|
|
|
// @TODO animate progress fraction
|
|
|
|
|
// Animate progress fraction update
|
|
|
|
|
timeout_add_local(Duration::from_millis(PROGRESS_ANIMATION_TIME), { |
|
|
|
|
let widget = self.widget.clone(); |
|
|
|
|
move || { |
|
|
|
|
if progress_fraction > widget.progress_fraction() { |
|
|
|
|
widget.set_progress_fraction( |
|
|
|
|
widget.progress_fraction() + PROGRESS_ANIMATION_STEP, |
|
|
|
|
); |
|
|
|
|
return ControlFlow::Continue; |
|
|
|
|
} else { |
|
|
|
|
widget.set_progress_fraction(progress_fraction); |
|
|
|
|
} |
|
|
|
|
ControlFlow::Break |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Setters
|
|
|
|
|