From 36c33e1ee6f90e442dfbd073f95e357d23f17cb9 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 24 Sep 2024 23:18:49 +0300 Subject: [PATCH] implement update action for reload button --- src/browser/main/tab/page/navigation/mod.rs | 2 +- src/browser/main/tab/page/navigation/reload/mod.rs | 6 +++--- src/browser/main/tab/page/navigation/request/mod.rs | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/browser/main/tab/page/navigation/mod.rs b/src/browser/main/tab/page/navigation/mod.rs index c4510bc3..8589139e 100644 --- a/src/browser/main/tab/page/navigation/mod.rs +++ b/src/browser/main/tab/page/navigation/mod.rs @@ -66,7 +66,7 @@ impl Navigation { pub fn update(&self) { self.base.update(); self.history.update(); - self.reload.update(); + self.reload.update(!self.request.is_empty()); self.request.update(); self.bookmark.update(); } diff --git a/src/browser/main/tab/page/navigation/reload/mod.rs b/src/browser/main/tab/page/navigation/reload/mod.rs index 01145678..f9ad5c50 100644 --- a/src/browser/main/tab/page/navigation/reload/mod.rs +++ b/src/browser/main/tab/page/navigation/reload/mod.rs @@ -1,4 +1,4 @@ -use gtk::Button; +use gtk::{prelude::WidgetExt, Button}; pub struct Reload { widget: Button, @@ -18,8 +18,8 @@ impl Reload { } // Actions - pub fn update(&self) { - // @TODO + pub fn update(&self, is_enabled: bool) { + self.widget.set_sensitive(is_enabled); } // Getters diff --git a/src/browser/main/tab/page/navigation/request/mod.rs b/src/browser/main/tab/page/navigation/request/mod.rs index b49ba285..39c3b31a 100644 --- a/src/browser/main/tab/page/navigation/request/mod.rs +++ b/src/browser/main/tab/page/navigation/request/mod.rs @@ -1,4 +1,4 @@ -use gtk::Entry; +use gtk::{prelude::EntryExt, Entry}; pub struct Request { widget: Entry, @@ -25,4 +25,8 @@ impl Request { pub fn widget(&self) -> &Entry { &self.widget } + + pub fn is_empty(&self) -> bool { + 0 == self.widget.text_length() + } }