mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-10 10:24:13 +00:00
implement base button sensitivity update
This commit is contained in:
parent
58d5c96f26
commit
98f88c5464
@ -65,7 +65,7 @@ impl Navigation {
|
||||
|
||||
// Actions
|
||||
pub fn update(&self) {
|
||||
self.base.update();
|
||||
self.base.update(self.request.uri());
|
||||
self.history.update();
|
||||
self.reload.update(!self.request.is_empty());
|
||||
self.request.update();
|
||||
|
@ -1,4 +1,4 @@
|
||||
use gtk::Button;
|
||||
use gtk::{glib::Uri, prelude::WidgetExt, Button};
|
||||
|
||||
pub struct Base {
|
||||
widget: Button,
|
||||
@ -18,8 +18,11 @@ impl Base {
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self) {
|
||||
// @TODO
|
||||
pub fn update(&self, uri: Option<Uri>) {
|
||||
self.widget.set_sensitive(match uri {
|
||||
Some(uri) => "/" != uri.path(),
|
||||
None => false,
|
||||
});
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
@ -1,5 +1,5 @@
|
||||
use gtk::{
|
||||
glib::GString,
|
||||
glib::{GString, Uri, UriFlags},
|
||||
prelude::{EditableExt, EntryExt, WidgetExt},
|
||||
Entry,
|
||||
};
|
||||
@ -66,4 +66,11 @@ impl Request {
|
||||
pub fn text(&self) -> GString {
|
||||
self.widget.text()
|
||||
}
|
||||
|
||||
pub fn uri(&self) -> Option<Uri> {
|
||||
match Uri::parse(&self.widget.text(), UriFlags::NONE) {
|
||||
Ok(uri) => Some(uri),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user