From 176d24da4fa364d4c7daa9103819bd35604bc23f Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 23 Jan 2025 15:03:30 +0200 Subject: [PATCH] remove extra levels --- .../tab/item/page/navigation/history.rs | 2 +- .../tab/item/page/navigation/history/back.rs | 31 ++++++++++----- .../page/navigation/history/back/widget.rs | 38 ------------------- .../item/page/navigation/history/forward.rs | 29 ++++++++++---- .../page/navigation/history/forward/widget.rs | 38 ------------------- 5 files changed, 43 insertions(+), 95 deletions(-) delete mode 100644 src/app/browser/window/tab/item/page/navigation/history/back/widget.rs delete mode 100644 src/app/browser/window/tab/item/page/navigation/history/forward/widget.rs diff --git a/src/app/browser/window/tab/item/page/navigation/history.rs b/src/app/browser/window/tab/item/page/navigation/history.rs index 6f78b250..dd1f8caa 100644 --- a/src/app/browser/window/tab/item/page/navigation/history.rs +++ b/src/app/browser/window/tab/item/page/navigation/history.rs @@ -36,7 +36,7 @@ impl History { let forward = Rc::new(Forward::build(action)); // Init widget - let widget = Rc::new(Widget::build(&back.widget.button, &forward.widget.button)); + let widget = Rc::new(Widget::build(&back.button, &forward.button)); // Init memory let memory = RefCell::new(Vec::new()); diff --git a/src/app/browser/window/tab/item/page/navigation/history/back.rs b/src/app/browser/window/tab/item/page/navigation/history/back.rs index 5cd9dbdd..208e26ba 100644 --- a/src/app/browser/window/tab/item/page/navigation/history/back.rs +++ b/src/app/browser/window/tab/item/page/navigation/history/back.rs @@ -1,13 +1,13 @@ -mod widget; - -use widget::Widget; - use super::WindowAction; +use gtk::{ + prelude::{ButtonExt, WidgetExt}, + Button, +}; use std::rc::Rc; pub struct Back { action: Rc, - pub widget: Rc, + pub button: Button, } impl Back { @@ -15,19 +15,30 @@ impl Back { /// Build new `Self` pub fn build(action: &Rc) -> Self { + // Init gobject + let button = Button::builder() + .icon_name("go-previous-symbolic") + .tooltip_text("Back") + .sensitive(false) + .build(); + + // Init events + button.connect_clicked({ + let action = action.clone(); + move |_| action.history_back.activate() + }); + + // Return activated `Self` Self { action: action.clone(), - widget: Rc::new(Widget::build(action)), + button, } } // Actions pub fn update(&self, status: bool) { - // Update actions self.action.history_back.simple_action.set_enabled(status); - - // Update child components - self.widget.update(status); + self.button.set_sensitive(status); } } diff --git a/src/app/browser/window/tab/item/page/navigation/history/back/widget.rs b/src/app/browser/window/tab/item/page/navigation/history/back/widget.rs deleted file mode 100644 index f35f82c6..00000000 --- a/src/app/browser/window/tab/item/page/navigation/history/back/widget.rs +++ /dev/null @@ -1,38 +0,0 @@ -use super::WindowAction; -use gtk::{ - prelude::{ButtonExt, WidgetExt}, - Button, -}; -use std::rc::Rc; - -pub struct Widget { - pub button: Button, -} - -impl Widget { - // Constructors - - /// Build new `Self` - pub fn build(action: &Rc) -> Self { - // Init gobject - let button = Button::builder() - .icon_name("go-previous-symbolic") - .tooltip_text("Back") - .sensitive(false) - .build(); - - // Init events - button.connect_clicked({ - let action = action.clone(); - move |_| action.history_back.activate() - }); - - // Return activated `Self` - Self { button } - } - - // Actions - pub fn update(&self, is_sensitive: bool) { - self.button.set_sensitive(is_sensitive); - } -} diff --git a/src/app/browser/window/tab/item/page/navigation/history/forward.rs b/src/app/browser/window/tab/item/page/navigation/history/forward.rs index cdd743e0..03243de2 100644 --- a/src/app/browser/window/tab/item/page/navigation/history/forward.rs +++ b/src/app/browser/window/tab/item/page/navigation/history/forward.rs @@ -1,13 +1,14 @@ -mod widget; - -use widget::Widget; +use gtk::{ + prelude::{ButtonExt, WidgetExt}, + Button, +}; use super::WindowAction; use std::rc::Rc; pub struct Forward { action: Rc, - pub widget: Rc, + pub button: Button, } impl Forward { @@ -15,21 +16,33 @@ impl Forward { /// Build new `Self` pub fn build(action: &Rc) -> Self { + // Init gobject + let button = Button::builder() + .icon_name("go-next-symbolic") + .tooltip_text("Forward") + .sensitive(false) + .build(); + + // Init events + button.connect_clicked({ + let action = action.clone(); + move |_| action.history_forward.activate() + }); + + // Return activated `Self` Self { action: action.clone(), - widget: Rc::new(Widget::build(action)), + button, } } // Actions pub fn update(&self, status: bool) { - // Update actions self.action .history_forward .simple_action .set_enabled(status); - // Update child components - self.widget.update(status); + self.button.set_sensitive(status); } } diff --git a/src/app/browser/window/tab/item/page/navigation/history/forward/widget.rs b/src/app/browser/window/tab/item/page/navigation/history/forward/widget.rs deleted file mode 100644 index 496bd85f..00000000 --- a/src/app/browser/window/tab/item/page/navigation/history/forward/widget.rs +++ /dev/null @@ -1,38 +0,0 @@ -use super::WindowAction; -use gtk::{ - prelude::{ButtonExt, WidgetExt}, - Button, -}; -use std::rc::Rc; - -pub struct Widget { - pub button: Button, -} - -impl Widget { - // Constructors - - /// Build new `Self` - pub fn build(action: &Rc) -> Self { - // Init gobject - let button = Button::builder() - .icon_name("go-next-symbolic") - .tooltip_text("Forward") - .sensitive(false) - .build(); - - // Init events - button.connect_clicked({ - let action = action.clone(); - move |_| action.history_forward.activate() - }); - - // Return activated `Self` - Self { button } - } - - // Actions - pub fn update(&self, is_sensitive: bool) { - self.button.set_sensitive(is_sensitive); - } -}