diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 090ebc62..87211b41 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -85,7 +85,11 @@ impl Item { } pub fn update(&self) { + // Update child components self.page.update(); + + // Update tab loading indicator + self.widget.gobject().set_loading(self.page.is_loading()); } pub fn clean( diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 442645a9..e061bace 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -447,22 +447,31 @@ impl Page { } pub fn update(&self) { + // Update components + self.navigation.update(self.progress_fraction()); + // @TODO self.content.update(); + } + + // Getters + pub fn progress_fraction(&self) -> Option { // Interpret status to progress fraction - let progress_fraction = match self.meta.borrow().status { + match self.meta.borrow().status { Some(Status::Prepare | Status::Reload) => Some(0.0), Some(Status::Connect) => Some(0.25), Some(Status::Request) => Some(0.50), Some(Status::Response) => Some(0.75), Some(Status::Failure | Status::Redirect | Status::Success) => Some(1.0), _ => None, - }; - - // Update components - self.navigation.update(progress_fraction); - // @TODO self.content.update(); + } + } + + pub fn is_loading(&self) -> bool { + match self.progress_fraction() { + Some(progress_fraction) => progress_fraction < 1.0, + None => false, + } } - // Getters pub fn meta_title(&self) -> Option { self.meta.borrow().title.clone() }